Commit Graph

2035 Commits

Author SHA1 Message Date
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
cloudhead 484cf0220c
node: Don't panic if we can't decode announcements
Bubble up the error instead.

Also, as part of the migration, delete existing announcements that won't
decode properly.
2024-06-13 21:38:30 +02:00
cloudhead 83786fbd80
node: Add a more elaborate message extension test
This required adding a type parameter to `Frame` to be able to test
different message types.
2024-06-13 11:28:09 +02:00
cloudhead 82c5884fdc
radicle: Improve SQL type errors 2024-06-13 11:28:09 +02:00
cloudhead a89a300390
node: Pass `Alias` by reference 2024-06-13 11:28:09 +02:00
cloudhead 76edc0c523
node: Add agent and version to node announcement
1. Adds a user-agent string to the node announcement. This lets us keep
   track of what software version everyone is running. Especially useful
   to see what percentage of the network has upgraded to a new release.

  For old nodes, this defaults to the string `/radicle/`.

  The user agent format is roughly based on BIP 0014.

2. Advertize protocol version in node announcement.

  By advertizing the protocol version, nodes can decide to only connect to
  peers with a compatible version. The default and current version is `1`.

  We bundle these two changes as they both modify the node announcement
  and node database.

3. Swap the order of the fields in announcements to make the message
   extensible.
2024-06-13 11:28:09 +02:00
cloudhead 5c0d1b10e0
node: Make sure all channels we use are bounded
This prevents potential memory leaks. We also ensure that sends fail
instead of blocking, in case the channels are full.

Additionally, we add some metrics to report on channel size.
2024-06-12 19:00:23 +02:00
cloudhead 345ca92380
cli: Clarify doc test example 2024-06-12 15:36:34 +02:00
cloudhead 614f3e7b77
node: Keep private repos out of inventory
Since repos can go from public to private, make sure that we remove them
from the routing table on startup.
2024-06-12 15:36:34 +02:00
cloudhead f0e2018ac5
cli: Correctly update inventory with seed commands
Make sure our inventory is up to date with the policy changes, as well
as when publishing private repositories.
2024-06-12 15:36:34 +02:00
cloudhead fc55d67929
cli: Add `rad node inventory` command
Prints the local node's inventory.
2024-06-12 15:36:34 +02:00
cloudhead 50379548c2
node: Don't announce inventory redundantly
Keep track of last announcement timestamp and don't re-announce if it
matches.
2024-06-12 15:36:34 +02:00
cloudhead 81f94d0cff
cli: Move common functionality out of the CLI 2024-06-12 15:36:34 +02:00
cloudhead a6b5c723c8
node: Rename certain functions for clarity 2024-06-12 15:36:34 +02:00
cloudhead b24f8a30d6
node: Update inventory when unseeding
Previously, our advertized inventory was not always correct: when we
stopped seeding a repository, it was still advertised as part of our
inventory until node restart, because the `Storage` type doesn't have
access to seeding policies.

In this change, we remove the concept of inventory from `Storage` and
make the authoritative place for it the routing table in our database.

To make this work, we have to add our node to the database on profile
creation, to not violate the foreign key constraint on the routing
table. Hence, the tests are changed to include our alias which is now
always available.
2024-06-12 15:36:34 +02:00
cloudhead d9fa83f9da
term: Don't print empty tables
Before this change, the table borders would be printed, as well as the
table header if any.
2024-06-12 15:36:34 +02:00
Yorgos Saslis 6966c97194
build: Switch to build args in Dockerfile
`--env` is a podman-specific feature. While it is clear that podman is a
requirement here, switching these to build arguments better expresses
intent.

 These values are meant to be configurable at build time, which is
 exactly what build arguments are for, while environment variables are
 meant to persist in the image built.

Signed-off-by: Yorgos Saslis <yorgos.work@proton.me>
2024-06-12 15:35:42 +02:00
Yorgos Saslis ce99f7e7e4
test: Fix backwards incompatibility with git 2.34
```
--- Expected
++++ actual:   stdout
   1      - branch 'master' set up to track 'origin/master'.
        1 + Branch 'master' set up to track remote branch 'master' from 'origin'.

Exit status: 0
```

As per @fintohaps' suggestion, this gets the tests passing again on git 2.34.

Co-Authored-By: fintohaps <fintan@monoidal.tech>
Signed-off-by: Yorgos Saslis <yorgos.work@proton.me>
2024-06-12 12:13:10 +02:00
cloudhead a6e33ec19a
build: Remove `rad-web` from Dockerfile 2024-06-06 15:28:16 +02:00
cloudhead a4989b7ce7
Remove `radicle-httpd` crate
The HTTP daemon is moved to the `radicle-explorer` repository. Hence,
all traces of it are removed from this repository.
2024-06-06 11:14:00 +02:00