Commit Graph

552 Commits

Author SHA1 Message Date
cloudhead 70d2e1a0db
node: Improve `Timestamp` conversion safety
Remove `Timestamp::from(u64)` instance, since not all `u64`s are valid
Timestamps, and add `try_from` instead.
2024-04-26 10:33:34 +02:00
cloudhead c607619683
node: Don't relay old messages
Avoids spamming peers on startup.
2024-04-24 13:25:58 +02:00
cloudhead 2b771921d5
node: Type-safe timestamps
Use a struct to represent timestamps, to improve type safety.
2024-04-24 12:19:40 +02:00
cloudhead 0fcfbb3ecf
node: Don't re-use timestamps
There are rare cases where ref announcements may be sent in close
succession, and the current clock time is re-used. This will cause the
second (newer) announcement to be ignored by peers.

We add a `timestamp` method that checks if the timestamp is re-used, and
increments it if so, ensuring that we always use a fresh one.
2024-04-24 12:19:40 +02:00
cloudhead cdebbe5bb7
node: Improved message logging 2024-04-23 10:41:43 +02:00
cloudhead d77b5d5abe
node: Add 'disconnect' command to handle 2024-04-23 09:52:25 +02:00
cloudhead 7a1ba7d4b1
node: Add support for `.onion` addresses in wire
Adds support for encoding and decoding onion addresses in the gossip
protocol.
2024-04-22 12:16:17 +02:00
cloudhead 4276a70eb1
node: Event on local refs announcement
This allows us to listen on the socket for when the user announces new
refs.
2024-04-18 10:57:55 +02:00
cloudhead e5d8563cca
node: Update routing table on fetch
Since a user can force a fetch of a private repository without any
announcement being involved, we update the routing table if the fetch
completes successfully, with the remote node.
2024-04-18 10:51:23 +02:00
Fintan Halpenny 8bf871903a
node: handle removal of cob from cache
When a `Patch` or `Issue` is entirely removed from the Git repository,
then there is no update to be made -- instead it should also be
removed from the cache.

This covers the case where the original author of the COB deletes the
COB.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-04-09 16:06:51 +02:00
cloudhead 53ecc88437
node: Always notify the service of a fetch result
Even if the peer is no longer connected.
2024-04-09 16:00:49 +02:00
cloudhead 395d317954
node: Keep track of data sent/received in fetch
Keep track and log the Git data sent/received.
2024-04-09 15:59:55 +02:00
cloudhead ef1ed621d7
node: Don't re-queue fetch that is already queued 2024-04-08 17:15:57 +02:00
cloudhead e19c773a86
fetch: Improve logging of clone 2024-04-08 17:06:38 +02:00
cloudhead 976b58ba7a
node: Simplify and fix fetch dequeueing
There was redundant code and a missing `break`.
2024-04-08 12:48:49 +02:00
cloudhead ad7ba82e6a
node: Populate refs db on startup
If the refs database is empty, populate it on startup.
Also includes a script to clear it.
2024-04-05 21:59:58 +02:00
cloudhead 7834dccd2c
node: Account for skipped refs when announcing 2024-04-05 17:40:53 +02:00
cloudhead bc247dff24
node: Skip fetch early if no refs in announcement 2024-04-05 12:17:17 +02:00
cloudhead e55c86f1ce
node: Improve fetch logging 2024-04-04 18:41:53 +02:00
cloudhead 6ff4efebed
node: Remove namespaces from fetch request
It was unused..
2024-04-04 18:22:19 +02:00
cloudhead f2fe0242e1
node: Always check refs status before fetching
We were only checking it on dequeue.

Also simplifies some of the logic by centralizing the check for fetching
our own refs.
2024-04-04 18:10:49 +02:00
cloudhead 51e64cfa8b
node: Fix logging for skipped refs
We were using the wrong condition.
2024-04-04 12:24:49 +02:00
Fintan Halpenny cd9b46fe51
radicle: fault tolerant thresholds
There are two areas where we can be more tolerant of delegate namespaces
being missing or not validating:
1. Calculating the canonical HEAD
2. Fetching from a remote

In 1. the protocol is tolerant in that if the local node does not have
the default branch for a delegate, it will still attempt to use any of
the delegates it does have to reach the threshold.

This is made safe by ensuring that if the threshold is being updated
then the node performing the update must have a threshold of delegates
locally in their storage. It also made safe by 2.

In 2. the protocol is tolerant by allowing delegates to be missing
from the serving side, as long as they can still meet a threshold of
delegates. This is further tolerant, when validating the received
data, a threshold of delegates are valid to consider the fetch
successful -- otherwise it will fail.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-04-03 14:30:05 +02:00
cloudhead 7e13e0759f
node: Simplify handling of fetch completion
* Don't branch based on whether it was a user-requested fetch or not.
* Only announce inventory on clones of public repos.
2024-04-03 14:25:02 +02:00
cloudhead fd4f5fff7d
node: Don't fetch if only our own remote
Skip the fetch from announcement if the announcement only contains our
own remote.
2024-04-03 14:25:02 +02:00
cloudhead 6744ffc325
node: Improvements to test reliability 2024-04-03 14:25:02 +02:00
cloudhead e90c6a49bc
node: Include identity doc in fetch result
This avoids having to reload the document in the service, which can be
an expensive operation.
2024-04-03 14:25:02 +02:00
cloudhead 2b9a014243
node: Small changes and note around initial state 2024-04-01 16:32:30 +02:00
cloudhead 256c620d31
node: Use refs cache to decide on fetching
When deciding whether or not to fetch a repo based on a refs
announcement, we need to know whether our signed refs are stale or not,
compared to the ones in the announcement. This can be quite expensive as
it requires multiple reads from Git's ODB, which often results in
packfile loading.

