Commit Graph

2174 Commits

Author SHA1 Message Date
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
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