Skip to content

Commit 8b89531

Browse files
replay: adding randomly generated seeds (#7552)
1 parent 8ec4597 commit 8b89531

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/discof/replay/fd_replay_tile.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,15 @@ struct fd_replay_tile {
155155
TODO: Add a flag to the toml to make this optional. */
156156
int has_identity_vote_rooted;
157157

158+
ulong reasm_seed;
158159
fd_reasm_t * reasm;
159160

160161
/* Replay state machine. */
161162
fd_sched_t * sched;
162163
ulong exec_cnt;
163164
fd_replay_out_link_t exec_out[ 1 ]; /* Sending work down to exec tiles */
164165

166+
ulong vote_tracker_seed;
165167
fd_vote_tracker_t * vote_tracker;
166168

167169
int has_genesis_hash;
@@ -325,6 +327,7 @@ struct fd_replay_tile {
325327
id to send a slot complete message to tower. */
326328
ulong block_id_len;
327329
fd_block_id_ele_t * block_id_arr;
330+
ulong block_id_map_seed;
328331
fd_block_id_map_t * block_id_map;
329332

330333
/* Capture-related configs */
@@ -2317,12 +2320,25 @@ privileged_init( fd_topo_t * topo,
23172320
if( FD_UNLIKELY( !tile->replay.bundle.vote_account_path[0] ) ) {
23182321
tile->replay.bundle.enabled = 0;
23192322
}
2323+
23202324
if( FD_UNLIKELY( tile->replay.bundle.enabled ) ) {
23212325
if( FD_UNLIKELY( !fd_base58_decode_32( tile->replay.bundle.vote_account_path, ctx->bundle.vote_account.uc ) ) ) {
23222326
const uchar * vote_key = fd_keyload_load( tile->replay.bundle.vote_account_path, /* pubkey only: */ 1 );
23232327
fd_memcpy( ctx->bundle.vote_account.uc, vote_key, 32UL );
23242328
}
23252329
}
2330+
2331+
if( FD_UNLIKELY( !fd_rng_secure( &ctx->reasm_seed, sizeof(ulong) ) ) ) {
2332+
FD_LOG_CRIT(( "fd_rng_secure failed" ));
2333+
}
2334+
2335+
if( FD_UNLIKELY( !fd_rng_secure( &ctx->vote_tracker_seed, sizeof(ulong) ) ) ) {
2336+
FD_LOG_CRIT(( "fd_rng_secure failed" ));
2337+
}
2338+
2339+
if( FD_UNLIKELY( !fd_rng_secure( &ctx->block_id_map_seed, sizeof(ulong) ) ) ) {
2340+
FD_LOG_CRIT(( "fd_rng_secure failed" ));
2341+
}
23262342
}
23272343

23282344
static void
@@ -2433,13 +2449,13 @@ unprivileged_init( fd_topo_t * topo,
24332449

24342450
ctx->larger_max_cost_per_block = tile->replay.larger_max_cost_per_block;
24352451

2436-
ctx->reasm = fd_reasm_join( fd_reasm_new( reasm_mem, 1 << 20, 0 ) );
2452+
ctx->reasm = fd_reasm_join( fd_reasm_new( reasm_mem, 1 << 20, ctx->reasm_seed ) );
24372453
FD_TEST( ctx->reasm );
24382454

24392455
ctx->sched = fd_sched_join( fd_sched_new( sched_mem, tile->replay.max_live_slots, ctx->exec_cnt ), tile->replay.max_live_slots );
24402456
FD_TEST( ctx->sched );
24412457

2442-
ctx->vote_tracker = fd_vote_tracker_join( fd_vote_tracker_new( vote_tracker_mem, 0UL ) );
2458+
ctx->vote_tracker = fd_vote_tracker_join( fd_vote_tracker_new( vote_tracker_mem, ctx->vote_tracker_seed ) );
24432459
FD_TEST( ctx->vote_tracker );
24442460

24452461
ctx->has_identity_vote_rooted = 0;
@@ -2455,14 +2471,13 @@ unprivileged_init( fd_topo_t * topo,
24552471
ctx->next_leader_slot = ULONG_MAX;
24562472
ctx->next_leader_tickcount = LONG_MAX;
24572473
ctx->highwater_leader_slot = ULONG_MAX;
2458-
ctx->slot_duration_nanos = 350L*1000L*1000L; /* TODO: Not fixed ... not always 400ms ... */
2474+
ctx->slot_duration_nanos = 350L*1000L*1000L; /* TODO: Not fixed ... not always 350ms ... */
24592475
ctx->slot_duration_ticks = (double)ctx->slot_duration_nanos*fd_tempo_tick_per_ns( NULL );
24602476
ctx->leader_bank = NULL;
24612477

2462-
/* TODO: We need a real seed here. */
24632478
ctx->block_id_len = tile->replay.max_live_slots;
24642479
ctx->block_id_arr = (fd_block_id_ele_t *)block_id_arr_mem;
2465-
ctx->block_id_map = fd_block_id_map_join( fd_block_id_map_new( block_id_map_mem, chain_cnt, 999UL ) );
2480+
ctx->block_id_map = fd_block_id_map_join( fd_block_id_map_new( block_id_map_mem, chain_cnt, ctx->block_id_map_seed ) );
24662481
FD_TEST( ctx->block_id_map );
24672482

24682483
for( ulong i=0UL; i<tile->replay.max_live_slots; i++ ) {

0 commit comments

Comments
 (0)