Commit Graph

428 Commits

Author SHA1 Message Date
Alexis Sellier bf22cea014
cob: Fix typos
Signed-off-by: Alexis Sellier <self@cloudhead.io>
2022-12-30 12:59:11 +01:00
Alexis Sellier 86e56d2053
cob: Move graph sorting to `evaluate` function
This avoids passing the sorted items as an iterator.

Signed-off-by: Alexis Sellier <self@cloudhead.io>
2022-12-28 19:24:22 +01:00
Alexis Sellier 70260236b2
cob: Simplify graph builder
Since we use `Oid` as the primary graph index, there's no need to keep
a separate index.

Signed-off-by: Alexis Sellier <self@cloudhead.io>
2022-12-28 18:01:24 +01:00
Alexis Sellier 57fcb117fc
cob: Remove redundant history indices
Signed-off-by: Alexis Sellier <self@cloudhead.io>
2022-12-28 17:53:00 +01:00
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
Alexis Sellier 86a38e208b
crypto: Fix an 'unused import' warning
Signed-off-by: Alexis Sellier <self@cloudhead.io>
2022-12-27 17:31:30 +01:00
Alexis Sellier f6177f85fe
cob: Remove redundant type
Signed-off-by: Alexis Sellier <self@cloudhead.io>
2022-12-27 17:30:06 +01:00
Alexis Sellier f193d7d6cc
Improvements to keystore
* Use the correct passphrase type everywhere
* Allow conversion of secret key
* Extract logic for storing a key in keystore

Signed-off-by: Alexis Sellier <self@cloudhead.io>
2022-12-27 13:43:16 +01:00
Alexis Sellier 2f1ea7f8da
Fix unused import in release mode
Signed-off-by: Alexis Sellier <self@cloudhead.io>
2022-12-27 13:43:16 +01:00
Alexis Sellier 9ec7a0a2ce
cli: Fix flaky tests
We were setting the CWD for the parent process, which wasn't such a good
idea.

Signed-off-by: Alexis Sellier <self@cloudhead.io>
2022-12-27 12:53:57 +01:00
Fintan Halpenny aa05f676f7
cli: add delegate cli
Adds a `rad delegate` CLI command.

The command consists of three subcommands:
* `add` -- add a new delegate to the set of delegates of a project
* `remove` -- remove an existing delegate from the set of delegates of a
  project
* `list` -- list the delegates of a project

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-12-27 12:25:24 +01:00
Fintan Halpenny d7170ff9e7
radicle: ensure unique signatures when parsing trailers
To ensure that signatures are unique for verifying an identity a
HashMap is used in place of a Vec of tuples.

This prevents any double counting for quorum checks.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-12-27 12:23:39 +01:00
Fintan Halpenny adaed6a3ac
radicle: validated construction of Project
The `validate` method of `Project` was unused, which is problematic if
the attributes are supposed to be validated based on some
constraints. The issue is that `Project` provided public construction
of its fields with enforcing validation.

This change makes `Project`'s attributes private and introduces a
smart constructor `new` which is fallible if any of the constraints
are not met. The error type was changed to be a vector of errors since
all of these errors can be collected for better error reporting.

Deserialization also provided a way of constructing a `Project`
without ensuring any of the constraints were checked. To prevent this
a hand-rolled `Deserialize` is provided that goes through
`Project::new`.

To access the fields of `Project`, accessor functions are added and
all call sites are updated to use them.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-12-27 12:23:39 +01:00
xphoniex bd1b4ac5c1
httpd: Use `TraceLayer` on uppermost router
This allows prefix of each route e.g. `/api/*` to be visible in logs.

Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2022-12-26 15:56:21 +01:00
Slack Coder 94be0ca392
cli: Make issue args more declarative
Avoid delegating argument parsing to issue::run().  Define the forms a
peer can take when given as an argument using an enum.  It is then used
to replace OperationName::Default, which is no longer needed, as the
commands default operation is now fully defined by the enum 'Operation'.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-12-26 15:53:06 +01:00
Slack Coder 61fe352ad9
cli: rad issue show
Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-12-26 15:52:14 +01:00
Slack Coder 260863f571
cli: list your assigned issues via 'rad issue'
Allow listing issues for a given peer by using 'rad issue list' with an optional
argument.

For convenience, make listing your own issues easy by making it the
default operation of 'rad issue'.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-12-26 15:52:14 +01:00
Slack Coder 83f2f2b5a5
cli: Make terminal::Table more accepting
Make the Table type easier to use by having it accept &str over String
types as arguments.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-12-26 15:44:19 +01:00
Slack Coder c0590a100d
cli: Lightly document terminal::Table
Help developers by giving a small description and example for its use.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-12-26 15:43:47 +01:00
Slack Coder 873ce895ae
cob: panic on badly formatted debug env var
Panic to clear to the operator something is wrong.  Panic'ing like this
is ok in debug mode, but must be avoided in production.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-12-26 15:38:39 +01:00
Slack Coder 6b67e0571e
cli: Use term::Table to print list of issues
Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-12-26 15:38:39 +01:00
Slack Coder 946d6ac675
cli: assign and unassign issues
Allow assigning an issue to one or more people via a new subcommand.

    rad assign <issue> <peer>

