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
//! Runtime configuration.
use crate::{common::version::Version, consensus::verifier::TrustRoot, types::Features};

/// Global runtime configuration.
#[derive(Clone, Debug, Default)]
pub struct Config {
    /// Semantic runtime version.
    pub version: Version,
    /// Optional trust root for consensus layer integrity verification.
    pub trust_root: Option<TrustRoot>,
    /// Storage configuration.
    pub storage: Storage,
    /// Advertised runtime features.
    pub features: Option<Features>,
    /// Whether storage state should be persisted between transaction check invocations. The state
    /// is invalidated on the next round.
    pub persist_check_tx_state: bool,
    /// Whether TEE freshness is verified with freshness proofs.
    pub freshness_proofs: bool,
}

/// Storage-related configuration.
#[derive(Clone, Debug)]
pub struct Storage {
    /// The maximum number of tree nodes held by the cache before eviction.
    /// A zero value denotes unlimited capacity.
    pub cache_node_capacity: usize,
    /// The total size, in bytes, of values held by the cache before eviction.
    /// A zero value denotes unlimited capacity.
    pub cache_value_capacity: usize,
}

impl Default for Storage {
    fn default() -> Self {
        Self {
            cache_node_capacity: 100_000,
            cache_value_capacity: 32 * 1024 * 1024, // 32 MiB
        }
    }
}