Commit Graph

2254 Commits

Author SHA1 Message Date
Fintan Halpenny 29e681210b
node: test multiple offline inits
Ensure that when a node initialises multiple repositories, those
repositories can successfully be fetched by another peer once they
connect.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-07-22 10:48:10 +02:00
Lorenz Leutgeb 723e2741f5
node: Socket Activation with systemd 2024-07-22 10:44:22 +02:00
Derick Eddington 6f8d75a00d
node: Fix "signals" thread
Fix "signals" thread to continue upon other signals.

Otherwise, previously, when one of the non-shutdown signals was
received, that would cause the "signals" thread to finish, but then a
subsequent signal that should cause shutdown would not because the
thread no longer existed to do so.  E.g. when SIGHUP or SIGWINCH was
received first and ignored and then SIGTERM or SIGINT was received next,
the program should still be shutdown, but it wouldn't be.  This is now
fixed by simply looping to continue handling subsequent signals.

Logging is now done for:
- Receiving of SIGHUP, at log level `debug`, because the default action
  for that signal would be to terminate the process but that is not done
  by `radicle_signals`.  Someone sending that signal might want to debug
  why the process isn't being terminated.
- Disconnection of the signal-notifications channel, at log level
  `warn`, because, even though that should be impossible, if it somehow
  occurs then a warning is warranted.

Logging is not done for receiving of SIGWINCH, because the default
action for that signal would be to ignore it, which is what
`radicle-node` does.

A wildcard pattern is not used in the match arms, so that any future
changes to the `Signal` variants will require reviewing their handling
in the "signals" thread.

Signed-off-by: Derick Eddington <kcired@pm.me>
2024-07-22 10:38:42 +02:00
cloudhead 123f7eb6bb
Update `radicle` crate to 0.12.0 2024-07-18 16:22:14 +02:00
RadsammyT 1848c2b85d
cli: Handle interrupts during an active spinner 2024-07-18 15:47:18 +02:00
Rūdolfs Ošiņš a831e18a72
node: Change node web config metadata fields
- Remove the `name` field as it is not required in the new design.
- Rename `imageUrl` to `bannerUrl` to hint users that it's going to be
  used as a header image.
- Add a new field `avatarUrl` so node operators can customize their
  node further.
2024-07-18 13:56:31 +02:00
cloudhead 4a497fa66f
node: Move the session lookup outside the loop
Small code change that was not possible before.
2024-07-16 19:58:47 +02:00
cloudhead 189046bb5d
node: Randomize order of missing inventories 2024-07-16 19:58:47 +02:00
cloudhead aac23dde0c
node: Add a max capacity to fetch queues 2024-07-16 19:58:44 +02:00
cloudhead 3c1c35f259
node: Have multiple fetch queues
In the current design it's possible for one peer to fill the fetch queue
so that fetches from other peers are delayed.

To improve fairness, we move to a queue per peer. We then try to dequeue
from all peers in a random order for good measure.
2024-07-16 17:11:46 +02:00
cloudhead 27eff8095d
node: Don't depend on `gix` directly
This avoids pulling in the same dependency twice.
2024-07-16 15:57:27 +02:00
cloudhead 297646412a
cli: Use pretty diffs for code review
We use the pretty diff renderer for code review.
2024-07-12 16:39:23 +02:00
cloudhead 823ece875e
cli: Improve pretty diff printing
Refactor, cleanup, improve tests etc.
2024-07-12 16:36:04 +02:00
Alexis Sellier 795ee35f37
cli: Output tree hash after review update 2024-07-11 14:17:17 +02:00
Alexis Sellier 54551b1174
cli: Make sure to configure checkouts properly
We were configure correctly on `rad init`, but not `rad checkout`.
2024-07-09 13:56:10 +02:00
Alexis Sellier 1388601cb6
cli: Fix hunk line ranges
Since the range has a non-exclusive end, we have to add one to it.
2024-07-09 13:46:49 +02:00
Alexis Sellier 605388f850
cli: Implement comment parsing out of diff hunks
Extracts comments out of a string where the diff is quoted with `>` and the
comments are not.
2024-07-09 13:46:44 +02:00
Alexis Sellier 13707fee32
term: Stop user scroll passed the end of a diff 2024-07-07 16:57:54 +02:00
Alexis Sellier d221095980
cli: Add `--unified` flag to `rad diff` help 2024-07-07 16:57:54 +02:00
Alexis Sellier 34112d8504
cli: Don't create empty code review
If the verdict and comment are both unset, return an error.
2024-07-07 16:57:50 +02:00
Alexis Sellier a32c4b93e2
docs: Fix `RAD_KEYGEN_SEED` docs 2024-07-06 12:30:30 +02:00
Alexis Sellier e56a70b0d3
node: Update `io-reactor` dependency
The previous version contained a bug which caused disconnections
to not be forwarded to the service.
2024-07-06 11:12:13 +02:00
Alexis Sellier 4b65c22305
node: Fix logging on maintain connections
We were comparing the available peers with the target, so the comparison
would always succeed. We now compare it with the missing count, and use
debug logging since it's not something of concern yet.
2024-07-04 12:03:42 +02:00
Fintan Halpenny fa19105f2f
cli: add un/resolve for patch review comments
Patch review comments can be resolved and unresolved as part of the Patch COB
API. This functionality was missing from the `rad patch command`.

