Commit Graph

60 Commits

Author SHA1 Message Date
Alexis Sellier 2f07b76fcb
Switch to our own DAG representation for COBs
We're using petgraph to encode an operation based CRDT (each graph node
is an operation) as a DAG, and one of the important things to ensure
is that the final state is not influenced by the order of concurrent
operations. In this case a concurrent operation would mean two potential
graph traversal orders, as there's no direct edge between the two
concurrent ops. This is essential a "partial order" of operations.

To be able to test this, we'd want some kind of control over how
neighbors are iterated over I guess, when there's more than one possible
sort order. Say we have a graph like this:

             ┌────────b◄─────┐
             ▼               │
             a               d
             ▲               │
             └────────c◄─────┘

There are two possible topological traverse orders: [a, b, c, d] and [a,
c, b, d]. Having a way to go through these different orders would
be super handy.

One option would be to allow random order traversal. This would allow us
to test all orders by running the test enough times to likely test all
permutations.

Since petgraph doesn't support this, we implement our own simple DAG in
`radicle-dag`, which implements random-order topological orders.

For now, we don't make explicit use of these improvements, we simply
replace the underlying graph with our own.
2022-12-28 13:34:17 +01:00
xphoniex 1f55d7a327
Update `radicle-git` to `79a94721366490053e2d8ac1c1afa14fb0c25f09`
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2022-12-23 13:22:55 +01:00
Dr Maxim Orlovsky aa02c52a2f
node: Integrate new Noise_XK transport
This is a large change that introduces transport encryption via
a Noise_XK handshake. The inner `Service` now works directly
with `NodeId` and doesn't need to interact with socket addresses.

The transport logic takes place in `wire::transport`, and the
established sessions are passed down to `Service`.

Note that the i/o implementation in the `poll-reactor` crate still
needs testing, and there is still work to be done to integrate the
Git transport as part of this architecture.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-13 14:59:06 +01:00
Alexis Sellier 98c1566109
Make `Doc` type payload generic 2022-12-09 22:05:38 +01:00
Alexis Sellier b7c1f091fa
Fix issue with colliding doc files
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-09 14:37:36 +01:00
Dr Maxim Orlovsky 3ba7a02207
Use new cyphernet ECDH-related traits 2022-12-09 13:43:08 +01:00
Fintan Halpenny 5f80ee9671
cobs: allow for batched operations
Sometimes it is more efficient to perform multiple operations at once
and store those in the collaborative object graph together.

Change the contents to be a non-empty sequence of byte sequences,
i.e. NonEmpty<Vec<u8>>. These are stored as blobs in a git tree in
order by their index in the non-empty sequence. They are, in turn,
retrieved in order of their original index.

Change the conversion of an `EntryWithClock` to return a non-empty
sequence of `Op`s, which are in turn used to apply many changes in
each `from_history` implementation.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-12-07 17:11:40 +01:00
Alexis Sellier db3568db2f
Update `sqlite` dependency to 0.30.3
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-07 15:41:56 +01:00
Alexis Sellier e63f334890
cli: Replace `trycmd` with our own test runner
This will allow us to run commands other than `rad`
and to have tests that switch between different users.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-06 10:01:38 +01:00
Alexis Sellier f9c81ab382
Replace `quickcheck` with `qcheck`
The latter is a fork of the former, which adds const generics
and a bunch of other quality of life improvements that aren't
in the original crate due to it being unmaintained.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-04 20:40:54 +01:00
Alexis Sellier e8a2432f9d
Move `Change` from `radicle-crdt` to `radicle`
Where it belongs.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-02 14:21:50 +01:00
Alexis Sellier b3faba715b
patch: Correctly merge review edits
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-01 12:05:44 +01:00
Alexis Sellier 0dc34dc15d
Implement patches with radicle CRDTs
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-01 12:05:44 +01:00
Alexis Sellier be789a487f
Move `hash` module to `radicle-crypto`
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-01 12:05:44 +01:00
xphoniex dea7082a6f
Migrate `/projects`: `root`, `project`, `commit`, `activity` handlers
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2022-11-30 13:06:03 +00:00
xphoniex 6f8511c360
Migrate `/v1/sessions` route
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2022-11-30 13:06:03 +00:00
xphoniex acd7aeb9c9
Migrate `/v1/`, `/v1/node` routes to heartwood
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2022-11-30 13:06:03 +00:00
Alexis Sellier fa9a89caa3
Start integrating new CRDTs into `radicle` crate
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-26 17:13:22 +01:00
Alexis Sellier 681a8c9374
Test CRDT storage, simplify `Thread`
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-26 17:13:22 +01:00
Alexis Sellier 35f061746c
Add `radicle-crdt` crate
Explorations with CRDTs.
2022-11-23 19:52:18 +01:00
Alexis Sellier 308112618f
Get around circular-dependency
This was causing an issue in rust-analyzer, and probably would fail
in other ways via cargo. In any case it wasn't a good idea.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-22 13:41:32 +01:00
Alexis Sellier e258c72eca
Implement some CLI tests using `trycmd`
I'm not entirely satisfied with `trycmd`, but it's a start.
If we choose to move to a different crate, or implement our own,
we can keep the example test cases.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-22 10:44:30 +01:00
Dr Maxim Orlovsky 3ec460056d
Add cyphernet dependency 2022-11-22 10:34:49 +01:00
Dr Maxim Orlovsky 2a6f3c4f55
Update ed25519-compact dependency 2022-11-21 16:07:43 +01:00
Fintan Halpenny c620f873e5
radicle-cob: test parse_refstr
Add quickcheck tests for parse_refstr to ensure the correct
behaviour.

