Commit Graph

698 Commits

Author SHA1 Message Date
cloudhead 16560950ec
radicle: Fix log when delegate is not found 2024-08-06 16:36:27 +02:00
cloudhead c6a8a00055
Update `rust-toolchain` to 1.80
Fix new clippy warnings.
2024-08-06 14:37:21 +02:00
cloudhead 0e08452323
node: Ensure we don't prune our own routes
Filter out routing entries of our own node when prunning.
2024-08-06 14:17:12 +02:00
Fintan Halpenny 52554af4f1
cli: add `rad unblock` command
Add the `rad unblock` command for reversing the effect of blocking an NID or RID.

In both cases, the entry is removed from the DB, if the policy was set to block
-- otherwise it is a no-op.
2024-08-06 14:12:44 +02:00
cloudhead 84e3ba1482
Validate project names properly in all places
We were only validating names when passed as a flag to `rad init
--name`.
2024-07-31 16:05:31 +02:00
cloudhead ee1c867800
cli: Add way to init from existing repositories
This adds an option to `rad init` to initialize a working copy with
an existing radicle repository in storage:

    rad init --existing <rid>

This sets up the remote(s) and configures the repo for you.
2024-07-29 11:49:19 +02:00
cloudhead 74336f961a
cli: Write comments into draft patch review
We tidy things up with an explicit `Brain` type that stores the accepted
state of the code.

Review comments are added to the patch draft.
2024-07-24 16:46:24 +02:00
cloudhead 7cecabed42
Add `id` to `Revision`, forbid duplicate reviews
Some changes to the `Patch` state needed for code review.
2024-07-24 16:46:24 +02:00
Fintan Halpenny dc34eafdf4
remote-helper: allow patch creation from detached HEAD
The patch creation flow would be partially interrupted when creating a
patch via a detached HEAD state. The creation of an upstream branch
would fail since there is no branch to set an upstream for. It would
result in the following error:

    ✓ Patch 6035d2f582afbe01ff23ea87528ae523d76875b6 opened
    To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
     ! [remote rejected] HEAD -> refs/patches (git: reference 'HEAD' is neither a local nor a remote branch.; class=Invalid (3))
    error: failed to push some refs to 'rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi'

To fix this, the reference that's resolved is checked to see if it a
local branch. If not, it will return early.

The behaviour is tested in the `rad-patch-detached-head` example.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-07-23 17:13:30 +02:00
cloudhead 123f7eb6bb
Update `radicle` crate to 0.12.0 2024-07-18 16:22:14 +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
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 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
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
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
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 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 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 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 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 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 ab532be033
Bump crate versions
We bump the versions of the crates required to publish a new version of
`radicle-httpd` in preparation of moving it out of the repo.
2024-06-05 16:51:55 +02:00
Alexis Sellier 3ae7e305bd
node: Simplify configuration
This is a change to the `config.json` file which removes certain options
that are best not touched and changes some options to make them easier
to work with.

1. We change the default journaling mode to "wal" and remove the config
   option.
2. We remove the option to set the peer connection "target", as it's not
   a good idea to set this to a different value, as it affects the
   network.
3. We combine seeding policy & scope, since there's no need to set the
   scope when the policy is "block". In that case, we always want to
   block "all" remotes. The new policy configuration has the following
   schema:

   { seedingPolicy: { default: "block" | "allow", scope?: "all" | "followed" } }

   The "scope" key is not used when "default" is set to "block".

4. We add an `extra` field to the node config for options that are not
   recognized. We use this to warn the user.
2024-06-04 14:08:15 +02:00
cloudhead 0834e0fc7d
node: Implement staggered broadcast for gossip
We use the *staggered broadcast* technique when relaying gossip messages
to reduce message amplification. In our basic simulation, it brings
amplification down from 3.5 to 1.5.

The idea is simply to accumulate gossip messages and relay them after a fixed
interval of time. This has two effects:

1) Old messages that haven't been sent yet are replaced by newer ones,
   so only one message is sent after the delay.
2) Because nodes have their own intervals, messages are not all sent at
   the same time, which reduces the chance of messages crossing paths.

