Skip to content

Commit

Permalink
syncing working again
Browse files Browse the repository at this point in the history
  • Loading branch information
Boog900 committed Oct 6, 2024
1 parent 49b8463 commit cbdfab3
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 54 deletions.
60 changes: 43 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ futures = { version = "0.3.30", default-features = false }
hex = { version = "0.4.3", default-features = false }
hex-literal = { version = "0.4", default-features = false }
indexmap = { version = "2.5.0", default-features = false }
monero-serai = { git = "https://github.com/Cuprate/serai.git", rev = "d5205ce", default-features = false }
monero-serai = { git = "https://github.com/Cuprate/serai.git", rev = "d7ecab6", default-features = false }
paste = { version = "1.0.15", default-features = false }
pin-project = { version = "1.1.5", default-features = false }
randomx-rs = { git = "https://github.com/Cuprate/randomx-rs.git", rev = "0028464", default-features = false }
Expand All @@ -88,8 +88,8 @@ tracing-subscriber = { version = "0.3.18", default-features = false }
tracing = { version = "0.1.40", default-features = false }

## workspace.dev-dependencies
monero-rpc = { git = "https://github.com/Cuprate/serai.git", rev = "d5205ce" }
monero-simple-request-rpc = { git = "https://github.com/Cuprate/serai.git", rev = "d5205ce" }
monero-rpc = { git = "https://github.com/Cuprate/serai.git", rev = "d7ecab6" }
monero-simple-request-rpc = { git = "https://github.com/Cuprate/serai.git", rev = "d7ecab6" }
tempfile = { version = "3" }
pretty_assertions = { version = "1.4.1" }
proptest = { version = "1" }
Expand Down
2 changes: 1 addition & 1 deletion binaries/cuprated/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ tokio-util = { workspace = true }
tokio-stream = { workspace = true }
tokio = { workspace = true }
tower = { workspace = true }
tracing-subscriber = { workspace = true }
tracing-subscriber = { workspace = true, features = ["ansi", "std", "fmt"] }
tracing = { workspace = true }

[lints]
Expand Down
1 change: 1 addition & 0 deletions binaries/cuprated/src/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ mod manager;
mod syncer;
mod types;

pub use manager::init_blockchain_manager;
use types::{
ConcreteBlockVerifierService, ConcreteTxVerifierService, ConsensusBlockchainReadHandle,
};
Expand Down
29 changes: 21 additions & 8 deletions binaries/cuprated/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
//! cuprated config
use serde::{Deserialize, Serialize};

use cuprate_consensus::ContextConfig;
use cuprate_helper::network::Network;
use cuprate_p2p::block_downloader::BlockDownloaderConfig;
use cuprate_p2p_core::ClearNet;
use serde::{Deserialize, Serialize};
use std::time::Duration;

mod p2p;
mod storage;
Expand All @@ -18,40 +21,50 @@ pub fn config() -> Config {
#[serde(deny_unknown_fields, default)]
pub struct Config {
network: Network,

p2p: P2PConfig,
storage: StorageConfig

storage: StorageConfig,
}

impl Config {
pub fn network(&self) -> Network {
self.network
}

pub fn clearnet_p2p_config(&self) -> cuprate_p2p::P2PConfig<ClearNet> {
cuprate_p2p::P2PConfig {
network: self.network,
outbound_connections: self.p2p.clear_net.general.outbound_connections,
extra_outbound_connections: self.p2p.clear_net.general.extra_outbound_connections,
max_inbound_connections:self.p2p.clear_net.general.max_inbound_connections,
max_inbound_connections: self.p2p.clear_net.general.max_inbound_connections,
gray_peers_percent: self.p2p.clear_net.general.gray_peers_percent,
server_config: Some(self.p2p.clear_net.server.clone()),
p2p_port: self.p2p.clear_net.general.p2p_port,
rpc_port: 0,
address_book_config: self.p2p.clear_net.general.address_book_config.clone(),
}
}

pub fn context_config(&self) -> ContextConfig {
match self.network {
Network::Mainnet => ContextConfig::main_net(),
Network::Stagenet => ContextConfig::stage_net(),
Network::Testnet => ContextConfig::test_net()
Network::Testnet => ContextConfig::test_net(),
}
}

pub fn blockchain_config(&self) -> cuprate_blockchain::config::Config {
self.storage.blockchain.clone()
}

pub fn block_downloader_config(&self) -> BlockDownloaderConfig {
BlockDownloaderConfig {
buffer_size: 50_000_000,
in_progress_queue_size: 50_000_000,
check_client_pool_interval: Duration::from_secs(30),
target_batch_size: 5_000_000,
initial_batch_size: 1,
}
}
}
2 changes: 1 addition & 1 deletion binaries/cuprated/src/config/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct SharedNetConfig {
impl Default for SharedNetConfig {
fn default() -> Self {
Self {
outbound_connections: 32,
outbound_connections: 64,
extra_outbound_connections: 8,
max_inbound_connections: 128,
gray_peers_percent: 0.7,
Expand Down
19 changes: 15 additions & 4 deletions binaries/cuprated/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,33 @@ fn main() {
let async_rt = init_tokio_rt(&config);

async_rt.block_on(async move {
blockchain:: check_add_genesis(&mut bc_read_handle, &mut bc_write_handle, config.network()).await;
blockchain::check_add_genesis(&mut bc_read_handle, &mut bc_write_handle, config.network())
.await;

let (block_verifier, _tx_verifier, context_svc) =
blockchain::init_consensus(bc_read_handle.clone(), config.context_config())
.await
.unwrap();

let net = cuprate_p2p::initialize_network(
p2p::request_handler:: {
p2p::request_handler::P2pProtocolRequestHandlerMaker {
blockchain_read_handle: bc_read_handle.clone(),
},
p2p::core_sync_service::CoreSyncService(context_svc.clone()),
config.clearnet_p2p_config(),
)
.await
.unwrap();
.await
.unwrap();

blockchain::init_blockchain_manager(
net,
bc_write_handle,
bc_read_handle,
context_svc,
block_verifier,
config.block_downloader_config(),
)
.await;

// TODO: this can be removed as long as the main thread does not exit, so when command handling
// is added
Expand Down
2 changes: 1 addition & 1 deletion binaries/cuprated/src/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
//!
//! Will handle initiating the P2P and contains a protocol request handler.

pub mod request_handler;
pub mod core_sync_service;
pub mod request_handler;
2 changes: 1 addition & 1 deletion binaries/cuprated/src/p2p/core_sync_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ impl Service<CoreSyncDataRequest> for CoreSyncService {
))
})
}
}
}
Loading

0 comments on commit cbdfab3

Please sign in to comment.