This required adding Arbitrary instances for TypeName and ObjectId, as
well as adding a mechanism for generating Invalid ObjectIds.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-17 17:42:22 +00:00
xphoniex 89bdf59e8e
Add `rad-issue` command
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2022-11-16 16:28:31 +01:00
Alexis Sellier 47d20003c0
Implement `rad-patch`
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-16 12:07:19 +01:00
Alexis Sellier 12988da089
Add `Patch`, `Issue`, `Label` COBs
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-14 12:40:00 +01:00
xphoniex 80401f89ae
Add `rad-inspect` command
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2022-11-14 12:23:24 +01:00
Alexis Sellier f05a040be6
Make `track` functions return correctly
Previously we always returned `true`. Now we return
what the node actually returns.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-09 13:29:54 +01:00
Fintan Halpenny cb2d83daae
radicle: wire up radicle-cob
To wire up radicle-cob, it is necessary to implement the traits for
the following types:
* `Repository`: `change::Storage`, `object::Storage`, and `Store`
* `project::Identity`: `identity::Identity`

For `Repository`, the `change::Storage` implementation is trivial, as
it uses the underlying `git2::Repository` implementation. Then
`object::Storage` simply defines the required references names and
does lookups or updates.

The aforementioned reference naming scheme is:

  refs/namespaces/<ns>/refs/cobs/<typename>/<object_id>

For `project::Identity`, the `identity::Identity` implementation is
straight-forward.

To finalise the work, a simplified API is exposed as `radicle::cob`
where the `create`, `update`, `get`, and `list` functions are
redefined in terms of `radicle` specific types.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-08 18:13:54 +00:00
Alexis Sellier 609d05fff2
Update `sqlite` dependency
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-08 09:39:23 +01:00
Alexis Sellier 32cd94dd23
Add `rad-init` command
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-07 22:01:49 +01:00
Alexis Sellier 223d36086e
Add `radicle-cli` crate's `terminal` module
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
Co-authored-by: xphoniex <dj.2dixx@gmail.com>
2022-11-07 14:48:01 +01:00
Fintan Halpenny f3c4a53e1e
radicle-cob: port collaborative objects
This is a minimal port of the collaborative objects code from
radicle-link[0].

A `CollaborativeObject` is made up of a `History` of `Change`s that
are expected to be stored in a `git` backend.

The library exposes a CRU series of functions `create`, `get`, `list`,
and `update`.

This implementation differs, to previous one, in that it does not
assume any kind of identity system -- its only assumption is that
identities have an identifier and can be addressed in the `git`
database. This means that it does not require an `author` to be passed
in and it only uses the `resource` (previously `authorizing_identity`)
to store its content-address in the `Change`.

It also foregoes any caching to simplify the port and not make any
early optimisation assumptions.

