Commit Graph

648 Commits

Author SHA1 Message Date
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 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 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
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
Dr Maxim Orlovsky a3cce22f7a
node: Patch dependencies for Tor/socks5 support 2024-05-06 22:19:36 +02:00
cloudhead 425e7b5092
docs: Fix docstring variable 2024-05-03 13:26:33 +02:00
cloudhead 0d880e12e1
node: Respect relay config on subscribe
Don't relay when a subscribe message is received, unless our relay
configuration allows us.
2024-05-02 13:48:47 +02:00
cloudhead a54180199e
node: Further increase the rate-limit defaults
The rate-limitter gets hit on connect, due to historical gossip messages
being exchanged. This results in a high initial burst that needs to be
accounted for.
2024-05-02 13:43:09 +02:00
cloudhead a9b94b0ad6
node: New relay configuration for nodes
Relay now has three values: "always", "never" and "auto".

The first two operate like the previous `true`/`false`. The
new (default) value turns relaying on for nodes with public (external)
addresses and off for nodes without. This should reduce redundant traffic on
the network, that was causing the rate limiters to trigger.
2024-05-02 11:45:29 +02:00
cloudhead abf89438ea
node: Increase default rate-limiter config
With the increase in traffic on the network after launch, the old
defaults don't make sense anymore.

Longer term, we should look into throttling outgoing messages as well,
prioritizing original messages over relayed messages.
2024-05-01 11:06:28 +02:00
cloudhead afe13b9e47
node: Don't rate-limit persistent peers 2024-05-01 11:06:28 +02:00
cloudhead b31fbde159
node: Add `log` to node config 2024-04-29 15:59:17 +02:00
cloudhead a3ffe51ddf
Rename `RAD_SEED` to `RAD_KEYGEN_SEED`
More explicit.
2024-04-26 10:38:54 +02:00
cloudhead fe5757d122
Tidy up environment variables
* Try to use constants instead of strings
* Move crypto seed override out of radicle-crypto
* Use GIT_COMMITTER_DATE for commit overrides
* Use RAD_LOCAL_TIME as general time override
* Allow variables to be used in release mode
2024-04-26 10:38:54 +02:00
cloudhead deeb39c558
node: Support "transparent" Tor
This allows for configuring your node such that `.onion` addresses
encountered are treated as regular DNS names.
2024-04-26 10:37:41 +02:00
cloudhead 70d2e1a0db
node: Improve `Timestamp` conversion safety
Remove `Timestamp::from(u64)` instance, since not all `u64`s are valid
Timestamps, and add `try_from` instead.
2024-04-26 10:33:34 +02:00
cloudhead 2b771921d5
node: Type-safe timestamps
Use a struct to represent timestamps, to improve type safety.
2024-04-24 12:19:40 +02:00
Lars Wirzenius 1a0221f726
radicle: fix tests to not leave temporary files behind
In radicle/src/test.rs, we have a helper type for a Node, which
creates a temporary directory using tempfile::tempdir, which creates a
TempDir. When the TempDir is dropped, it deletes its associated
directory. Before that happens, the Node has already stored the path.
Right after that the TempDir is dropped, and the directory deleted.
When the test code later opens the repository, using Storage::open,
it recreates the directory. As a result, there is nothing that would
delete the directory when the test finishes.

This means tests that use the helper Node type leave temporary files
behind.

Fix this by storing the TempDir in the helper Node, not just its path.
This means the TempDir is only dropped at the end of the test its used
in, and no temporary files are left behind.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-04-24 11:47:14 +02:00
cloudhead cdebbe5bb7
node: Improved message logging 2024-04-23 10:41:43 +02:00
cloudhead d77b5d5abe
node: Add 'disconnect' command to handle 2024-04-23 09:52:25 +02:00
cloudhead 7a1ba7d4b1
node: Add support for `.onion` addresses in wire
Adds support for encoding and decoding onion addresses in the gossip
protocol.
2024-04-22 12:16:17 +02:00
cloudhead 95b5191533
Reproducible cross-compiled builds
Implement a new build pipeline using `podman` and `zig` that is
reproducible and can be run entirely on linux.

We also simplify the versioning system, defaulting to the output of `git
describe` when there are no exact tag matches.
2024-04-20 11:11:00 +02:00
cloudhead 4276a70eb1
node: Event on local refs announcement
This allows us to listen on the socket for when the user announces new
refs.
2024-04-18 10:57:55 +02:00
Fintan Halpenny 3556758386
cli: fix rad inbox clear output
If multiple ids are specified for `rad inbox clear`, it would report
that only 1 item was cleared, when in fact multiple were.

This was found to be due to the SQL code returning a change count of
`1`. This is likely due to the way the statement is being reset each
time. The `sqlite` library does not seem to easily support the usage
of `IN` in a `WHERE` clause. So instead, the `count` is aggregated in
the loop and returned instead.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-04-09 16:09:44 +02:00
cloudhead bd8e0ebcda
cli: Add tool in case `sqlite3` is unavailable
Adds the `rad node db exec <query>` command.

Easy way to run sqlite queries if the sqlite3 CLI is not available or
too old.
2024-04-06 17:55:59 +02:00
cloudhead 6be77ca9c3
radicle: Implement `remote_refs_at`
Implement this function on `RemoteRepository`, and move `repositories`
to the trait level.

