Commit 0f1b0dc
feat: add sqlite peer_db (#6963)
Description
---
- Added an sqlite implementation of peer_db.
- Removed the lmdb implementation of peer_db.
Motivation and Context
---
The lmdb peer_db was memory and resource intensive.
How Has This Been Tested?
---
New unit tests
Existing unit tests depending on the new peer_db implementation pass
System-level testing passed
What process can a PR reviewer use to test or verify this change?
---
Code review
System-level testing
<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->
Breaking Changes
---
- [ ] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [X] Other - Please specify
<!-- Does this include a breaking change? If so, include this line as a
footer -->
BREAKING CHANGES:
- The existing lmbd peer_db will be discarded (left intact but not used
anymore).
- In PeerManager, the method `fn closest_peers` is replaced with `fn
closest_n_active_peers` as amore flexible alternative.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
## Summary by CodeRabbit
- **New Features**
- Transitioned peer storage backend from LMDB to SQLite, enhancing
reliability and simplifying setup.
- Added test utilities for creating peers with address stats and recent
last-seen timestamps.
- Extended peer and address data structures with constructors,
conversion methods, and reset functions.
- **Bug Fixes**
- Unified peer add/update operations into `add_or_update_peer` for
consistency across modules.
- Corrected configuration comments to specify SQLite database paths
instead of LMDB.
- **Refactor**
- Removed legacy peer query framework and migration code; replaced with
async wrappers over SQLite.
- Enhanced peer selection, filtering, and banning logic to leverage new
database queries.
- Simplified batch peer retrieval in wallet and FFI layers with direct
SQL queries.
- Updated test setups to use SQLite, replacing in-memory or LMDB
dependencies.
- Replaced direct sync calls with async wrappers in discovery, network,
and connection modules.
- Improved asynchronous handling and batch processing for peer
management.
- **Chores**
- Removed LMDB and related dependencies; added SQLite, Diesel, and
migration crates.
- Created SQL migration scripts for node identity, peers, and addresses
schemas.
- Managed temporary database cleanup in tests and connection pools.
- Cleaned imports and streamlined peer manager initialization in
examples and tests.
- **Documentation**
- Updated configuration comments to clarify transition from LMDB to
SQLite storage paths.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Stan Bondi <sdbondi@users.noreply.github.com>1 parent 8a6f229 commit 0f1b0dc
File tree
121 files changed
+6092
-2937
lines changed- applications
- minotari_console_wallet/src
- automation
- grpc
- init
- ui
- state
- minotari_node/src
- commands/command
- grpc
- base_layer
- contacts
- src
- chat_client/src
- contacts_service/storage
- tests
- core
- src
- base_node
- state_machine_service/states
- sync/rpc
- mempool/rpc
- test_helpers
- transactions/transaction_key_manager
- tests/tests
- p2p
- src
- services/liveness
- wallet_ffi/src
- wallet
- src
- storage/sqlite_utilities
- tests
- other
- transaction_service_tests
- common_sqlite
- src
- common/config/presets
- comms
- core
- examples
- stress
- src
- builder
- connection_manager
- tests
- connectivity
- net_address
- peer_manager
- migrations
- storage
- migrations
- 2025-04-14-072200_initial
- protocol
- messaging
- rpc/test
- test_utils
- factories
- tests/tests
- dht
- examples
- memory_net
- propagation
- src
- connectivity
- discovery
- inbound
- dht_handler
- network_discovery
- rpc
- test_utils
- tests
- supply-chain
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
121 files changed
+6092
-2937
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| |||
2600 | 2600 | | |
2601 | 2601 | | |
2602 | 2602 | | |
2603 | | - | |
2604 | 2603 | | |
2605 | 2604 | | |
2606 | 2605 | | |
2607 | | - | |
| 2606 | + | |
2608 | 2607 | | |
2609 | 2608 | | |
2610 | 2609 | | |
| |||
Lines changed: 23 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1205 | 1205 | | |
1206 | 1206 | | |
1207 | 1207 | | |
1208 | | - | |
1209 | | - | |
1210 | | - | |
1211 | | - | |
1212 | | - | |
1213 | | - | |
1214 | | - | |
1215 | | - | |
1216 | | - | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
1217 | 1231 | | |
1218 | 1232 | | |
1219 | 1233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
350 | | - | |
351 | | - | |
| 350 | + | |
352 | 351 | | |
353 | 352 | | |
354 | | - | |
| 353 | + | |
355 | 354 | | |
356 | 355 | | |
357 | 356 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| |||
Lines changed: 8 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
942 | 942 | | |
943 | 943 | | |
944 | 944 | | |
945 | | - | |
946 | | - | |
947 | | - | |
948 | | - | |
949 | | - | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
950 | 953 | | |
951 | | - | |
952 | 954 | | |
953 | 955 | | |
954 | 956 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| |||
Lines changed: 20 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
63 | 77 | | |
64 | 78 | | |
65 | 79 | | |
| |||
Lines changed: 12 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
0 commit comments