[0]: https://github.com/radicle-dev/radicle-link/tree/master/cob

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-04 16:11:18 +00:00
Alexis Sellier 6e8e1e0972
Zeroize secret key in signer
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-03 16:49:29 +01:00
Slack Coder c7706156c6
node: fix test dependency error
Enable Radicle Crypto's test feature.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-11-03 16:02:50 +01:00
Alexis Sellier 5494490c40
crypto: implement an OpenSSH keystore
This will become the primary keystore.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-02 14:11:07 +01:00
Alexis Sellier 6f3a598cc1
Remove `git-url` dependency
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-31 18:14:54 +01:00
Alexis Sellier 7b7e83fbc7
node: implement node announcement sybil resistance
We implement a small proof-of-work on the node announcement message
to prevent the routing table from being filled by fake entries.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-31 18:13:14 +01:00
Fintan Halpenny c0b0d29e19
radicle-crypto: split out from radicle
The crypto types are useful to use in other components that are
separate from the radicle crate, e.g. the incoming radicle-cobs
crate.

Separate out the types into a radicle-crypto crate. This crate defines
the usual PublicKey, SecretKey, and Signature types. It also provides
the ssh functionality, under the `ssh` feature. It is also necessary
to provide the `From` impl for `Component` here, which again is
guarded by the `git-ref-format` feature.

The `Arbitrary` implementation are moved. The arbitrary decision of
redefining `ByteArray` in both radicle-crypto and radicle was made.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-10-27 20:40:39 +01:00
Alexis Sellier 2f6cf9c7a5
httpd: implement `git` fetch-only server
Introduces a new `radicle-httpd` crate which will serve as the basis
for heartwood's HTTP backend.

The first part of this is a git server which allows projects to be
fetched from storage using plain `git`.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 11:36:16 +02:00
Alexis Sellier a2fc976ed6
remote-helper: Initialize
Implement a `git-remote-rad` helper for `rad://` remotes.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-17 16:23:16 +02:00
Fintan Halpenny a56d9008e6
radicle: depend on radicle-git published crates
The `git-ref-format`[0] and `radicle-git-ext`[1] crates are now
published to crates.io.

Switch the dependency to rely on them. This also required to update
the `git2` dependency to `0.15.0` as well as using the
`vendored-libgit2` feature -- avoiding the openssl dependency too.

[0]: https://crates.io/crates/git-ref-format
[1]: https://crates.io/crates/radicle-git-ext

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-10-14 13:16:11 +02:00
Alexis Sellier a06ed9f6de
Statically link sqlite3 2022-10-12 13:27:45 +02:00
Fintan Halpenny df15b497ab
radicle: namespace peers
The previous iteration of the storage layout for projects organised
peer's subtrees by the `refs/remotes` category. This layout leads to
problems when linking a working copy to the storage project. The fetch
refspec would look something like:

  fetch = +refs/remotes/abc/heads/*:refs/remotes/rad/*

This works perfectly fine when running:

  git fetch rad

but will fail when one tries to specify:

  git fetch rad main

Instead, the command would need to be:

  git fetch remotes/abc/heads/main

This patch proposes to move the use of `refs/namespaces` for each
peer. The layout looks similar in that each peer has a subtree, but
instead it is under `refs/namespaces/<peer>/refs/...`.

The previous refspec would look more familiar in its new form:

  fetch = +refs/heads/*:refs/remotes/rad/*

With this in place running:

  git --namespace=abc rad main

Will work as expected and place the reference under
`refs/remotes/rad/main`. Similary, `git --namespace=abc push` will
work as expected.

Another benefit of this approach is that the use of namespacing means
that a tag is pushed it will be placed under the respective namespace
rather than in the global `refs/tags` category.

The actual implementation needed to work around the fact that
`git2`/`libgit2` does not have any options for fetching or pushing
using namespaces. The working copy code uses processes to shell out to
`git` for namespacing needs.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-10-12 12:30:05 +02:00
Alexis Sellier b8c2ab5316
Switch to a lighter sqlite dependency
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-08 12:13:59 +02:00
Alexis Sellier 85ac8a1d4d
Implement routing table persistence
Uses SQLite for persistence.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-05 12:13:12 +02:00
Alexis Sellier 2acd999c16
Add SSH functionality with new `radicle-ssh`
We borrow code from `thrussh`, refactored to be runtime-less.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-03 10:34:59 +02:00
Slack Coder f9ad3ac155 git: Use RefString types for git::refs
Lean on rust's type system to improve safety.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-09-28 16:11:03 -05:00