Commit Graph

2001 Commits

Author SHA1 Message Date
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
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
Sebastian Martinez dff6df10fb
httpd: Add /raw route to get file at canonical head
Instead of requiring to specify a commit to obtain a file through the
/raw route, this commit allows to prefix `/head` to get the file at the
current canonical head commit.
2024-06-04 14:19:11 +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 cc7d0cf363
cli: Fix `rad id show` delegate output
We were not showing the correct list of delegates, we were always
showing the "current" list.
2024-06-04 11:10:29 +02:00
Lars Wirzenius db98daecca
cli: make `rad debug` work without a profile
Reported-by: Lorenz Leutgeb
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-05-24 17:04:22 +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
cloudhead 3075a399e9
node: Add test for message amplification 2024-05-24 16:44:22 +02:00
cloudhead 1a8b2f5e2c
node: Fix subscription 'since' timestamp
It was always effectively set to "now" because we insert rows into the
gossip table on startup.
2024-05-24 12:24:20 +02:00
Yorgos Saslis 34d213ad23
docker: Remove outdated docker-compose files
After the Dockerfiles for radicle-node and radicle-httpd have been
removed, these files can also be removed.

Signed-off-by: Yorgos Saslis <yorgos.work@proton.me>
2024-05-24 12:07:02 +02:00
cloudhead 61733ebb95
cli: Allow `--inventory` and `--announce` together
Allow these flags to be used together, since we are announcing the
inventory.
2024-05-24 11:10:48 +02:00
cloudhead a85e7f7442
node: Set TCP_KEEPALIVE on sockets
Ensures dead connections are not kept around longer than necessary.
Note that the ping/pong mechanism is more expensive and checks that the
session is active and healthy, while TCP_KEEPALIVE is lower level,
cheaper, and checks that the connection is still alive.
2024-05-22 14:46:08 +02:00
cloudhead 90deb20405
node: Set socket options for inbounds too
We were only setting socket options for outbound connections.
2024-05-22 14:38:31 +02:00
cloudhead 3403a66d0f
node: Ignore messages from newer protocol versions
This allows for protocol upgrades without breaking old nodes.
2024-05-22 13:56:47 +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
Lorenz Leutgeb 72dad241e2
cli: `rad cob {show → log}` 2024-05-22 11:47:09 +02:00
cloudhead 30c9b0db0b
cli: Add `rad node debug` command 2024-05-21 16:00:30 +02:00
Lars Wirzenius 749e823985
cli: use Rust stdlib to get path to current exe
This is more portable than reading /proc/self/exe, which only works on
Linux.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-05-21 13:51:27 +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
Lars Wirzenius 860f1dc867
debian: add lintian overrides
These make the Debian package checker, lintian, complain less. This
makes any other warning and errors stand out better.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-05-21 13:39:41 +02:00
Lars Wirzenius 22491b5994
debian: drop use of dh-cargo
We don't actually need to use it, and it doesn't help in any way. In
fact, it makes things more difficult, as it insists on using the
Debian-packaged cargo.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-05-21 13:39:41 +02:00
cloudhead 191278f0d9
cli: Use current local tip in `rad sync status`
In the case of an out-of-sync local node, we were showing the wrong tip.
Additionally, mark your tip as unannounced if it isn't announced. This
isn't fool-proof, but can be useful to debug certain issues.
2024-05-21 13:32:40 +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
cloudhead 9f36320d83
node: Don't fail connection if TCP_NODELAY errors 2024-05-21 12:34:38 +02:00
Fintan Halpenny 064ece32ac
node: reduce default upload-pack timeout
From empirical testing, the `FETCH_TIMEOUT` can be set to a lower value of 3s.
For a repository that is about 300MiB, the process will successfully send all
packfile bytes and the references will be written.

The `--timeout` option is also used in the `git-upload-pack` process for good
measure.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-05-17 21:05:50 +02:00
Fintan Halpenny de434bb437
node: simplify upload-pack reader joining
The `join` method is equivalent to the custom loop that was written for joining
the `reader` thread in upload-pack.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-05-17 21:05:50 +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
Lorenz Leutgeb a4e10f0344
fetch: upgrade gix crates
Upgrade the family of `gix` crates and resolve any breaking API changes.

Fixes RUSTEC-2024-0335[[0]].

[0]: https://rustsec.org/advisories/RUSTSEC-2024-0335.html

Co-authored-by: Fintan Halpenny <fintan.halpenny@gmail.com>
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-05-17 13:27:18 +02:00
Lorenz Leutgeb b2992814b6
nix: Polish `flake.nix`
* Remove empty `inherit`s

  These were not doing anything.

      { inherit (f) x; }

  is equivalent to

      { x = f.x; }

  but

      { inherit (f); }

  is equivalent to

      {}

  since there is no attribute name given.

* Refactor `srcFilters` to use `any`

  That's more lighweight and easier to extend.

* Use `installShellFiles` for `buildManPages`
* Produce a more stable version
* Move package `radicle` next to the others

  It's nothing special!

* Refactor Flake

  More code reuse, and a little more direct, basically.

* Set environment variable on derivation
* Compress even more by removing special crate
* Use `with pkgs` before lists of packages
* Use system-independent `lib`
* Clean up
* Update `flake.lock`
* Enable checks `audit`, `deny`
2024-05-17 12:19:30 +02:00
Lorenz Leutgeb d839418c56
fetch: rustfmt 2024-05-16 18:02:45 +02:00
Fintan Halpenny d56d619f56
fetch: remove `.keep` files
A `.keep` file in the `objects/pack` directory acts as a lock to ensure that
operations like `git gc` do not clean up `.idx` files while a fetch is being
performed. It is safe to remove the `.keep` file once a fetch has completed and
a reference points to a given object in the packfile.

To ensure this happens in `radicle-fetch`, a newtype `Keepfile` is introduced.
It uses special `Drop` semantics by attempting to remove the file when the
object is dropped -- logging a warning if it fails to do so.

`FetchState` is augmented to keep a set of the `Keepfile`s. This ensures that
when the fetch completes, either successfully or with a failure, when
`FetchState` is dropped then so are the `Keepfile`s.

We ensure that the expected behaviour of removing the `.keep`files occurs by
adding a check in `e2e::test_replication` to check Alice's repository's packs.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-05-16 15:47:14 +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