Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10,822 changes: 2,432 additions & 8,390 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ storb_miner = { version = "*", path = "crates/storb_miner" }
storb_validator = { version = "*", path = "crates/storb_validator" }

# Crabtensor
crabtensor = { git = "https://github.com/storb-tech/crabtensor.git", version = "0.5.2" }
sp-runtime = "=39.0.2"
subxt = "=0.38.0"
crabtensor = { git = "https://github.com/storb-tech/crabtensor.git", tag = "v0.6.0" }
sp-core = "36.1.0"
subxt = "0.41.0"

# Third party
anyhow = "1.0.95"
Expand Down
1 change: 1 addition & 0 deletions crates/storb_validator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ rustls.workspace = true
rusqlite.workspace = true
serde.workspace = true
serde_json.workspace = true
sp-core.workspace = true
subxt.workspace = true
tokio.workspace = true
tokio-serde.workspace = true
Expand Down
9 changes: 6 additions & 3 deletions crates/storb_validator/src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use base::constants::MIN_BANDWIDTH;
use base::piece::PieceHash;
use base::verification::{HandshakePayload, KeyRegistrationInfo, VerificationMessage};
use base::{AddressBook, BaseNeuron, NodeInfo};
use crabtensor::sign::sign_message;
use crabtensor::sign::{sign_message, PairSigner};
use futures::stream::FuturesUnordered;
use tokio::sync::{mpsc, Mutex, RwLock};
use tokio_stream::StreamExt;
Expand Down Expand Up @@ -47,7 +47,7 @@ pub async fn get_piece_from_miner(
req_client: reqwest::Client,
node_info: &NodeInfo,
piece_hash: PieceHash,
signer: Arc<subxt::tx::PairSigner<subxt::SubstrateConfig, subxt::ext::sp_core::sr25519::Pair>>,
signer: Arc<PairSigner>,
vali_uid: u16,
scoring_system: Arc<RwLock<ScoringSystem>>,
) -> Result<reqwest::Response> {
Expand All @@ -66,7 +66,10 @@ pub async fn get_piece_from_miner(
},
};
let signature = sign_message(&signer, &message);
let payload = HandshakePayload { signature, message };
let payload = HandshakePayload {
signature: signature?,
message,
};
let payload_bytes = bincode::serialize(&payload)?;

