Commit Graph

180 Commits

Author SHA1 Message Date
Alexis Sellier 111480cd6e
Make use of `git2::Repository::refname_to_id`
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 14:47:12 +02:00
Alexis Sellier 94f7675c72
Move `sign_refs` to `WriteRepository` trait
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 14:41:12 +02:00
Alexis Sellier 657a951df0
Create `url` module shared between crates
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 14:30:01 +02:00
Alexis Sellier 617e0c1877
Remove redundant `Options` type
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 11:47:29 +02: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 3bff9a9dc1
Set repository canonical refs
We set the `HEAD` and eg. `refs/heads/master` refs when updating
repositories, which allows users to easily clone with git.

For now, `HEAD` is chosen based on a unanimity quorum of delegates.
This can be made more sophisticated in the future.

We've also had to ignore some refs during verification, since these
have cropped in for eg. due to the staging copy clone and the
changes included here.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 10:27:24 +02:00
Slack Coder 10d8519101
node: improve ping/pong tests
Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-10-18 17:23:31 +02:00
Alexis Sellier 09c438f8fb
Remove `Envelope` type
This type that was wrapping `Message` isn't very useful here.
If we decide that we do need something like that, it's best handled one
layer below.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 16:45:10 +02:00
Alexis Sellier 156a3a576a
Enforce max size for `Message` type on wire
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 15:44:06 +02:00
Alexis Sellier f5e881b5a9
Move message size constant to `Message` type
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 13:06:45 +02:00
Alexis Sellier c306392d13
Improve wire module
* Set `Size` correctly to `u16`
* Remove `usize` support, since it's OS-dependent

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 13:04:12 +02:00
Alexis Sellier 874386540a
Document service constants
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 13:04:12 +02:00
Alexis Sellier ae95b229f5
Activate lint for dead-code checking
For test code, we need it in a couple of places.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 13:03:34 +02:00
Alexis Sellier 1df5cf0c45
Remove redundant docs from trait impl
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 13:00:55 +02:00
Alexis Sellier 2499317589
Implement `Handle::listening`
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 13:00:50 +02:00
Alexis Sellier d3523ccf78
Remove unused type
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 12:37:01 +02:00
Alexis Sellier fbd4fd9fea
Use session RNG for ping
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 12:33:12 +02:00
Alexis Sellier 86ed10fca9
Move timestamp columns to the right table
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-17 20:39:30 +02:00
Slack Coder 14690d1951 Service: drop unresponsive peers
Use pings to check connection health with network peers and drop them if
they prove unresponsive.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-10-17 10:22:43 -05:00
Alexis Sellier 240825387d
Implement correct `did:key` format
We weren't including the *multicodec* bytes previously.
This is now tested against some test vectors from the spec.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-17 16:37:06 +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
Alexis Sellier 7936ba8773
node: use consistent terminology for tests
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-14 18:55:30 +02:00
Alexis Sellier d9517cc966
node: add more tests for refs relay
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-14 18:51:53 +02:00
Alexis Sellier ba95725028
Add placeholder README 2022-10-14 13:19:28 +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 7c45971998
node: handle announcement relay correctly
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-14 13:09:06 +02:00
Alexis Sellier 45ea9cc97d
node: refactor announcement timestamp handling
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-14 12:14:26 +02:00
Alexis Sellier 4c1aa65f90
node: correct handling of announcement timestamps
Since we now have three announcement message types, we need at least
three timestamps per peer. But even that is not enough, since we don't
want to conflate ref announcements for different projects with each
other.

The solution is to also keep a map of timestamps per peer, for each
tracked project. That way we are able to know when a ref announcement is
interesting to us or not.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-14 11:59:54 +02:00
Alexis Sellier 07add86bb6
node: Handle node announcements
To build an address book, peers communicate via gossip, sending
`NodeAnnouncement` messages.

These need to be handled by storing the addresses in an address book
and the addresses need to be persisted to disk.

Node announcement messages should also be relayed to peers like other
gossip messages.
2022-10-14 11:58:17 +02:00
Alexis Sellier 0482f0ce04
ssh: remove unused traits, simplify code
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-13 22:33:36 +02:00
Slack Coder c294f2ab5c
ssh: support encoding/decoding armored signatures
Armored signatures are used by Git for signing commits. Support reading
writing these signatures by implementing a new trait to read and write
to the SSH formmat.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-10-13 21:15:19 +02:00
Fintan Halpenny 8d80359c38
radicle: remove verified field in Remote
The `V` parameter of `Remote` is already determined by the `refs`
field. The `verified: PhantomData<V>` field is not required.

Remove the `verified` field to simplify the `Remote` struct.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-10-12 13:29:15 +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
Fintan Halpenny 50dd817762
meta: add nix tooling
Adds nix tooling to allow people to develop using nix dependencies.

Uses niv to pin nixpkgs, rust-overlay, and niv itself.

This will give Rust tooling that is up to date with rustc-1.64.0.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-10-12 12:21:01 +02:00
Alexis Sellier a104f9681c
Warn on `unwrap`, remove last remaining instances
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-11 09:31:54 +02:00
Alexis Sellier 5ccf9a388a
Handle errors in `rad::remote` properly
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-11 09:31:53 +02:00
Alexis Sellier 6ef74c6674
Don't nest options inside results
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-11 09:31:52 +02:00
Alexis Sellier fde0af09f7
Handle errors correctly in storage
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-11 09:31:48 +02:00
Alexis Sellier d652df7c30
node: Handle error in handshake call
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-10 14:47:50 +02:00
Alexis Sellier 832c6ad53f
Improve error handling in a few places
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-10 11:29:22 +02:00
Alexis Sellier 78545c2f0f
Implement routing table pruning functions
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-08 13:45:15 +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 e909e04c6c
Implement proper `node::Features` type
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-07 22:49:58 +02:00
Alexis Sellier 77ee404e83
Fix issue with dev mode on `radicle` crate
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-06 18:39:32 +02:00
Alexis Sellier 2d52a53ce5
Add variable bloom filter sizes
This should help small nodes waste less bandwidth, while standardizing
on set sizes.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-05 15:58:34 +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 15f525299e
Add commnads to query internal service state
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-04 21:07:57 +02:00
Alexis Sellier efdc8c52c7
Add a `CommitObject::TryFrom<git2::Buf>` instance
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-03 21:33:04 +02:00
Alexis Sellier fece740fcb
Implement commit parsing/formatting
To be able to support git commits with multiple signature
headers, we have to implement our own parsing and formatting.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-03 21:17:52 +02:00