replay_dynamic_effects/
lib.rs1use ::node::{ActionWithMeta, Store};
2use openmina_node_invariants::{InvariantIgnoreReason, InvariantResult, Invariants};
3use openmina_node_native::NodeService;
4
5pub mod ret {
6 macro_rules! define {
7 (
8 $(
9 $(#[$docs:meta])*
10 ($num:expr, $konst:ident);
11 )+
12 ) => {
13 $(
14 $(#[$docs])*
15 pub const $konst: u8 = $num;
16 )+
17 }
18 }
19
20 define! {
21 (0, CONTINUE);
24 (1, PAUSE);
26 }
27}
28
29#[no_mangle]
30extern "C" fn replay_dynamic_effects(
31 store: &mut Store<NodeService>,
32 action: &ActionWithMeta,
33) -> u8 {
34 for (invariant, res) in Invariants::check_all(store, action) {
35 match res {
36 InvariantResult::Ignored(InvariantIgnoreReason::GlobalInvariantNotInTestingCluster) => {
37 }
38 InvariantResult::Violation(violation) => {
39 eprintln!(
40 "Invariant({}) violated! violation: {violation}",
41 invariant.to_str()
42 );
43 return ret::PAUSE;
44 }
45 InvariantResult::Updated => {}
46 InvariantResult::Ok => {}
47 }
48 }
49
50 let (action, meta) = (action.action(), action.meta().clone());
51 let state = store.state.get();
52 let _ = (state, meta, action);
53
54 ret::CONTINUE
55}