Commit Graph

349 Commits

Author SHA1 Message Date
Alexis Sellier a3f8305eb4
node: Reduce test flakiness
Most of the test flakiness was caused by the git-daemon not being able
to bind to a port. It seems like using an RNG was not a good enough
solution.

After this change, tests seem to be passing without issue.
2023-06-08 16:44:04 +02:00
Vincenzo Palazzo 431a389944
radicle: Use "bundled" sqlite dependency
Our build was faking the inclusion of SQLite and dynamically
linking it in the 'radicle' crate and other components.

This patch solves the following error and requires reinstallation
of the `radicle-cli`, `radicle-node`, and, if used, the `radicle-httpd`

```
✗ Sync failed: internal error: malformed database schema (node-policies) - near "strict": syntax error (code 11): malformed database schema (node-policies) - near "strict": syntax error (code 11)
```

Tested-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-06-08 15:08:22 +02:00
Alexis Sellier 91404e4c37
node: Fix regression on control socket delete
The removal of the control socket on shutdown was mistakenly taken out.
We add it back here.
2023-06-07 11:39:23 +02:00
Alexis Sellier ff7338de17
node: Always send node announcement on handshake
Previously, we only sent the announcement when there were external
addresses. But it contains other information like the node alias,
therefore we always send it.

Since the proof-of-work can be expensive to compute everytime, we add
the ability to load the local node announcement from the file system.

We also change the proof-of-work parameters so that they are relaxed
when running in debug mode, instead of when running tests.

Finally, we remove the boolean validation of the PoW. Instead, we store
the work per-node, in the database, to be used in the future in case of
DoS attacks or network congestion.
2023-06-07 11:39:23 +02:00
xphoniex f526465f1b
radicle: Make addresses.db accessible from profile
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-06-02 14:49:20 +02:00
Alexis Sellier 4652f309b4
Update to Rust 1.70 2023-06-02 14:40:44 +02:00
Alexis Sellier c400961cec
Update `io-reactor` and related dependencies 2023-05-27 20:43:56 +02:00
Alexis Sellier 664aa570e6
node: Spawn a thread for each control connection
Previously, only one connection to the node control socket could be
handled at a time. This usually worked fine, but if one connection hangs
for whatever reason, no other process can access the node.
2023-05-24 11:33:55 +02:00
Alexis Sellier b8c2f2a647
node: Rename `InvalidPacketLine` error variant
In case of timeout on reading the packet-line, we would get this error.
It would be confusing, as the packet-line wasn't invalid, just never
received.
2023-05-24 11:33:55 +02:00
Alexis Sellier 5fa677c5fb
node: Fix worker fetch deadlock
It turns out it's possible to create a deadlock when using
`child.wait()` with `Stdio::piped()`, if we don't read the output while
the child process is running. This is because the pipe has an internal
kernel buffer that will eventually fill up, causing the child process to
block on writing to stdout and never exit.

To remedy this situation, we read the stdout in a thread while the child
process is running.
2023-05-23 16:12:52 +02:00
Alexis Sellier 5a46ded318
node: Allow seed not to be connected on fetch
See code comment for explanation.
2023-05-22 15:30:27 +02:00
xphoniex 95e3b9673d
cli: Show alias on `rad issue` and `rad patch`
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-05-22 15:13:28 +02:00
Alexis Sellier eef813fd46
node: Small simplification in wire protocol 2023-05-12 11:08:29 +02:00
Alexis Sellier 7037b52474
node: Read with timeout from worker channel
This change ensures that if we're waiting on a Git request packetline
that never arrives, we time out.
2023-05-11 14:52:55 +02:00
Alexis Sellier d758c4f203
node: Move seeds log to better place
Instead of logging connected/disconnected seeds every time the seeds function
is called, we only log it when a user calls the function.
2023-05-11 10:36:30 +02:00
xphoniex 35ce6663c1
node: Add `--alias` option to node
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-05-10 17:03:42 +02:00
Alexis Sellier d249937a61
Update dependencies
* radicle-surf
* radicle-git-ext
* amplify
2023-05-10 15:56:21 +02:00
Alexis Sellier 1d9ee81b6d
node: Rename `reactor` module to `io`
The name was always confusing and didn't mean much in the contetx of the
service.
2023-05-08 19:31:20 +02:00
Fintan Halpenny 8508eab8fa
radicle: update radicle-git-ext
This change updates to the latest radicle-git-ext, which required a
few changes within the radicle family of crates.

