1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
use crate::config::SafetyRulesConfig;
use diem_types::{account_address::AccountAddress, block_info::Round};
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, path::PathBuf};
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(default, deny_unknown_fields)]
pub struct ConsensusConfig {
pub contiguous_rounds: u32,
pub max_block_size: u64,
pub max_pruned_blocks_in_mem: usize,
pub mempool_executed_txn_timeout_ms: u64,
pub mempool_txn_pull_timeout_ms: u64,
pub round_initial_timeout_ms: u64,
pub proposer_type: ConsensusProposerType,
pub safety_rules: SafetyRulesConfig,
pub sync_only: bool,
pub mempool_poll_count: u64,
pub decoupled_execution: bool,
pub channel_size: usize,
pub back_pressure_limit: u64,
}
impl Default for ConsensusConfig {
fn default() -> ConsensusConfig {
ConsensusConfig {
contiguous_rounds: 2,
max_block_size: 1000,
max_pruned_blocks_in_mem: 100,
mempool_txn_pull_timeout_ms: 1000,
mempool_executed_txn_timeout_ms: 1000,
round_initial_timeout_ms: 1000,
proposer_type: ConsensusProposerType::LeaderReputation(LeaderReputationConfig {
active_weights: 99,
inactive_weights: 1,
}),
safety_rules: SafetyRulesConfig::default(),
sync_only: false,
mempool_poll_count: 1,
decoupled_execution: false, channel_size: 30, back_pressure_limit: 1,
}
}
}
impl ConsensusConfig {
pub fn set_data_dir(&mut self, data_dir: PathBuf) {
self.safety_rules.set_data_dir(data_dir);
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "snake_case", tag = "type")]
pub enum ConsensusProposerType {
FixedProposer,
RotatingProposer,
LeaderReputation(LeaderReputationConfig),
RoundProposer(HashMap<Round, AccountAddress>),
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct LeaderReputationConfig {
pub active_weights: u64,
pub inactive_weights: u64,
}