Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DNM] ZKsync demo #121

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 2 additions & 0 deletions lgn-messages/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub enum TaskType
V1Preprocessing(v1::preprocessing::WorkerTask),
V1Query(v1::query::WorkerTask),
V1Groth16(v1::groth16::WorkerTask),
Flat(Vec<u8>),
}

#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
Expand All @@ -46,6 +47,7 @@ pub enum ReplyType
V1Preprocessing(WorkerReply),
V1Query(WorkerReply),
V1Groth16(WorkerReply),
Flat(Vec<u8>),
}

#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
Expand Down
28 changes: 28 additions & 0 deletions lgn-worker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ use lgn_messages::types::UpstreamPayload;
use lgn_worker::avs::utils::read_keystore;
use metrics::counter;
use mimalloc::MiMalloc;
use rand::distributions::Uniform;
use rand::prelude::Distribution;
use serde_json::Number;
use tokio::io::AsyncWriteExt;
use tokio_stream::StreamExt;
use tonic::metadata::MetadataValue;
Expand Down Expand Up @@ -416,6 +419,23 @@ fn process_downstream_payload(
envelope: MessageEnvelope<TaskType>,
) -> Result<MessageReplyEnvelope<ReplyType>, String>
{
if let TaskType::Flat(_) = envelope.inner
{
println!("Processing FLAT proof");
std::thread::sleep(std::time::Duration::from_secs(3));
return Ok(
MessageReplyEnvelope::new(
envelope
.query_id
.clone(),
envelope
.task_id
.clone(),
ReplyType::Flat(vec![32; 150]),
),
);
}

let span = span!(
Level::INFO,
"Received Task",
Expand Down Expand Up @@ -622,6 +642,10 @@ fn get_claims(config: &Config) -> Result<Claims>
};

let version = env!("CARGO_PKG_VERSION");
let price_range = Uniform::new(
3000,
5000,
);
let private = [
(
"version".to_string(),
Expand All @@ -636,6 +660,10 @@ fn get_claims(config: &Config) -> Result<Claims>
.to_string(),
),
),
(
"price".to_string(),
serde_json::Value::Number(Number::from(price_range.sample(&mut rand::thread_rng()))),
),
]
.into_iter()
.collect::<BTreeMap<String, serde_json::Value>>();
Expand Down
Loading