Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
REVIEW
✗ CI failure Lorenz Leutgeb committed 3 months ago
commit 52c346e0b9055f91ba43879f4c3683eaf5838803
parent 5f8f19e3321c832d62eb8b02c54318233002b47e
1 failed (1 total) View logs
10 files changed +44 -40
modified Cargo.lock
@@ -2825,6 +2825,7 @@ dependencies = [
 "qcheck",
 "qcheck-macros",
 "radicle-cob",
+
 "radicle-core",
 "radicle-crypto",
 "radicle-git-metadata",
 "radicle-git-ref-format",
@@ -2935,6 +2936,7 @@ dependencies = [
 "multibase",
 "proptest",
 "qcheck",
+
 "radicle-crypto",
 "radicle-git-ref-format",
 "radicle-oid",
 "schemars",
modified Cargo.toml
@@ -45,6 +45,7 @@ radicle = { version = "0.20", path = "crates/radicle" }
radicle-cli = { version = "0.17", path = "crates/radicle-cli" }
radicle-cli-test = { path = "crates/radicle-cli-test" }
radicle-cob = { version = "0.17", path = "crates/radicle-cob" }
+
radicle-core = { version = "0.1", path = "crates/radicle-core" }
radicle-crypto = { version = "0.14", path = "crates/radicle-crypto" }
radicle-dag = { version = "0.10", path = "crates/radicle-dag" }
radicle-fetch = { version = "0.16", path = "crates/radicle-fetch" }
modified crates/radicle-core/Cargo.toml
@@ -22,6 +22,7 @@ gix-hash = { workspace = true, optional = true }
multibase = { workspace = true }
proptest = { workspace = true, optional = true }
qcheck = { workspace = true, optional = true }
+
radicle-crypto = { workspace = true }
radicle-git-ref-format = { workspace = true, optional = true }
radicle-oid = { workspace = true, default-features = false, features = ["sha1"] }
schemars = { workspace = true, optional = true, default-features = false, features = ["derive"] }
modified crates/radicle-core/src/lib.rs
@@ -71,5 +71,8 @@ extern crate std as doc_std;

extern crate alloc;

+
pub mod node;
+
pub use node::NodeId;
+

pub mod repo;
pub use repo::RepoId;
added crates/radicle-core/src/node.rs
@@ -0,0 +1,24 @@
+
//! A Radicle node on the network is identified by its [`NodeId`], which in turn
+
//! is a Ed25519 public key.
+
//!
+
//! The human-readable format is a multibase-encoded format of the underlying Ed25519 public key, i.e.
+
//! ```
+
//! MULTIBASE(base58-btc, MULTICODEC(public-key-type, raw-public-key-bytes))
+
//! ```
+
//! which results in strings that look like:
+
//! ```
+
//! z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
+
//! ```
+

+
use radicle_crypto::PublicKey;
+

+
/// Public identifier of a node device in the network.
+
///
+
/// # Legacy
+
///
+
/// This is a type alias, providing little protection around evolving a [`NodeId`]
+
/// and having it very tightly coupled with a [`PublicKey`].
+
///
+
/// Future iterations will change this to provide a better API for working with
+
/// [`NodeId`]'s and their usage in the protocol.
+
pub type NodeId = PublicKey;
modified crates/radicle/Cargo.toml
@@ -13,7 +13,16 @@ rust-version.workspace = true
default = []
test = ["tempfile", "qcheck", "radicle-crypto/test", "radicle-cob/test"]
logger = ["colored", "chrono"]
-
schemars = ["radicle-oid/schemars", "radicle-localtime/schemars", "dep:schemars"]
+
qcheck = [
+
  "radicle-core/qcheck",
+
  "dep:qcheck"
+
]
+
schemars = [
+
  "radicle-oid/schemars",
+
  "radicle-core/schemars",
+
  "radicle-localtime/schemars",
+
  "dep:schemars"
+
]

[dependencies]
amplify = { workspace = true, features = ["std"] }
@@ -33,6 +42,7 @@ multibase = { workspace = true }
nonempty = { workspace = true, features = ["serialize"] }
qcheck = { workspace = true, optional = true }
radicle-cob = { workspace = true, features = ["git2"] }
+
radicle-core = { workspace = true, features = ["git2", "serde", "sqlite"] }
radicle-crypto = { workspace = true, features = ["git-ref-format-core", "ssh", "sqlite", "cyphernet"] }
radicle-git-ref-format = { workspace = true, features = ["macro", "serde"] }
radicle-localtime = { workspace = true, features = ["serde"] }
modified crates/radicle/src/identity/doc.rs
@@ -1,7 +1,5 @@
pub mod update;

-
mod id;
-

use std::collections::{BTreeMap, BTreeSet};
use std::fmt;
use std::num::{NonZeroU32, NonZeroUsize};
@@ -29,7 +27,7 @@ use crate::storage;
use crate::storage::{ReadRepository, RepositoryError};

pub use crypto::PublicKey;
-
pub use id::*;
+
pub use radicle_core::repo::*;

use super::crefs::{self, RawCanonicalRefs};
use super::CanonicalRefs;
modified crates/radicle/src/node.rs
@@ -50,6 +50,7 @@ pub use cyphernet::addr::{HostName, PeerAddr, PeerAddrParseError};
pub use db::Database;
pub use events::{Event, Events};
pub use features::Features;
+
pub use radicle_core::NodeId;
pub use seed::SyncedAt;
pub use timestamp::Timestamp;

@@ -1002,9 +1003,6 @@ impl<T: DeserializeOwned> Iterator for LineIter<T> {
    }
}

-
/// Public node & device identifier.
-
pub type NodeId = PublicKey;
-

/// Node controller.
#[derive(Debug, Clone)]
pub struct Node {
modified crates/radicle/src/sql.rs
@@ -4,7 +4,6 @@ use std::str::FromStr;
use sqlite as sql;
use sqlite::Value;

-
use crate::identity::RepoId;
use crate::node;
use crate::node::{Address, UserAgent};

@@ -28,29 +27,6 @@ pub fn transaction<T, E: From<sql::Error>>(
    }
}

-
impl TryFrom<&Value> for RepoId {
-
    type Error = sql::Error;
-

-
    fn try_from(value: &Value) -> Result<Self, Self::Error> {
-
        match value {
-
            Value::String(id) => RepoId::from_urn(id).map_err(|e| sql::Error {
-
                code: None,
-
                message: Some(e.to_string()),
-
            }),
-
            _ => Err(sql::Error {
-
                code: None,
-
                message: Some(format!("sql: invalid type `{:?}` for id", value.kind())),
-
            }),
-
        }
-
    }
-
}
-

-
impl sqlite::BindableWithIndex for &RepoId {
-
    fn bind<I: sql::ParameterIndex>(self, stmt: &mut sql::Statement<'_>, i: I) -> sql::Result<()> {
-
        self.urn().as_str().bind(stmt, i)
-
    }
-
}
-

impl sql::BindableWithIndex for node::Features {
    fn bind<I: sql::ParameterIndex>(self, stmt: &mut sql::Statement<'_>, i: I) -> sql::Result<()> {
        (*self.deref() as i64).bind(stmt, i)
modified crates/radicle/src/test/arbitrary.rs
@@ -270,15 +270,6 @@ impl Arbitrary for storage::Remote<crypto::Unverified> {
    }
}

-
impl Arbitrary for RepoId {
-
    fn arbitrary(g: &mut qcheck::Gen) -> Self {
-
        let bytes = <[u8; 20]>::arbitrary(g);
-
        let oid = crate::git::Oid::from_sha1(bytes);
-

-
        RepoId::from(oid)
-
    }
-
}
-

impl Arbitrary for AddressType {
    fn arbitrary(g: &mut qcheck::Gen) -> Self {
        let t = *g.choose(&[1, 2, 3, 4]).unwrap() as u8;