Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add multiaddr with range checks for use with universe (tari-pro…
…ject#6557) Description --- Added `MultiaddrRange`, which implements range checks for `Multiaddr`, when using IP4 with TCP. This enables specifying a range of IP4 with TCP addresses. As an exmple, any communication node can enable test addresses to connect to them (`allow_test_addresses = true`), but refrain from dialling any test addresses in return (`excluded_dial_addresses = ["/ip4/127.*.*.*/tcp/*"]`). With application to universe: - TCP seed node settings: ``` allow_test_addresses = true excluded_dial_addresses = [ "/ip4/127.*.*.*/tcp/0:18188", "/ip4/127.*.*.*/tcp/18190:65534", "/ip4/127.0.0.0/tcp/18189", "/ip4/127.1:255.1:255.2:255/tcp/18189" ] # Only '/ip4/127.0.0.1/tcp/0:18189' allowed ``` - Universe base node settings: ``` type = "tcp" public_addresses = ["/ip4/127.0.0.1/tcp/18189"] tcp.listener_address = "/ip4/0.0.0.0/tcp/18189" allow_test_addresses = true public_addresses = ["/ip4/127.0.0.1/tcp/18189"] #excluded_dial_addresses = [] ``` - Universe wallet settings: ``` dns_seeds = [] custom_base_node = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx::/ip4/127.0.0.1/tcp/18189" type = "tcp" public_addresses = ["/ip4/127.0.0.1/tcp/18188"] tcp.listener_address = "/ip4/0.0.0.0/tcp/18188" allow_test_addresses = true public_addresses = ["/ip4/127.0.0.1/tcp/18188"] #excluded_dial_addresses = [] ``` Motivation and Context --- Currently, Universe base nodes and wallets use `/ip4/172.2.3.4/tcp/18189` and `/ip4/172.2.3.4/tcp/18188` as their public addresses respectively, but any node trying to contact them is not able to. This results in many wasted resources. The Universe wallets also maintain connections with the seed nodes, which is not ideal. How Has This Been Tested? --- - Added new unit tests - System-level testing using the suggested settings^ (simulated seed node, simulated universe base node, simulated universe wallet) **From the seed node to the universe wallet** ``` >> add-peer 4602fb85883fec887e6b5e5a93cbc9547f19817685e78ff0a9e585826e322b44 /ip4/127.0.0.1/tcp/18188 Peer with node id '9a7764f742bf4e4bae6c5bd4f6' was added to the base node. >> ☎️ Dialing peer... ☠️ ConnectionFailed: All peer addresses are excluded for peer 9a7764f742bf4e4bae6c5bd4f6 ``` **From the seed node to the universe base node** ``` >> add-peer ee9ad9dce31a2d4a9225f4965e50df98ae4f85b58f94b34b9db9cc44f2aa2921 /ip4/127.0.0.1/tcp/18189 Peer with node id '998eb49cf4f2dd3b3d5a394c8e' was added to the base node. ☎️ Dialing peer... ⚡️ Peer connected in 0ms! Connection: Id: 1, Node ID: 998eb49cf4f2dd3b, Direction: Inbound, Peer Address: /ip4/192.168.5.114/tcp/62398, Age: 1913s, #Substreams: 2, #Refs: 2 ``` **From the universe base node to the universe wallet** ``` >> add-peer 4602fb85883fec887e6b5e5a93cbc9547f19817685e78ff0a9e585826e322b44 /ip4/127.0.0.1/tcp/18188 Peer with node id '9a7764f742bf4e4bae6c5bd4f6' was added to the base node. ☎️ Dialing peer... ⚡️ Peer connected in 0ms! Connection: Id: 8, Node ID: 9a7764f742bf4e4b, Direction: Inbound, Peer Address: /ip4/127.0.0.1/tcp/62412, Age: 2054s, #Substreams: 6, #Refs: 2 ``` **From the universe base node to the seed node** ``` >> add-peer 6677c4d401b98f403de671712a98ad8bf2976db27a1d411b08bedfd86751e048 /ip4/192.168.5.114/tcp/9991 Peer with node id '85d605836f02951c65651f99d0' was added to the base node. ☎️ Dialing peer... >> ⚡️ Peer connected in 0ms! Connection: Id: 0, Node ID: 85d605836f02951c, Direction: Outbound, Peer Address: /ip4/192.168.5.114/tcp/9991, Age: 2050s, #Substreams: 2, #Refs: 3 ``` 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 --- - [x] None - [ ] Requires data directory on base node to be deleted - [ ] Requires hard fork - [ ] Other - Please specify <!-- Does this include a breaking change? If so, include this line as a footer --> <!-- BREAKING CHANGE: Description what the user should do, e.g. delete a database, resync the chain -->
- Loading branch information