1#![forbid(unsafe_code)]
9
10mod configurable_validator_signer;
11mod consensus_state;
12mod error;
13mod logging;
14mod persistent_safety_storage;
15mod safety_rules;
16
17pub use crate::{
18 consensus_state::ConsensusState, error::Error,
19 persistent_safety_storage::PersistentSafetyStorage,
20 safety_rules::SafetyRules,
21};
22
23pub fn create_safety_rules(
29 config: &diem_config::config::SafetyRulesConfig,
30 author: diem_types::PeerId,
31 consensus_private_key: diem_types::validator_config::ConsensusPrivateKey,
32 vrf_private_key: Option<
33 diem_types::validator_config::ConsensusVRFPrivateKey,
34 >,
35 export_consensus_key: bool,
36) -> SafetyRules {
37 use diem_secure_storage::{KVStorage, OnDiskStorage};
38
39 let internal_storage: OnDiskStorage = (&config.backend).into();
40 if let Err(error) = internal_storage.available() {
41 panic!("Storage is not available: {:?}", error);
42 }
43
44 let persistent_storage = PersistentSafetyStorage::initialize(
45 internal_storage,
46 author,
47 consensus_private_key,
48 config.enable_cached_safety_data,
49 );
50
51 SafetyRules::new(
52 persistent_storage,
53 export_consensus_key,
54 vrf_private_key,
55 author,
56 )
57}
58
59#[cfg(any(test, feature = "fuzzing"))]
60pub mod fuzzing_utils;
61
62#[cfg(any(test, feature = "fuzzing"))]
63pub use crate::fuzzing_utils::fuzzing;
64
65#[cfg(any(test, feature = "testing"))]
66pub mod test_utils;
67
68#[cfg(test)]
69mod tests;