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
//! Configuration options for the execution engine.
use serde::{Deserialize, Serialize};
use crate::shared::utils;
const DEFAULT_MAX_GLOBAL_STATE_SIZE: usize = 805_306_368_000; // 750 GiB
/// Contract runtime configuration.
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
// Disallow unknown fields to ensure config files and command-line overrides contain valid keys.
#[serde(deny_unknown_fields)]
pub struct Config {
max_global_state_size: Option<usize>,
}
impl Config {
/// The maximum size of the database to use for the global state store.
///
/// Defaults to 805,306,368,000 == 750 GiB.
///
/// The size should be a multiple of the OS page size.
pub fn max_global_state_size(&self) -> usize {
let value = self
.max_global_state_size
.unwrap_or(DEFAULT_MAX_GLOBAL_STATE_SIZE);
utils::check_multiple_of_page_size(value);
value
}
}
impl Default for Config {
fn default() -> Self {
Config {
max_global_state_size: Some(DEFAULT_MAX_GLOBAL_STATE_SIZE),
}
}
}