Commit Graph

36 Commits

Author SHA1 Message Date
Fintan Halpenny 5cb4ad4622
node: `info` announcements
An informational message for the protocol is useful for sending
messages to a node that is not required to be relayed.

This message is introduced by starting with an ACK message for a set
of references being synced. This fixes an issue for announcing to a
node that is already synced, since it can now ACK that it received the
message and replies that it is synced.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-11-17 16:29:29 +01:00
cloudhead bea86871de
node: Test that message encoding doesn't panic
Previously, it was possible for the `wire::serialize` function to panic
due to large ref announcements. Now that ref announcements are properly
bounded in size, this shouldn't happen anymore.
2023-11-17 12:22:50 +01:00
Fintan Halpenny d27cd0db0c
node: minimise refs announcement to key and Oid
The RefsAnnouncement previous announced its complete set of
`rad/sigrefs`. This was useful in that verification can occur on the
receiveing side immediately by verifying the refs and proceeding with
the fetch -- note that it did nothing with the ref information it
received.

This can be minimised to only advertising the namespace, i.e. the
NID, and the new SHA of the `rad/sigrefs`. This is represented by a
new message type, `RefsAt`, which contains the NID and the Oid.

For checking if an announcement is stale or fresh, the receiving
side can check the existence of the SHA in its Git repository.

The tests are appropriately modified to use NIDs and Oids.

To prepare for a follow-up change, the announcement data is also
threaded through for the fetch protocol to focus fetching only the
advertised set of Oids.

N.B.: because the refs aren't communicated, the verification happens
when fetching since the data needs to be fetched before
verifying. This is a trade-off with minimising the message payload for
verifying earlier.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-11-09 17:47:09 +01:00
cloudhead 0358d7bcf0
node: Prefix gossip messages with varint length
This is a breaking protocol change that prefixes all gossip messages
with their length.

This is to allow message extensions, as we'll be able to read the whole
message inclulding the extensions, without having to decode the
extensions.

It also makes it easier to check the message length before we start
decoding, so that we can reject messages that are too big.
2023-08-17 11:48:31 +02:00
Alexis Sellier eb701be033
node: Make node aliases required
This is a fairly substantial change, which adds a new configuration file
to the user's `$RAD_HOME` that includes node configuration, including
the alias, and also makes node aliases required.

When running `rad auth`, the user is now prompted for an alias, which
defaults to `$USER`.

When running `rad self`, the alias is now shown.

If the user runs radicle without a config file, the defaults are loaded,
and `$USER` is used as the alias.
2023-07-11 18:08:59 +02:00
Alexis Sellier df25e9a2a5
radicle: Fix unverified `Remote::new` constructor
We were allowing remotes to be constructed via a function that didn't
check its inputs.

This is now fixed by moving the public key into the `SignedRefs` struct.
2023-04-26 10:57:26 +02:00
Alexis Sellier 89b9eb53b7
node: Implement protocol multiplexing
To improve the reliability and flexibility of the protocol, we introduce
multiplexing over peer connections. This involves a new `Frame` type
that carries a stream-id and payload.

Three stream types are made available:

1. Control
2. Gossip
3. Git

This change brings the following improvements:

* Removed need to queue fetch requests
* Removed need to queue gossip messages
* Removed need for `Fetch` and `FetchOk` messages
* Service doesn't need to know about inbound fetches
* Removed one round-trip for fetch negotiation
* Removed special `done` git packet
* Removed session logic and state around Git/Fetch protocols
* Removed code around upgrading/downgrading transport
* Worker in responder mode is able to process any number of fetches
* Connections support any number of concurrent fetches

We had to introduce a few extra things however to make it all work:

* A `VarInt` type for variable-length integers, since we want the frames
  to be lightweight.
* A custom "tunnel" implementation, since we couldn't use the existing
  one anymore.

Overall the change removes more complexity than it adds, while improving
the protocol along the way.
2023-04-10 14:41:55 +02:00
Alexis Sellier 7e1b2b6222
crypto: Cleanup `hash` module
Remove `Digest` type and use `ssh-key` for formatting public ssh key.
2023-02-17 10:51:27 +01:00
Alexis Sellier 067b532154
node: Get replication test to pass
Signed-off-by: Alexis Sellier <self@cloudhead.io>
2023-01-18 17:45:46 +01:00
Alexis Sellier 741f7c9651
node: Rename `Transport` to `Wire`
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 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 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
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
Dr. Maxim Orlovsky 3e48548745
Integrate framing and muxer into wire protocol 2022-11-21 16:05:53 +01:00
Dr. Maxim Orlovsky 13c9491e49
Implement framer and multiplexer 2022-11-21 16:05:53 +01:00
Dr. Maxim Orlovsky 983b2dc534
Two-stage connectivity with handshake 2022-11-21 16:05:53 +01:00
Dr. Maxim Orlovsky 4d77f95c21
Disconnect peers on failed handshakes 2022-11-21 16:05:53 +01:00
Dr. Maxim Orlovsky e9ae5897f7
Complete transcoder
* Encode/encrypt data sent to the remote peer
* Remove unused Transport
* Rename Decoder -> Deserializer
2022-11-21 16:05:53 +01:00
Dr. Maxim Orlovsky 56fb4d67a9
Introduce transcoder parameter to Wire & Transport 2022-11-21 16:05:53 +01:00
Dr. Maxim Orlovsky 6b87eed670
Identify remote peers by full `SocketAddr`
Wire inboxes were kept per IP address. However, there could be multiple peers
connecting from the same IP (for instance, if it is an IP of a NAT).
2022-11-21 16:05:53 +01:00
Alexis Sellier 45c7f3049b
Update to Rust 1.65
* Use new let-else syntax
* Fix new clippy lints

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-05 12:47:26 +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 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 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 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 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 e909e04c6c
Implement proper `node::Features` type
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-07 22:49:58 +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 fcb1007f9d
Refactor service
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-09-23 15:43:55 +02:00
Alexis Sellier 46501507be
Split repository into two creates
* `radicle`: core library
* `radicle-node`: node

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-09-21 15:11:17 +02:00
Alexis Sellier d1ccf1b807
node: Rename folder to `radicle-node`
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-09-21 11:38:09 +02:00
Renamed from node/src/wire.rs (Browse further)