Add a subcommand `rad patch resolve` which can resolve a review comment, and
unresolve given the `--undo` flag.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-07-03 20:21:46 +02:00
Fintan Halpenny 84aaf9efd0
remote-helper: relax the quorum checks
The rules for checking the quorum of the remote helper, when pushing to the
canonical branch, can prevent the operator from even attempting to try converge
to a state of agreeance.

Instead, the checking of the quorum rules are relaxed. It is still the case that
if the peer is pushing a diverging commit while in a working state they are
warned and the push does not go through. However, there are two cases where it
is fine to force push a change:

1. When pushing a new tip, as a delegate, there is still a canonical tip and the
   new tip still converges with the history, i.e. it is equal to, behind, or
   ahead of another delegate tip.
2. If there is no quorum in the current state, for example there were multiple
   concurrent pushes, then the peer is free to continue to push to their default
   branch in attempt to converge with the other peers.

The example tests ensure that these cases are covered, while also preserving the
old behaviour.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-07-03 15:14:58 +01:00
Fintan Halpenny 54d23545ff
radicle: port quorum code to Canonical
Remove the old `quorum` function in favour of using the newly introduced
`Canonical` code. Port over the tests to use the `Canonical` type. The change is
minimised by introducing a helper function called `quorum` in the test module
that acts like the old function.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-07-03 15:10:43 +01:00
Fintan Halpenny 7fd9c3be8f
radicle: introduce Canonical type
Introduces a type, `Canonical`, to make manipulating and calculating canonical
reference quorum's easier.

The idea is that the type can be constructed by providing a set of delegates and
the reference name for which the calculations are referencing. It can construct
the set of tips and can output the quourum.

It provides a shortcut for constructing the `default_branch` set of tips.

It also provides some extra methods for helping in quorum calculations that will
be used within the remote helper code.

Note that this does not yet replace the `quorum` function in the `git` module --
this is to help minimise the review of this commit.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-07-03 15:09:38 +01:00
Fintan Halpenny b731dd1429
cli: test delegate convergence
If a delegate is in a diverged state from the canonical head, ensure
that they can easily reset to another delegate's head to converge
again.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-07-03 15:08:26 +01:00
cloudhead a79ca5e8fc
node: Constrain worker channel size
To avoid buffering large amounts of data in the process, we set the
worker channel size to `64`. Keep in mind that this is one
`ChannelEvent`, not one byte. `ChannelEvent::Data` can already contain
an arbitrary amount of data via its `Vec<u8>`, but in practice the
maximum is 8192, due to the use of `io::copy`.

We also remove an unused function, and move the flushing to the
`ChannelFlushWriter`.
2024-07-03 14:15:45 +02:00
cloudhead 38592955b2
remote-helper: Fix key-mismatch error
The error is about the remote namespace, so that's the one we should
include.
2024-06-30 10:28:23 +02:00
cloudhead 92c9e21873
Bump `radicle` crate to 0.11.1 2024-06-26 14:49:10 +02:00
cloudhead f7d8f1b8da
radicle: Distinguish seeding policy types
We create a separate type for the default seeding policy, that
serializes differently and is only used in the node configuraiton.
2024-06-26 11:57:04 +02:00
cloudhead bbb292c8e6
node: Don't panic on connection logic error
It seems like the underlying network library has a bug, and transport
handovers don't always happen.
2024-06-26 11:31:07 +02:00
Rūdolfs Ošiņš 0be7453e76
node: Add metadata fields to node web config
This allows us to show a custom header background image in
radicle-explorer as well as display a title and description.
2024-06-25 22:20:25 +02:00
cloudhead 9edb633d98
cli: Add `--from` and other options to `rad seed`
Gives the same options to `rad seed` as `rad sync --fetch`.

