@@ -153,21 +153,18 @@ scratch_align( void ) {
153153FD_FN_PURE static inline ulong
154154scratch_footprint ( FD_PARAM_UNUSED fd_topo_tile_t const * tile ) {
155155 ulong slot_max = tile -> tower .max_live_slots ;
156- int lg_slot_max = fd_ulong_find_msb ( fd_ulong_pow2_up ( slot_max ) ) + 1 ;
157156 FD_LOG_DEBUG (( "hfork footprint %lu" , fd_hfork_footprint ( slot_max , FD_VOTER_MAX ) ));
158157 ulong l = FD_LAYOUT_INIT ;
159- l = FD_LAYOUT_APPEND ( l , alignof(ctx_t ), sizeof (ctx_t ) );
160- l = FD_LAYOUT_APPEND ( l , fd_ghost_align (), fd_ghost_footprint ( 2 * slot_max , FD_VOTER_MAX ) );
161- l = FD_LAYOUT_APPEND ( l , fd_hfork_align (), fd_hfork_footprint ( slot_max , FD_VOTER_MAX ) );
162- l = FD_LAYOUT_APPEND ( l , fd_notar_align (), fd_notar_footprint ( tile -> tower .max_vote_lookahead ) );
163- l = FD_LAYOUT_APPEND ( l , fd_tower_align (), fd_tower_footprint () );
164- l = FD_LAYOUT_APPEND ( l , fd_tower_accts_align (), fd_tower_accts_footprint ( FD_VOTER_MAX ) );
165- l = FD_LAYOUT_APPEND ( l , fd_forks_align (), fd_forks_footprint ( slot_max , FD_VOTER_MAX ) );
166- l = FD_LAYOUT_APPEND ( l , fd_tower_align (), fd_tower_footprint () );
167- l = FD_LAYOUT_APPEND ( l , fd_epoch_stakes_align (), fd_epoch_stakes_footprint ( slot_max ) );
168- l = FD_LAYOUT_APPEND ( l , fd_tower_forks_align (), fd_tower_forks_footprint ( lg_slot_max ) );
169- l = FD_LAYOUT_APPEND ( l , fd_tower_align (), fd_tower_footprint () ); /* ctx->tower_spare */
170- l = FD_LAYOUT_APPEND ( l , notif_align (), notif_footprint ( slot_max ) );
158+ l = FD_LAYOUT_APPEND ( l , alignof(ctx_t ), sizeof (ctx_t ) );
159+ l = FD_LAYOUT_APPEND ( l , fd_ghost_align (), fd_ghost_footprint ( 2 * slot_max , FD_VOTER_MAX ) );
160+ l = FD_LAYOUT_APPEND ( l , fd_hfork_align (), fd_hfork_footprint ( slot_max , FD_VOTER_MAX ) );
161+ l = FD_LAYOUT_APPEND ( l , fd_notar_align (), fd_notar_footprint ( tile -> tower .max_vote_lookahead ) );
162+ l = FD_LAYOUT_APPEND ( l , fd_tower_align (), fd_tower_footprint () );
163+ l = FD_LAYOUT_APPEND ( l , fd_tower_accts_align (), fd_tower_accts_footprint ( FD_VOTER_MAX ) );
164+ l = FD_LAYOUT_APPEND ( l , fd_forks_align (), fd_forks_footprint ( slot_max , FD_VOTER_MAX ) );
165+ l = FD_LAYOUT_APPEND ( l , fd_tower_align (), fd_tower_footprint () ); /* ctx->tower_spare */
166+ l = FD_LAYOUT_APPEND ( l , fd_epoch_stakes_align (), fd_epoch_stakes_footprint ( slot_max ) );
167+ l = FD_LAYOUT_APPEND ( l , notif_align (), notif_footprint ( slot_max ) );
171168 return FD_LAYOUT_FINI ( l , scratch_align () );
172169}
173170
@@ -474,7 +471,12 @@ replay_slot_completed( ctx_t * ctx,
474471 /* Query our on-chain vote acct and reconcile with our local tower. */
475472
476473 int found = query_vote_state_from_accdb ( ctx -> accdb , & xid , ctx -> vote_account , ctx -> our_vote_acct );
477- if ( FD_LIKELY ( found ) ) fd_tower_reconcile ( ctx -> tower , ctx -> root_slot , ctx -> our_vote_acct );
474+ if ( FD_LIKELY ( found ) ) {
475+ fd_tower_reconcile ( ctx -> tower , ctx -> root_slot , ctx -> our_vote_acct );
476+ /* Sanity check that most recent vote in tower exists in tower forks */
477+ fd_tower_vote_t const * last_vote = fd_tower_peek_tail_const ( ctx -> tower );
478+ FD_TEST ( !last_vote || fd_forks_query ( ctx -> forks , last_vote -> slot ) );
479+ }
478480
479481 /* Insert the vote acct addrs and stakes from the bank into accts. */
480482
@@ -782,19 +784,19 @@ unprivileged_init( fd_topo_t * topo,
782784 void * accts = FD_SCRATCH_ALLOC_APPEND ( l , fd_tower_accts_align (), fd_tower_accts_footprint ( FD_VOTER_MAX ) );
783785 void * forks = FD_SCRATCH_ALLOC_APPEND ( l , fd_forks_align (), fd_forks_footprint ( slot_max , FD_VOTER_MAX ) );
784786 void * spare = FD_SCRATCH_ALLOC_APPEND ( l , fd_tower_align (), fd_tower_footprint () );
785- void * stake = FD_SCRATCH_ALLOC_APPEND ( l , fd_epoch_stakes_align (), fd_epoch_stakes_footprint ( slot_max ) );
787+ void * stake = FD_SCRATCH_ALLOC_APPEND ( l , fd_epoch_stakes_align (), fd_epoch_stakes_footprint ( slot_max ) );
786788 void * notif = FD_SCRATCH_ALLOC_APPEND ( l , notif_align (), notif_footprint ( slot_max ) );
787789 FD_SCRATCH_ALLOC_FINI ( l , scratch_align () );
788790
789- ctx -> ghost = fd_ghost_join ( fd_ghost_new ( ghost , 2 * slot_max , FD_VOTER_MAX , 42UL ) ); /* FIXME seed */
790- ctx -> hfork = fd_hfork_join ( fd_hfork_new ( hfork , slot_max , FD_VOTER_MAX , ctx -> seed , tile -> tower .hard_fork_fatal ) );
791- ctx -> notar = fd_notar_join ( fd_notar_new ( notar , tile -> tower .max_vote_lookahead ) );
792- ctx -> tower = fd_tower_join ( fd_tower_new ( tower ) );
793- ctx -> tower_accts = fd_tower_accts_join ( fd_tower_accts_new ( accts , FD_VOTER_MAX ) );
794- ctx -> forks = fd_forks_join ( fd_forks_new ( forks , slot_max , FD_VOTER_MAX ) );
795- ctx -> tower_spare = fd_tower_join ( fd_tower_new ( spare ) );
796- ctx -> slot_stakes = fd_epoch_stakes_join ( fd_epoch_stakes_new ( stake , slot_max ) );
797- ctx -> notif = notif_join ( notif_new ( notif , slot_max ) );
791+ ctx -> ghost = fd_ghost_join ( fd_ghost_new ( ghost , 2 * slot_max , FD_VOTER_MAX , 42UL ) ); /* FIXME seed */
792+ ctx -> hfork = fd_hfork_join ( fd_hfork_new ( hfork , slot_max , FD_VOTER_MAX , ctx -> seed , tile -> tower .hard_fork_fatal ) );
793+ ctx -> notar = fd_notar_join ( fd_notar_new ( notar , tile -> tower .max_vote_lookahead ) );
794+ ctx -> tower = fd_tower_join ( fd_tower_new ( tower ) );
795+ ctx -> tower_accts = fd_tower_accts_join ( fd_tower_accts_new ( accts , FD_VOTER_MAX ) );
796+ ctx -> forks = fd_forks_join ( fd_forks_new ( forks , slot_max , FD_VOTER_MAX ) );
797+ ctx -> tower_spare = fd_tower_join ( fd_tower_new ( spare ) );
798+ ctx -> slot_stakes = fd_epoch_stakes_join ( fd_epoch_stakes_new ( stake , slot_max ) );
799+ ctx -> notif = notif_join ( notif_new ( notif , slot_max ) );
798800 FD_TEST ( ctx -> ghost );
799801 FD_TEST ( ctx -> hfork );
800802 FD_TEST ( ctx -> notar );
0 commit comments