This function will be used to quickly get the `RefsAt` of all repository
remotes.
2024-04-05 21:59:28 +02:00
Fintan Halpenny cd9b46fe51
radicle: fault tolerant thresholds
There are two areas where we can be more tolerant of delegate namespaces
being missing or not validating:
1. Calculating the canonical HEAD
2. Fetching from a remote

In 1. the protocol is tolerant in that if the local node does not have
the default branch for a delegate, it will still attempt to use any of
the delegates it does have to reach the threshold.

This is made safe by ensuring that if the threshold is being updated
then the node performing the update must have a threshold of delegates
locally in their storage. It also made safe by 2.

In 2. the protocol is tolerant by allowing delegates to be missing
from the serving side, as long as they can still meet a threshold of
delegates. This is further tolerant, when validating the received
data, a threshold of delegates are valid to consider the fetch
successful -- otherwise it will fail.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-04-03 14:30:05 +02:00
cloudhead 7e13e0759f
node: Simplify handling of fetch completion
* Don't branch based on whether it was a user-requested fetch or not.
* Only announce inventory on clones of public repos.
2024-04-03 14:25:02 +02:00
cloudhead 6744ffc325
node: Improvements to test reliability 2024-04-03 14:25:02 +02:00
cloudhead e90c6a49bc
node: Include identity doc in fetch result
This avoids having to reload the document in the service, which can be
an expensive operation.
2024-04-03 14:25:02 +02:00
cloudhead 991505ec9d
radicle: Switch error type for repository methods
This simplifies error handling for the next commit.
2024-04-03 14:25:02 +02:00
cloudhead 9a60d4ad7f
node: Put new `refs` table in new migration 2024-04-01 15:00:13 +02:00
cloudhead 256c620d31
node: Use refs cache to decide on fetching
When deciding whether or not to fetch a repo based on a refs
announcement, we need to know whether our signed refs are stale or not,
compared to the ones in the announcement. This can be quite expensive as
it requires multiple reads from Git's ODB, which often results in
packfile loading.

To remedy this, we introduce a refs cache in our node database that is
consulted when an announcement is received.

We also remove the logic that generates `info` messages, since they are
rarely needed and introduced more complexity.

Additionally, we revert commit 3ad2b4431f,
which introduced logic to minimze wants and haves with additional logic,
since it potentially also increases the load on the ODB.
2024-03-29 16:00:33 +01:00
cloudhead 9cdf0aa1fd
Update radicle crates to 0.9.0 2024-03-26 11:56:27 +01:00
cloudhead 77076af23c
radicle: Add new `ash.radicle.garden` seed node
Add the new `ash` node as a preferred seed, to load balance.
2024-03-26 10:36:31 +01:00
cloudhead 5b5a6842c1
Update toolchain to Rust 1.77 2024-03-26 10:03:11 +01:00
cloudhead 7b1847d8ad
Make sure user-supplied timeout takes precedence 2024-03-25 14:03:08 +01:00
cloudhead 0bcec941ee
node: Change behavior on conflicting connections
Instead of dropping the existing connection(s), we drop the same
connection on both sides, by using a simple rule that yields the same
result whether the node sees the connection as inbound or outbound.

The trick is to use something that both nodes agree on, for instance
whos public key is greater than the other, and use that information
to close the same connection on both sides.
2024-03-25 12:48:27 +01:00
cloudhead dbf47fe4e9
Implement new versioning system
See `VERSIONING.md` for details.
2024-03-25 11:54:08 +01:00
cloudhead e6728db15a
cli: Unify all syncing code
We were using similar but slightly different syncing code in the
remote-helper, issues/patches and `rad sync`. This commit unifies them.
2024-03-22 16:35:06 +01:00
cloudhead 8f89f088c6
cli: Correctly honor sync timeout 2024-03-22 16:35:06 +01:00
cloudhead 38a76a42de
radicle: Don't update sync status redundantly
We were updating it even when the `head` was the same.
2024-03-22 16:35:06 +01:00
Sebastian Martinez 0581c017ae
cli: Add `rad patch archive --undo`
Allows archived patches to be reverted to open state.
2024-03-21 20:33:15 +01:00
cloudhead 6288dd0a24
radicle: Load inventory lazily
Instead of loading the inventory cache on storage open, load it
when the `inventory` function is called and the cache is `None`.
2024-03-21 18:03:18 +01:00
cloudhead 057af40ea3
radicle: Fix config loading with bad alias
Previously, a config would load fine with an invalid alias,
due to how serde is configured for the `Alias` type. This fixes it.
2024-03-21 14:44:04 +01:00
cloudhead d771ce8522
node: Make `Storage::refresh` private 2024-03-21 12:40:58 +01:00
cloudhead 2bcb03b021
node: Re-think inventory update code
Instead of re-loading the full inventory on `rad init`, we simply add
the new repository to the in-memory cache.

We also keep track of whether a fetch was a full clone, to know when
to update our routing table.
2024-03-21 12:40:58 +01:00
cloudhead 0e880e12e6
node: Cache node inventory
For large seeds with many repos, it's expensive to traverse the
inventory everytime the node connects to a new peer, for example.

To improve the situation, we cache the inventory per `Storage` instance,
and add a `refresh` method to refresh the inventory.

This method is called when the node is told to synchronize its
inventory.
2024-03-21 12:40:58 +01:00
Alexis Sellier f15afa84be
cli: Add timing information to `rad-sync` 2024-03-19 17:27:18 +01:00