// Create URL
Expand Down
20 changes: 10 additions & 10 deletions crates/storb_validator/src/metadata/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2740,7 +2740,7 @@ mod tests {
let message = infohash_value.get_signature_message(&nonce);
let signature = sign_message(&signer, &message);
let infohash_value = InfohashValue {
signature, // Use the signed signature
signature: signature.unwrap(), // Use the signed signature
..infohash_value
};

Expand Down Expand Up @@ -2851,7 +2851,7 @@ mod tests {
let message = infohash_value.get_signature_message(&nonce);
let signature = sign_message(&signer, &message);
let infohash_value = InfohashValue {
signature, // Use the signed signature
signature: signature.unwrap(), // Use the signed signature
..infohash_value
};

Expand Down Expand Up @@ -2932,7 +2932,7 @@ mod tests {
let message = infohash_value.get_signature_message(&nonce);
let signature = sign_message(&signer, &message);
let infohash_value = InfohashValue {
signature, // Use the signed signature
signature: signature.unwrap(), // Use the signed signature
..infohash_value
};

Expand Down Expand Up @@ -3049,7 +3049,7 @@ mod tests {
let message = infohash_value.get_signature_message(&nonce);
let signature = sign_message(&signer, &message);
let infohash_value = InfohashValue {
signature, // Use the signed signature
signature: signature.unwrap(), // Use the signed signature
..infohash_value
};

Expand Down Expand Up @@ -3152,7 +3152,7 @@ mod tests {
let message = infohash_value.get_signature_message(&nonce);
let signature = sign_message(&signer, &message);
let infohash_value = InfohashValue {
signature, // Use the signed signature
signature: signature.unwrap(), // Use the signed signature
..infohash_value
};

Expand Down Expand Up @@ -3283,7 +3283,7 @@ mod tests {
let message = infohash_value1.get_signature_message(&nonce);
let signature = sign_message(&signer, &message);
let infohash_value1 = InfohashValue {
signature, // Use the signed signature
signature: signature.unwrap(), // Use the signed signature
..infohash_value1
};

Expand Down Expand Up @@ -3342,7 +3342,7 @@ mod tests {
let message = infohash_value2.get_signature_message(&nonce);
let signature = sign_message(&signer, &message);
let infohash_value2 = InfohashValue {
signature, // Use the signed signature
signature: signature.unwrap(), // Use the signed signature
..infohash_value2
};

Expand Down Expand Up @@ -3425,7 +3425,7 @@ mod tests {
let message = infohash_value3.get_signature_message(&nonce);
let signature = sign_message(&signer, &message);
let infohash_value3 = InfohashValue {
signature, // Use the signed signature
signature: signature.unwrap(), // Use the signed signature
..infohash_value3
};

Expand Down Expand Up @@ -3512,7 +3512,7 @@ mod tests {
let message = infohash_value.get_signature_message(&nonce);
let signature = sign_message(&signer, &message);
let infohash_value = InfohashValue {
signature, // Use the signed signature
signature: signature.unwrap(), // Use the signed signature
..infohash_value
};
let chunk = ChunkValue {
Expand Down Expand Up @@ -3562,7 +3562,7 @@ mod tests {
let message = infohash_value.get_signature_message(&nonce);
let signature = sign_message(&signer, &message);
let infohash_value = InfohashValue {
signature, // Use the signed signature
signature: signature.unwrap(), // Use the signed signature
..infohash_value.clone()
};

Expand Down
18 changes: 9 additions & 9 deletions crates/storb_validator/src/routes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::str::FromStr;
use std::sync::Arc;

use anyhow::Result;
Expand All @@ -9,9 +10,8 @@ use axum::response::{AppendHeaders, IntoResponse};
use base::piece::InfoHash;
use crabtensor::sign::KeypairSignature;
use crabtensor::AccountId;
use subxt::ext::sp_core::crypto::Ss58Codec;
use subxt::ext::sp_core::ByteArray;
use subxt::ext::sp_runtime::AccountId32;
use sp_core::ByteArray;
use subxt::utils::AccountId32;
use tokio::sync::RwLock;
use tracing::{debug, error, info, trace};

Expand Down Expand Up @@ -136,8 +136,8 @@ pub async fn generate_nonce(
debug!("Generating nonce for account_id: {}", account_id);
let metadatadb_sender = state.validator.metadatadb_sender.clone();
// create an AccountId from the ss58 string account_id
let acc_id: AccountId = match AccountId32::from_string(account_id) {
Ok(acc_id) => acc_id.into(),
let acc_id: AccountId = match AccountId32::from_str(account_id) {
Ok(acc_id) => acc_id,
Err(e) => {
error!("Failed to parse account_id: {}: {}", account_id, e);
return Err((
Expand Down Expand Up @@ -216,8 +216,8 @@ pub async fn upload_file(
)
})?;

let account_id: AccountId = match AccountId32::from_string(account_id_str) {
Ok(acc_id) => acc_id.into(),
let account_id: AccountId = match AccountId32::from_str(account_id_str) {
Ok(acc_id) => acc_id,
Err(e) => {
error!("Failed to parse account_id: {}: {}", account_id_str, e);
return Err((
Expand Down Expand Up @@ -531,8 +531,8 @@ pub async fn delete_file(
)
})?;

let account_id: AccountId = match AccountId32::from_string(account_id_str) {
Ok(acc_id) => acc_id.into(),
let account_id: AccountId = match AccountId32::from_str(account_id_str) {
Ok(acc_id) => acc_id,
Err(e) => {
error!("Failed to parse account_id: {}: {}", account_id_str, e);
return Err((
Expand Down
7 changes: 5 additions & 2 deletions crates/storb_validator/src/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use quinn::Connection;
use rand::rngs::StdRng;
use rand::seq::SliceRandom;
use rand::SeedableRng;
use sp_core::hexdisplay::AsBytesRef;
use subxt::ext::codec::Compact;
use subxt::ext::sp_core::hexdisplay::AsBytesRef;
use tokio::sync::{mpsc, RwLock};
use tracing::{debug, error, info, trace, warn};

Expand Down Expand Up @@ -74,7 +74,10 @@ pub async fn upload_piece_data(
},
};
let signature = sign_message(&signer, &message);
let payload = HandshakePayload { signature, message };
let payload = HandshakePayload {
signature: signature?,
message,
};
let payload_bytes = bincode::serialize(&payload)?;
debug!("payload_bytes: {:?}", payload_bytes);

Expand Down
7 changes: 5 additions & 2 deletions crates/storb_validator/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl Validator {
let signature = sign_message(&signer, message);

let infohash_value = metadata::models::InfohashValue {
signature,
signature: signature?,
..infohash_value
};

Expand Down Expand Up @@ -643,7 +643,10 @@ impl Validator {
let piece_len = piece_size;

let signature = sign_message(&signer, &message);
let payload = HandshakePayload { signature, message };
let payload = HandshakePayload {
signature: signature?,
message,
};
let payload_bytes = match bincode::serialize(&payload) {
Ok(bytes) => bytes,
Err(e) => {
Expand Down
Loading