Commit Graph

857 Commits

Author SHA1 Message Date
Alexis Sellier 89b9eb53b7
node: Implement protocol multiplexing
To improve the reliability and flexibility of the protocol, we introduce
multiplexing over peer connections. This involves a new `Frame` type
that carries a stream-id and payload.

Three stream types are made available:

1. Control
2. Gossip
3. Git

This change brings the following improvements:

* Removed need to queue fetch requests
* Removed need to queue gossip messages
* Removed need for `Fetch` and `FetchOk` messages
* Service doesn't need to know about inbound fetches
* Removed one round-trip for fetch negotiation
* Removed special `done` git packet
* Removed session logic and state around Git/Fetch protocols
* Removed code around upgrading/downgrading transport
* Worker in responder mode is able to process any number of fetches
* Connections support any number of concurrent fetches

We had to introduce a few extra things however to make it all work:

* A `VarInt` type for variable-length integers, since we want the frames
  to be lightweight.
* A custom "tunnel" implementation, since we couldn't use the existing
  one anymore.

Overall the change removes more complexity than it adds, while improving
the protocol along the way.
2023-04-10 14:41:55 +02:00
Adam Szkoda 0f47dc9057
cli: Make `rad rm` work without a fork 2023-04-10 10:42:22 +02:00
Alexis Sellier 3d40a606f7
cli: Fix `rad track` help output
Even though we accept `did:key` as a substitute for NIDs, we don't
generally accept DIDs in this command.
2023-04-10 10:28:46 +02:00
Alexis Sellier c1face7cd8
cli: Fix and simplify `rad review`
* Properly remove review help message from review
* Remove `--no-confirm` and confirmation step

The CLI should be mostly non-interactive for day-to-day commands,
keeping the interactivity for the TUI.
2023-04-10 10:27:52 +02:00
Alexis Sellier f999a62da2
cli: Show patch status in color in `patch show` 2023-04-10 10:17:38 +02:00
Alexis Sellier 7d1e3d489b
cli: Add `patch archive` sub-command 2023-04-10 10:17:37 +02:00
xphoniex 414477a316
cli: Unify format of help messages
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-04-10 10:06:45 +02:00
Adam Szkoda 992e94ebe4
ci: Improve directory structure 2023-04-07 11:37:17 +02:00
Adam Szkoda f1821e0b99
ci: Update releases volume path 2023-04-07 11:37:15 +02:00
Alexis Sellier 505dd9ea96
Add `install` script
Downloads binaries and installs them, based on your operating system.

