Skip to content

Commit 1326424

Browse files
snapshots: add cluster selection
1 parent 74f2c52 commit 1326424

File tree

6 files changed

+35
-17
lines changed

6 files changed

+35
-17
lines changed

src/app/firedancer/config/default.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,11 @@ user = ""
319319
# completing snapshot download.
320320
maximum_download_retry_abort = 5
321321

322+
# The cluster to download snapshots from. This is a temporary
323+
# config option that will be removed once the snapshot tiles
324+
# are integrated with gossip
325+
cluster = "testnet"
326+
322327
[rpc]
323328
# If nonzero, enable JSON RPC on this port, and use the next port
324329
# for the RPC websocket. If zero, disable JSON RPC.

src/app/firedancer/topology.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ static void
187187
setup_snapshots( config_t * config,
188188
fd_topo_tile_t * tile ) {
189189
fd_memcpy( tile->snaprd.snapshots_path, config->paths.snapshots, PATH_MAX );
190+
fd_memcpy( tile->snaprd.cluster, config->firedancer.snapshots.cluster, sizeof(tile->snaprd.cluster) );
190191
tile->snaprd.incremental_snapshot_fetch = config->firedancer.snapshots.incremental_snapshots;
191192
tile->snaprd.do_download = config->firedancer.snapshots.download;
192193
tile->snaprd.maximum_local_snapshot_age = config->firedancer.snapshots.maximum_local_snapshot_age;

src/app/shared/fd_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ struct fd_configf {
135135
char known_validators[ 16 ][ 256 ];
136136
uint minimum_download_speed_mib;
137137
uint maximum_download_retry_abort;
138+
char cluster[ 8UL ];
138139
} snapshots;
139140
};
140141

src/app/shared/fd_config_parse.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ fd_config_extract_podf( uchar * pod,
107107
CFG_POP_ARRAY ( cstr, snapshots.known_validators );
108108
CFG_POP ( uint, snapshots.minimum_download_speed_mib );
109109
CFG_POP ( uint, snapshots.maximum_download_retry_abort );
110+
CFG_POP ( cstr, snapshots.cluster );
110111

111112
return config;
112113
}

src/disco/topo/fd_topo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ struct fd_topo_tile {
452452

453453
struct {
454454
char snapshots_path[ PATH_MAX ];
455+
char cluster[ 8UL ];
455456
int incremental_snapshot_fetch;
456457
int do_download;
457458
uint maximum_local_snapshot_age;

src/discof/restore/fd_snaprd_tile.c

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@
146146

147147
/* TODO: these should be received from gossip */
148148
#define CLUSTER_SNAPSHOT_SLOT 0
149-
#define INITIAL_PEERS_COUNT 2UL
149+
#define INITIAL_PEERS_TESTNET_COUNT 2UL
150+
#define INITIAL_PEERS_PRIVATE_COUNT 1UL
150151

151-
fd_snapshot_peer_t initial_peers[ 2UL ] = {
152+
fd_snapshot_peer_t initial_peers_testnet[ 2UL ] = {
152153
{ .dest = {
153154
/* Solana testnet peer */
154155
.addr = FD_IP4_ADDR( 145, 40, 95, 69 ),
@@ -163,20 +164,14 @@ fd_snapshot_peer_t initial_peers[ 2UL ] = {
163164
}
164165
};
165166

166-
// fd_snapshot_peer_t initial_peers[ 2UL ] = {
167-
// { .dest = {
168-
// /* Solana testnet peer */
169-
// .addr = FD_IP4_ADDR( 170, 39, 214, 146 ),
170-
// .port = 8899
171-
// },
172-
// },
173-
// { .dest = {
174-
// /* A fast testnet peer from snapshot-finder script */
175-
// .addr = FD_IP4_ADDR( 177, 54, 155, 187 ),
176-
// .port = 8899
177-
// },
178-
// }
179-
// };
167+
fd_snapshot_peer_t initial_peers_private[ 1UL ] = {
168+
{ .dest = {
169+
/* A private cluster peer */
170+
.addr = FD_IP4_ADDR( 147, 28, 185, 47 ),
171+
.port = 8899
172+
},
173+
}
174+
};
180175

181176
/* fd_snaprd_download_pair indicates whether
182177
the full and incremental snapshots need to be downloaded or not. */
@@ -216,6 +211,7 @@ struct fd_snaprd_tile {
216211
uint maximum_local_snapshot_age;
217212
uint minimum_download_speed_mib;
218213
uint maximum_download_retry_abort;
214+
char cluster[ 8UL ];
219215
} config;
220216

221217
struct {
@@ -273,6 +269,7 @@ static void
273269
fd_snaprd_init_config( fd_snaprd_tile_t * ctx,
274270
fd_topo_tile_t * tile ) {
275271
fd_memcpy( ctx->config.path, tile->snaprd.snapshots_path, PATH_MAX );
272+
fd_memcpy( ctx->config.cluster, tile->snaprd.cluster, sizeof(ctx->config.cluster) );
276273
ctx->config.incremental_snapshot_fetch = tile->snaprd.incremental_snapshot_fetch;
277274
ctx->config.do_download = tile->snaprd.do_download;
278275
ctx->config.maximum_local_snapshot_age = tile->snaprd.maximum_local_snapshot_age;
@@ -613,9 +610,21 @@ after_credit( fd_snaprd_tile_t * ctx,
613610

614611
/* Because we are not receiving from gossip right now, just
615612
set peers to be initial peers */
613+
fd_snapshot_peer_t * initial_peers = NULL;
614+
ulong peers_cnt = 0UL;
615+
if( strcmp( ctx->config.cluster, "testnet" )==0 ) {
616+
initial_peers = initial_peers_testnet;
617+
peers_cnt = INITIAL_PEERS_TESTNET_COUNT;
618+
} else if( strcmp( ctx->config.cluster, "private" )== 0 ) {
619+
initial_peers = initial_peers_private;;
620+
peers_cnt = INITIAL_PEERS_PRIVATE_COUNT;
621+
} else {
622+
FD_LOG_ERR(( "snaprd: unexpected cluster %s", ctx->config.cluster ));
623+
}
624+
616625
fd_snapshot_peers_manager_set_peers_testing( ctx->peers_manager,
617626
initial_peers,
618-
INITIAL_PEERS_COUNT );
627+
peers_cnt );
619628
if( ctx->peers_manager->peers_cnt > 0 ) {
620629
ctx->wait_deadline_nanos = fd_log_wallclock() + ctx->wait_duration_nanos;
621630
ctx->state = FD_SNAPRD_STATE_COLLECTING_PEERS;

0 commit comments

Comments
 (0)