Skip to content

Commit cfa4a06

Browse files
authored
perf: add rayon to verify signatures process (#255)
Signed-off-by: Gustavo Inacio <[email protected]>
1 parent 3c56018 commit cfa4a06

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

tap_aggregator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ tower = { version = "0.4", features = ["util", "steer"] }
3939
tonic = { version = "0.12.3", features = ["transport", "zstd"] }
4040
prost = "0.13.3"
4141
hyper = { version = "1", features = ["full"] }
42+
rayon = "1.10.0"
4243

4344
[build-dependencies]
4445
tonic-build = "0.12.3"
4546

46-
4747
[dev-dependencies]
4848
jsonrpsee = { workspace = true, features = ["http-client", "jsonrpsee-core"] }
4949
rand.workspace = true

tap_aggregator/src/aggregator.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use alloy::{
88
sol_types::SolStruct,
99
};
1010
use anyhow::{bail, Ok, Result};
11-
11+
use rayon::prelude::*;
1212
use tap_core::{
1313
rav::ReceiptAggregateVoucher,
1414
receipt::Receipt,
@@ -25,18 +25,14 @@ pub fn check_and_aggregate_receipts(
2525
check_signatures_unique(receipts)?;
2626

2727
// Check that the receipts are signed by an accepted signer address
28-
receipts.iter().try_for_each(|receipt| {
29-
check_signature_is_from_one_of_addresses(
30-
receipt.clone(),
31-
domain_separator,
32-
accepted_addresses,
33-
)
28+
receipts.par_iter().try_for_each(|receipt| {
29+
check_signature_is_from_one_of_addresses(receipt, domain_separator, accepted_addresses)
3430
})?;
3531

3632
// Check that the previous rav is signed by an accepted signer address
3733
if let Some(previous_rav) = &previous_rav {
3834
check_signature_is_from_one_of_addresses(
39-
previous_rav.clone(),
35+
previous_rav,
4036
domain_separator,
4137
accepted_addresses,
4238
)?;
@@ -74,7 +70,7 @@ pub fn check_and_aggregate_receipts(
7470
}
7571

7672
fn check_signature_is_from_one_of_addresses<M: SolStruct>(
77-
message: EIP712SignedMessage<M>,
73+
message: &EIP712SignedMessage<M>,
7874
domain_separator: &Eip712Domain,
7975
accepted_addresses: &HashSet<Address>,
8076
) -> Result<()> {

0 commit comments

Comments
 (0)