Can be used in a one liner, for example:

    sh <(curl https://radicle.xyz/install)
2023-04-06 11:29:42 +02:00
Adam Szkoda b33893741f
ci: Migrate away from Google Cloud Storage 2023-04-06 11:28:46 +02:00
Alexis Sellier 9db91e976e
Add `.gitsigners` file with core team 2023-04-05 11:46:57 +02:00
Alexis Sellier 33461e4be1
Set patch status to `merged` automatically
When a merge is applied to a patch, we check whether the threshold
of delegates has been reached, at which point we set the patch status
to `merged`.

This requires threading the identity document oid through the "apply"
process.
2023-04-05 10:32:45 +02:00
Alexis Sellier 6b44955cd9
cli: Show timeline in `patch show` 2023-04-04 21:19:50 +02:00
Alexis Sellier ed4c266a51
node: Don't prune owned refs
Owned refs were being pruned on fetch.
2023-04-03 22:09:41 +02:00
Alexis Sellier 9e50d9053a
cli: Additional fixes in the merge process 2023-04-03 16:06:24 +02:00
Alexis Sellier b6fa4a4b2a
cli: Some improvements to `rad merge` 2023-04-03 16:06:24 +02:00
Alexis Sellier c3e14c346b
node: Add `--force` option to start node
Forces the node to start even in the presence of an existing socket
file.
2023-03-31 17:30:55 +02:00
Alexis Sellier cf37950828
node: Rename control socket
The old name, `radicle.sock` didn't tell us much about the purpose
of this socket.
2023-03-31 17:29:58 +02:00
Slack Coder 0b7f169c8b
cli: Support revision id in `rad merge`
Revision IDs are globally unique.  Users will be able to use the
Revision ID in place of its patch ID.

Make `rad merge` refuse to merge an older revision unless the `--force`
option is given.
2023-03-31 17:24:55 +02:00
Fintan Halpenny 8404b5925d
radicle: force new or initial construction of LWWReg
Using LWWReg::from will always set the clock value to the default,
which can end up being used wrong.

Instead, introduce a constructor method `initial` to indicate that it
should be used on initial construction, while `new` should be used for
newer values of the register.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-31 15:49:55 +02:00
Slack Coder 6417a71e08
node: systemd file
Support users with systemd integration by providing a systemd service
file.  The file includes basic instructions for how to adapt to the
users context.

There are two scenarios it would be run in, as a system service, or as a
user service.  The scenario as a user service is problematic.
`radicle-node` relies on ssh-agent or a clear text RAD_PASSPHRASE.
2023-03-31 15:48:32 +02:00
Alexis Sellier 3f389f37ea
node: Make sure we retry on lock contention
This fixes an issue that came up in tests where we would be reading
and writing to the database at the same time, and it would fail with
an error due to the lock being contended on.
2023-03-31 14:07:45 +02:00
Alexis Sellier b20f81eb0c
Use cached canonical `rad/id` refs
We were recomputing the `rad/id` ref every time it was accessed.
2023-03-31 13:52:12 +02:00
Sebastian Martinez 87f47cdc67
Reduce pub accessors in patch and issue cob structs
Replaces pub accessors to struct fields with methods
Also creates some methods to compute necessary information

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-03-31 13:44:37 +02:00
Fintan Halpenny c618c3e443
node: remove Namespaces::One
The One variant caused many paint points for fetching logic, where it
was not necessary. It was only constructed in one place, which could
be replaced by using the variant that holds a set of keys.

Remove the Namespaces::One variant and rename Namespaces::Many to
Namespaces::Trusted.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-31 12:23:32 +01:00
Fintan Halpenny adf6312a55
node: fetch trusted peers on clone
When a repository does not yet exist during a fetch, i.e. a clone,
then only delegates are being fetched.

Augment Namespaces::Many to hold the trusted and optional delegate peers
separately. Doing so allows the construction of the variant without
the repository existing, but tracking relationships existing.

This variant can then be used to build refspecs for both the trusted
peers and delegates when doing a cloning fetch.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-31 12:23:31 +01:00
Fintan Halpenny f78e010c55
node: e2e test simulating a peer migrating their key
Previously, if a peer created a project which was replicated and then
moved to another setup, ultimately deleting that project, then they
would not be able to fetch it again since their remote namespace would
be excluded from the fetch.

This test confirms that a peer can remove their project and clone it
again from a peer that has replicated the project. This is simulated
by directly removing the project directory in the test and fetching
the project from the other peer.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-31 12:19:37 +01:00
Fintan Halpenny 6e08f0be59
node: enable test_fetch_trusted_remotes
With the latest fetch updates, the test for fetching trusted remotes
can be enabled.

The caveat is that its expected behaviour is to fetch the delegate
upon a clone and fetch all trusted peers on a subsequent
fetch. Fetching all trusted peers is left as a follow-up task.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-31 12:19:36 +01:00
Fintan Halpenny db0ceddf6b
node: multistep fetching logic
The previous fetching logic had some pitfalls regarding its logic:

* Fetched 'rad' references could end up not being verifiable and leaving
  the storage in a corrupt state
* Forced pushes would be prohibited, since they would be rejected by
  the client side due to the refspecs being used.

The new approach is to stage a fetch in 2 steps. The first step is to
fetch the relevant `rad/id` and `rad/sigrefs` for verification. For
all remotes that are verified, fetch all references listed in their
respective `rad/sigrefs`, using the `+` marker in the refspec,
allowing to update for any force pushes -- note that this becomes a
safe operation since the `sigrefs` are signed by the remote that
created them.

To prevent unverifiable 'rad' references from polluting storage, all
fetch negotiations are done in a staging repository set up in a
temporary directory. All successful fetches are then transferred,
using the 'file://' protocol, from the temporary directory into the
radicle storage.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-31 12:19:36 +01:00
Fintan Halpenny d73d485848
crypto: add PublicKey::to_namespace
Add a helper function for creating the `RefString`,
`refs/namespaces/<public key>`, for a given `PublicKey`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-30 15:53:27 +01:00
Sebastian Martinez 91efbd9630
Rename `patch::State::Proposed to `patch::State::Open`
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-03-30 10:46:57 +02:00
Sebastian Martinez 8907ddb8a5
httpd: Add `patch::Action::Lifecycle`
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-03-30 10:46:57 +02:00
Sebastian Martinez c9aaaec2ee
cob: Add `patch::Action::EditRevision`
To be able to change the description of a patch revision, without the
need to create a new revision.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-03-30 10:42:49 +02:00
Sebastian Martinez fa15ca59f1
cob: Use `LWWReg::new` instead of `LWWReg::from`
Using LWWReg::from was giving subsequent actions
the same clock value as their predecessors.

This resulted in a Reject not being able
to turn into an Accept on a second review of a patch.

The solution is to use the clock value that was produced for the Op
and pass that into new, avoiding the call to from.

Co-authored-by: Fintan Halpenny <fintan.halpenny@gmail.com>
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-03-30 10:40:21 +02:00
Alexis Sellier 973f618cd3
node: Fix routing table update on refs
The announcer is always the one who must have the refs, not the relayer.
This was changed in a recent patch.
2023-03-30 10:24:09 +02:00
Alexis Sellier 7c41c5edff
node: Replace most sleeps with events
With the new event system, we can replace the thread sleeps by
waiting for events. This should speed tests up a lot and
be more reliable.
2023-03-30 10:24:06 +02:00
Alexis Sellier 6fb6cff708
term: Add border support for tables 2023-03-27 17:46:32 +02:00
Fintan Halpenny af99d6f47a
radicle: set identity head on init
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-27 10:13:04 +01:00
Fintan Halpenny a629f91b1e
node: set identity head after fetch
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-27 10:13:03 +01:00
Fintan Halpenny a32101ab75
radicle: canoncial refs/rad/id
Introduce a canonical reference for refs/rad/id to aid in discovering
information about a repository without knowing a peer -- e.g. if a
peer wants to clone a new repository it needs to find out which peers
are delegates for that project, but does not know what their NIDs are
up front.

The approach mirrors the canonical `head` for a repository and
introduces useful constructors for `Doc`/`DocAt`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-27 10:13:03 +01:00
Han Xu b030e9ea80
node: Only fetch from tracked nodes
The tracked nodes include nodes marked tracked in the db, and
the delegates and `Namespaces::All` if it is a new repo.

Signed-off-by: Han Xu <keepsimple@gmail.com>
2023-03-25 12:27:29 +01:00
Sebastian Martinez a5746b4f08
httpd: Add reactions to issue and patch json
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-03-25 12:04:53 +01:00
Sebastian Martinez 6b62f5bb28
httpd: Add patch head refs to patch output
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-03-25 11:54:09 +01:00
Alexis Sellier da9d63b284
node: Fix fetch requests code
We were not correctly deleting the fetch request, since only one
was kept per RID.
2023-03-24 13:25:40 +01:00
Alexis Sellier fe8953ab8b
node: Don't penalize peer for protocol mismatch
Instead of returning a non-transient disconnect reason, return
a transient one, since protocol mismatches can happen.
2023-03-24 13:23:43 +01:00
Alexis Sellier d3f4189324
node: Fix reconnection logic
First, we make sure to always attempt reconnection to persistent peers,
no matter the reason.

Second, we don't re-attempt connections when an inbound peer
disconnects. This minimizes the chance of connections crossing.

Third, we clean up `session::Error`, and don't use it to signal a
missing session, since it doesn't really belong there.
2023-03-24 13:20:34 +01:00
Alexis Sellier 4438a10498
node: Change ping interval to 1 minute
30 seconds is too chatty.
2023-03-24 13:19:36 +01:00
Alexis Sellier 8dba01d6ae
cli: Improve patch command output
* Fix timeline ordering
* Remove spinner noise
* Add revisions to timeline
2023-03-24 13:04:52 +01:00
Alexis Sellier 40eb6f2a6e
term: Remove unused file 2023-03-24 11:25:04 +01:00