@@ -20,9 +20,41 @@ use node::{
20
20
21
21
use openmina_node_native:: { archive:: config:: ArchiveStorageOptions , tracing, NodeBuilder } ;
22
22
23
- /// Openmina node
23
+ /// OpenMina node configuration and runtime options
24
+ ///
25
+ /// This struct defines all available command-line parameters for running an OpenMina node.
26
+ /// The node can operate in different modes (basic node, block producer, archive node)
27
+ /// depending on the parameters provided.
28
+ ///
29
+ /// # Basic Usage
30
+ ///
31
+ /// ```bash
32
+ /// # Run a basic node on devnet
33
+ /// openmina node --network devnet
34
+ ///
35
+ /// # Run with custom ports and logging
36
+ /// openmina node --network devnet --port 3001 --libp2p-port 8303 --verbosity debug
37
+ /// ```
38
+ ///
39
+ /// # Block Producer Mode
40
+ ///
41
+ /// ```bash
42
+ /// # Run as block producer
43
+ /// openmina node --network devnet --producer-key /path/to/key --coinbase-receiver B62q...
44
+ /// ```
45
+ ///
46
+ /// # Archive Node Mode
47
+ ///
48
+ /// ```bash
49
+ /// # Run as archive node with local storage
50
+ /// openmina node --network devnet --archive-local-storage
51
+ /// ```
24
52
#[ derive( Debug , clap:: Args ) ]
25
53
pub struct Node {
54
+ /// Working directory for node data, logs, and configuration files
55
+ ///
56
+ /// Can be set via OPENMINA_HOME environment variable.
57
+ /// Defaults to ~/.openmina
26
58
#[ arg(
27
59
long,
28
60
short = 'd' ,
@@ -31,7 +63,10 @@ pub struct Node {
31
63
) ]
32
64
pub work_dir : String ,
33
65
34
- /// Peer secret key
66
+ /// P2P networking secret key for node identity
67
+ ///
68
+ /// If not provided, a new key will be generated automatically.
69
+ /// Can be set via OPENMINA_P2P_SEC_KEY environment variable.
35
70
#[ arg( long, short = 's' , env = "OPENMINA_P2P_SEC_KEY" ) ]
36
71
pub p2p_secret_key : Option < SecretKey > ,
37
72
@@ -49,15 +84,28 @@ pub struct Node {
49
84
#[ arg( long) ]
50
85
pub libp2p_external_ip : Vec < String > ,
51
86
52
- /// Http port to listen on
87
+ /// HTTP server port for RPC API and web interface
88
+ ///
89
+ /// The node will serve its HTTP API and dashboard on this port.
90
+ /// Default: 3000
53
91
#[ arg( long, short, env, default_value = "3000" ) ]
54
92
pub port : u16 ,
55
93
56
- /// LibP2P port to listen on
94
+ /// LibP2P networking port for peer-to-peer communication
95
+ ///
96
+ /// This port is used for connecting to other nodes in the network.
97
+ /// Default: 8302
57
98
#[ arg( long, env, default_value = "8302" ) ]
58
99
pub libp2p_port : u16 ,
59
100
60
- /// Verbosity level (options: trace, debug, info, warn, error)
101
+ /// Logging verbosity level
102
+ ///
103
+ /// Controls the amount of logging output. Options in order of verbosity:
104
+ /// - error: Only show errors
105
+ /// - warn: Show warnings and errors
106
+ /// - info: Show informational messages, warnings, and errors (default)
107
+ /// - debug: Show debug information and all above
108
+ /// - trace: Show all possible logging output
61
109
#[ arg( long, short, env, default_value = "info" ) ]
62
110
pub verbosity : Level ,
63
111
@@ -73,21 +121,71 @@ pub struct Node {
73
121
#[ arg( long, env = "OPENMINA_LOG_PATH" , default_value = "$OPENMINA_HOME" ) ]
74
122
pub log_path : String ,
75
123
124
+ /// Initial peers to connect to on startup
125
+ ///
126
+ /// Specify peer multiaddresses to connect to when the node starts.
127
+ /// Can be used multiple times to add multiple peers.
128
+ ///
129
+ /// # Multiaddr Format
130
+ ///
131
+ /// Multiaddresses follow the format: `/protocol/address/protocol/port/protocol/peer_id`
132
+ ///
133
+ /// **IPv4 Example:**
134
+ /// ```
135
+ /// /ip4/192.168.1.100/tcp/8302/p2p/12D3KooWABCDEF1234567890abcdef...
136
+ /// ```
137
+ ///
138
+ /// **IPv6 Example:**
139
+ /// ```
140
+ /// /ip6/2001:db8::1/tcp/8302/p2p/12D3KooWABCDEF1234567890abcdef...
141
+ /// ```
142
+ ///
143
+ /// **DNS Example:**
144
+ /// ```
145
+ /// /dns4/node.example.com/tcp/8302/p2p/12D3KooWABCDEF1234567890abcdef...
146
+ /// ```
147
+ ///
148
+ /// Where:
149
+ /// - `ip4/ip6/dns4` specifies the address type
150
+ /// - IP address or hostname
151
+ /// - `tcp` protocol with port number (typically 8302 for OpenMina)
152
+ /// - `p2p` protocol with the peer's public key identifier
76
153
#[ arg( long, short = 'P' , alias = "peer" ) ]
77
154
pub peers : Vec < P2pConnectionOutgoingInitOpts > ,
78
155
79
- /// File containing initial peers.
156
+ /// File containing initial peers to connect to
80
157
///
81
- /// Each line should contain peer's multiaddr.
158
+ /// Each line should contain a peer's multiaddr following the format described above.
159
+ ///
160
+ /// **Example file content:**
161
+ /// ```
162
+ /// /ip4/192.168.1.100/tcp/8302/p2p/12D3KooWABCDEF1234567890abcdef...
163
+ /// /ip4/10.0.0.50/tcp/8302/p2p/12D3KooWXYZ9876543210fedcba...
164
+ /// /dns4/bootstrap.example.com/tcp/8302/p2p/12D3KooW123ABC...
165
+ /// ```
166
+ ///
167
+ /// Empty lines and lines starting with `#` are ignored.
82
168
#[ arg( long, env) ]
83
169
pub peer_list_file : Option < PathBuf > ,
84
170
85
- /// File containing initial peers.
171
+ /// URL to fetch initial peers list from
86
172
///
87
- /// Each line should contain peer's multiaddr.
173
+ /// The URL should return a text file with one peer multiaddr per line,
174
+ /// using the same format as described in `peer_list_file`.
175
+ /// Useful for dynamic peer discovery from a central bootstrap service.
176
+ ///
177
+ /// **Example URL response:**
178
+ /// ```
179
+ /// /ip4/bootstrap1.example.com/tcp/8302/p2p/12D3KooW...
180
+ /// /ip4/bootstrap2.example.com/tcp/8302/p2p/12D3KooX...
181
+ /// ```
88
182
#[ arg( long, env) ]
89
183
pub peer_list_url : Option < Url > ,
90
184
185
+ /// Maximum number of peer connections to maintain
186
+ ///
187
+ /// The node will attempt to maintain up to this many connections
188
+ /// to other peers in the network. Default: 100
91
189
#[ arg( long, default_value = "100" ) ]
92
190
pub max_peers : usize ,
93
191
0 commit comments