One set of changes is that the radicle-git-ext crate subsumes
git-commit, git-trailers, and git-ref-format -- so all those imports
go through radicle-git-ext.

The commit code requires that parent `Oid`s point to commits, which
made some tests fail. One of the reasons for these failures is that
the patch tests used fabricated `Oid`s and so the verification would
fail. This is fixed by allowing the test context code to create
`PatchRequest`s that create valid commits.
The other reason for failure was that the identity `Action` passed an
`Oid` that pointed to a blob. This is fixed by removing that code and
making a note of it in documentation.

The final major change was moving the Refspec type into git-ref-format
and removing the AsRefspecs trait. The trait was not required and
could its usage could be replaced by simpler code.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-05-08 10:36:15 +01:00
Alexis Sellier 0349699200
node: Don't connect to recently attempted peers 2023-05-05 17:23:52 +02:00
Alexis Sellier ca0abc4356
node: Keep track of connection attempts
When attempting to connect to a peer, and when succeeding, write the timestamp
to the database.

This will allow us to better select addresses and not retry peers to
soon.
2023-05-05 17:23:52 +02:00
Alexis Sellier c20421b0c6
node: Fix superfluous fetch error on macOS
On macOS, shutting down a socket returns an error if the socket is
already closed. We don't consider that a problem, as it just returns
`Ok(())` on Linux.
2023-05-03 17:20:32 +02:00
Alexis Sellier 0886ab0a3c
node: Get the failing fetch tests passing
We fix the failing fetch tests by:

1. Not verifying our own refs, unless we're cloning, since we're
   otherwise not fetching our own refs.
2. Always force-fetching `sigrefs` from remotes into the staging copy.
3. Making sure that sigref updates are fast-forward before transfering
   the remote into the production copy.
2023-05-03 16:16:34 +02:00
Alexis Sellier 1326774d4f
node: Add failing test for sigrefs fetch
Fetching sigrefs fails if the remote ref is an ancestor of the local ref.
2023-05-03 16:16:34 +02:00
Alexis Sellier 448ef67833
node: Add `Disconnect` command
This is useful especially in tests to disconnect two nodes. We also
expose `command` on the handle type (but not the trait).
2023-05-03 16:16:34 +02:00
Fintan Halpenny 3bfea69642
node: validate production in debug mode
Ensure that the production repository is validated after fetching and
performing deletions. This is to highlight any inconsistencies that
may show up between fetching and deleting references.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-04-28 14:26:47 +02:00
Fintan Halpenny 024218014b
node: test case for outdated refs
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-04-28 14:26:47 +02:00
Fintan Halpenny 694bd345d9
node: use ls-remote when in fetching mode
Given the scenario of 3 peers, A, B, and C each having a project R. If
peer A has B's fork, but C does not, then when peer A attempts to
fetch from C the fetch will be rejected since Git will fail when a
refspec that is asked for does not exist on the remote side.

To avoid this, the fetch logic is changed so that the client first calls
ls-remote to the remote side, which results in the references that the
remote has which the client is interested in. The follow-up fetch then
uses these refs as the refspecs -- which should succeed unless there
was a race for a deletion on the remote side.

The rest of the verification logic stays the same, so the storage
should still be in a working state before transferring from the staged
repository to the production repository.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-04-28 14:26:47 +02:00
Fintan Halpenny 5a48cdf507
node: ensure that we can fetch with a non-existent tracked node
Ensure that non-existent tracking relationships do not affect
fetching.

