Commit Graph

68 Commits

Author SHA1 Message Date
Alexis Sellier a7d2fa95cd
node: Remove redundant handshake
With `NoiseXK` handshake implemented, there is no longer a need to
have an `Initialize` message and an extra state in the session.
2023-02-16 15:10:31 +01:00
Alexis Sellier 71561a8e12
node: Move state transition code to session 2023-02-16 15:09:53 +01:00
Alexis Sellier 011923f1df
node: Buffer gossips until fetch is completed
This change ensures that gossip messages are buffered if we try to
send them during a fetch, and sent after the fetch completes.
2023-02-16 15:09:53 +01:00
Alexis Sellier 0f81f8a7aa
node: Take session reference when writing messages
This ensures that we have an existing session when sending messages.
It also will allow us to check the session's state.
2023-02-16 15:09:53 +01:00
Alexis Sellier 950fae209d
Make `ReadStorage` more usable
Previously, we were not able to access a `ReadRepository` instance
through `ReadStorage`. With this change, we are able to.
2023-02-15 22:08:20 +01:00
Alexis Sellier 89fcc6de1c
node: Subscribe on track-repo
We re-subscribe after our tracking policy has been changed so that
peers are informed of our interests.
2023-02-15 22:07:51 +01:00
Alexis Sellier 8cbc3c2403
node: Move to NoiseXK
Move from NoiseNN with a custom authentication protocol, to NoiseXK.
Uses ECDH on the ed25519 curve via the `ec25519` library.
2023-02-15 22:05:04 +01:00
Alexis Sellier ee513ccf7e
node: Complete the "relay" seed test
These are the final changes to get the "relay" scenario passing.
There are still some issues left, though it's done as far as the
test is concerned.
2023-02-14 20:31:40 +01:00
Alexis Sellier 7919c7ea61
node: Use millisecond precision for timestamps
Previously we used seconds, which could result in false positives
when checking for stale announcements, if things happened too quickly.
2023-02-14 20:31:40 +01:00
Alexis Sellier 2f1a18470e
node: Fix filter construction and policy code 2023-02-12 17:07:57 +01:00
Alexis Sellier 42b4d95f93
node: Improve output of `Session::fetch` function 2023-02-12 16:22:51 +01:00
Alexis Sellier bd7c5a0daa
node: Add ability to have default tracking policy
When a specific tracking policy isn't found, we allow setting a default.
To preserve existing behavior, the default is `Block`, ie. if a node
isn't tracked explicitly, it is blocked.

However, this change allows for using `Track` as the default, which
is a way to track everything without having to know the entities in
advance.
2023-02-12 16:22:51 +01:00
Alexis Sellier 7bdedd0ffd
node: Fix bug with persistent peer reconnect
We weren't updating the sessions map when a persistent peer
was re-attempted. It would then panic when `connected` was called,
because the state would be `Disconnected`.
2023-02-07 10:47:35 +01:00
Alexis Sellier 45e31a5192
Communicate fetch results through control socket
This allows a CLI to report to the user what fetch requests were
fulfilled, and which ones failed.
2023-02-07 10:46:12 +01: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 be77eebc3d
node: Only try to fetch from connected nodes 2023-01-30 11:20:33 +01:00
Alexis Sellier be95222fb5
node: Fix bug in upload-pack
We were not properly exiting one of the threads that was copying
data from the stream to the upload-pack process. This is a fix.
2023-01-27 15:09:17 +01:00
Alexis Sellier ef950d515a
node: Fully integrate worker fetch into service 2023-01-25 10:21:57 +01:00
Alexis Sellier ec2e7d7ee1
node: Refactor fetch response code
Only user-requested fetches require a response.

Signed-off-by: Alexis Sellier <self@cloudhead.io>
2023-01-25 10:21:57 +01:00
Alexis Sellier 3bc07195f5
Migrate to `localtime` from `nakamoto`
The only thing we needed nakamoto for was `LocalTime`.

Signed-off-by: Alexis Sellier <self@cloudhead.io>
2023-01-18 18:03:11 +01:00
Alexis Sellier 3bedb4438e
node: Fix a few logging-related things
Signed-off-by: Alexis Sellier <self@cloudhead.io>
2023-01-17 11:01:36 +01:00
Alexis Sellier 63e7248847
node: Complete Noise handshake integration
Co-authored-by: Dr. Maxim Orlovsky <dr.orlovsky@gmail.com>
Signed-off-by: Alexis Sellier <self@cloudhead.io>
2023-01-17 11:01:36 +01:00
Alexis Sellier 6d420813f5
node: Fix attempted session state
We shouldn't be marking attempted peers as "connected". We should wait
for the connection to be properly established.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2023-01-13 15:44:01 +01:00
Alexis Sellier 438ae84304
node: Implement E2E node test
There are few unrelated changes in this commit that I wasn't able to
split out, mostly due to laziness, so I'll list them here:

