Commit e5a0854
feat: new bootstrap process (#7121)
Description
---
Implement a better bootstrap process so we don't overload seed nodes
Motivation and Context
---
Implement the following bootstrap process:
1. Get the list of seed peers.
2. Connect to the seed peers (all of them) one at a time, and get THEIR
list of peers, and then immediately disconnect.
3. Once the peer DHT is populated with a bunch of non-seed peers then we
can actually connect to the network - but we also make sure the seed
peers DO NOT form part of the DHT.
Basically the seed nodes should never be connected to for very long,
because otherwise their connection pool dries up.
How Has This Been Tested?
---
"It works on my machine"
What process can a PR reviewer use to test or verify this change?
---
Clear the whole ~/.tari/mainnet folder, and start the node up from
scratch. Look for the following debug lines in network.log:
`[comms::dht::network_discovery::seed_strap] [Thread:55429085] DEBUG
Attempting to discover peers via seed nodes. //
comms/dht/src/network_discovery/seed_strap.rs:61`
And then:
`[comms::dht::network_discovery::seed_strap] [Thread:55429095] INFO
Added 992 peers via seed nodes. Transitioning to Ready state. //
comms/dht/src/network_discovery/seed_strap.rs:71`
Breaking Changes
---
- [x] None
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **New Features**
- Introduced a new seed bootstrap phase for peer discovery, improving
network initialization and robustness.
- Enhanced UI to display detailed bootstrap progress, including current
and total bootstrap rounds.
- Added configuration options for controlling bootstrap and seed peer
synchronization behavior.
- Added new events signaling bootstrap method determination and primary
bootstrap completion.
- **Improvements**
- More accurate and explicit tracking of bootstrap completion and peer
synchronization status.
- Improved event handling and state transitions during node startup and
synchronization, integrating DHT events.
- Enhanced logging and diagnostics for bootstrap and peer discovery
processes.
- Refined sync state transitions based on peer metadata and bootstrap
completion.
- Updated peer flags to explicitly mark seed peers.
- Replaced peer manager event streams with DHT event subscriptions for
state machine event handling.
- Expanded public API to expose additional network discovery types and
modules.
- Improved test stability and coverage by updating imports and event
sources.
- Added a bootstrap timeout mechanism to prevent UI deadlocks during
prolonged bootstrap.
- Enhanced network discovery state machine with explicit bootstrap
method tracking and event publishing.
- Improved peer discovery logic with early exit conditions and detailed
peer categorization.
- Refactored discovery ready state to better handle discovery rounds and
transitions.
- **Bug Fixes**
- Resolved issues where missed bootstrap events could cause UI state
inconsistencies or deadlocks.
- Suppressed unnecessary warnings in mempool validation and Monero extra
field deserialization.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Riccardo Spagni <ric@spagni.net>1 parent 1e7ac28 commit e5a0854
File tree
31 files changed
+1867
-456
lines changed- base_layer
- core
- src
- base_node
- state_machine_service
- states
- sync
- mempool
- proof_of_work/monero_rx
- tests
- helpers
- tests
- p2p/src
- comms/dht/src
- network_discovery
- rpc
31 files changed
+1867
-456
lines changedLines changed: 4 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | 23 | | |
26 | | - | |
| 24 | + | |
| 25 | + | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
| |||
104 | 103 | | |
105 | 104 | | |
106 | 105 | | |
107 | | - | |
108 | 106 | | |
109 | 107 | | |
110 | 108 | | |
111 | 109 | | |
| 110 | + | |
112 | 111 | | |
113 | 112 | | |
114 | 113 | | |
115 | 114 | | |
116 | | - | |
117 | 115 | | |
| 116 | + | |
118 | 117 | | |
119 | 118 | | |
120 | 119 | | |
| |||
123 | 122 | | |
124 | 123 | | |
125 | 124 | | |
126 | | - | |
127 | 125 | | |
128 | 126 | | |
129 | 127 | | |
| |||
Lines changed: 41 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | | - | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | 93 | | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
107 | | - | |
| 108 | + | |
| 109 | + | |
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
111 | 113 | | |
112 | | - | |
113 | 114 | | |
| 115 | + | |
114 | 116 | | |
115 | 117 | | |
116 | 118 | | |
| |||
123 | 125 | | |
124 | 126 | | |
125 | 127 | | |
126 | | - | |
127 | 128 | | |
| 129 | + | |
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
134 | 136 | | |
| 137 | + | |
135 | 138 | | |
136 | 139 | | |
137 | 140 | | |
| |||
283 | 286 | | |
284 | 287 | | |
285 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
286 | 321 | | |
287 | 322 | | |
288 | 323 | | |
| |||
Lines changed: 55 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| |||
179 | 178 | | |
180 | 179 | | |
181 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
182 | 229 | | |
183 | 230 | | |
184 | 231 | | |
| |||
211 | 258 | | |
212 | 259 | | |
213 | 260 | | |
214 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
215 | 268 | | |
216 | 269 | | |
217 | 270 | | |
| |||
0 commit comments