Commit Graph

17 Commits

Author SHA1 Message Date
cloudhead 9cdf0aa1fd
Update radicle crates to 0.9.0 2024-03-26 11:56:27 +01:00
cloudhead eee304e0b7
cob: Expose operation concurrency
When evaluating a COB, expose to the `apply` function the operations
concurrent to the current one being applied. These are essentially
"related" nodes in the graph, that are neither ancestors or descendants.

This will let us for example have different failure modes depending on
whether there were conflicting operations, as well as expose conflicts
to the user.
2024-01-22 21:20:01 +01:00
cloudhead 135725d6f6
dag: Fix topological order
We were using a breadth-first search which doesn't work as-is for
topological ordering in all cases. Instead of using Kahn's algorithm
which is a little complex, we switch to a depth-first search.
2023-11-03 14:17:57 +01:00
cloudhead bb3c1b5684
dag: Add "dot" format output 2023-10-11 14:53:59 +02:00
cloudhead 8657cd8fc8
dag: Add a few more tests 2023-10-11 14:53:59 +02:00
cloudhead 457b82f723
cob: Evaluate COB state eagerly
Instead of returning histories from `radicle-cob`, we return an
evaluated object which we build during initial graph traversal.

We do this so that branches can be correctly pruned when operations are
invalid at the application level. This way, new operations are not
building on top of invalid ones contained in the history.

To achieve this, we introduce a new `Evaluate` trait that is implemented
by all COBs, and we make change graph evaluation fallible.

Doing this means that we get `apply` errors returned for free when an
invalid transaction is applied, and no longer need to check for action
validity in multiple places.

We also implement a new `Dag::prune` method to avoid having to copy
graph nodes during traversal.
2023-09-11 23:25:28 +02:00
cloudhead f760b1153f
dag: Accept multiple roots in `fold`, remove depth
This allows the fold to start anywhere in our DAG.
2023-09-07 11:48:21 +02:00
cloudhead 8cb8398be9
Introduce `cargo-deny`
Add `deny.toml` with a few exceptions, and update certain dependencies
to get rid of duplicates.

Running `cargo deny check` will yield some warnings still, but no
errors.
2023-08-22 14:33:00 +02:00
cloudhead b456d3a401
Prepare crates for publishing to `crates.io` 2023-08-07 11:31:11 +02:00
Alexis Sellier 5f731fad0e
dag: Improve trait bounds 2023-05-30 16:31:01 +02:00
Alexis Sellier 0e14dacb99
cob: Simplify graph evaluation
Simplify graph traversal and evaluation by building in some of the
functionality into `radicle-dag`, namely the pruning fold.

We avoid building vectors of graph nodes this way, and simply iterate
over the graph in one go.
2023-05-30 16:31:01 +02:00
Alexis Sellier 3e9c3d2679
cob: Don't overwrite nodes during traversal
By not checking if the node exists, if a node is traversed twice,
the second instance of it gets overwritten, and all the edges get
lost.
2023-04-27 14:44:47 +02:00
Alexis Sellier 8205f8ad4e
Update `fastrand` dependency to 1.9.0 2023-04-14 13:15:52 +02:00
Fintan Halpenny 3f48c2c516
Rust 1.67
Rust 1.67 was announced[0]. Update the necessary files for running
1.67 and fix the clippy suggestions for string interpolation.

[0]: https://blog.rust-lang.org/2023/01/26/Rust-1.67.0.html

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-02-04 19:30:29 +01:00
Alexis Sellier 2f42bc942c
cob: Make it easy to build histories
Signed-off-by: Alexis Sellier <self@cloudhead.io>
2023-01-03 14:23:47 +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