To remedy this, we introduce a refs cache in our node database that is
consulted when an announcement is received.

We also remove the logic that generates `info` messages, since they are
rarely needed and introduced more complexity.

Additionally, we revert commit 3ad2b4431f,
which introduced logic to minimze wants and haves with additional logic,
since it potentially also increases the load on the ODB.
2024-03-29 16:00:33 +01:00
cloudhead 9cdf0aa1fd
Update radicle crates to 0.9.0 2024-03-26 11:56:27 +01:00
cloudhead 5b5a6842c1
Update toolchain to Rust 1.77 2024-03-26 10:03:11 +01:00
cloudhead 0bcec941ee
node: Change behavior on conflicting connections
Instead of dropping the existing connection(s), we drop the same
connection on both sides, by using a simple rule that yields the same
result whether the node sees the connection as inbound or outbound.

The trick is to use something that both nodes agree on, for instance
whos public key is greater than the other, and use that information
to close the same connection on both sides.
2024-03-25 12:48:27 +01:00
cloudhead e695d06bbb
node: Logging improvements & other small things 2024-03-25 12:05:05 +01:00
cloudhead dbf47fe4e9
Implement new versioning system
See `VERSIONING.md` for details.
2024-03-25 11:54:08 +01:00
cloudhead ada492f699
node: Improve logging more 2024-03-22 18:00:48 +01:00
cloudhead a4928f50b6
node: Combine event with sync status change
Use the same logic to check whether the sync status was updated, to emit
the `RefsSynced` event. That way they are at least consistent.
2024-03-22 17:07:56 +01:00
cloudhead 474df7fc3c
node: Update logging config
Promote message logging to `debug` level, and change default level to
`info`.

This is because `trace` level often covers details at a different level
of detail than for eg. messages sent and received. This means we don't
have to use `trace` level just to see the gossip.
2024-03-22 16:42:35 +01:00
cloudhead 98b0d55fde
cli: Include all nodes we can announce to on sync
Previously, we only kept tracked of unsynced nodes we were connected to.
Now we track all unsynced nodes, since announcements are relayed.

We also cap the replicas to exit earlier in case of very low replica
count.
2024-03-22 16:35:06 +01:00
cloudhead e6728db15a
cli: Unify all syncing code
We were using similar but slightly different syncing code in the
remote-helper, issues/patches and `rad sync`. This commit unifies them.
2024-03-22 16:35:06 +01:00
Fintan Halpenny ca9d2b44df
node: fix clippy suggestion on borrowing
Remove the borrow of `rid` to fix the clippy warning.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-03-21 20:29:11 +01:00
cloudhead 6288dd0a24
radicle: Load inventory lazily
Instead of loading the inventory cache on storage open, load it
when the `inventory` function is called and the cache is `None`.
2024-03-21 18:03:18 +01:00
Alexis Sellier 8b1dc8f168
node: Connect to preferred seeds
Make sure we connect to and keep connected to preferred seeds.
2024-03-21 12:47:32 +01:00
cloudhead f1f1313b6d
node: Update `netservices` to 0.8.0
The previous version was relying on a broken method from `socket2` that
switched non-blocking sockets to blocking.
2024-03-21 12:40:58 +01:00
cloudhead d771ce8522
node: Make `Storage::refresh` private 2024-03-21 12:40:58 +01:00
cloudhead 2bcb03b021
node: Re-think inventory update code
Instead of re-loading the full inventory on `rad init`, we simply add
the new repository to the in-memory cache.

We also keep track of whether a fetch was a full clone, to know when
to update our routing table.
2024-03-21 12:40:58 +01:00
cloudhead 0e880e12e6
node: Cache node inventory
For large seeds with many repos, it's expensive to traverse the
inventory everytime the node connects to a new peer, for example.

To improve the situation, we cache the inventory per `Storage` instance,
and add a `refresh` method to refresh the inventory.

This method is called when the node is told to synchronize its
inventory.
2024-03-21 12:40:58 +01:00
Alexis Sellier ddd4bde302
node: Make worker count configurable 2024-03-19 16:34:15 +01:00
cloudhead 74abd789c7
httpd: Fix private repo visibility
Make private repos invisible on all routes, including /raw endpoints
and Git clones.
2024-03-17 21:13:25 +01:00
Fintan Halpenny 3ad2b4431f
fetch: only send changed wants and haves
This change limits the amount of `wants` and `haves` data that is sent
to the serving side of a fetch.

When a `RefsAt` announcement is sent, the fetching peer can calculate
the difference between the `rad/sigrefs` they're aware of -- if it
exists -- and the newly advertised `rad/sigrefs`. This means they can
efficiently ask for the `wants` and `haves` of references that have
changed -- saving some data sent over to the serving side.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-03-12 13:01:03 +01:00
cloudhead 93ff59ae25
cli: Add `rad version --json` flag
This will be used to automatically populated metadata around releases
for the homepage.
2024-03-11 17:36:31 +01:00