Commit Graph

7609 Commits

Author SHA1 Message Date
lunar-mining
736459aa51 chore: cleanup
fix warnings + debug statements
2024-01-10 08:49:29 +01:00
lunar-mining
96cad54d81 net: 99.9999% of the time it works 100% of the time
cleaned up refinery code and seem to have eliminated deadlocks...
2024-01-08 12:20:10 +01:00
lunar-mining
fcf5a87a28 net: fix deadlock (partial fix)
* don't fetch addresses with lock in a nested way- first fetch the
  address, then apply the locking checks

* delete blocking function get_active_connect_count. instead, just use
  slots rather that active connections to avoid deadlock on p2p channels.

TODO: there seems to be another deadlock that occurs more rarely. From
preliminary investigations, it doesn't seem to be related to p2p channels.
2024-01-07 12:50:04 +01:00
lunar-mining
4cde069c53 store: document and cleanup 2024-01-03 18:50:04 +01:00
lunar-mining
e472003b6d outbound_session: fetch_address() logic bug fix
we need to use else if rather than chaining if statements as it gets
confused and calls multiple fetch methods otherwise.
2024-01-03 18:00:23 +01:00
lunar-mining
0ac12ff19d store: add test_fetch_address() unit test 2024-01-03 17:59:56 +01:00
lunar-mining
79e9039b9b store: create test_fetch_anchorlist() unit test 2024-01-03 15:57:15 +01:00
lunar-mining
ad3675eb3c store: fix death loop
if we don't remove the greylist entry, keeps trying to connect to
it
2024-01-02 11:06:53 +01:00
lunar-mining
5f00598c12 outbound_session: remove peer from anchor or whitelist when try_connect fails 2024-01-01 13:47:03 +01:00
lunar-mining
27d1b3aa03 hosts: fix logic on anchorlist_fetch_with_schemes
if we don't have any hosts on the anchorlist, chose from the whitelist.
if we don't have any on the whitelist, chose from the greylist.

same principle for whitelist_fetch_with_schemes (each method has a
different selection priority)
2024-01-01 01:09:47 +01:00
lunar-mining
426efdf90b chore: cargo fmt 2023-12-31 11:49:55 +01:00
lunar-mining
18479be298 test: add seed node to net/test.rs 2023-12-31 11:48:48 +01:00
lunar-mining
1578138e8f outbound_session: move fetch_address logic into new function 2023-12-31 11:47:42 +01:00
lunar-mining
2696290aad store: fix logic on is_empty_hostlist()
anchorlist, greylist AND whitelist must be empty for this to return
true (previously OR)
2023-12-30 15:31:36 +01:00
lunar-mining
ca885a43ee store: improve error naming
Error::InvalidIndex -> Error::HostDoesNotExist
2023-12-30 12:05:47 +01:00
lunar-mining
07c2d667e1 session: remove redundant anchorlist write
We are already storing anchorlist entries in perform_handshake_protocols of session/mod.rs.
2023-12-30 11:58:26 +01:00
lunar-mining
4d4392f9e8 net: add test module to mod.rs 2023-12-30 11:45:27 +01:00
lunar-mining
873cd35e0e net: add hostlist documentation 2023-12-29 17:31:21 +01:00
lunar-mining
51b4263a93 net: remove connection from anchorlist when it disconnects and cleanup.
also remove perform_local_handshake function as it's made redudant by
the anchorlist removal change.
2023-12-29 17:31:03 +01:00
lunar-mining
a555f2e744 net: add anchor_connection_count and white_connect_percent to Settings and cleanup 2023-12-29 17:30:51 +01:00
lunar-mining
ca4d523dd3 net: remove unwrap()'s and cleanup 2023-12-29 17:30:38 +01:00
lunar-mining
6e8671d5b0 net: create greylist_refinery_interval in net::Settings and update TODOs 2023-12-29 17:30:29 +01:00
lunar-mining
995ff6f6c2 lilith: add hostlist path to NetInfo and default config 2023-12-29 17:29:26 +01:00
lunar-mining
d15cc3b2bd net: read hostlist path from Settings. Define a default setting and allow overriding in config 2023-12-29 17:28:39 +01:00
lunar-mining
b456d8f5ec lilith: remove load and save host functionality (made redundant by greylist upgrade) 2023-12-29 17:28:15 +01:00
lunar-mining
5be6a07c61 net: add save_hosts() and load_hosts() methods and invoke on greylist refinery start and stop 2023-12-29 17:28:04 +01:00
lunar-mining
03e6e99e90 net: move host selection logic back into hosts/store to avoid insane nesting in outbound session loop 2023-12-29 17:27:47 +01:00
lunar-mining
0096f778c6 net: improve outbound_session connection loop logic. 2023-12-29 17:27:34 +01:00
lunar-mining
6a39e926f1 net: prevent inbound session channels from being stored in the anchorlist 2023-12-29 17:26:54 +01:00
lunar-mining
c850f629b8 net: cleanup connect loop code reuse by implement connect_slot() method. also prevent infinite loop by doing peer discovery when the hostlist is empty.
also fix tests.
2023-12-29 17:26:44 +01:00
lunar-mining
b5bf749fe9 net: replace outbound connection loop with monero grey/white/anchor connection_maker()
see: ac02af9286/src/p2p/net_node.inl (L1807)

