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
84
85
86
87
88
89
90
91
92
93
94
95
use fuel_chain_config::ChainConfig;
use fuel_core_interfaces::{
common::{
prelude::SecretKey,
secrecy::Secret,
},
model::SecretKeyWrapper,
};
use std::{
net::{
Ipv4Addr,
SocketAddr,
},
path::PathBuf,
};
use strum_macros::{
Display,
EnumString,
EnumVariantNames,
};
#[cfg(feature = "p2p")]
use fuel_p2p::config::{
NotInitialized,
P2PConfig,
};
#[derive(Clone, Debug)]
pub struct Config {
pub addr: SocketAddr,
pub database_path: PathBuf,
pub database_type: DbType,
pub chain_conf: ChainConfig,
pub utxo_validation: bool,
pub manual_blocks_enabled: bool,
pub vm: VMConfig,
pub txpool: fuel_txpool::Config,
pub block_importer: fuel_block_importer::Config,
pub block_producer: fuel_block_producer::Config,
pub block_executor: fuel_block_executor::Config,
pub sync: fuel_sync::Config,
#[cfg(feature = "relayer")]
pub relayer: fuel_relayer::Config,
#[cfg(feature = "p2p")]
pub p2p: P2PConfig<NotInitialized>,
pub consensus_key: Option<Secret<SecretKeyWrapper>>,
}
impl Config {
pub fn local_node() -> Self {
let chain_conf = ChainConfig::local_testnet();
let utxo_validation = false;
let min_gas_price = 0;
Self {
addr: SocketAddr::new(Ipv4Addr::new(127, 0, 0, 1).into(), 0),
database_path: Default::default(),
database_type: DbType::InMemory,
chain_conf: chain_conf.clone(),
manual_blocks_enabled: false,
vm: Default::default(),
utxo_validation,
txpool: fuel_txpool::Config::new(chain_conf, min_gas_price, utxo_validation),
block_importer: Default::default(),
block_producer: Default::default(),
block_executor: Default::default(),
sync: Default::default(),
#[cfg(feature = "relayer")]
relayer: Default::default(),
#[cfg(feature = "p2p")]
p2p: P2PConfig::<NotInitialized>::default("test_network"),
consensus_key: Some(Secret::new(default_consensus_dev_key().into())),
}
}
}
#[derive(Clone, Debug, Default)]
pub struct VMConfig {
pub backtrace: bool,
}
#[derive(Clone, Debug, Display, Eq, PartialEq, EnumString, EnumVariantNames)]
#[strum(serialize_all = "kebab_case")]
pub enum DbType {
InMemory,
RocksDb,
}
pub fn default_consensus_dev_key() -> SecretKey {
const DEV_KEY_PHRASE: &str =
"winner alley monkey elephant sun off boil hope toward boss bronze dish";
SecretKey::new_from_mnemonic_phrase_with_path(DEV_KEY_PHRASE, "m/44'/60'/0'/0/0")
.expect("valid key")
}