This is tested by first performing a clone, by `bob` from `alice`,
after `bob` tracks a remote that does not exist. `alice` creates an
issue which is then fetched by `bob` -- to ensure the fetching
scenario is also tested.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-04-28 14:26:47 +02:00
xphoniex ac12a4deee
cli: Implement `rad node start` with support for deamonizing
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-04-28 14:19:20 +02:00
Alexis Sellier 83547f9c8a
node: Close worker streams on disconnect
This is in an attempt to fix the worker pool from being backed up.
2023-04-27 11:42:33 +02:00
Alexis Sellier df25e9a2a5
radicle: Fix unverified `Remote::new` constructor
We were allowing remotes to be constructed via a function that didn't
check its inputs.

This is now fixed by moving the public key into the `SignedRefs` struct.
2023-04-26 10:57:26 +02:00
Alexis Sellier ccbfe5b6fa
node: Add warning if workers are all busy 2023-04-26 09:59:19 +02:00
Alexis Sellier 10fe2ae299
node: Add worker channel timeouts
It's currently possible for a channel to be blocked forever while
waiting for data, if the remote peer keeps the connection alive.
This can occupy a worker indefinitely.

With these timeouts, we ensure that workers exit if there is no
activity after a certain amount of time.
2023-04-26 09:59:19 +02:00
Alexis Sellier 5428420f27
node: Rework peer map to not panic
In the wire protocol, we often panic in case a peer is not found.
With this change, we instead log an error.
2023-04-26 09:59:19 +02:00
Alexis Sellier 045d201916
node: Fix log pluralization 2023-04-25 12:47:36 +02:00
Alexis Sellier 671c169244
node: Implement `rad sync` command
This command announces refs to peers and waits for them to be
in sync.

Adds a subscribe method to `Handle` so that we can get the events
from the seed to allow us to confirm that the configured seeds fetched
from us.
2023-04-24 11:39:37 +02:00
Alexis Sellier fd3a6583d0
node: Improve framing code
Thanks to @fintohaps for these suggestions.
2023-04-23 15:10:42 +02:00
Alexis Sellier bf8653b6c2
node: Fix keep-alive delta
By having the keep-alive delta be the same as the ping timeout,
we essentially disconnected peers right after we sent them our
first ping.

This fixes that issue by setting the ping timeout to double the
keep-alive delta.
2023-04-21 16:54:03 +02:00
Alexis Sellier a16be24517
node: Fix log output in `--help`
The logs were being output in the help text.
2023-04-20 16:32:41 +02:00
Alexis Sellier 26ee6d26dc
node: Reduce log messages when sending messages 2023-04-20 16:32:41 +02:00
Alexis Sellier 9120db4ddb
node: Reduce log verbosity when receiving messages 2023-04-20 16:32:41 +02:00
Alexis Sellier 189eb3f201
node: Cleanup logging 2023-04-20 16:32:41 +02:00
Alexis Sellier b51d491ad9
node: Preserve tracking policy on startup
We were needlessly overwriting the policy if it was set to "trusted".
2023-04-20 16:29:55 +02:00
Alexis Sellier 2598886018
node: Delete unsigned refs on fetch 2023-04-19 11:32:46 +02:00
Alexis Sellier 0d98b84861
node: Skip trusted peers that aren't local 2023-04-18 14:49:13 +02:00
Alexis Sellier 94bef61944
node: Return only remotes that were fetched from
Instead of returning the namespaces that we fetched with,
we return the remotes that were actually fetched from.

This can differ if some trusted peers were not available
on the remote node.

Previously, if that was the case, it would cause errors
since the remotes were looked up and that lookup failed.
2023-04-17 18:58:56 +02:00
Alexis Sellier bb07e25571
node: Emit event when refs are synced
This will help us give the user feedback when he pushes.
2023-04-17 16:18:34 +02:00
Alexis Sellier 4b2bc365ef
node: Better differentiate fetch results
We use an enum to separate initiator vs. responder results.
2023-04-17 16:18:34 +02:00
Alexis Sellier 51b372ecad
node: Share channel type between modules
Shares the `Channels` type between the `wire::protocol` and
`worker` modules.
2023-04-17 15:56:24 +02:00