To unassign:

    rad unassign <issue> <peer>

To support testing and documentation, create an example for maintaining
issues for a project.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-12-26 15:38:39 +01:00
Slack Coder edef49d1ef
Improve client example test determinism
Collaborative object IDs are derived from their commit oid.  These
IDs must be reproducible to support testing the client's example.  All but
one of the parameters used to derive the Object ID is the commit's Author
and committer timestamp.

Introduce an environment variable 'RAD_COMMIT_TIME' to set both Author and
Committer timestamp when creating a commit in the cob module.

Use single variable, instead of Git's two (for author and committer), to
keep the changes simple.  The function being modified returns a single
timestamp which is derived from the author's.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-12-26 15:37:55 +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
Fintan Halpenny 9017c59110
nix: update sources for rust-1.66
To match the new toolchain update, run `niv update` to get the latest
rust-1.66.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-12-19 13:03:15 +00:00
Alexis Sellier 4307478718
Test comment editing
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-16 12:32:28 +01:00
Alexis Sellier f1217713af
Add edits to thread test generator
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-16 12:32:23 +01:00
Alexis Sellier e47d7ca2aa
cob: Implement comment edit action
This implementation intentionally preserves all edits such that
they may be displayed in an application as an edit history.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-16 12:32:20 +01:00
Alexis Sellier c68a5a8857
Move `thread` COB to test module
Threads are only intended to be used as part of other COBs.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-16 12:26:16 +01:00
Alexis Sellier f26674a5a9
Upgrade Rust to 1.66
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-15 20:55:26 +01:00
Alexis Sellier b32ae984ce
Start adding support for replies in COBs
This makes a change to comments, such that all comments require a
parent, except the "root" comment, which is created with the COB.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-15 14:43:40 +01:00
Adam Szkoda ac3ee5f709
Build container images for deployment
Signed-off-by: Adam Szkoda <adaszko@gmail.com>
2022-12-14 17:15:40 +01:00
Adam Szkoda 9186d1f30f
Do not install OpenSSL as it's statically linked 2022-12-14 17:15:40 +01:00
Adam Szkoda 294ae8fd24
Put fully static binaries into containers 2022-12-14 17:15:40 +01:00
Adam Szkoda 4abb24feca
Dockerize services
Signed-off-by: Adam Szkoda <adaszko@gmail.com>
2022-12-14 17:15:40 +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 909b99bb7c
Refactor using `NonEmpty::try_map`
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-13 10:16:18 +01:00
Alexis Sellier f90f714fcf
Rename issue action to match patch
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-13 10:16:18 +01:00
Alexis Sellier 24f1de980e
Remove redundant `apply_one` function
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-13 10:16:18 +01:00
Alexis Sellier 0b3a32627b
Use transactions for issue COB
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-13 10:16:18 +01:00
Alexis Sellier 90f20f447a
Make `Transaction` generic, move to `store`
This allows us to use the transaction logic for any COB.
2022-12-13 10:16:18 +01:00
Alexis Sellier 036442af87
Use operation bundle for patch creation
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-13 10:16:18 +01:00
Alexis Sellier e5e1ba583f
Bundle patch CRDT operations
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-13 10:16:18 +01:00
Alexis Sellier 335fcbca89
cob: Return correct clock value for multi-ops
We weren't accounting for batches ops in an entry.
This change should account for it by adding N-1
to the clock value of an entry, where N is the number
of entries.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-13 10:16:18 +01:00
Alexis Sellier bdbf111163
Refactor identity verification
Introduces a new `DocAt` type.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-12 15:01:47 +01:00
Alexis Sellier edafe055b4
Verify identity root commit signatures
In RIP-2, we specify that identity document root commits must include
the signature of all founding delegates.

This commit adds the required signatures during document creation
and verifies them on load.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-12 15:01:42 +01:00
Alexis Sellier c183f80a22
Cleanup some of the git error variants
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-09 22:06:21 +01:00
Alexis Sellier d309f593b1
Move doc initialization to storage
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-09 22:06:21 +01:00
Alexis Sellier b37fef9f22
Re-organize identity types and modules
The new hierarchy should be much more correct, and cleaner:

* `identity` (`Identity`)
* `identity::did` (`Did`)
* `identity::doc` (`Doc`, `Payload`)
  * `identity::doc::id` (`Id`)
* `identity::project` (`Project`)

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-09 22:06:20 +01:00
Alexis Sellier 8735719ecc
radicle: Remove unused error variants
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-09 22:05:42 +01:00