Skip to content

Commit 89a9f1a

Browse files
committed
Increments pending_items on tower-batch-control Workers by item_size() instead of 1, and increases halo2 max batch size from 2 to 64
1 parent 5bf0219 commit 89a9f1a

File tree

2 files changed

+4
-37
lines changed

2 files changed

+4
-37
lines changed

tower-batch-control/src/worker.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,9 @@ where
144144

145145
match self.service.ready().await {
146146
Ok(svc) => {
147+
self.pending_items += req.item_size();
147148
let rsp = svc.call(req.into());
148149
let _ = tx.send(Ok(rsp));
149-
150-
self.pending_items += 1;
151150
}
152151
Err(e) => {
153152
self.failed(e.into());

zebra-consensus/src/primitives/halo2.rs

+3-35
Original file line numberDiff line numberDiff line change
@@ -28,47 +28,22 @@ use tower_fallback::Fallback;
2828

2929
use super::spawn_fifo;
3030

31-
// #[cfg(test)]
32-
// mod tests;
33-
3431
/// Adjusted batch size for halo2 batches.
3532
///
3633
/// Unlike other batch verifiers, halo2 has aggregate proofs.
3734
/// This means that there can be hundreds of actions verified by some proofs,
3835
/// but just one action in others.
3936
///
40-
/// To compensate for larger proofs, we decrease the batch size.
41-
///
42-
/// We also decrease the batch size for these reasons:
43-
/// - the default number of actions in `zcashd` is 2,
44-
/// - halo2 proofs take longer to verify than Sapling proofs, and
45-
/// - transactions with many actions generate very large proofs.
46-
///
47-
/// # TODO
48-
///
49-
/// Count each halo2 action as a batch item.
50-
/// We could increase the batch item count by the action count each time a batch request
51-
/// is received, which would reduce batch size, but keep the batch queue size larger.
52-
const HALO2_MAX_BATCH_SIZE: usize = 2;
53-
54-
/* TODO: implement batch verification
55-
56-
/// The type of the batch verifier.
57-
type BatchVerifier = plonk::BatchVerifier<vesta::Affine>;
58-
*/
37+
/// To compensate for larger proofs, we process the batch once there are over
38+
/// [`HALO2_MAX_BATCH_SIZE`] total actions among pending items in the queue.
39+
const HALO2_MAX_BATCH_SIZE: usize = super::MAX_BATCH_SIZE;
5940

6041
/// The type of verification results.
6142
type VerifyResult = bool;
6243

6344
/// The type of the batch sender channel.
6445
type Sender = watch::Sender<Option<VerifyResult>>;
6546

66-
/* TODO: implement batch verification
67-
68-
/// The type of a raw verifying key.
69-
/// This is the key used to verify batches.
70-
pub type BatchVerifyingKey = VerifyingKey<vesta::Affine>;
71-
*/
7247
/// Temporary substitute type for fake batch verification.
7348
///
7449
/// TODO: implement batch verification
@@ -83,13 +58,6 @@ lazy_static::lazy_static! {
8358
pub static ref VERIFYING_KEY: ItemVerifyingKey = ItemVerifyingKey::build();
8459
}
8560

86-
// === TEMPORARY BATCH HALO2 SUBSTITUTE ===
87-
//
88-
// These types are meant to be API compatible with the batch verification APIs
89-
// in bellman::groth16::batch, reddsa::batch, redjubjub::batch, and
90-
// ed25519-zebra::batch. Once Halo2 batch proof verification math and
91-
// implementation is available, this code can be replaced with that.
92-
9361
/// A Halo2 verification item, used as the request type of the service.
9462
#[derive(Clone, Debug)]
9563
pub struct Item {

0 commit comments

Comments
 (0)