Skip to main content

commonware_consensus/marshal/
config.rs

1use crate::{
2    types::{Epoch, Epocher, ViewDelta},
3    Block,
4};
5use commonware_cryptography::certificate::Provider;
6use commonware_parallel::Strategy;
7use commonware_runtime::buffer::paged::CacheRef;
8use std::num::{NonZeroU64, NonZeroUsize};
9
10/// Marshal configuration.
11///
12/// # Epocher and Provider Coverage
13///
14/// Any height marshal is asked to sync must be covered by both the
15/// [epocher](Self::epocher) and the [provider](Self::provider). If
16/// either returns `None` for a requested height, resolved requests will
17/// be acknowledged and then dropped. If no longer needed (say a duplicate request
18/// for a height we've long since processed), this drop is harmless. However, failing
19/// to provide either the epocher or the provider for a height we still require to
20/// process the canonical chain will lead marshal to stall (acknowledged requests
21/// may not be retried).
22///
23/// ## Safe Pruning
24///
25/// Applications may prune epocher/provider entries once the last processed
26/// height passes a prune target. The last processed height can be
27/// derived from an `Update::Block` at height `H` as
28/// `H - max_pending_acks` (the maximum backlog of blocks the application can buffer).
29pub struct Config<B, P, ES, T>
30where
31    B: Block,
32    P: Provider<Scope = Epoch>,
33    ES: Epocher,
34    T: Strategy,
35{
36    /// Provider for epoch-specific signing schemes.
37    ///
38    /// Must cover every epoch that contains heights the marshal will sync.
39    pub provider: P,
40
41    /// Configuration for epoch lengths across block height ranges.
42    ///
43    /// Must cover every height the marshal will sync.
44    pub epocher: ES,
45
46    /// The prefix to use for all partitions.
47    pub partition_prefix: String,
48
49    /// Size of backfill request/response mailbox.
50    pub mailbox_size: usize,
51
52    /// Minimum number of views to retain temporary data after the application processes a block.
53    ///
54    /// Useful for keeping around information that peers may desire to have.
55    pub view_retention_timeout: ViewDelta,
56
57    /// Prunable archive partition prefix.
58    pub prunable_items_per_section: NonZeroU64,
59
60    /// The page cache to use for the freezer journal.
61    pub page_cache: CacheRef,
62
63    /// The size of the replay buffer for storage archives.
64    pub replay_buffer: NonZeroUsize,
65
66    /// The size of the write buffer for the key journal of storage archives.
67    pub key_write_buffer: NonZeroUsize,
68
69    /// The size of the write buffer for the value journal of storage archives.
70    pub value_write_buffer: NonZeroUsize,
71
72    /// Codec configuration for block type.
73    pub block_codec_config: B::Cfg,
74
75    /// Maximum number of blocks to repair at once.
76    pub max_repair: NonZeroUsize,
77
78    /// Maximum number of blocks dispatched to the application that have not
79    /// yet been acknowledged. Increasing this value allows the application
80    /// to buffer work while marshal continues dispatching, hiding ack latency.
81    pub max_pending_acks: NonZeroUsize,
82
83    /// Strategy for parallel operations.
84    pub strategy: T,
85}