We create a new net Setting called BanPolicy that can be Strict or
Relaxed. If it's set to Strict, we ban peers that send messages without
us having a corresponding Dispatcher. If it's set to Relaxed we simply
close the connection.
Lilith is set to Relaxed by default while other peers are set to Strict.
This helps us avoid Lilith blacklisting peers that send messages for
protocols it is not subscribed to.
Storing manual peers on the hostlist creates redundancy since we can
never connect to them in Outbound Session or refine them in Refine
Session, so they just pointlessly sit on our greylist forever.
This was a bug regarding the following state transition functions:
Free -> Connected
Free -> Move
Inbound connections go directly to Connected (1) and Move (2) in the
following cases- when an inbound connection connects to us (1), when we
blacklist a peer due to missing dispatchers (2).
If we previously had a connection on the same port that was now marked
as HostState::Free in the hostregistry, this would create a panic.
We introduce a new HostState called HostState::Free, which means a host
is freely available for use. This fixes race conditions where multiple threads could try to delete
the entry (using the unregister() call) at the same time.
Fixes a bug on seedsync_session where due to us quickly stopping
channels after they are formed the Subscription would occasionally miss
the channel.stop() event.
We previously deleted the call to `unregister()` after the refinery is
successful on a16dd562d9.
It was considered redundant since the `unregister()` call happens in
`subscribe_on_stop()`, which for refine session is called directly after
the refinery process finishes (after `channel.stop()`).
However, in a highly async environment the `unregister()` call in
`subscribe_on_stop()` can be called before the call to `move_host()`, meaning
that the host would then be stuck in the `Moving` state.
We have fixed this by specifying that `unregister` should only be called
in `subscribe_on_stop()` to peers that are not part of a refine session.
We seperately call `unregister` after `move_host` in the refinery.
This commit also fixes some documentation.
Note: the call to `unregister()` is highly fragile and can lead to race
conditions. We are working to replace this with something more robust
(like `tombstone()`).
- All rpc use same fn to perform requests towards darkfid\n- Moved all rpc related Drk fns to rpc.rs\n- Fixed subscribe where if darkfid went off, drk subscription errored and drk hanged
unregister() will get called when the refine session channel disconnects
in session::remove_sub_on_stop(). Calling it here is actually dangerous
and creates rare race conditions.
We organize this functionality into distinct methods which get called
higher up, for example rather than manually resizing inside of store(),
we call resize() after we call store().
This is about reducing the "critical section" where locks are held and
using function scopes to ensure locks are released as quickly as possible.
Rationale: using a sync Mutex wherever possible is the recommended
method.
Additionally, using a sync Mutex here fixes some really weird fairness
behaviors we observed in the smol::lock::RwLock where writers in the
priority queue were occassionally ignored.