1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/// Clients events related logic and type definitions.
pub(crate) mod client_events;
/// Peer node configuration.
pub mod config;
/// Handling of contracts and delegates functionality.
mod contract;
// Re-export for integration tests (tests/ directory needs pub access)
#[cfg(any(test, feature = "testing", feature = "redb"))]
pub use contract::storages;
/// Generated messages from the flatbuffers schema for the network monitor.
pub mod generated;
/// Network messages for transactions.
mod message;
/// Node configuration, implementations and execution (entry points for the binaries).
mod node;
pub use node::{EventLoopExitReason, Node, ShutdownHandle, run_local_node, run_network_node};
/// Network operation/transaction state machines.
mod operations;
/// Ring connections and routing.
mod ring;
/// Router implementation.
mod router;
/// Local server used to communicate with the peer core.
#[cfg(feature = "websocket")]
pub mod server;
/// Local network topology management.
mod topology;
/// Tracing and loging infrastructure. Includes our custom event log register. Tracing collectors, etc.
#[cfg_attr(test, allow(dead_code))]
pub mod tracing;
/// Code for communicating with other peers over UDP, handles hole-punching, error handling, etc.
pub mod transport;
pub mod util;
/// WASM code execution runtime, tailored for the contract and delegate APIs.
mod wasm_runtime;
/// Deterministic simulation testing framework.
pub mod simulation;
/// Exports to build a running local node.
pub mod local_node {
use super::*;
pub use contract::Executor;
pub use contract::OperationMode;
pub use node::NodeConfig;
}
/// Exports for the dev tool.
pub mod dev_tool {
use super::*;
pub use crate::config::{Config, GlobalTestMetrics};
pub use client_events::{
AuthToken, ClientEventsProxy, ClientId, OpenRequest, test::MemoryEventsGen,
test::NetworkEventGenerator,
};
pub use contract::{
Executor, OperationMode, clear_crdt_contracts, is_crdt_contract, register_crdt_contract,
storages::Storage,
};
pub use flatbuffers;
pub use message::Transaction;
pub use node::{
InitPeerNode, NetworkStats, NodeConfig, PeerId,
testing_impl::{
ChurnConfig, ContractDistribution, ControlledEventChain, ControlledSimulationResult,
ConvergedContract, ConvergenceResult, DivergedContract, EventChain, EventSummary,
NetworkPeer, NodeLabel, OperationStats, OperationSummary, PeerMessage, PeerStatus,
PutOperationStats, RunningNode, ScheduledOperation, SimNetwork, SimOperation,
TurmoilConfig, TurmoilResult, UpdateOperationStats, check_convergence_from_logs,
run_turmoil_simulation,
},
};
pub use ring::Location;
pub use transport::{TransportKeypair, TransportPublicKey};
// #1454 Phase 3b — test hook to verify client-initiated GETs
// actually route through the task-per-tx driver rather than being
// satisfied by the `client_events.rs` local-cache shortcut.
#[cfg(any(test, feature = "testing"))]
pub use crate::operations::get::op_ctx_task::DRIVER_CALL_COUNT as GET_DRIVER_CALL_COUNT;
// #1454 Phase 5 / #3883 — test hook to verify the dispatch site in
// `handle_pure_network_message_v1` routes fresh inbound relay
// GETs through the task-per-tx driver. Phase 5 final (GET slice)
// retired the legacy `handle_op_request<GetOp>` fallthrough; every
// GET wire variant now dispatches unconditionally to a task-per-tx
// driver. The originator-loopback case (`source_addr=None`) is
// mapped to `upstream_addr=own_addr` at the dispatch site, so the
// same `start_relay_get` driver handles both true relay hops and
// originator-loopback. UPDATE auto-fetch was migrated to
// `start_targeted_sub_op_get` in the same slice.
#[cfg(any(test, feature = "testing"))]
pub use crate::operations::get::op_ctx_task::RELAY_DRIVER_CALL_COUNT as GET_RELAY_DRIVER_CALL_COUNT;
// #1454 Phase 5 follow-up slice A (#3917) — test hook to verify
// the dispatch gate in `handle_pure_network_message_v1` actually
// routes fresh inbound relay PUTs through the task-per-tx driver
// (vs. the legacy `handle_op_request` fallthrough used for
// client-initiated loopback and GC-spawned retries).
#[cfg(any(test, feature = "testing"))]
pub use crate::operations::put::op_ctx_task::RELAY_PUT_DRIVER_CALL_COUNT;
// #1454 Phase 5 follow-up slice B — test hook for streaming PUT
// relay dispatch. Fires when the streaming driver is spawned for
// a fresh inbound `PutMsg::RequestStreaming` (vs. legacy
// `handle_op_request` fallthrough for GC retries / loopback /
// variants that stay on the legacy path).
#[cfg(any(test, feature = "testing"))]
pub use crate::operations::put::op_ctx_task::RELAY_PUT_STREAMING_DRIVER_CALL_COUNT;
// #1454 Phase 5 follow-up slice A (#3932) — test hook to verify
// the dispatch gate in `handle_pure_network_message_v1` actually
// routes fresh inbound relay SUBSCRIBEs through the task-per-tx
// driver (vs. the legacy `handle_op_request` fallthrough used
// for renewals, PUT sub-op subscribes, executor auto-subscribe,
// and GC-spawned retries).
#[cfg(any(test, feature = "testing"))]
pub use crate::operations::subscribe::op_ctx_task::RELAY_SUBSCRIBE_DRIVER_CALL_COUNT;
// Test hooks for the relay-hop routing-event plumbing. Each counter
// increments every time `operations::record_relay_route_event` fires
// for the corresponding op type. Used by simulation tests to verify
// that relay-forwarded operations actually feed the local Router's
// failure-probability model — without these hooks, the router would
// only see events from originator paths (the bug this work fixes).
#[cfg(any(test, feature = "testing"))]
pub use crate::operations::{
RELAY_GET_ROUTE_EVENT_COUNT, RELAY_PUT_ROUTE_EVENT_COUNT,
RELAY_SUBSCRIBE_ROUTE_EVENT_COUNT, RELAY_UPDATE_ROUTE_EVENT_COUNT,
};
// Re-export state verification for telemetry-based consistency analysis
pub use crate::tracing::state_verifier::{StateAnomaly, StateVerifier, VerificationReport};
// Re-export topology registry for subscription validation in tests
pub use ring::topology_registry::{
ContractSubscription, ProximityViolation, TopologySnapshot, TopologyValidationResult,
clear_all_topology_snapshots, clear_current_network_name, clear_topology_snapshots,
get_all_topology_snapshots, get_current_network_name, get_topology_snapshot,
register_topology_snapshot, set_current_network_name, validate_topology,
validate_topology_from_snapshots,
};
pub use wasm_runtime::{
ContractStore, DelegateStore, MockStateStorage, Runtime, SecretsStore, StateStore,
};
// Re-export simulation types for test infrastructure
pub use crate::simulation::{
FaultConfig, FaultConfigBuilder, Partition, SimulationRng, TimeSource, VirtualTime,
WakeupId,
};
// Re-export fault injector for mid-simulation fault injection in Turmoil tests
pub use crate::node::{FaultInjectorState, get_fault_injector, set_fault_injector};
// Re-export counter reset functions for deterministic simulation testing
pub use crate::client_events::RequestId;
pub use crate::contract::reset_event_id_counter;
pub use crate::node::reset_channel_id_counter;
pub use crate::test_utils::reset_global_node_index;
pub use crate::transport::StreamId;
pub use crate::transport::reset_nonce_counter;
}
/// Deadlock detection for parking_lot locks in test builds.
///
/// Available when compiled with `--cfg test` (unit tests) or with the `testing`
/// feature flag (integration tests). Uses parking_lot's `deadlock_detection`
/// feature to catch Mutex/RwLock deadlocks at runtime.
#[cfg(any(test, feature = "testing"))]
pub mod deadlock_detection;
pub mod test_utils;