Allows seeding and syncing from specific seeds in one command:

  rad seed <rid> --from <nid>

Useful for seeding private repos on public nodes.
2024-06-25 12:01:52 +02:00
cloudhead 765fc48c84
node: Fix edge case in persistent peer connections
If two peers are persistent for each other and experience
disconnections, it's possible that an outbound connection is turned into
an inbound one. But if we don't set that correctly, we'll eventually run
into a crash where an already connected peer re-connects, since the
disconnection logic checks for the link direction.
2024-06-24 14:29:00 +02:00
cloudhead c94ce020a1
cli: Small fix to ddif parsing 2024-06-24 12:09:44 +02:00
cloudhead f8c6cf8bf9
node: Fix Tor full-proxy mode support
We ensure that the global proxy is used as the connection address if
set.
2024-06-21 16:16:51 +02:00
cloudhead 6a9f11a1d9
cli: Honor `--quiet` flag in `rad id update` 2024-06-21 13:05:40 +02:00
Fintan Halpenny 80f1e6516c
cli: idempotent `rad id update`
Instead of producing an error when there is no update during `rad id
update`, a message that the document is up to date is printed. The
command is considered is considered successful.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-06-21 13:01:59 +02:00
cloudhead 42ffbf3fe6
cli: Make `rad id update` description optional
If a `--title` is specified, the description is optional, and will be
set to the empty string.
2024-06-20 17:33:48 +02:00
Fintan Halpenny f26be552c2
cli: improve rad id allow list UX
The previous implementation of using the `--allow` option in `rad id
update` would be an absolute list, rather than additive. That is, if
there were existing DIDs not passed in via `--allow` then they would
be remove.

Change this behaviour to check the existing value of the document's
allow list, and add to it if `--allow` is specified.

To enable the user to also remove a DID, the `--disallow` option is
also added.

The correct usage of these options is improved by checking the
validity of the `--visibility` option being used, the current state of
the repository's privacy, and the use of the `--allow` and
`--disallow` options.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-06-20 17:22:38 +02:00
cloudhead 6f91f2fb8f
clippy: Fix a few warnings 2024-06-20 15:10:39 +02:00
Fintan Halpenny 3260046c67
radicle: fix diverging quorum
When calculating a quorum there was a case where two heads that were equal would
result in double-counting, allowing the quorum to pass a threshold higher than
the expected votes.

To prevent this, each head is immediately counted as a direct vote. Then, when
comparing the head to the rest of the set, if they are equal that iteration
would be skipped. This is because the merge base of two equal commits is that
commit, resulting in the double-counting.

Note that the `skip` can also skip the current head, so `i + 1` is used.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-06-20 14:57:00 +02:00
cloudhead 589c375624
build: Update env vars for build process
Use the standard `SOURCE_DATE_EPOCH` instead of `GIT_COMMIT_TIME`.
Set `GIT_HEAD` properly.
2024-06-20 10:47:50 +02:00
cloudhead 6598e77456
node: Log IP ban rejections 2024-06-19 20:38:23 +02:00
cloudhead 0a7a9c2945
cli: Fix disconnection timestamp
It should show since when we've been disconnected.
2024-06-19 20:37:36 +02:00
cloudhead dd7a0b3524
node: Revise fetch dequeue behavior
The fetch queue could sometimes not drain due to skipped fetches not
signaling that to the dequeue loop.

We now return a `bool` from `try_fetch` and keep trying to dequeue
fetches until one of them actually is initiated.

Additionally, we try to dequeue fetches at a regular interval
(`IDLE_INTERVAL`) to ensure that the queue is drained.
2024-06-19 15:31:00 +02:00
cloudhead 47c9f792e6
node: Handle connection state discrepancies
There are cases where the service state doesn't match the state
of the underlying wire protocol. We remedy this by transitioning peers
to a "connected" state when a message is received, if they are in a
"connecting" state.

The long term solution to this will likely be to merge the service and
protocol layer so that there are no inconsistencies.

The other case happens when a persistent peer is in "disconnected" state
and attempts an inbound connection to us.
2024-06-18 15:55:28 +02:00
cloudhead a1c9a927c2
node: Keep track of last announce separately
Fixes a bug where we try to announce the inventory over and over even
though there's nothing to announce.
2024-06-18 13:58:48 +02:00