Skip to content

Commit

Permalink
identity import & unused deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Apr 27, 2024
1 parent 562c82a commit 39913dd
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 65 deletions.
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ overflow-checks = true
resolver = "2"
members = [
"crates/common",
"crates/compiler",
"crates/delegator",
"crates/executor",
"crates/peer",
"crates/prover",
"crates/runner",
"crates/compiler",
"crates/tests",

]
Expand All @@ -34,7 +34,6 @@ futures-util = "0.3.30"
hex = "0.4.3"
itertools = "0.12.1"
libp2p = { version = "0.53.2", features = [

"ecdsa",
"tokio",
"gossipsub",
Expand Down Expand Up @@ -65,10 +64,10 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
zip-extensions = "0.6.2"

sharp-p2p-common = { path = "crates/common" }
sharp-p2p-compiler = { path = "crates/compiler" }
sharp-p2p-delegator = { path = "crates/delegator" }
sharp-p2p-executor = { path = "crates/executor" }
sharp-p2p-peer = { path = "crates/peer" }
sharp-p2p-prover = { path = "crates/prover" }
sharp-p2p-runner = { path = "crates/runner" }
sharp-p2p-compiler = { path = "crates/compiler" }
sharp-p2p-tests = { path = "crates/tests" }
5 changes: 1 addition & 4 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ license-file.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bincode.workspace = true
cairo-felt.workspace = true
futures.workspace = true
hex.workspace = true
libp2p.workspace = true
num-bigint.workspace = true
proptest-derive.workspace = true
proptest.workspace = true
serde_json.workspace = true
serde_with.workspace = true
serde.workspace = true
starknet-crypto.workspace = true
starknet.workspace = true
strum.workspace = true
tempfile.workspace = true
thiserror.workspace = true
tokio.workspace = true
tokio.workspace = true
9 changes: 1 addition & 8 deletions crates/compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,13 @@ license-file.workspace = true

[dependencies]
async-process.workspace = true
cairo-proof-parser.workspace = true
futures.workspace = true
hex.workspace = true
itertools.workspace = true
libp2p.workspace = true
rand.workspace = true
serde_json.workspace = true
serde.workspace = true
sharp-p2p-common.workspace = true
starknet-crypto.workspace = true
starknet.workspace = true
strum.workspace = true
tempfile.workspace = true
thiserror.workspace = true
tokio.workspace = true
tracing.workspace = true
zip-extensions.workspace = true
tracing.workspace = true
11 changes: 5 additions & 6 deletions crates/delegator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ license-file.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
futures-util.workspace = true
futures.workspace = true
hex.workspace = true
libp2p.workspace = true
serde_json.workspace = true
sharp-p2p-common.workspace = true
sharp-p2p-peer.workspace = true
sharp-p2p-compiler.workspace = true
sharp-p2p-peer.workspace = true
tokio.workspace = true
tracing-subscriber.workspace = true
tracing.workspace = true
starknet.workspace = true
serde_json.workspace = true
futures.workspace = true
tracing.workspace = true
10 changes: 8 additions & 2 deletions crates/delegator/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use futures::StreamExt;
use libp2p::gossipsub::Event;
use libp2p::{
gossipsub::Event,
identity::{ecdsa, Keypair},
};
use sharp_p2p_common::{
hash,
job::Job,
Expand All @@ -23,7 +26,10 @@ use tracing_subscriber::EnvFilter;
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let _ = tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).try_init();

let p2p_local_keypair = libp2p::identity::Keypair::generate_ecdsa();
let private_key =
hex::decode("018ef9563461ec2d88236d59039babf44c97d8bf6200d01d81170f1f60a78f32")?;
let p2p_local_keypair =
Keypair::from(ecdsa::Keypair::from(ecdsa::SecretKey::try_from_bytes(&private_key)?));

// Generate topic
let new_job_topic = gossipsub_ident_topic(Network::Sepolia, Topic::NewJob);
Expand Down
11 changes: 5 additions & 6 deletions crates/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ license-file.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
futures-util.workspace = true
futures.workspace = true
hex.workspace = true
libp2p.workspace = true
serde_json.workspace = true
sharp-p2p-common.workspace = true
sharp-p2p-peer.workspace = true
starknet.workspace = true
sharp-p2p-prover.workspace = true
sharp-p2p-runner.workspace = true
tokio.workspace = true
tracing-subscriber.workspace = true
tracing.workspace = true
futures.workspace = true
sharp-p2p-prover.workspace = true
sharp-p2p-runner.workspace = true
tracing.workspace = true
36 changes: 22 additions & 14 deletions crates/executor/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#![deny(unused_crate_dependencies)]

use futures::{stream::FuturesUnordered, StreamExt};
use libp2p::gossipsub::Event;
use libp2p::{
gossipsub::Event,
identity::{ecdsa, Keypair},
};
use sharp_p2p_common::{
hash,
job::Job,
Expand Down Expand Up @@ -37,7 +42,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.join("../../");
let program_path = ws_root.join("target/bootloader.json");

let p2p_local_keypair = libp2p::identity::Keypair::generate_ecdsa();
let private_key =
hex::decode("07c7a41c77c7a3b19e7c77485854fc88b09ed7041361595920009f81236d55d2")?;
let p2p_local_keypair =
Keypair::from(ecdsa::Keypair::from(ecdsa::SecretKey::try_from_bytes(&private_key)?));

// Generate topic
let new_job_topic = gossipsub_ident_topic(Network::Sepolia, Topic::NewJob);
Expand All @@ -54,7 +62,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut message_stream = swarm_runner.run(picked_job_topic, send_topic_rx);
let mut event_stream = registry_handler.subscribe_events(vec!["0x0".to_string()]);

let p2p_local_keypair_ecdsa = p2p_local_keypair.try_into_ecdsa().unwrap();
let p2p_local_keypair_ecdsa = p2p_local_keypair.try_into_ecdsa()?;
let runner = CairoRunner::new(program_path, p2p_local_keypair_ecdsa.public());
let prover = StoneProver::new();

Expand All @@ -77,14 +85,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Event::Message { message, .. } => {
// Received a new-job message from the network
if message.topic == gossipsub_ident_topic(Network::Sepolia, Topic::NewJob).into() {
let job: Job = serde_json::from_slice(&message.data).unwrap();
let job: Job = serde_json::from_slice(&message.data)?;
info!("Received a new job event: {}", hash!(&job));
job_record.register_job(job);

}
// Received a picked-job message from the network
if message.topic == gossipsub_ident_topic(Network::Sepolia, Topic::PickedJob).into() {
let job: Job = serde_json::from_slice(&message.data).unwrap();
let job: Job = serde_json::from_slice(&message.data)?;
info!("Received picked job event: {}", hash!(&job));
job_record.remove_job(&job);
}
Expand All @@ -103,7 +111,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
},
Some(Ok(job_trace)) = runner_scheduler.next() => {
info!("Scheduled proving of job_trace: {}", hash!(&job_trace));
prover_scheduler.push(prover.run(job_trace).unwrap());
prover_scheduler.push(prover.run(job_trace)?);
},
Some(Ok(job_witness)) = prover_scheduler.next() => {
info!("Calculated job_witness: {}", hash!(&job_witness));
Expand All @@ -115,14 +123,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
&& prover_scheduler.len() < MAX_PARALLEL_JOBS
&& !job_record.is_empty()
{
let job = job_record.take_job().await.unwrap();

let serialized_job = serde_json::to_string(&job).unwrap();
send_topic_tx.send(serialized_job.into()).await?;
info!("Sent picked job event: {}", hash!(&job));

info!("Scheduled run of job: {}", hash!(&job));
runner_scheduler.push(runner.run(job).unwrap());
if let Some(job) = job_record.take_job().await {
let serialized_job = serde_json::to_string(&job)?;
send_topic_tx.send(serialized_job.into()).await?;
info!("Sent picked job event: {}", hash!(&job));

info!("Scheduled run of job: {}", hash!(&job));
runner_scheduler.push(runner.run(job)?);
}
}
}

Expand Down
4 changes: 0 additions & 4 deletions crates/peer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ license-file.workspace = true

[dependencies]
async-stream.workspace = true
futures-core.workspace = true
futures-util.workspace = true
futures.workspace = true
libp2p.workspace = true
sharp-p2p-common.workspace = true
starknet.workspace = true
tokio-util.workspace = true
tokio.workspace = true
tracing-subscriber.workspace = true
tracing.workspace = true
2 changes: 1 addition & 1 deletion crates/peer/src/registry.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use async_stream::try_stream;
use futures_core::stream::Stream;
use futures::stream::Stream;
use starknet::{
core::types::{BlockId, EmittedEvent, EventFilter, FieldElement},
providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider, Url},
Expand Down
2 changes: 1 addition & 1 deletion crates/peer/src/swarm.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use async_stream::stream;
use futures_core::stream::Stream;
use futures::stream::Stream;
use libp2p::futures::StreamExt;
use libp2p::gossipsub::{self, IdentTopic};
use libp2p::identity::Keypair;
Expand Down
1 change: 0 additions & 1 deletion crates/prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ itertools.workspace = true
serde_json.workspace = true
serde.workspace = true
sharp-p2p-common.workspace = true
strum.workspace = true
tempfile.workspace = true
thiserror.workspace = true
tokio.workspace = true
Expand Down
12 changes: 2 additions & 10 deletions crates/runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,17 @@ license-file.workspace = true

[dependencies]
async-process.workspace = true
cairo-proof-parser.workspace = true
futures.workspace = true
hex.workspace = true
itertools.workspace = true
libp2p.workspace = true
# TODO: yet runner using secp256k1
libsecp256k1 = "0.7.1"
rand.workspace = true
serde_json.workspace = true
starknet.workspace = true
starknet-crypto.workspace = true
serde.workspace = true
sharp-p2p-common.workspace = true
strum.workspace = true
starknet-crypto.workspace = true
tempfile.workspace = true
thiserror.workspace = true
tokio.workspace = true
tracing.workspace = true
zip-extensions.workspace = true

[features]
full_test = []
full_test = []
12 changes: 7 additions & 5 deletions crates/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ license-file.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[dev-dependencies]
futures.workspace = true
libp2p.workspace = true
rand.workspace = true
sharp-p2p-compiler.workspace = true
sharp-p2p-prover.workspace = true
sharp-p2p-runner.workspace = true
sharp-p2p-compiler.workspace = true
tokio.workspace = true
rand.workspace = true
libp2p.workspace = true
starknet-crypto.workspace = true
tokio.workspace = true

[features]
full_test = []
full_test = []

0 comments on commit 39913dd

Please sign in to comment.