fuel_poa_coordinator/config.rs
1use fuel_core_interfaces::{
2 common::{
3 prelude::Word,
4 secrecy::Secret,
5 },
6 model::SecretKeyWrapper,
7};
8use serde::{
9 Deserialize,
10 Serialize,
11};
12use tokio::time::Duration;
13
14#[derive(Default, Debug, Clone)]
15pub struct Config {
16 pub trigger: Trigger,
17 pub block_gas_limit: Word,
18 pub signing_key: Option<Secret<SecretKeyWrapper>>,
19 pub metrics: bool,
20}
21
22/// Block production trigger for PoA operation
23#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
24#[serde(rename_all = "kebab-case")]
25#[serde(tag = "trigger")]
26pub enum Trigger {
27 /// A new block is produced instantly when transactions are available.
28 /// This is useful for some test cases.
29 #[default]
30 Instant,
31 /// This node doesn't produce new blocks. Used for passive listener nodes.
32 Never,
33 /// A new block is produced periodically. Used to simulate consensus block delay.
34 Interval {
35 #[serde(with = "humantime_serde")]
36 block_time: Duration,
37 },
38 /// A new block will be produced when the timer runs out.
39 /// Set to `max_block_time` when the txpool is empty, otherwise
40 /// `min(max_block_time, max_tx_idle_time)`. If it expires,
41 /// but minimum block time hasn't expired yet, then the deadline
42 /// is set to `last_block_created + min_block_time`.
43 /// See https://github.com/FuelLabs/fuel-core/issues/50#issuecomment-1241895887
44 /// Requires `min_block_time` <= `max_tx_idle_time` <= `max_block_time`.
45 Hybrid {
46 /// Minimum time between two blocks, even if there are more txs available
47 #[serde(with = "humantime_serde")]
48 min_block_time: Duration,
49 /// If there are txs available, but not enough for a full block,
50 /// this is how long the block is waiting for more txs
51 #[serde(with = "humantime_serde")]
52 max_tx_idle_time: Duration,
53 /// Time after which a new block is produced, even if it's empty
54 #[serde(with = "humantime_serde")]
55 max_block_time: Duration,
56 },
57}