For now we only turn this on for inventory messages, since this is the
least likely to be noticed by users, and also the most problematic
currently.
2024-05-24 16:44:22 +02:00
Lorenz Leutgeb 6d11ea17c8
cli: Implement `rad cob show` with new meaning 2024-05-22 11:56:01 +02:00
Lorenz Leutgeb 6147a8a2fb
cli: Add `rad cob log` format options
Add `--format json` and `--format pretty`.
2024-05-22 11:54:25 +02:00
cloudhead 30c9b0db0b
cli: Add `rad node debug` command 2024-05-21 16:00:30 +02:00
Fintan Halpenny d46b0b6d11
radicle: Fix file limit setting for FreeBSD
On FreeBSD systems, the file limits are of type `i64` in comparison to
`u64` on Linux systems.

Also fix `rad web` command name on Windows and FreeBSD.

Co-authored-by: cloudhead <cloudhead@radicle.xyz>
Co-authored-by: Shawn Webb <shawn.webb@hardenedbsd.org>
2024-05-21 13:48:44 +02:00
cloudhead f78e5a4281
node: Update sync status for private repos
Only public repos were being updated on node initialization.
2024-05-21 13:32:40 +02:00
Fintan Halpenny 740106d759
cli: upload-pack events
Introduce an `UploadPack` type for keeping track of relevant data from
upload-pack events and displaying progress to the terminal.

It keeps track of the number of remotes that are being uploaded to as well as
the throughput of transmitted data.

The `Progress` events are logged rather than being displayed since they don't
provide any useful details to the user.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-05-17 21:05:43 +02:00
cloudhead 3fe6bbe1cf
node: Update control sock command tag
Breaking change: when writing to the node socket, command names should
be specified via the `"command"` field instead of the `"type"` field.

This was changed to be more readable.
2024-05-17 14:32:39 +02:00
cloudhead 8402b85ad9
cli: Simplify private repo fetching
* Remove `rad sync --force` flag
* Remove `rad clone --private` flag

These flags are no longer necessary. Simplify specifying which seed
to fetch from with `--seed` is enough.
2024-05-16 15:46:24 +02:00
cloudhead ca7db1620c
node: Improve Tor configuration flexibility
*Breaking change* The `tor` configuration field is no longer
supported. Users must remove that field from their config.

Allows for a mixed mode, where regular addresses bypass the Tor proxy,
while onion addresses go through it.

When `onion.mode` is set to "forward", Tor connections are fowarded to
the global proxy, and if it isn't set, to the OS's DNS resolution.

For mixed mode, a global proxy simply isn't set, so that IP/DNS is not
proxied.
2024-05-16 14:53:52 +02:00
cloudhead a6cb4d0f48
node: Implement IP-based banning
The previous banning implementation didn't work, since it included port
numbers in the address value.

Here, we keep a separate table with (node, ip) pairs and update this
table when a node connects or is banned.
2024-05-15 12:10:23 +02:00
Fintan Halpenny 027bfbef67
node: stream timeout semantics for `Node::call`
The timeout for a `UnixStream` will interrupt a `read` even when more data is
available. The preference would be that the timeout applies to each read, where
the timeout is reset again once a read is successful. This better supports
streaming semantics expected for the `Handle::subscribe` method.

To achieve this, the `LineIter` type holds the `UnixStream` and timeout
`Duration`. The `Iterator` implementation can then use `read_line` to progress
the stream one line at a time, and the timeout only applies to each read.

Co-authored-by: Alexis Sellier <alexis@radicle.xyz>
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-05-15 10:07:56 +01:00
Fintan Halpenny 89627a8b6a
radicle: add upload-pack events
Add a variant for upload-pack events to allow reporting from the upload-pack
process.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-05-15 10:07:56 +01:00
Fintan Halpenny f0648c2a18
radicle: move Emitter to events module
Move the events Emitter to the `radicle::node::events` module to allow it to be
used outside of `radicle-node`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-05-15 10:07:56 +01:00
cloudhead cadd996a76
Move prepared statements out of transaction
There's no need to create these on each loop iteration.
2024-05-14 16:36:04 +02:00
cloudhead 21cced05c1
node: Allow for "WAL" mode in sqlite
This solves concurrency issues between the node and http daemon.
2024-05-14 16:34:30 +02:00
cloudhead 25c6660a59
node: Use inventory cache for checking missing
Use the cache when checking whether we're missing an inventory.
This is a lot faster.
2024-05-13 16:37:02 +02:00