spacejam_service/params/
mod.rs

1//! Chain parameters
2
3use serde::{Deserialize, Serialize};
4#[cfg(feature = "std")]
5pub use std_impl::*;
6
7mod tiny;
8
9/// Parameters for version 1
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct Parameters {
12    /// (B_I) The additional deposit required for storage item in an account.
13    pub deposit_per_item: u64,
14    /// (B_L)The additional deposit required for each byte of each storage item in an account and preimage of an account.
15    pub deposit_per_byte: u64,
16    /// (B_S) The base deposit required to retain an account.
17    pub deposit_per_account: u64,
18    /// (C = V/3) The number of validators per core is always 3
19    pub validators_per_core: u16,
20    /// (D) Minimum period in blocks between going from becoming Available to Zombie, and then again from Zombie to non-existent.
21    pub min_turnaround_period: u32,
22    /// (E) The epoch period, defined in number of slots.
23    pub epoch_period: u32,
24    /// (G_A) Maximum gas which may be used to accumulate a single work-report.
25    pub max_accumulate_gas: u64,
26    /// (G_I) Maximum gas which may be used to authorize a single work-package.
27    pub max_is_authorized_gas: u64,
28    /// (G_R) Maximum gas which may be used to refine a single work-report.
29    pub max_refine_gas: u64,
30    /// (G_T) Maximum gas which can be processed in a single block.
31    pub block_gas_limit: u64,
32    /// (H) The number of blocks which are kept in the recent block cache.
33    pub recent_block_count: u16,
34    /// (I) Maximum number of Work Items in a Work Package.
35    pub max_work_items: u16,
36    /// (J) Maximum number of dependencies (total of prerequisites and SR lookup entries).
37    pub max_dependencies: u16,
38    /// (K) The maximum number of tickets which may be submitted in a single extrinsic.
39    pub max_tickets_per_extrinsic: u16,
40    /// (L) Maximum age, in blocks, that the lookup anchor may be, taken from the regular anchor.
41    pub max_lookup_anchor_age: u32,
42    /// (N) The number of ticket entries per validator
43    pub ticket_entries_per_validator: u16,
44    /// (O) Number of items in the authorization window.
45    pub auth_window: u16,
46    /// (P) the slot period
47    pub slot_period: u16,
48    /// (Q) Number of authorizations in a queue allocated to a core.
49    pub auth_queue_len: u16,
50    /// (R) The rotation period, defined in number of slots.
51    pub rotation_period: u16,
52    /// (T) Maximum number of extrinsics in a Work Package.
53    pub max_extrinsics: u16,
54    /// (U) The period in timeslots after which reported but unavailable work may be replaced.
55    pub availability_timeout: u16,
56    /// (V) Total number of validators.
57    pub val_count: u16,
58    /// (W_A) the max size of is-authorized code
59    pub max_is_authorized_code_size: u32,
60    /// (W_B) Maximum size of a Work Package together with all extrinsic data and imported segments.
61    pub max_input: u32,
62    /// (W_C) The maximum size of Refine/Accumulate code.
63    pub max_refine_code_size: u32,
64    /// (W_E) Number of octets in a erasure-coded piece.
65    pub basic_piece_len: u32,
66    /// (W_M) Maximum number of imports in a Work Package.
67    pub max_imports: u32,
68    /// (W_P) The number of erasure-coded pieces in a segment
69    pub erasure_coded_pieces: u32,
70    /// (W_R) The maximum amount of RAM which may be used by Refine/Accumulate code.
71    pub max_refine_memory: u32,
72    /// (W_T) the size of the transfer memo
73    pub transfer_memo_size: u32,
74    /// (W_X) The maximum number of exports in a work package
75    pub max_exports: u32,
76    /// (Y) The ticket submission period
77    pub ticket_submission_period: u32,
78}
79
80impl Default for Parameters {
81    fn default() -> Self {
82        Self::tiny()
83    }
84}
85
86#[cfg(feature = "std")]
87mod std_impl {
88    use crate::Parameters;
89    use std::sync::{LazyLock, RwLock, RwLockReadGuard};
90
91    /// Parameters for the chain
92    static PARAMS: LazyLock<RwLock<Parameters>> = LazyLock::new(|| RwLock::new(Parameters::tiny()));
93
94    /// Get the parameters
95    pub fn get() -> RwLockReadGuard<'static, Parameters> {
96        PARAMS.read().expect("Failed to read parameters")
97    }
98
99    /// Set new parameters
100    pub fn set(params: Parameters) {
101        *PARAMS.write().expect("Failed to write parameters") = params;
102    }
103}