* The node startup logic is moved out of the main function, and into a
  dedicated functionin `client.rs`.
* There is a tentative worker implementation that is untested, and
  handles git replication both ways. It's likely lacking in various ways
  but I wanted to get it in there anyway.
* `Address` was moved from `radicle-node` to `radicle`, because it's
  needed to send `Connect` commands from the node handle.
* The `netservices` dependency was updated.
* Finally, there is a first end-to-end node test, which currently
  doesn't use NoiseXK, but uses the new reactor in `netservices`.

Signed-off-by: Alexis Sellier <self@cloudhead.io>
2023-01-12 20:34:31 +01:00
Dr. Maxim Orlovsky a7b1c19746
node: Implement worker thread handover
Also implements listener behavior.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2023-01-05 15:16:38 +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
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
Slack Coder e7f2637126
node: Limit number of Refs in RefAnnouncements
Use the BoundedVec to limit the supported number of refs in
RefAnnouncement messages.  The size (235) is the maximum supported by
message wire size.

To reduce the complexity of the changes, BoundedVec is used again
instead of using a new bounded Refs or BTreeMap.  This requires
defining new Decode/Encode logic for Ref's element types, and
workarounds for arbitrary instances.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-12-09 21:54:10 +01:00
Alexis Sellier 1007756238
node: Add tracking configuration store
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-07 15:41:56 +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 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
Slack Coder fe60305455
node: Define naive message vector limits
Restrict message size decoding by limiting Message's vector size.
Introduce the BoundedVec type to do this on the type level for
convenience and clarity.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-12-01 14:54:40 +01:00
Dr Maxim Orlovsky da55e521a1
Use socket addr instead of Ip for the address book 2022-11-29 17:58:38 +01:00
Dr. Maxim Orlovsky 4d77f95c21
Disconnect peers on failed handshakes 2022-11-21 16:05:53 +01:00
Slack Coder 5472931ff0 node: prune project routing table
Avoid wasting persistent memory by cleaning up stale routing entries
when the routing table is considered constrained.  Limit pruning to
improve resiliency in the face of long intervals between service
downtimes.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-11-15 12:26:34 -05:00
Slack Coder a74cb416c1 node: sync project routing for known nodes
Keep the node's understanding of project hosting location current by
updating how Inventory Announcement messages are processed.

The Inventory Announcements contain a node's entire listing of projects.
Replace the routing table information for the announcer with those from the
message.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-11-15 12:26:08 -05:00
Slack Coder a9b38dc1ae node: let others know their address
Include the node's IP address in the Node's announcements.  Source it
from the service's configuration which can assumed to be populated with
default values when available.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-11-09 09:49:07 -05: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
Alexis Sellier 609d05fff2
Update `sqlite` dependency
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-08 09:39:23 +01:00
Alexis Sellier a79ef67b2a
Add `Signer::try_sign` method and cleanup usage
To support ssh-agent, add a signing method that can fail.
Also cleanup usage so that we always accept signer references.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-03 10:12:22 +01:00
Slack Coder 25c982cd8c
node: use method to access session's Node ID
Make accessing an important session value, the Node ID, as a method to
Session.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-10-31 18:17:27 +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
Slack Coder a8895aee80 node: follow up on session renaming
Rename the module to session from peer to be consistent with recent
renaming of the type from Peer to Session.  Remove stutter by renaming
session::SessionState to session::State, and session::SessionError to
session::Error.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-10-28 09:57:56 -05: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 2a1154ef87
Re-work git transports
The changes in this commit are all intertwined and it was hard to
split them into smaller commits:

* Use custom transports everywhere

Instead of `file://` and instead of using a child process for fetching
and pushing; we go through our custom transports, which use the `rad://`
and `heartwood://` schemes.

* Introduce a 'mock' remote transport

To test the remote transport without needing to spawn TCP streams,
we add a mock transport that works between storages on the file
system.

* Get rid of node's `git-url`

Instead of git urls, nodes simply use their node-ids to replicate.
2022-10-26 21:40:19 +02:00
Alexis Sellier 2ec320acec
Use 'primary key' constraint instead of index
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 22:39: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 fbd4fd9fea
Use session RNG for ping
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 12:33:12 +02:00