Skip to content

Commit

Permalink
perf: add rayon to verify signatures process
Browse files Browse the repository at this point in the history
Signed-off-by: Gustavo Inacio <[email protected]>
  • Loading branch information
gusinacio committed Dec 27, 2024
1 parent 3c56018 commit 1a994f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tap_aggregator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ tower = { version = "0.4", features = ["util", "steer"] }
tonic = { version = "0.12.3", features = ["transport", "zstd"] }
prost = "0.13.3"
hyper = { version = "1", features = ["full"] }
rayon = "1.10.0"

[build-dependencies]
tonic-build = "0.12.3"


[dev-dependencies]
jsonrpsee = { workspace = true, features = ["http-client", "jsonrpsee-core"] }
rand.workspace = true
Expand Down
14 changes: 5 additions & 9 deletions tap_aggregator/src/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use alloy::{
sol_types::SolStruct,
};
use anyhow::{bail, Ok, Result};

use rayon::prelude::*;
use tap_core::{
rav::ReceiptAggregateVoucher,
receipt::Receipt,
Expand All @@ -25,18 +25,14 @@ pub fn check_and_aggregate_receipts(
check_signatures_unique(receipts)?;

// Check that the receipts are signed by an accepted signer address
receipts.iter().try_for_each(|receipt| {
check_signature_is_from_one_of_addresses(
receipt.clone(),
domain_separator,
accepted_addresses,
)
receipts.par_iter().try_for_each(|receipt| {
check_signature_is_from_one_of_addresses(receipt, domain_separator, accepted_addresses)
})?;

// Check that the previous rav is signed by an accepted signer address
if let Some(previous_rav) = &previous_rav {
check_signature_is_from_one_of_addresses(
previous_rav.clone(),
previous_rav,
domain_separator,
accepted_addresses,
)?;
Expand Down Expand Up @@ -74,7 +70,7 @@ pub fn check_and_aggregate_receipts(
}

fn check_signature_is_from_one_of_addresses<M: SolStruct>(
message: EIP712SignedMessage<M>,
message: &EIP712SignedMessage<M>,
domain_separator: &Eip712Domain,
accepted_addresses: &HashSet<Address>,
) -> Result<()> {
Expand Down

0 comments on commit 1a994f0

Please sign in to comment.