@@ -31,10 +31,14 @@ struct GithubContent {
3131pub async fn init_fullnode_yaml (
3232 home_dir : Option < PathBuf > ,
3333 overwrite_peers : bool ,
34+ archive_mode : bool ,
3435) -> anyhow:: Result < PathBuf > {
3536 let waypoint = get_genesis_waypoint ( home_dir. clone ( ) ) . await ?;
3637
37- let yaml = make_fullnode_yaml ( home_dir. clone ( ) , waypoint) ?;
38+ let yaml = match archive_mode {
39+ true => make_fullnode_archive_yaml ( home_dir. clone ( ) , waypoint) ?,
40+ false => make_fullnode_fast_sync_yaml ( home_dir. clone ( ) , waypoint) ?,
41+ } ;
3842
3943 let home = home_dir. unwrap_or_else ( global_config_dir) ;
4044 let p = home. join ( FN_FILENAME ) ;
@@ -85,8 +89,51 @@ pub async fn fetch_seed_addresses(
8589 Ok ( seeds)
8690}
8791
92+ /// A fullnode config which does a fast sync to the chain
93+ /// as opposed to the default fullnode config for archive nodes.
94+ pub fn make_fullnode_fast_sync_yaml (
95+ home_dir : Option < PathBuf > ,
96+ waypoint : Waypoint ,
97+ ) -> anyhow:: Result < String > {
98+ let home_dir = home_dir. unwrap_or_else ( global_config_dir) ;
99+ let path = home_dir. display ( ) . to_string ( ) ;
100+
101+ // Create the YAML template with necessary configurations
102+ let template = format ! (
103+ "
104+ base:
105+ role: 'full_node'
106+ data_dir: '{path}/data'
107+ waypoint:
108+ from_config: '{waypoint}'
109+
110+ execution:
111+ genesis_file_location: '{path}/genesis/genesis.blob'
112+
113+ state_sync:
114+ state_sync_driver:
115+ bootstrapping_mode: DownloadLatestStates
116+ continuous_syncing_mode: ApplyTransactionOutputs
117+
118+ full_node_networks:
119+ - network_id: 'public'
120+ listen_address: '/ip4/0.0.0.0/tcp/6182'
121+ max_outbound_connections: 10
122+
123+
124+ api:
125+ enabled: true
126+ address: '0.0.0.0:8080'
127+ "
128+ ) ;
129+ Ok ( template)
130+ }
131+
88132/// Create a fullnode yaml to bootstrap node
89- pub fn make_fullnode_yaml ( home_dir : Option < PathBuf > , waypoint : Waypoint ) -> anyhow:: Result < String > {
133+ pub fn make_fullnode_archive_yaml (
134+ home_dir : Option < PathBuf > ,
135+ waypoint : Waypoint ,
136+ ) -> anyhow:: Result < String > {
90137 let home_dir = home_dir. unwrap_or_else ( global_config_dir) ;
91138 let path = home_dir. display ( ) . to_string ( ) ;
92139
@@ -106,10 +153,19 @@ state_sync:
106153 state_sync_driver:
107154 bootstrapping_mode: ExecuteOrApplyFromGenesis
108155 continuous_syncing_mode: ApplyTransactionOutputs
156+ storage:
157+ storage_pruner_config:
158+ ledger_pruner_config:
159+ enable: false
160+ state_merkle_pruner_config:
161+ enable: false
162+ epoch_snapshot_pruner_config:
163+ enable: false
109164
110165full_node_networks:
111166- network_id: 'public'
112167 listen_address: '/ip4/0.0.0.0/tcp/6182'
168+ max_outbound_connections: 10
113169
114170api:
115171 enabled: true
@@ -146,9 +202,19 @@ state_sync:
146202 bootstrapping_mode: ApplyTransactionOutputsFromGenesis
147203 continuous_syncing_mode: ApplyTransactionOutputs
148204
205+ storage:
206+ storage_pruner_config:
207+ ledger_pruner_config:
208+ enable: false
209+ state_merkle_pruner_config:
210+ enable: false
211+ epoch_snapshot_pruner_config:
212+ enable: false
213+
149214full_node_networks:
150215- network_id: 'public'
151216 listen_address: '/ip4/0.0.0.0/tcp/6182'
217+ max_outbound_connections: 10
152218 identity:
153219 type: 'from_file'
154220 path: {path}/validator-full-node-identity.yaml
@@ -180,21 +246,14 @@ mempool:
180246 Ok ( template)
181247}
182248
183- // #[tokio::test]
184- // async fn get_peers() {
185- // let _seed = fetch_seed_addresses(None).await.unwrap();
186-
187- // TODO: test
188- // }
189-
190249#[ tokio:: test]
191250async fn get_yaml ( ) {
192251 use std:: str:: FromStr ;
193252 let p = diem_temppath:: TempPath :: new ( ) . path ( ) . to_owned ( ) ;
194253
195254 let seeds = fetch_seed_addresses ( None ) . await . unwrap ( ) ;
196255
197- let y = make_fullnode_yaml (
256+ let y = make_fullnode_archive_yaml (
198257 Some ( p. clone ( ) ) ,
199258 Waypoint :: from_str ( "0:95023f4d6a7e24cac3e52cad29697184db260214210b57aef3f1031ad4d8c02c" )
200259 . unwrap ( ) ,
0 commit comments