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/// # Warning
13///
14/// Any height the marshal is asked to sync must be covered by both the
15/// [epocher](Self::epocher) and the [provider](Self::provider). If the epocher
16/// cannot map a height to an epoch, or the provider cannot supply a scheme for
17/// that epoch, the marshal will silently drop the sync request. Callers are
18/// responsible for ensuring both are configured for the full range of heights
19/// they intend to sync.
20pub struct Config<B, P, ES, T>
21where
22 B: Block,
23 P: Provider<Scope = Epoch>,
24 ES: Epocher,
25 T: Strategy,
26{
27 /// Provider for epoch-specific signing schemes.
28 ///
29 /// Must cover every epoch that contains heights the marshal will sync.
30 pub provider: P,
31
32 /// Configuration for epoch lengths across block height ranges.
33 ///
34 /// Must cover every height the marshal will sync.
35 pub epocher: ES,
36
37 /// The prefix to use for all partitions.
38 pub partition_prefix: String,
39
40 /// Size of backfill request/response mailbox.
41 pub mailbox_size: usize,
42
43 /// Minimum number of views to retain temporary data after the application processes a block.
44 ///
45 /// Useful for keeping around information that peers may desire to have.
46 pub view_retention_timeout: ViewDelta,
47
48 /// Prunable archive partition prefix.
49 pub prunable_items_per_section: NonZeroU64,
50
51 /// The page cache to use for the freezer journal.
52 pub page_cache: CacheRef,
53
54 /// The size of the replay buffer for storage archives.
55 pub replay_buffer: NonZeroUsize,
56
57 /// The size of the write buffer for the key journal of storage archives.
58 pub key_write_buffer: NonZeroUsize,
59
60 /// The size of the write buffer for the value journal of storage archives.
61 pub value_write_buffer: NonZeroUsize,
62
63 /// Codec configuration for block type.
64 pub block_codec_config: B::Cfg,
65
66 /// Maximum number of blocks to repair at once.
67 pub max_repair: NonZeroUsize,
68
69 /// Maximum number of blocks dispatched to the application that have not
70 /// yet been acknowledged. Increasing this value allows the application
71 /// to buffer work while marshal continues dispatching, hiding ack latency.
72 pub max_pending_acks: NonZeroUsize,
73
74 /// Strategy for parallel operations.
75 pub strategy: T,
76}