mina_node/snark/mod.rs
1//! SNARK verification integration for the node.
2//!
3//! This module integrates the SNARK verification state machine with the node's
4//! Redux store, enabling verification of:
5//!
6//! - **Block proofs**: Consensus-layer proofs validating block production
7//! - **Transaction proofs**: Ledger proofs for transaction validity (SNARK work)
8//! - **User commands**: Signatures and zkApp proofs for user transactions
9//!
10//! ## Architecture
11//!
12//! The module re-exports [`mina_snark`] and provides the
13//! [`redux::SubStore`] implementation that connects the SNARK state machine
14//! to the node's global state.
15//!
16//! Verification runs in dedicated threads to avoid blocking the main Redux
17//! loop:
18//!
19//! - Block verification: Single dedicated thread (`block_proof_verifier`)
20//! - Work/command verification: Rayon thread pool with FIFO scheduling
21//!
22//! For the underlying verification implementation, see [`mina_snark`] and
23//! [`ledger::proofs::verification`].
24
25pub use ::mina_snark::*;
26
27pub mod block_verify;
28pub mod user_command_verify;
29pub mod work_verify;
30
31mod snark_effects;
32pub use snark_effects::*;
33
34impl<S> redux::SubStore<crate::State, SnarkState> for crate::Store<S>
35where
36 S: redux::Service,
37{
38 type SubAction = SnarkAction;
39 type Service = S;
40
41 fn state(&self) -> &SnarkState {
42 &self.state.get().snark
43 }
44
45 fn service(&mut self) -> &mut Self::Service {
46 &mut self.service
47 }
48
49 fn state_and_service(&mut self) -> (&SnarkState, &mut Self::Service) {
50 (&self.state.get().snark, &mut self.service)
51 }
52
53 fn dispatch<A>(&mut self, action: A) -> bool
54 where
55 A: Into<SnarkAction> + redux::EnablingCondition<SnarkState>,
56 {
57 crate::Store::sub_dispatch(self, action)
58 }
59
60 fn dispatch_callback<T>(&mut self, callback: redux::Callback<T>, args: T) -> bool
61 where
62 T: 'static,
63 SnarkAction: From<redux::AnyAction> + redux::EnablingCondition<SnarkState>,
64 {
65 crate::Store::dispatch_callback(self, callback, args)
66 }
67}