Skip to content

Commit 4a2ff61

Browse files
committed
fix(mempool): Really verify tx snarks in another thread
1 parent b08c599 commit 4a2ff61

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

node/common/src/service/snarks.rs

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -155,31 +155,33 @@ impl node::service::SnarkUserCommandVerifyService for NodeService {
155155
}
156156

157157
let tx = self.event_sender().clone();
158-
let result = {
159-
let (verified, invalid): (Vec<_>, Vec<_>) = ledger::verifier::Verifier
160-
.verify_commands(commands, None)
161-
.into_iter()
162-
.partition(Result::is_ok);
163-
164-
let verified: Vec<_> = verified.into_iter().map(Result::unwrap).collect();
165-
let invalid: Vec<_> = invalid.into_iter().map(Result::unwrap_err).collect();
166-
167-
if !invalid.is_empty() {
168-
let transaction_pool_errors = invalid
158+
rayon::spawn_fifo(move || {
159+
let result = {
160+
let (verified, invalid): (Vec<_>, Vec<_>) = ledger::verifier::Verifier
161+
.verify_commands(commands, None)
169162
.into_iter()
170-
.map(TransactionError::Verifier)
171-
.collect();
172-
Err(TransactionPoolErrors::BatchedErrors(
173-
transaction_pool_errors,
174-
))
175-
} else {
176-
Ok(verified)
177-
}
178-
};
163+
.partition(Result::is_ok);
164+
165+
let verified: Vec<_> = verified.into_iter().map(Result::unwrap).collect();
166+
let invalid: Vec<_> = invalid.into_iter().map(Result::unwrap_err).collect();
167+
168+
if !invalid.is_empty() {
169+
let transaction_pool_errors = invalid
170+
.into_iter()
171+
.map(TransactionError::Verifier)
172+
.collect();
173+
Err(TransactionPoolErrors::BatchedErrors(
174+
transaction_pool_errors,
175+
))
176+
} else {
177+
Ok(verified)
178+
}
179+
};
179180

180-
let result = result.map_err(|err| err.to_string());
181+
let result = result.map_err(|err| err.to_string());
181182

182-
let _ = tx.send(SnarkEvent::UserCommandVerify(req_id, result).into());
183+
let _ = tx.send(SnarkEvent::UserCommandVerify(req_id, result).into());
184+
});
183185
}
184186
}
185187

0 commit comments

Comments
 (0)