Commit Graph

1966 Commits

Author SHA1 Message Date
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
Fintan Halpenny cb2cbf014a
cli: reject `rad id` proposals that do not verify
To ensure that the `rad id` command does not modify the project payload without
it being able to be deserialized into the `Project` type, the command performs
this check throught the `project` method, and returns an error if this fails.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-05-16 10:11:48 +01:00
Lorenz Leutgeb 11a1bca0fc
cargo: Ignore tracked advisories 2024-05-16 12:08:57 +02:00
RadsammyT d5045417d6
cli: remove op check for `--repo` in `rad inbox`
As a response to Issue # c4134924cf2ce84444c6f7235a27651ad49311b5.
A no-op command in rad inbox defaults to show, but the inbox argument parser
only permits --repo in instances where the operation is explicity declared.

Here, the check for an explicit operation is removed so one is never required.
2024-05-16 12:07:08 +02:00
Lars Wirzenius 0d00528d48
cli: add SHELL environment variable to "rad debug" output
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-05-16 12:06:04 +02:00
Lorenz Leutgeb 660236225e
signals: Add license to calm `cargo deny` 2024-05-16 12:05:22 +02:00
cloudhead 6dd29d4b50
build: Move `ulimit` flag to correct location 2024-05-15 14:47:57 +02:00
Sebastian Martinez 5727359319
httpd: Validate blob sizes 2024-05-15 13:03:28 +02:00
Rūdolfs Ošiņš 3b342ab385
httpd: Set cache header for immutable blob endpoint
It is safe to do so because it is content-addressed.
2024-05-15 12:28:30 +02:00
cloudhead b195a3eb35
build: Set ulimit on container
This was necessary on some machines.
2024-05-15 12:24:44 +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 72c715016f
fetch: add trace logging to fetch protocol
Log the following at the trace level:
- Receiving the pack along with the amount of time it took
- The closing of the connection

Also organising the imports, while in the neighbourhood.

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 f038b7ee5c
cli: watch for upload-pack events in `rad init`
To improve the user experience of `rad init`, the events listener waits for
upload-pack messages indefinitely. The spinner reports back the upload progress
over time.

This process can be cancelled via Ctrl+C without affecting the announcement,
since that is happening in the background.

To also improve the experience, the remote NIDs that have successfully synced
are reported to the terminal.

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 344fe3a901
node: increase `FETCH_TIMEOUT`
After empirically testing HardenedBSD[[0]], which has a total blob size of
42GiB, and its largest checkout is 1.26GiB (using `git-sizer`[[1]]), it was
found that letting the background process fetch the repository with a timeout of
1 hour is enough (a very generous estimate).

This deemed sufficient, since cases smaller than this will report back that they
are done before this time. For cases larger than this, more research will be
needed.

[0]: https://git.hardenedbsd.org/hardenedbsd/HardenedBSD
[1]: https://github.com/github/git-sizer

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 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 c8a24d5584
node: report upload-pack progress
Emit the `UploadPack` events from the `upload_pack` method.

A wrapper type, `Reporter`, is introduced for implementing a `Write` instance
that will parse the given bytes as `gix_protocol::RemoteProgress`, if possible,
and emit it via the `Emitter`, and then write the bytes to the underlying
writer. This allows any subscribers to see the progress of an upload-pack, i.e.
`Compressing objects`, `Counting object`, `Enumerating objects`.

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
Fintan Halpenny fd4c4cd0af
node: dynamic fetch timeout via channels
Instead of using `DEFAULT_CHANNEL_TIMEOUT`, the timeout is dynamically set
per-fetch by the caller.

This passed via the `Io::Fetch` variant -- when initiating a fetch, and the
`Control::Open` variant when responding to a fetch.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-05-15 10:07:55 +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
cloudhead cce46a3d8b
Try to improve performance of repository open
By using `open_ext` with `BARE`, we defer loading of the Git config,
which has been shown to be expensive.
2024-05-13 16:37:02 +02:00
cloudhead 8e541dcf58
node: Set TCP NO_DELAY for node connections
Just experimenting. I think this will be a better default for the type
of data exchanged between nodes.
2024-05-13 16:12:41 +02:00
cloudhead 2ca1e74707
cli: Have way to delete payload field in `rad id`
Allow for deleting a field by setting it to `null`.
2024-05-13 16:12:41 +02:00
Alexis Sellier 930f9b0a7e
node: Don't always connect to Tor addresses
Only connect if Tor is configured.
2024-05-10 13:38:02 +02:00
Alexis Sellier c5395f0674
cli: Improve `rad stats` output
Use daily/weekly figures.
2024-05-10 13:13:03 +02:00
Alexis Sellier 9766c67671
node: Fix tor proxy issue for regular addresses
This should allow using a Tor proxy for regular connections.
2024-05-09 21:45:48 +02:00
cloudhead 6ab3bfcba0
node: Use banning for repeated offenders
When the penalty score for a node reaches a certain threshold, we ban
the node.

Banned nodes are not allowed to connect to us.
2024-05-07 14:49:02 +02:00
cloudhead 9a82aae993
node: Reset connection attempts when stable
Instead of resetting the number of attempts on connection, reset it when
the connection is stable, ie. after some time has passed.

This prevents connection retries from happening in succession when a
peer is disconnected during the initial handshake, as is the case with
invalid subscribe timestamps.
2024-05-07 14:49:02 +02:00
cloudhead ef4efe3200
node: Improve logging for storage check 2024-05-07 14:49:02 +02:00
cloudhead 7484d737d5
node: Re-use inventory message timestamps
If our inventory hasn't updated, don't issue a new inventory
announcement, simply use the previous message.

This avoids identical inventories propagating over the network and using
up resources.
2024-05-07 14:49:02 +02:00
cloudhead 88a4029789
node: Use `BoundedVec` for inbox 2024-05-07 14:49:02 +02:00
cloudhead f212dbb2ee
node: Make sure we bound peer message inboxes 2024-05-07 14:49:02 +02:00
Fintan Halpenny e8f2f88bf6
cli: Add test for unknown field in identity doc
Add a test to confirm that the identity can still be deserialized when an
unknown field is added.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-05-07 10:21:07 +02:00
Fintan Halpenny 9b719d0cca
radicle: allow for unknown fields in Project deserialization
Allow unknown fields to pass through when deserializing the `Project` payload.
This allows the deserialization to be more resilient when unknown fields are
added, e.g. from the CLI, and improves backwards-compatability when new fields
may be added in the future.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-05-07 10:19:59 +02:00