ab_client_consensus_common/
lib.rs

1#![expect(incomplete_features, reason = "generic_const_exprs")]
2// TODO: This feature is not actually used in this crate, but is added as a workaround for
3//  https://github.com/rust-lang/rust/issues/141492
4#![feature(generic_const_exprs, get_mut_unchecked)]
5
6pub mod consensus_parameters;
7pub mod state;
8
9use ab_core_primitives::block::{BlockNumber, BlockTimestamp};
10use ab_core_primitives::pot::{SlotDuration, SlotNumber};
11use ab_core_primitives::segments::HistorySize;
12
13/// Proof-of-time consensus constants
14#[derive(Debug, PartialEq, Eq, Clone, Copy)]
15pub struct PotConsensusConstants {
16    /// Interval, in blocks, between blockchain entropy injection into the proof of time chain
17    pub entropy_injection_interval: BlockNumber,
18    /// Interval, in entropy injection intervals, where to take entropy for injection from
19    pub entropy_injection_lookback_depth: u8,
20    /// Delay after block, in slots, when entropy injection takes effect
21    pub entropy_injection_delay: SlotNumber,
22}
23
24/// Consensus constants
25#[derive(Debug, PartialEq, Eq, Clone, Copy)]
26pub struct ConsensusConstants {
27    /// Depth `K` after which a block enters the recorded history
28    pub confirmation_depth_k: BlockNumber,
29    /// Number of slots between slot arrival and when the corresponding block can be produced
30    pub block_authoring_delay: SlotNumber,
31    /// Proof-of-time consensus constants
32    pub pot: PotConsensusConstants,
33    /// Era duration in blocks
34    pub era_duration: BlockNumber,
35    /// Slot probability
36    pub slot_probability: (u64, u64),
37    /// The slot duration in milliseconds
38    pub slot_duration: SlotDuration,
39    /// Number of latest archived segments that are considered "recent history"
40    pub recent_segments: HistorySize,
41    /// Fraction of pieces from the "recent history" (`recent_segments`) in each sector
42    pub recent_history_fraction: (HistorySize, HistorySize),
43    /// Minimum lifetime of a plotted sector, measured in archived segments
44    pub min_sector_lifetime: HistorySize,
45    /// Max block timestamp drift allowed
46    pub max_block_timestamp_drift: BlockTimestamp,
47}