1
1
use anyhow:: Result ;
2
- use aptos_config:: config:: {
3
- Peer , PeerRole , PeerSet , RocksdbConfigs , StorageDirPaths , NO_OP_STORAGE_PRUNER_CONFIG ,
4
- } ;
5
- use aptos_crypto:: { x25519, ValidCryptoMaterialStringExt } ;
2
+ use aptos_config:: config:: { RocksdbConfigs , StorageDirPaths , NO_OP_STORAGE_PRUNER_CONFIG } ;
6
3
use aptos_db:: AptosDB ;
7
4
use aptos_storage_interface:: DbReader ;
8
- use aptos_types:: {
9
- account_address:: from_identity_public_key, network_address:: NetworkAddress ,
10
- transaction:: Transaction , waypoint:: Waypoint , PeerId ,
11
- } ;
12
- use serde_yaml;
13
- use std:: {
14
- collections:: { HashMap , HashSet } ,
15
- fs,
16
- path:: Path ,
17
- str:: FromStr ,
18
- } ;
5
+ use aptos_types:: { transaction:: Transaction , waypoint:: Waypoint } ;
6
+ use std:: { fs, path:: Path } ;
19
7
20
8
/// Extract genesis transaction and waypoint from an Aptos database
21
9
pub fn extract_genesis_and_waypoint ( db_path : & str , output_dir : & str ) -> Result < ( ) > {
@@ -51,11 +39,15 @@ pub fn extract_genesis_and_waypoint(db_path: &str, output_dir: &str) -> Result<(
51
39
// Extract genesis transaction
52
40
extract_genesis_transaction ( & db, latest_ver, output_dir) ?;
53
41
42
+ // Extract genesis waypoint
43
+ extract_genesis_waypoint ( & db, latest_ver, output_dir) ?;
44
+
54
45
// Extract waypoint
55
46
extract_waypoint ( & db, output_dir) ?;
56
47
57
48
println ! ( "✓ Genesis extraction completed successfully!" ) ;
58
49
println ! ( " - genesis.blob: Contains the BCS-serialized genesis transaction" ) ;
50
+ println ! ( " - genesis_waypoint.txt: Contains the genesis waypoint for bootstrapping" ) ;
59
51
println ! ( " - waypoint.txt: Contains the initial waypoint for bootstrapping" ) ;
60
52
61
53
Ok ( ( ) )
@@ -82,6 +74,30 @@ fn extract_genesis_transaction(db: &AptosDB, latest_ver: u64, output_dir: &str)
82
74
Ok ( ( ) )
83
75
}
84
76
77
+ /// Extract the genesis waypoint from the database at version 0
78
+ fn extract_genesis_waypoint ( db : & AptosDB , _latest_ver : u64 , output_dir : & str ) -> Result < ( ) > {
79
+ println ! ( "Extracting genesis waypoint (version 0)..." ) ;
80
+
81
+ // Get the epoch ending ledger info for version 0 (genesis)
82
+ // This should always exist for a properly initialized database
83
+ let genesis_ledger_info_with_sigs = db
84
+ . get_epoch_ending_ledger_info ( 0 )
85
+ . expect ( "genesis waypoint should exist" ) ;
86
+
87
+ let genesis_ledger_info = genesis_ledger_info_with_sigs. ledger_info ( ) ;
88
+
89
+ // Generate genesis waypoint using the genesis ledger info
90
+ let genesis_waypoint = Waypoint :: new_any ( genesis_ledger_info) ;
91
+
92
+ // Write genesis_waypoint.txt
93
+ let genesis_waypoint_path = format ! ( "{}/genesis_waypoint.txt" , output_dir) ;
94
+ fs:: write ( & genesis_waypoint_path, genesis_waypoint. to_string ( ) ) ?;
95
+ println ! ( "Genesis waypoint written to: {}" , genesis_waypoint_path) ;
96
+ println ! ( "Genesis waypoint: {}" , genesis_waypoint) ;
97
+
98
+ Ok ( ( ) )
99
+ }
100
+
85
101
/// Extract the waypoint from the database using proper waypoint conversion
86
102
fn extract_waypoint ( db : & AptosDB , output_dir : & str ) -> Result < ( ) > {
87
103
// Get the ledger info to extract waypoint
0 commit comments