mirror of
https://github.com/Cuprate/cuprate.git
synced 2024-12-22 19:49:28 +00:00
fix config
This commit is contained in:
parent
5c10d35581
commit
17a8065286
14 changed files with 37 additions and 32 deletions
|
@ -11,8 +11,10 @@ network = "Mainnet"
|
||||||
|
|
||||||
## Tracing config.
|
## Tracing config.
|
||||||
[tracing]
|
[tracing]
|
||||||
## The minimum level for log events to be displayed.
|
## The stdout loggig config.
|
||||||
level = "info"
|
stdout = { level = "info" }
|
||||||
|
## The file output logging config.
|
||||||
|
file = { level = "debug", max_log_files = 7 }
|
||||||
|
|
||||||
## Clear-net config.
|
## Clear-net config.
|
||||||
[p2p.clear_net]
|
[p2p.clear_net]
|
||||||
|
@ -49,11 +51,6 @@ target_batch_bytes= 5_000_000
|
||||||
## The amount of time between checking the pool of connected peers for free peers to download blocks.
|
## The amount of time between checking the pool of connected peers for free peers to download blocks.
|
||||||
check_client_pool_interval = { secs = 30, nanos = 0 }
|
check_client_pool_interval = { secs = 30, nanos = 0 }
|
||||||
|
|
||||||
## Storage config
|
|
||||||
[storage]
|
|
||||||
## The amount of reader threads to spawn.
|
|
||||||
reader_threads = "Percent(0.25)"
|
|
||||||
|
|
||||||
## Txpool storage config.
|
## Txpool storage config.
|
||||||
[storage.txpool]
|
[storage.txpool]
|
||||||
## The database sync mode for the txpool.
|
## The database sync mode for the txpool.
|
||||||
|
|
|
@ -69,7 +69,7 @@ pub fn read_config_and_args() -> Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The config for all of Cuprate.
|
/// The config for all of Cuprate.
|
||||||
#[derive(Default, Deserialize, Serialize)]
|
#[derive(Debug, Default, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(deny_unknown_fields, default)]
|
#[serde(deny_unknown_fields, default)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
/// The network we should run on.
|
/// The network we should run on.
|
||||||
|
|
|
@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use cuprate_helper::fs::{CUPRATE_CACHE_DIR, CUPRATE_DATA_DIR};
|
use cuprate_helper::fs::{CUPRATE_CACHE_DIR, CUPRATE_DATA_DIR};
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(deny_unknown_fields, default)]
|
#[serde(deny_unknown_fields, default)]
|
||||||
pub struct FileSystemConfig {
|
pub struct FileSystemConfig {
|
||||||
pub data_directory: PathBuf,
|
pub data_directory: PathBuf,
|
||||||
|
|
|
@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use cuprate_helper::{fs::address_book_path, network::Network};
|
use cuprate_helper::{fs::address_book_path, network::Network};
|
||||||
|
|
||||||
/// P2P config.
|
/// P2P config.
|
||||||
#[derive(Default, Deserialize, Serialize)]
|
#[derive(Debug, Default, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(deny_unknown_fields, default)]
|
#[serde(deny_unknown_fields, default)]
|
||||||
pub struct P2PConfig {
|
pub struct P2PConfig {
|
||||||
/// Clear-net config.
|
/// Clear-net config.
|
||||||
|
@ -18,7 +18,7 @@ pub struct P2PConfig {
|
||||||
pub block_downloader: BlockDownloaderConfig,
|
pub block_downloader: BlockDownloaderConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize, Eq, PartialEq)]
|
||||||
#[serde(deny_unknown_fields, default)]
|
#[serde(deny_unknown_fields, default)]
|
||||||
pub struct BlockDownloaderConfig {
|
pub struct BlockDownloaderConfig {
|
||||||
/// The size in bytes of the buffer between the block downloader and the place which
|
/// The size in bytes of the buffer between the block downloader and the place which
|
||||||
|
@ -56,7 +56,7 @@ impl Default for BlockDownloaderConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The config values for P2P clear-net.
|
/// The config values for P2P clear-net.
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Debug,Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(deny_unknown_fields, default)]
|
#[serde(deny_unknown_fields, default)]
|
||||||
pub struct ClearNetConfig {
|
pub struct ClearNetConfig {
|
||||||
/// The server config.
|
/// The server config.
|
||||||
|
@ -75,7 +75,7 @@ impl Default for ClearNetConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Network config values shared between all network zones.
|
/// Network config values shared between all network zones.
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(deny_unknown_fields, default)]
|
#[serde(deny_unknown_fields, default)]
|
||||||
pub struct SharedNetConfig {
|
pub struct SharedNetConfig {
|
||||||
/// The number of outbound connections to make and try keep.
|
/// The number of outbound connections to make and try keep.
|
||||||
|
@ -111,7 +111,7 @@ impl SharedNetConfig {
|
||||||
impl Default for SharedNetConfig {
|
impl Default for SharedNetConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
outbound_connections: 64,
|
outbound_connections: 32,
|
||||||
extra_outbound_connections: 8,
|
extra_outbound_connections: 8,
|
||||||
max_inbound_connections: 128,
|
max_inbound_connections: 128,
|
||||||
gray_peers_percent: 0.7,
|
gray_peers_percent: 0.7,
|
||||||
|
@ -121,7 +121,7 @@ impl Default for SharedNetConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize, Eq, PartialEq)]
|
||||||
#[serde(deny_unknown_fields, default)]
|
#[serde(deny_unknown_fields, default)]
|
||||||
pub struct AddressBookConfig {
|
pub struct AddressBookConfig {
|
||||||
max_white_list_length: usize,
|
max_white_list_length: usize,
|
||||||
|
@ -134,7 +134,7 @@ impl Default for AddressBookConfig {
|
||||||
Self {
|
Self {
|
||||||
max_white_list_length: 1_000,
|
max_white_list_length: 1_000,
|
||||||
max_gray_list_length: 5_000,
|
max_gray_list_length: 5_000,
|
||||||
peer_save_period: Duration::from_secs(30),
|
peer_save_period: Duration::from_secs(90),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize, Eq, PartialEq)]
|
||||||
#[serde(deny_unknown_fields, default)]
|
#[serde(deny_unknown_fields, default)]
|
||||||
pub struct RayonConfig {
|
pub struct RayonConfig {
|
||||||
pub threads: usize,
|
pub threads: usize,
|
||||||
|
|
|
@ -7,11 +7,11 @@ use cuprate_database_service::ReaderThreads;
|
||||||
use cuprate_helper::fs::CUPRATE_DATA_DIR;
|
use cuprate_helper::fs::CUPRATE_DATA_DIR;
|
||||||
|
|
||||||
/// The storage config.
|
/// The storage config.
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(deny_unknown_fields, default)]
|
#[serde(deny_unknown_fields, default)]
|
||||||
pub struct StorageConfig {
|
pub struct StorageConfig {
|
||||||
/// The amount of reader threads to spawn between the tx-pool and blockchain.
|
/// The amount of reader threads to spawn between the tx-pool and blockchain.
|
||||||
pub reader_threads: ReaderThreads,
|
pub reader_threads: usize,
|
||||||
/// The tx-pool config.
|
/// The tx-pool config.
|
||||||
pub txpool: TxpoolConfig,
|
pub txpool: TxpoolConfig,
|
||||||
/// The blockchain config.
|
/// The blockchain config.
|
||||||
|
@ -21,7 +21,7 @@ pub struct StorageConfig {
|
||||||
impl Default for StorageConfig {
|
impl Default for StorageConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
reader_threads: ReaderThreads::Percent(0.25),
|
reader_threads: std::thread::available_parallelism().unwrap().get().div_ceil(4),
|
||||||
txpool: Default::default(),
|
txpool: Default::default(),
|
||||||
blockchain: Default::default(),
|
blockchain: Default::default(),
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ impl Default for StorageConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The blockchain config.
|
/// The blockchain config.
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(deny_unknown_fields, default)]
|
#[serde(deny_unknown_fields, default)]
|
||||||
pub struct BlockchainConfig {
|
pub struct BlockchainConfig {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
|
@ -47,7 +47,7 @@ impl Default for BlockchainConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The tx-pool config.
|
/// The tx-pool config.
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(deny_unknown_fields, default)]
|
#[serde(deny_unknown_fields, default)]
|
||||||
pub struct TxpoolConfig {
|
pub struct TxpoolConfig {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
|
@ -69,7 +69,7 @@ impl Default for TxpoolConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Config values shared between the tx-pool and blockchain.
|
/// Config values shared between the tx-pool and blockchain.
|
||||||
#[derive(Default, Deserialize, Serialize)]
|
#[derive(Debug, Default, Deserialize, Serialize, PartialEq)]
|
||||||
#[serde(deny_unknown_fields, default)]
|
#[serde(deny_unknown_fields, default)]
|
||||||
pub struct SharedStorageConfig {
|
pub struct SharedStorageConfig {
|
||||||
/// The [`SyncMode`] of the database.
|
/// The [`SyncMode`] of the database.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// [`tokio`] config.
|
/// [`tokio`] config.
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize, Eq, PartialEq)]
|
||||||
#[serde(deny_unknown_fields, default)]
|
#[serde(deny_unknown_fields, default)]
|
||||||
pub struct TokioConfig {
|
pub struct TokioConfig {
|
||||||
/// The amount of threads to spawn for the async thread-pool
|
/// The amount of threads to spawn for the async thread-pool
|
||||||
|
|
|
@ -2,14 +2,14 @@ use serde::{Deserialize, Serialize};
|
||||||
use tracing::level_filters::LevelFilter;
|
use tracing::level_filters::LevelFilter;
|
||||||
|
|
||||||
/// [`tracing`] config.
|
/// [`tracing`] config.
|
||||||
#[derive(Default, Deserialize, Serialize)]
|
#[derive(Debug, Default, Deserialize, Serialize, Eq, PartialEq)]
|
||||||
#[serde(deny_unknown_fields, default)]
|
#[serde(deny_unknown_fields, default)]
|
||||||
pub struct TracingConfig {
|
pub struct TracingConfig {
|
||||||
pub stdout: StdoutTracingConfig,
|
pub stdout: StdoutTracingConfig,
|
||||||
pub file: FileTracingConfig,
|
pub file: FileTracingConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize, Eq, PartialEq)]
|
||||||
#[serde(deny_unknown_fields, default)]
|
#[serde(deny_unknown_fields, default)]
|
||||||
pub struct StdoutTracingConfig {
|
pub struct StdoutTracingConfig {
|
||||||
/// The default minimum log level.
|
/// The default minimum log level.
|
||||||
|
@ -25,7 +25,7 @@ impl Default for StdoutTracingConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize, Eq, PartialEq)]
|
||||||
#[serde(deny_unknown_fields, default)]
|
#[serde(deny_unknown_fields, default)]
|
||||||
pub struct FileTracingConfig {
|
pub struct FileTracingConfig {
|
||||||
/// The default minimum log level.
|
/// The default minimum log level.
|
||||||
|
|
|
@ -42,5 +42,7 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn generate_config_text_is_valid() {
|
fn generate_config_text_is_valid() {
|
||||||
let config: Config = toml::from_str(EXAMPLE_CONFIG).unwrap();
|
let config: Config = toml::from_str(EXAMPLE_CONFIG).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(config, Config::default());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,7 +238,7 @@ async fn get_chain(
|
||||||
split_u128_into_low_high_bits(cumulative_difficulty);
|
split_u128_into_low_high_bits(cumulative_difficulty);
|
||||||
|
|
||||||
Ok(ProtocolResponse::GetChain(ChainResponse {
|
Ok(ProtocolResponse::GetChain(ChainResponse {
|
||||||
start_height: usize_to_u64(std::num::NonZero::get(start_height)),
|
start_height: usize_to_u64(start_height),
|
||||||
total_height: usize_to_u64(chain_height),
|
total_height: usize_to_u64(chain_height),
|
||||||
cumulative_difficulty_low64,
|
cumulative_difficulty_low64,
|
||||||
cumulative_difficulty_top64,
|
cumulative_difficulty_top64,
|
||||||
|
|
|
@ -302,9 +302,12 @@ impl<Z: BorshNetworkZone> AddressBook<Z> {
|
||||||
if peb.pruning_seed != peer.pruning_seed {
|
if peb.pruning_seed != peer.pruning_seed {
|
||||||
return Err(AddressBookError::PeersDataChanged("Pruning seed"));
|
return Err(AddressBookError::PeersDataChanged("Pruning seed"));
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if Z::CHECK_NODE_ID && peb.id != peer.id {
|
if Z::CHECK_NODE_ID && peb.id != peer.id {
|
||||||
return Err(AddressBookError::PeersDataChanged("peer ID"));
|
return Err(AddressBookError::PeersDataChanged("peer ID"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
// TODO: cuprate doesn't need last seen timestamps but should we have them anyway?
|
// TODO: cuprate doesn't need last seen timestamps but should we have them anyway?
|
||||||
peb.last_seen = 0;
|
peb.last_seen = 0;
|
||||||
peb.rpc_port = peer.rpc_port;
|
peb.rpc_port = peer.rpc_port;
|
||||||
|
|
|
@ -115,8 +115,11 @@ where
|
||||||
tokio::spawn(
|
tokio::spawn(
|
||||||
async move {
|
async move {
|
||||||
let client = timeout(HANDSHAKE_TIMEOUT, fut).await;
|
let client = timeout(HANDSHAKE_TIMEOUT, fut).await;
|
||||||
if let Ok(Ok(peer)) = client {
|
|
||||||
drop(new_connection_tx.send(peer).await);
|
match client {
|
||||||
|
Ok(Ok(peer)) => drop(new_connection_tx.send(peer).await),
|
||||||
|
Err(_) => tracing::debug!("Timed out"),
|
||||||
|
Ok(Err(e)) => tracing::debug!("error: {e:?}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.instrument(Span::current()),
|
.instrument(Span::current()),
|
||||||
|
|
|
@ -631,7 +631,7 @@ fn next_chain_entry(
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(BlockchainResponse::NextChainEntry {
|
Ok(BlockchainResponse::NextChainEntry {
|
||||||
start_height: std::num::NonZero::new(first_known_height),
|
start_height: Some(first_known_height),
|
||||||
chain_height,
|
chain_height,
|
||||||
block_ids,
|
block_ids,
|
||||||
block_weights,
|
block_weights,
|
||||||
|
|
|
@ -288,7 +288,7 @@ pub enum BlockchainResponse {
|
||||||
/// If all blocks were unknown `start_height` will be [`None`], the other fields will be meaningless.
|
/// If all blocks were unknown `start_height` will be [`None`], the other fields will be meaningless.
|
||||||
NextChainEntry {
|
NextChainEntry {
|
||||||
/// The start height of this entry, [`None`] if we could not find the split point.
|
/// The start height of this entry, [`None`] if we could not find the split point.
|
||||||
start_height: Option<std::num::NonZero<usize>>,
|
start_height: Option<usize>,
|
||||||
/// The current chain height.
|
/// The current chain height.
|
||||||
chain_height: usize,
|
chain_height: usize,
|
||||||
/// The next block hashes in the entry.
|
/// The next block hashes in the entry.
|
||||||
|
|
Loading…
Reference in a new issue