we have made connection_maker()mless nested and adapted it to the existing structure.

WARNING: UNTESTED
2023-12-29 17:26:33 +01:00
lunar-mining
03ae65956a net: add peer to the anchorlist with an updated last_seen when we call p2p.store() on a connected channel 2023-12-29 17:26:20 +01:00
lunar-mining
ebe8eb1626 net: check whether host is in the peerlist before adding to greylist. also make additional anchorlist utils.
we do this because otherwise a whitelisted or anchor node could be added
to the greylist as a new peer, resulting in duplicates across the
peerlist.
2023-12-29 17:26:10 +01:00
lunar-mining
3725de07ec net: and anchorlist and minimal utilities. also clarify hosts specific TODOs. 2023-12-29 17:25:58 +01:00
lunar-mining
065f254661 lilith: comment out broken load_hosts code and add FIXME note 2023-12-29 17:25:44 +01:00
lunar-mining
560b332e37 net: create perform_local_handshake which does a version exchange without adding channel to the p2p store, and use in ping_node 2023-12-29 17:25:34 +01:00
lunar-mining
d591fac8dc net: remove whitelist_downgrade() from outbound_session (monero doesn't do this) 2023-12-29 17:25:08 +01:00
lunar-mining
1a282a951d net: call channel.stop() when we get a handshake error on ping_node 2023-12-29 17:24:55 +01:00
lunar-mining
845b9ded6b net: fix tests on store.rs 2023-12-29 17:24:44 +01:00
lunar-mining
e693b48cb5 net: clean up reference/ pass by value usage in store.rs 2023-12-29 17:24:30 +01:00
lunar-mining
ef3b95ffdf net: avoid adding our own address to the greylist when on localnet
also standardize the whitelist_store_or_update function call
2023-12-29 17:24:19 +01:00
parazyd
80df5b68b5 net/hosts: Add missing mod.rs 2023-12-29 17:24:10 +01:00
lunar-mining
a61a08c020 net: remove whitelist_store_or_update call from OutboundSession
this should be redundant due to the GreylistRefinery task which is
responsible for filtering host lists. OutboundSession is just focused on
reading from the whitelist, not writing to it.
2023-12-29 17:23:58 +01:00
lunar-mining
4adc0585c0 net: change try_read() and try_write() to read() and write() and cleanup warnings
also experiment with a longer greylist refinery period
2023-12-29 17:22:16 +01:00
lunar-mining
c4ebcb3d45 net: reimplement address filtering on greylist_store().
we don't need to implement this for whitelist as it would be redundant
(whitelist gets data from greylist)
2023-12-29 17:22:03 +01:00
lunar-mining
ae5b4d0a69 net/store: reimplement test_greylist_store() 2023-12-29 17:21:53 +01:00
lunar-mining
2a2d516ac4 net: if a greylist peer is non responsive, remove it from the greylist 2023-12-29 17:21:42 +01:00
lunar-mining
0639e9bdf7 net: working greylist protocol
Working on this commit:

* Nodes connect to a seed node, do ProtocolAddr, ping themselves and send over their ADDR if the address is reachable.
* Seed nodes add addresses into greylist, probe them to make sure they're reachable, then promote to whitelist and send to other peers.
* On receiving whitelisted addresses, nodes add to greylist and after performing refinery process, promote to whitelist.

Still TODO:

* reimplement address filtering
* test: unstable_sort_by_key
* implement "anchor" connections when we've already established a connection to a node
* keep track of how many times we ping ourselves to avoid redundant self ping
* idle handshake protocol
2023-12-29 17:21:17 +01:00
lunar-mining
de2fb840bf net: invoke GreylistRefinery in p2p.rs and cleanup 2023-12-29 17:20:48 +01:00
lunar-mining
748c659f93 lilith: fix warnings 2023-12-29 17:20:38 +01:00