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

Asynchronous Groth16 verification #830

Merged
merged 1 commit into from
Feb 5, 2021
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
125 changes: 114 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 18 additions & 2 deletions tower-batch/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ use super::{

use crate::semaphore::Semaphore;
use futures_core::ready;
use std::task::{Context, Poll};
use std::{
fmt,
task::{Context, Poll},
};
use tokio::sync::{mpsc, oneshot};
use tower::Service;

/// Allows batch processing of requests.
///
/// See the module documentation for more details.
#[derive(Debug)]
pub struct Batch<T, Request>
where
T: Service<BatchControl<Request>>,
Expand All @@ -35,6 +37,20 @@ where
handle: Handle,
}

impl<T, Request> fmt::Debug for Batch<T, Request>
where
T: Service<BatchControl<Request>>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let name = std::any::type_name::<Self>();
f.debug_struct(name)
.field("tx", &self.tx)
.field("semaphore", &self.semaphore)
.field("handle", &self.handle)
.finish()
}
}

impl<T, Request> Batch<T, Request>
where
T: Service<BatchControl<Request>>,
Expand Down
3 changes: 3 additions & 0 deletions zebra-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ once_cell = "1.5"
rand = "0.7"
redjubjub = "0.2"
serde = { version = "1", features = ["serde_derive"] }
bellman = "0.8"
bls12_381 = "0.3.1"

futures = "0.3.12"
futures-util = "0.3.6"
Expand All @@ -28,6 +30,7 @@ tower-batch = { path = "../tower-batch/" }
zebra-chain = { path = "../zebra-chain" }
zebra-state = { path = "../zebra-state" }
zebra-script = { path = "../zebra-script" }
pairing = "0.18.0"

[dev-dependencies]
color-eyre = "0.5.10"
Expand Down
8 changes: 8 additions & 0 deletions zebra-consensus/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@ pub mod redjubjub;

/// The maximum batch size for any of the batch verifiers.
const MAX_BATCH_SIZE: usize = 64;

/// The maximum latency bound for any of the batch verifiers.
const MAX_BATCH_LATENCY: std::time::Duration = std::time::Duration::from_millis(100);

/// The size of the buffer in the broadcast channels used by batch verifiers.
///
/// This bound limits the number of concurrent batches for each verifier.
/// If tasks delay checking for verifier results, and the bound is too small,
/// new batches will be rejected with `RecvError`s.
const BROADCAST_BUFFER_SIZE: usize = 512;
Loading