From b4b73ec61c14aa0b383e63d75c3fa60365e16eed Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 16 Aug 2024 02:23:18 +0100 Subject: [PATCH 01/72] add cuprated skeleton --- Cargo.lock | 4 ++++ Cargo.toml | 1 + binaries/cuprated/Cargo.toml | 13 +++++++++++++ binaries/cuprated/src/blockchain.rs | 6 ++++++ binaries/cuprated/src/blockchain/manager.rs | 0 binaries/cuprated/src/blockchain/syncer.rs | 0 binaries/cuprated/src/config.rs | 1 + binaries/cuprated/src/main.rs | 9 +++++++++ binaries/cuprated/src/p2p.rs | 5 +++++ binaries/cuprated/src/p2p/request_handler.rs | 0 binaries/cuprated/src/rpc.rs | 5 +++++ binaries/cuprated/src/rpc/request_handler.rs | 0 binaries/cuprated/src/txpool.rs | 3 +++ 13 files changed, 47 insertions(+) create mode 100644 binaries/cuprated/Cargo.toml create mode 100644 binaries/cuprated/src/blockchain.rs create mode 100644 binaries/cuprated/src/blockchain/manager.rs create mode 100644 binaries/cuprated/src/blockchain/syncer.rs create mode 100644 binaries/cuprated/src/config.rs create mode 100644 binaries/cuprated/src/main.rs create mode 100644 binaries/cuprated/src/p2p.rs create mode 100644 binaries/cuprated/src/p2p/request_handler.rs create mode 100644 binaries/cuprated/src/rpc.rs create mode 100644 binaries/cuprated/src/rpc/request_handler.rs create mode 100644 binaries/cuprated/src/txpool.rs diff --git a/Cargo.lock b/Cargo.lock index 39458962..052b1ee6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -881,6 +881,10 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cuprated" +version = "0.1.0" + [[package]] name = "curve25519-dalek" version = "4.1.3" diff --git a/Cargo.toml b/Cargo.toml index 71efcca4..06b49a0a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ resolver = "2" members = [ + "binaries/cuprated", "consensus", "consensus/fast-sync", "consensus/rules", diff --git a/binaries/cuprated/Cargo.toml b/binaries/cuprated/Cargo.toml new file mode 100644 index 00000000..b5243906 --- /dev/null +++ b/binaries/cuprated/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "cuprated" +version = "0.1.0" +edition = "2021" +description = "The Cuprate Monero Rust node." +license = "AGPL-3.0-only" +authors = ["Boog900", "hinto-janai", "SyntheticBird45"] +repository = "https://github.com/Cuprate/cuprate/tree/main/binaries/cuprated" + +[dependencies] + +[lints] +workspace = true diff --git a/binaries/cuprated/src/blockchain.rs b/binaries/cuprated/src/blockchain.rs new file mode 100644 index 00000000..4abebeb6 --- /dev/null +++ b/binaries/cuprated/src/blockchain.rs @@ -0,0 +1,6 @@ +//! Blockchain +//! +//! Will contain the chain manager and syncer. + +mod manager; +mod syncer; diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs new file mode 100644 index 00000000..e69de29b diff --git a/binaries/cuprated/src/blockchain/syncer.rs b/binaries/cuprated/src/blockchain/syncer.rs new file mode 100644 index 00000000..e69de29b diff --git a/binaries/cuprated/src/config.rs b/binaries/cuprated/src/config.rs new file mode 100644 index 00000000..d613c1fc --- /dev/null +++ b/binaries/cuprated/src/config.rs @@ -0,0 +1 @@ +//! cuprated config diff --git a/binaries/cuprated/src/main.rs b/binaries/cuprated/src/main.rs new file mode 100644 index 00000000..918429c9 --- /dev/null +++ b/binaries/cuprated/src/main.rs @@ -0,0 +1,9 @@ +mod blockchain; +mod config; +mod p2p; +mod rpc; +mod txpool; + +fn main() { + todo!() +} diff --git a/binaries/cuprated/src/p2p.rs b/binaries/cuprated/src/p2p.rs new file mode 100644 index 00000000..f5b72ba3 --- /dev/null +++ b/binaries/cuprated/src/p2p.rs @@ -0,0 +1,5 @@ +//! P2P +//! +//! Will handle initiating the P2P and contains a protocol request handler. + +mod request_handler; diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs new file mode 100644 index 00000000..e69de29b diff --git a/binaries/cuprated/src/rpc.rs b/binaries/cuprated/src/rpc.rs new file mode 100644 index 00000000..80b2789e --- /dev/null +++ b/binaries/cuprated/src/rpc.rs @@ -0,0 +1,5 @@ +//! RPC +//! +//! Will contain the code to initiate the RPC and a request handler. + +mod request_handler; diff --git a/binaries/cuprated/src/rpc/request_handler.rs b/binaries/cuprated/src/rpc/request_handler.rs new file mode 100644 index 00000000..e69de29b diff --git a/binaries/cuprated/src/txpool.rs b/binaries/cuprated/src/txpool.rs new file mode 100644 index 00000000..a6f05e75 --- /dev/null +++ b/binaries/cuprated/src/txpool.rs @@ -0,0 +1,3 @@ +//! Transaction Pool +//! +//! Will handle initiating the tx-pool, providing the preprocessor required for the dandelion pool. From 39d48fe9fc83fce523d812b669c9a1197fe574d9 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 16 Aug 2024 15:01:42 +0100 Subject: [PATCH 02/72] fmt and add deny exception --- binaries/cuprated/src/blockchain/manager.rs | 1 + binaries/cuprated/src/blockchain/syncer.rs | 1 + binaries/cuprated/src/p2p/request_handler.rs | 1 + binaries/cuprated/src/rpc/request_handler.rs | 1 + deny.toml | 2 +- 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index e69de29b..8b137891 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -0,0 +1 @@ + diff --git a/binaries/cuprated/src/blockchain/syncer.rs b/binaries/cuprated/src/blockchain/syncer.rs index e69de29b..8b137891 100644 --- a/binaries/cuprated/src/blockchain/syncer.rs +++ b/binaries/cuprated/src/blockchain/syncer.rs @@ -0,0 +1 @@ + diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index e69de29b..8b137891 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -0,0 +1 @@ + diff --git a/binaries/cuprated/src/rpc/request_handler.rs b/binaries/cuprated/src/rpc/request_handler.rs index e69de29b..8b137891 100644 --- a/binaries/cuprated/src/rpc/request_handler.rs +++ b/binaries/cuprated/src/rpc/request_handler.rs @@ -0,0 +1 @@ + diff --git a/deny.toml b/deny.toml index 85e7da28..f469d062 100644 --- a/deny.toml +++ b/deny.toml @@ -133,7 +133,7 @@ confidence-threshold = 0.8 # aren't accepted for every possible crate as with the normal allow list exceptions = [ # Cuprate (AGPL-3.0) - # { allow = ["AGPL-3.0"], name = "cuprated", version = "*" } + { allow = ["AGPL-3.0"], name = "cuprated", version = "*" } # Each entry is the crate and version constraint, and its specific allow # list From a01846954dc35ec2095a2cbbf5d5b12da188ed35 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Tue, 20 Aug 2024 16:39:23 +0100 Subject: [PATCH 03/72] add main chain batch handler --- Cargo.lock | 14 ++ binaries/cuprated/Cargo.toml | 13 ++ binaries/cuprated/src/blockchain.rs | 1 + binaries/cuprated/src/blockchain/manager.rs | 13 ++ .../src/blockchain/manager/batch_handler.rs | 143 ++++++++++++++++++ binaries/cuprated/src/blockchain/syncer.rs | 121 +++++++++++++++ binaries/cuprated/src/blockchain/types.rs | 27 ++++ consensus/fast-sync/src/fast_sync.rs | 3 +- consensus/src/block.rs | 4 +- p2p/p2p/src/lib.rs | 2 +- 10 files changed, 337 insertions(+), 4 deletions(-) create mode 100644 binaries/cuprated/src/blockchain/manager/batch_handler.rs create mode 100644 binaries/cuprated/src/blockchain/types.rs diff --git a/Cargo.lock b/Cargo.lock index 052b1ee6..fbcd326a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -884,6 +884,20 @@ dependencies = [ [[package]] name = "cuprated" version = "0.1.0" +dependencies = [ + "cuprate-blockchain", + "cuprate-consensus", + "cuprate-p2p", + "cuprate-p2p-core", + "cuprate-types", + "futures", + "hex", + "rayon", + "thiserror", + "tokio", + "tower", + "tracing", +] [[package]] name = "curve25519-dalek" diff --git a/binaries/cuprated/Cargo.toml b/binaries/cuprated/Cargo.toml index b5243906..dd6cdc1d 100644 --- a/binaries/cuprated/Cargo.toml +++ b/binaries/cuprated/Cargo.toml @@ -8,6 +8,19 @@ authors = ["Boog900", "hinto-janai", "SyntheticBird45"] repository = "https://github.com/Cuprate/cuprate/tree/main/binaries/cuprated" [dependencies] +cuprate-consensus = { path = "../../consensus" } +cuprate-blockchain = { path = "../../storage/blockchain" } +cuprate-p2p = { path = "../../p2p/p2p" } +cuprate-p2p-core = { path = "../../p2p/p2p-core" } +cuprate-types = { path = "../../types" } + +rayon = { workspace = true } +futures = { workspace = true } +tokio = { workspace = true } +tower = { workspace = true } +tracing = { workspace = true } +thiserror = { workspace = true } +hex = { workspace = true } [lints] workspace = true diff --git a/binaries/cuprated/src/blockchain.rs b/binaries/cuprated/src/blockchain.rs index 4abebeb6..0b6cd3b4 100644 --- a/binaries/cuprated/src/blockchain.rs +++ b/binaries/cuprated/src/blockchain.rs @@ -4,3 +4,4 @@ mod manager; mod syncer; +mod types; diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index 8b137891..c9f9b06b 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -1 +1,14 @@ +mod batch_handler; +use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; +use cuprate_consensus::{BlockChainContextService, BlockVerifierService, TxVerifierService}; + +struct BlockchainManager { + blockchain_write_handle: BlockchainWriteHandle, + blockchain_context_service: BlockChainContextService, + block_verifier_service: BlockVerifierService< + BlockChainContextService, + TxVerifierService, + BlockchainReadHandle, + >, +} diff --git a/binaries/cuprated/src/blockchain/manager/batch_handler.rs b/binaries/cuprated/src/blockchain/manager/batch_handler.rs new file mode 100644 index 00000000..f080f310 --- /dev/null +++ b/binaries/cuprated/src/blockchain/manager/batch_handler.rs @@ -0,0 +1,143 @@ +//! Block batch handling functions. + +use crate::blockchain::types::ConsensusBlockchainReadHandle; +use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; +use cuprate_consensus::context::NewBlockData; +use cuprate_consensus::{ + BlockChainContextRequest, BlockChainContextResponse, BlockChainContextService, + BlockVerifierService, BlockchainReadRequest, BlockchainResponse, ExtendedConsensusError, + VerifyBlockRequest, VerifyBlockResponse, VerifyTxRequest, VerifyTxResponse, +}; +use cuprate_p2p::block_downloader::BlockBatch; +use cuprate_types::blockchain::BlockchainWriteRequest; +use cuprate_types::{Chain, HardFork}; +use tower::{Service, ServiceExt}; +use tracing::{debug, error, info}; + +pub async fn handle_incoming_block_batch( + batch: BlockBatch, + block_verifier_service: &mut BlockVerifierService, + blockchain_context_service: &mut C, + blockchain_read_handle: &mut BlockchainReadHandle, + blockchain_write_handle: &mut BlockchainWriteHandle, +) where + C: Service< + BlockChainContextRequest, + Response = BlockChainContextResponse, + Error = tower::BoxError, + > + Clone + + Send + + 'static, + C::Future: Send + 'static, + + TxV: Service + + Clone + + Send + + 'static, + TxV::Future: Send + 'static, +{ + let (first_block, _) = batch + .blocks + .first() + .expect("Block batch should not be empty"); + + match blockchain_read_handle + .oneshot(BlockchainReadRequest::FindBlock( + first_block.header.previous, + )) + .await + { + Err(_) | Ok(BlockchainResponse::FindBlock(None)) => { + // The block downloader shouldn't be downloading orphan blocks + error!("Failed to find parent block for first block in batch."); + return; + } + Ok(BlockchainResponse::FindBlock(Some((chain, _)))) => match chain { + Chain::Main => { + handle_incoming_block_batch_main_chain( + batch, + block_verifier_service, + blockchain_context_service, + blockchain_write_handle, + ) + .await; + } + Chain::Alt(_) => todo!(), + }, + + Ok(_) => panic!("Blockchain service returned incorrect response"), + } +} + +async fn handle_incoming_block_batch_main_chain( + batch: BlockBatch, + block_verifier_service: &mut BlockVerifierService, + blockchain_context_service: &mut C, + blockchain_write_handle: &mut BlockchainWriteHandle, +) where + C: Service< + BlockChainContextRequest, + Response = BlockChainContextResponse, + Error = tower::BoxError, + > + Clone + + Send + + 'static, + C::Future: Send + 'static, + + TxV: Service + + Clone + + Send + + 'static, + TxV::Future: Send + 'static, +{ + let Ok(VerifyBlockResponse::MainChainBatchPrepped(prepped)) = block_verifier_service + .ready() + .await + .expect("TODO") + .call(VerifyBlockRequest::MainChainBatchPrepareBlocks { + blocks: batch.blocks, + }) + .await + else { + info!("Error verifying batch, banning peer"); + todo!() + }; + + for (block, txs) in prepped { + let Ok(VerifyBlockResponse::MainChain(verified_block)) = block_verifier_service + .ready() + .await + .expect("TODO") + .call(VerifyBlockRequest::MainChainPrepped { block, txs }) + .await + else { + info!("Error verifying batch, banning peer"); + todo!() + }; + + blockchain_context_service + .ready() + .await + .expect("TODO") + .call(BlockChainContextRequest::Update(NewBlockData { + block_hash: verified_block.block_hash, + height: verified_block.height, + timestamp: verified_block.block.header.timestamp, + weight: verified_block.weight, + long_term_weight: verified_block.long_term_weight, + generated_coins: verified_block.generated_coins, + vote: HardFork::from_vote(verified_block.block.header.hardfork_signal), + cumulative_difficulty: verified_block.cumulative_difficulty, + })) + .await + .expect("TODO"); + + blockchain_write_handle + .ready() + .await + .expect("TODO") + .call(BlockchainWriteRequest::WriteBlock(verified_block)) + .await + .expect("TODO"); + } +} diff --git a/binaries/cuprated/src/blockchain/syncer.rs b/binaries/cuprated/src/blockchain/syncer.rs index 8b137891..21c367b8 100644 --- a/binaries/cuprated/src/blockchain/syncer.rs +++ b/binaries/cuprated/src/blockchain/syncer.rs @@ -1 +1,122 @@ +use std::time::Duration; +use futures::StreamExt; +use tokio::{sync::mpsc, time::sleep}; +use tower::{Service, ServiceExt}; +use tracing::instrument; + +use cuprate_consensus::{BlockChainContext, BlockChainContextRequest, BlockChainContextResponse}; +use cuprate_p2p::{ + block_downloader::{BlockBatch, BlockDownloaderConfig, ChainSvcRequest, ChainSvcResponse}, + NetworkInterface, +}; +use cuprate_p2p_core::ClearNet; + +/// An error returned from the [`syncer`]. +#[derive(Debug, thiserror::Error)] +enum SyncerError { + #[error("Incoming block channel closed.")] + IncomingBlockChannelClosed, + #[error("One of our services returned an error: {0}.")] + ServiceError(#[from] tower::BoxError), +} + +#[instrument(level = "debug", skip_all)] +pub async fn syncer( + mut context_svc: C, + our_chain: CN, + clearnet_interface: NetworkInterface, + incoming_block_batch_tx: mpsc::Sender, + block_downloader_config: BlockDownloaderConfig, +) -> Result<(), SyncerError> +where + C: Service< + BlockChainContextRequest, + Response = BlockChainContextResponse, + Error = tower::BoxError, + >, + C::Future: Send + 'static, + CN: Service + + Clone + + Send + + 'static, + CN::Future: Send + 'static, +{ + tracing::info!("Starting blockchain syncer"); + + let BlockChainContextResponse::Context(mut blockchain_ctx) = context_svc + .ready() + .await? + .call(BlockChainContextRequest::GetContext) + .await? + else { + panic!("Blockchain context service returned wrong response!"); + }; + + let mut peer_sync_watch = clearnet_interface.top_sync_stream(); + + tracing::debug!("Waiting for new sync info in top sync channel"); + + while let Some(top_sync_info) = peer_sync_watch.next().await { + tracing::debug!( + "New sync info seen, top height: {}, top block hash: {}", + top_sync_info.chain_height, + hex::encode(top_sync_info.top_hash) + ); + + // The new info could be from a peer giving us a block, so wait a couple seconds to allow the block to + // be added to our blockchain. + sleep(Duration::from_secs(2)).await; + + check_update_blockchain_context(&mut context_svc, &mut blockchain_ctx).await?; + let raw_blockchain_context = blockchain_ctx.unchecked_blockchain_context(); + + if top_sync_info.cumulative_difficulty <= raw_blockchain_context.cumulative_difficulty { + tracing::debug!("New peer sync info is not ahead, nothing to do."); + continue; + } + + tracing::debug!( + "We are behind peers claimed cumulative difficulty, starting block downloader" + ); + let mut block_batch_stream = + clearnet_interface.block_downloader(our_chain.clone(), block_downloader_config); + + while let Some(batch) = block_batch_stream.next().await { + tracing::debug!("Got batch, len: {}", batch.blocks.len()); + if incoming_block_batch_tx.send(batch).await.is_err() { + return Err(SyncerError::IncomingBlockChannelClosed); + } + } + } + + Ok(()) +} + +async fn check_update_blockchain_context( + context_svc: C, + old_context: &mut BlockChainContext, +) -> Result<(), tower::BoxError> +where + C: Service< + BlockChainContextRequest, + Response = BlockChainContextResponse, + Error = tower::BoxError, + >, + C::Future: Send + 'static, +{ + if old_context.blockchain_context().is_ok() { + return Ok(()); + } + + let BlockChainContextResponse::Context(ctx) = context_svc + .oneshot(BlockChainContextRequest::GetContext) + .await? + else { + panic!("Blockchain context service returned wrong response!"); + }; + + *old_context = ctx; + + Ok(()) +} diff --git a/binaries/cuprated/src/blockchain/types.rs b/binaries/cuprated/src/blockchain/types.rs new file mode 100644 index 00000000..0387a7df --- /dev/null +++ b/binaries/cuprated/src/blockchain/types.rs @@ -0,0 +1,27 @@ +use cuprate_blockchain::cuprate_database::RuntimeError; +use cuprate_blockchain::service::BlockchainReadHandle; +use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; +use futures::future::MapErr; +use futures::TryFutureExt; +use std::task::{Context, Poll}; +use tower::Service; + +#[derive(Clone)] +pub struct ConsensusBlockchainReadHandle(BlockchainReadHandle); + +impl Service for ConsensusBlockchainReadHandle { + type Response = BlockchainResponse; + type Error = tower::BoxError; + type Future = MapErr< + >::Future, + fn(RuntimeError) -> tower::BoxError, + >; + + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + self.0.poll_ready(cx).map_err(Into::into) + } + + fn call(&mut self, req: BlockchainReadRequest) -> Self::Future { + self.0.call(req).map_err(Into::into) + } +} diff --git a/consensus/fast-sync/src/fast_sync.rs b/consensus/fast-sync/src/fast_sync.rs index 35fa6742..6baac8d3 100644 --- a/consensus/fast-sync/src/fast_sync.rs +++ b/consensus/fast-sync/src/fast_sync.rs @@ -40,11 +40,12 @@ static HASHES_OF_HASHES: &[HashOfHashes] = &[ const BATCH_SIZE: usize = 4; #[inline] -fn max_height() -> u64 { +pub fn max_height() -> u64 { (HASHES_OF_HASHES.len() * BATCH_SIZE) as u64 } #[derive(Debug, PartialEq)] +#[repr(transparent)] pub struct ValidBlockId(BlockId); fn valid_block_ids(block_ids: &[BlockId]) -> Vec { diff --git a/consensus/src/block.rs b/consensus/src/block.rs index e785a6b7..7297a5a6 100644 --- a/consensus/src/block.rs +++ b/consensus/src/block.rs @@ -250,7 +250,7 @@ where + Clone + Send + 'static, - D: Database + Clone + Send + Sync + 'static, + D: Database + Clone + Send + 'static, D::Future: Send + 'static, { /// Creates a new block verifier. @@ -284,7 +284,7 @@ where + 'static, TxV::Future: Send + 'static, - D: Database + Clone + Send + Sync + 'static, + D: Database + Clone + Send + 'static, D::Future: Send + 'static, { type Response = VerifyBlockResponse; diff --git a/p2p/p2p/src/lib.rs b/p2p/p2p/src/lib.rs index be18c2a3..82ecfce7 100644 --- a/p2p/p2p/src/lib.rs +++ b/p2p/p2p/src/lib.rs @@ -21,7 +21,7 @@ use cuprate_p2p_core::{ CoreSyncSvc, NetworkZone, ProtocolRequestHandler, }; -mod block_downloader; +pub mod block_downloader; mod broadcast; mod client_pool; pub mod config; From f909c262faf912647e7b800662f467d07a7636ce Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Wed, 21 Aug 2024 16:02:00 +0100 Subject: [PATCH 04/72] add blockchain init --- Cargo.lock | 70 +++++++++++++++++++ binaries/cuprated/Cargo.toml | 8 ++- binaries/cuprated/src/blockchain.rs | 67 ++++++++++++++++++ binaries/cuprated/src/blockchain/manager.rs | 49 +++++++++++++- binaries/cuprated/src/blockchain/syncer.rs | 4 +- binaries/cuprated/src/blockchain/types.rs | 75 ++++++++++++++++++++- binaries/cuprated/src/main.rs | 25 ++++++- consensus/src/lib.rs | 15 ++--- 8 files changed, 292 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fbcd326a..58b66fe6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,12 +44,55 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + [[package]] name = "anstyle" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +[[package]] +name = "anstyle-parse" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "async-stream" version = "0.3.5" @@ -352,8 +395,10 @@ version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" dependencies = [ + "anstream", "anstyle", "clap_lex", + "strsim", ] [[package]] @@ -374,6 +419,12 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" +[[package]] +name = "colorchoice" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" + [[package]] name = "core-foundation" version = "0.9.4" @@ -885,6 +936,7 @@ dependencies = [ name = "cuprated" version = "0.1.0" dependencies = [ + "clap", "cuprate-blockchain", "cuprate-consensus", "cuprate-p2p", @@ -1590,6 +1642,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "itoa" version = "1.0.11" @@ -2623,6 +2681,12 @@ dependencies = [ "spin", ] +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "subtle" version = "2.5.0" @@ -2992,6 +3056,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "version_check" version = "0.9.4" diff --git a/binaries/cuprated/Cargo.toml b/binaries/cuprated/Cargo.toml index dd6cdc1d..74eb2d59 100644 --- a/binaries/cuprated/Cargo.toml +++ b/binaries/cuprated/Cargo.toml @@ -16,11 +16,13 @@ cuprate-types = { path = "../../types" } rayon = { workspace = true } futures = { workspace = true } -tokio = { workspace = true } +tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } tower = { workspace = true } tracing = { workspace = true } thiserror = { workspace = true } hex = { workspace = true } -[lints] -workspace = true +clap = { workspace = true, features = ["default", "derive"] } + +#[lints] +#workspace = true diff --git a/binaries/cuprated/src/blockchain.rs b/binaries/cuprated/src/blockchain.rs index 0b6cd3b4..a9af7d72 100644 --- a/binaries/cuprated/src/blockchain.rs +++ b/binaries/cuprated/src/blockchain.rs @@ -2,6 +2,73 @@ //! //! Will contain the chain manager and syncer. +use crate::blockchain::manager::BlockchainManager; +use crate::blockchain::types::{ + ChainService, ConcreteBlockVerifierService, ConcreteTxVerifierService, + ConsensusBlockchainReadHandle, +}; +use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; +use cuprate_consensus::{ + BlockChainContextService, BlockVerifierService, ContextConfig, TxVerifierService, +}; +use cuprate_p2p::block_downloader::BlockDownloaderConfig; +use cuprate_p2p::NetworkInterface; +use cuprate_p2p_core::ClearNet; +use tokio::sync::mpsc; + mod manager; mod syncer; mod types; + +pub async fn init_consensus( + blockchain_read_handle: BlockchainReadHandle, + context_config: ContextConfig, +) -> Result< + ( + ConcreteBlockVerifierService, + ConcreteTxVerifierService, + BlockChainContextService, + ), + tower::BoxError, +> { + let ctx_service = cuprate_consensus::initialize_blockchain_context( + context_config, + ConsensusBlockchainReadHandle(blockchain_read_handle.clone()), + ) + .await?; + + let (block_verifier_svc, tx_verifier_svc) = cuprate_consensus::initialize_verifier( + ConsensusBlockchainReadHandle(blockchain_read_handle), + ctx_service.clone(), + ); + + Ok((block_verifier_svc, tx_verifier_svc, ctx_service)) +} + +pub fn init_blockchain_manager( + clearnet_interface: NetworkInterface, + block_downloader_config: BlockDownloaderConfig, + blockchain_write_handle: BlockchainWriteHandle, + blockchain_read_handle: BlockchainReadHandle, + blockchain_context_service: BlockChainContextService, + block_verifier_service: ConcreteBlockVerifierService, +) { + let (batch_tx, batch_rx) = mpsc::channel(1); + + tokio::spawn(syncer::syncer( + blockchain_context_service.clone(), + ChainService(blockchain_read_handle.clone()), + clearnet_interface, + batch_tx, + block_downloader_config, + )); + + let manager = BlockchainManager::new( + blockchain_write_handle, + blockchain_read_handle, + blockchain_context_service, + block_verifier_service, + ); + + tokio::spawn(manager.run(batch_rx)); +} diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index c9f9b06b..5a526a59 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -1,14 +1,57 @@ mod batch_handler; +use crate::blockchain::manager::batch_handler::handle_incoming_block_batch; +use crate::blockchain::types::ConsensusBlockchainReadHandle; use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; use cuprate_consensus::{BlockChainContextService, BlockVerifierService, TxVerifierService}; +use cuprate_p2p::block_downloader::BlockBatch; +use futures::StreamExt; +use tokio::sync::mpsc::Receiver; -struct BlockchainManager { +pub struct BlockchainManager { blockchain_write_handle: BlockchainWriteHandle, + blockchain_read_handle: BlockchainReadHandle, blockchain_context_service: BlockChainContextService, block_verifier_service: BlockVerifierService< BlockChainContextService, - TxVerifierService, - BlockchainReadHandle, + TxVerifierService, + ConsensusBlockchainReadHandle, >, } + +impl BlockchainManager { + pub const fn new( + blockchain_write_handle: BlockchainWriteHandle, + blockchain_read_handle: BlockchainReadHandle, + blockchain_context_service: BlockChainContextService, + block_verifier_service: BlockVerifierService< + BlockChainContextService, + TxVerifierService, + ConsensusBlockchainReadHandle, + >, + ) -> Self { + Self { + blockchain_write_handle, + blockchain_read_handle, + blockchain_context_service, + block_verifier_service, + } + } + + pub async fn run(mut self, mut batch_rx: Receiver) { + tokio::select! { + Some(batch) = batch_rx.recv() => { + handle_incoming_block_batch( + batch, + &mut self.block_verifier_service, + &mut self.blockchain_context_service, + &mut self.blockchain_read_handle, + &mut self.blockchain_write_handle + ).await; + } + else => { + todo!("Exit the BC manager") + } + } + } +} diff --git a/binaries/cuprated/src/blockchain/syncer.rs b/binaries/cuprated/src/blockchain/syncer.rs index 21c367b8..dc738123 100644 --- a/binaries/cuprated/src/blockchain/syncer.rs +++ b/binaries/cuprated/src/blockchain/syncer.rs @@ -14,7 +14,7 @@ use cuprate_p2p_core::ClearNet; /// An error returned from the [`syncer`]. #[derive(Debug, thiserror::Error)] -enum SyncerError { +pub enum SyncerError { #[error("Incoming block channel closed.")] IncomingBlockChannelClosed, #[error("One of our services returned an error: {0}.")] @@ -58,7 +58,7 @@ where tracing::debug!("Waiting for new sync info in top sync channel"); while let Some(top_sync_info) = peer_sync_watch.next().await { - tracing::debug!( + tracing::info!( "New sync info seen, top height: {}, top block hash: {}", top_sync_info.chain_height, hex::encode(top_sync_info.top_hash) diff --git a/binaries/cuprated/src/blockchain/types.rs b/binaries/cuprated/src/blockchain/types.rs index 0387a7df..46576a46 100644 --- a/binaries/cuprated/src/blockchain/types.rs +++ b/binaries/cuprated/src/blockchain/types.rs @@ -1,13 +1,23 @@ use cuprate_blockchain::cuprate_database::RuntimeError; use cuprate_blockchain::service::BlockchainReadHandle; +use cuprate_consensus::{BlockChainContextService, BlockVerifierService, TxVerifierService}; +use cuprate_p2p::block_downloader::{ChainSvcRequest, ChainSvcResponse}; use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; -use futures::future::MapErr; -use futures::TryFutureExt; +use futures::future::{BoxFuture, MapErr}; +use futures::{FutureExt, TryFutureExt}; use std::task::{Context, Poll}; use tower::Service; +pub type ConcreteBlockVerifierService = BlockVerifierService< + BlockChainContextService, + TxVerifierService, + ConsensusBlockchainReadHandle, +>; + +pub type ConcreteTxVerifierService = TxVerifierService; + #[derive(Clone)] -pub struct ConsensusBlockchainReadHandle(BlockchainReadHandle); +pub struct ConsensusBlockchainReadHandle(pub BlockchainReadHandle); impl Service for ConsensusBlockchainReadHandle { type Response = BlockchainResponse; @@ -25,3 +35,62 @@ impl Service for ConsensusBlockchainReadHandle { self.0.call(req).map_err(Into::into) } } + +#[derive(Clone)] +pub struct ChainService(pub BlockchainReadHandle); + +impl Service for ChainService { + type Response = ChainSvcResponse; + type Error = tower::BoxError; + type Future = BoxFuture<'static, Result>; + + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + self.0.poll_ready(cx).map_err(Into::into) + } + + fn call(&mut self, req: ChainSvcRequest) -> Self::Future { + let map_res = |res: BlockchainResponse| match res { + BlockchainResponse::CompactChainHistory { + block_ids, + cumulative_difficulty, + } => ChainSvcResponse::CompactHistory { + block_ids, + cumulative_difficulty, + }, + BlockchainResponse::FindFirstUnknown(res) => ChainSvcResponse::FindFirstUnknown(res), + _ => panic!("Blockchain returned wrong response"), + }; + + match req { + ChainSvcRequest::CompactHistory => self + .0 + .call(BlockchainReadRequest::CompactChainHistory) + .map_ok(map_res) + .map_err(Into::into) + .boxed(), + ChainSvcRequest::FindFirstUnknown(req) => self + .0 + .call(BlockchainReadRequest::FindFirstUnknown(req)) + .map_ok(map_res) + .map_err(Into::into) + .boxed(), + ChainSvcRequest::CumulativeDifficulty => self + .0 + .call(BlockchainReadRequest::CompactChainHistory) + .map_ok(|res| { + // TODO create a custom request instead of hijacking this one. + let BlockchainResponse::CompactChainHistory { + cumulative_difficulty, + .. + } = res + else { + panic!("Blockchain returned wrong response"); + }; + + ChainSvcResponse::CumulativeDifficulty(cumulative_difficulty) + }) + .map_err(Into::into) + .boxed(), + } + } +} diff --git a/binaries/cuprated/src/main.rs b/binaries/cuprated/src/main.rs index 918429c9..4d205a15 100644 --- a/binaries/cuprated/src/main.rs +++ b/binaries/cuprated/src/main.rs @@ -1,9 +1,32 @@ +use clap::Parser; + mod blockchain; mod config; mod p2p; mod rpc; mod txpool; +#[derive(Parser)] +struct Args {} fn main() { - todo!() + let _args = Args::parse(); + + let (bc_read_handle, bc_write_handle, _) = + cuprate_blockchain::service::init(cuprate_blockchain::config::Config::default()).unwrap(); + + let async_rt = tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build() + .unwrap(); + + async_rt.block_on(async move { + let (block_verifier, tx_verifier, context_svc) = blockchain::init_consensus( + bc_read_handle, + cuprate_consensus::ContextConfig::main_net(), + ) + .await + .unwrap(); + + //blockchain::init_blockchain_manager() + }); } diff --git a/consensus/src/lib.rs b/consensus/src/lib.rs index 3b7f2ae1..2c69e667 100644 --- a/consensus/src/lib.rs +++ b/consensus/src/lib.rs @@ -50,16 +50,13 @@ pub enum ExtendedConsensusError { } /// Initialize the 2 verifier [`tower::Service`]s (block and transaction). -pub async fn initialize_verifier( +pub fn initialize_verifier( database: D, ctx_svc: Ctx, -) -> Result< - ( - BlockVerifierService, D>, - TxVerifierService, - ), - ConsensusError, -> +) -> ( + BlockVerifierService, D>, + TxVerifierService, +) where D: Database + Clone + Send + Sync + 'static, D::Future: Send + 'static, @@ -75,7 +72,7 @@ where { let tx_svc = TxVerifierService::new(database.clone()); let block_svc = BlockVerifierService::new(ctx_svc, tx_svc.clone(), database); - Ok((block_svc, tx_svc)) + (block_svc, tx_svc) } use __private::Database; From f25588d3489e69d1b8f75da6bc821afca5c1ef26 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 23 Aug 2024 23:55:54 +0100 Subject: [PATCH 05/72] very rough block manager --- .idea/vcs.xml | 6 + .idea/workspace.xml | 637 ++++++++++++++++++ Cargo.lock | 80 ++- Cargo.toml | 6 +- binaries/cuprated/Cargo.toml | 8 + binaries/cuprated/src/blockchain.rs | 54 +- binaries/cuprated/src/blockchain/manager.rs | 26 +- .../src/blockchain/manager/batch_handler.rs | 29 +- binaries/cuprated/src/main.rs | 43 +- binaries/cuprated/src/p2p.rs | 26 +- binaries/cuprated/src/p2p/core_sync_svc.rs | 51 ++ binaries/cuprated/src/p2p/request_handler.rs | 32 + consensus/src/block.rs | 2 +- consensus/src/lib.rs | 1 + consensus/src/transactions.rs | 4 + consensus/src/transactions/free.rs | 3 +- p2p/p2p-core/src/lib.rs | 1 + p2p/p2p/src/config.rs | 3 +- p2p/p2p/src/lib.rs | 2 +- p2p_state.bin | Bin 0 -> 162918 bytes 20 files changed, 965 insertions(+), 49 deletions(-) create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 binaries/cuprated/src/p2p/core_sync_svc.rs create mode 100644 p2p_state.bin diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 00000000..8ddf4f0e --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,637 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { + "associatedIndex": 4 +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1722869508802 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 58b66fe6..22e7fdd0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -939,6 +939,7 @@ dependencies = [ "clap", "cuprate-blockchain", "cuprate-consensus", + "cuprate-cryptonight", "cuprate-p2p", "cuprate-p2p-core", "cuprate-types", @@ -949,6 +950,7 @@ dependencies = [ "tokio", "tower", "tracing", + "tracing-subscriber", ] [[package]] @@ -983,7 +985,7 @@ dependencies = [ [[package]] name = "dalek-ff-group" version = "0.4.1" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "crypto-bigint", "curve25519-dalek", @@ -1138,7 +1140,7 @@ dependencies = [ [[package]] name = "flexible-transcript" version = "0.3.2" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "blake2", "digest", @@ -1802,7 +1804,7 @@ dependencies = [ [[package]] name = "monero-address" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "monero-io", @@ -1815,7 +1817,7 @@ dependencies = [ [[package]] name = "monero-borromean" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "monero-generators", @@ -1828,7 +1830,7 @@ dependencies = [ [[package]] name = "monero-bulletproofs" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "monero-generators", @@ -1843,7 +1845,7 @@ dependencies = [ [[package]] name = "monero-clsag" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "dalek-ff-group", @@ -1863,7 +1865,7 @@ dependencies = [ [[package]] name = "monero-generators" version = "0.4.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "dalek-ff-group", @@ -1877,7 +1879,7 @@ dependencies = [ [[package]] name = "monero-io" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "std-shims", @@ -1886,7 +1888,7 @@ dependencies = [ [[package]] name = "monero-mlsag" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "monero-generators", @@ -1900,7 +1902,7 @@ dependencies = [ [[package]] name = "monero-primitives" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "monero-generators", @@ -1913,7 +1915,7 @@ dependencies = [ [[package]] name = "monero-rpc" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "async-trait", "curve25519-dalek", @@ -1930,7 +1932,7 @@ dependencies = [ [[package]] name = "monero-serai" version = "0.1.4-alpha" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "hex-literal", @@ -1948,7 +1950,7 @@ dependencies = [ [[package]] name = "monero-simple-request-rpc" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "async-trait", "digest_auth", @@ -1958,6 +1960,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -2005,6 +2017,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "page_size" version = "0.6.0" @@ -2607,6 +2625,15 @@ dependencies = [ "keccak", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -2619,7 +2646,7 @@ dependencies = [ [[package]] name = "simple-request" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "http-body-util", "hyper", @@ -2675,7 +2702,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "std-shims" version = "0.1.1" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "hashbrown", "spin", @@ -2974,6 +3001,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", ] [[package]] @@ -2982,7 +3021,12 @@ version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ + "nu-ansi-term", + "sharded-slab", + "smallvec", + "thread_local", "tracing-core", + "tracing-log", ] [[package]] @@ -3062,6 +3106,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index 06b49a0a..e1f068eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,7 +65,7 @@ futures = { version = "0.3.29", default-features = false } hex = { version = "0.4.3", default-features = false } hex-literal = { version = "0.4", default-features = false } indexmap = { version = "2.2.5", 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 = "50686e8", default-features = false } paste = { version = "1.0.14", default-features = false } pin-project = { version = "1.1.3", default-features = false } randomx-rs = { git = "https://github.com/Cuprate/randomx-rs.git", rev = "0028464", default-features = false } @@ -85,8 +85,8 @@ tracing-subscriber = { version = "0.3.17", 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 = "50686e8" } +monero-simple-request-rpc = { git = "https://github.com/Cuprate/serai.git", rev = "50686e8" } tempfile = { version = "3" } pretty_assertions = { version = "1.4.0" } proptest = { version = "1" } diff --git a/binaries/cuprated/Cargo.toml b/binaries/cuprated/Cargo.toml index 74eb2d59..c01e2cca 100644 --- a/binaries/cuprated/Cargo.toml +++ b/binaries/cuprated/Cargo.toml @@ -13,6 +13,7 @@ cuprate-blockchain = { path = "../../storage/blockchain" } cuprate-p2p = { path = "../../p2p/p2p" } cuprate-p2p-core = { path = "../../p2p/p2p-core" } cuprate-types = { path = "../../types" } +cuprate-cryptonight = { path = "../../cryptonight" } rayon = { workspace = true } futures = { workspace = true } @@ -23,6 +24,13 @@ thiserror = { workspace = true } hex = { workspace = true } clap = { workspace = true, features = ["default", "derive"] } +tracing-subscriber = { workspace = true, features = ["default"] } #[lints] #workspace = true + +[profile.dev] +panic = 'abort' + +[profile.release] +panic = 'abort' diff --git a/binaries/cuprated/src/blockchain.rs b/binaries/cuprated/src/blockchain.rs index a9af7d72..c0b7e6ce 100644 --- a/binaries/cuprated/src/blockchain.rs +++ b/binaries/cuprated/src/blockchain.rs @@ -8,18 +8,64 @@ use crate::blockchain::types::{ ConsensusBlockchainReadHandle, }; use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; -use cuprate_consensus::{ - BlockChainContextService, BlockVerifierService, ContextConfig, TxVerifierService, -}; +use cuprate_consensus::{generate_genesis_block, BlockChainContextService, ContextConfig}; +use cuprate_cryptonight::cryptonight_hash_v0; use cuprate_p2p::block_downloader::BlockDownloaderConfig; use cuprate_p2p::NetworkInterface; -use cuprate_p2p_core::ClearNet; +use cuprate_p2p_core::{ClearNet, Network}; +use cuprate_types::blockchain::{ + BlockchainReadRequest, BlockchainResponse, BlockchainWriteRequest, +}; +use cuprate_types::VerifiedBlockInformation; use tokio::sync::mpsc; +use tower::{Service, ServiceExt}; mod manager; mod syncer; mod types; +pub async fn check_add_genesis( + blockchain_read_handle: &mut BlockchainReadHandle, + blockchain_write_handle: &mut BlockchainWriteHandle, + network: &Network, +) { + if blockchain_read_handle + .ready() + .await + .unwrap() + .call(BlockchainReadRequest::ChainHeight) + .await + .is_ok() + { + return; + } + + let genesis = generate_genesis_block(network); + + blockchain_write_handle + .ready() + .await + .unwrap() + .call(BlockchainWriteRequest::WriteBlock( + VerifiedBlockInformation { + block_blob: genesis.serialize(), + txs: vec![], + block_hash: genesis.hash(), + pow_hash: cryptonight_hash_v0(&genesis.serialize_pow_hash()), + height: 0, + generated_coins: genesis.miner_transaction.prefix().outputs[0] + .amount + .unwrap(), + weight: genesis.miner_transaction.weight(), + long_term_weight: genesis.miner_transaction.weight(), + cumulative_difficulty: 1, + block: genesis, + }, + )) + .await + .unwrap(); +} + pub async fn init_consensus( blockchain_read_handle: BlockchainReadHandle, context_config: ContextConfig, diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index 5a526a59..e13c9073 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -39,18 +39,20 @@ impl BlockchainManager { } pub async fn run(mut self, mut batch_rx: Receiver) { - tokio::select! { - Some(batch) = batch_rx.recv() => { - handle_incoming_block_batch( - batch, - &mut self.block_verifier_service, - &mut self.blockchain_context_service, - &mut self.blockchain_read_handle, - &mut self.blockchain_write_handle - ).await; - } - else => { - todo!("Exit the BC manager") + loop { + tokio::select! { + Some(batch) = batch_rx.recv() => { + handle_incoming_block_batch( + batch, + &mut self.block_verifier_service, + &mut self.blockchain_context_service, + &mut self.blockchain_read_handle, + &mut self.blockchain_write_handle + ).await; + } + else => { + todo!("TODO: exit the BC manager") + } } } } diff --git a/binaries/cuprated/src/blockchain/manager/batch_handler.rs b/binaries/cuprated/src/blockchain/manager/batch_handler.rs index f080f310..c4a3d6e5 100644 --- a/binaries/cuprated/src/blockchain/manager/batch_handler.rs +++ b/binaries/cuprated/src/blockchain/manager/batch_handler.rs @@ -41,6 +41,16 @@ pub async fn handle_incoming_block_batch( .first() .expect("Block batch should not be empty"); + handle_incoming_block_batch_main_chain( + batch, + block_verifier_service, + blockchain_context_service, + blockchain_write_handle, + ) + .await; + + // TODO: alt block to the DB + /* match blockchain_read_handle .oneshot(BlockchainReadRequest::FindBlock( first_block.header.previous, @@ -67,6 +77,8 @@ pub async fn handle_incoming_block_batch( Ok(_) => panic!("Blockchain service returned incorrect response"), } + + */ } async fn handle_incoming_block_batch_main_chain( @@ -90,7 +102,12 @@ async fn handle_incoming_block_batch_main_chain( + 'static, TxV::Future: Send + 'static, { - let Ok(VerifyBlockResponse::MainChainBatchPrepped(prepped)) = block_verifier_service + info!( + "Handling batch to main chain height: {}", + batch.blocks.first().unwrap().0.number().unwrap() + ); + + let VerifyBlockResponse::MainChainBatchPrepped(prepped) = block_verifier_service .ready() .await .expect("TODO") @@ -98,21 +115,21 @@ async fn handle_incoming_block_batch_main_chain( blocks: batch.blocks, }) .await + .unwrap() else { - info!("Error verifying batch, banning peer"); - todo!() + panic!("Incorrect response!"); }; for (block, txs) in prepped { - let Ok(VerifyBlockResponse::MainChain(verified_block)) = block_verifier_service + let VerifyBlockResponse::MainChain(verified_block) = block_verifier_service .ready() .await .expect("TODO") .call(VerifyBlockRequest::MainChainPrepped { block, txs }) .await + .unwrap() else { - info!("Error verifying batch, banning peer"); - todo!() + panic!("Incorrect response!"); }; blockchain_context_service diff --git a/binaries/cuprated/src/main.rs b/binaries/cuprated/src/main.rs index 4d205a15..5ccb8382 100644 --- a/binaries/cuprated/src/main.rs +++ b/binaries/cuprated/src/main.rs @@ -1,4 +1,10 @@ +use crate::blockchain::check_add_genesis; use clap::Parser; +use cuprate_p2p::block_downloader::BlockDownloaderConfig; +use cuprate_p2p::P2PConfig; +use cuprate_p2p_core::Network; +use std::time::Duration; +use tracing::Level; mod blockchain; mod config; @@ -11,7 +17,11 @@ struct Args {} fn main() { let _args = Args::parse(); - let (bc_read_handle, bc_write_handle, _) = + tracing_subscriber::fmt() + .with_max_level(Level::DEBUG) + .init(); + + let (mut bc_read_handle, mut bc_write_handle, _) = cuprate_blockchain::service::init(cuprate_blockchain::config::Config::default()).unwrap(); let async_rt = tokio::runtime::Builder::new_multi_thread() @@ -20,13 +30,38 @@ fn main() { .unwrap(); async_rt.block_on(async move { - let (block_verifier, tx_verifier, context_svc) = blockchain::init_consensus( - bc_read_handle, + check_add_genesis(&mut bc_read_handle, &mut bc_write_handle, &Network::Mainnet).await; + + let (block_verifier, _tx_verifier, context_svc) = blockchain::init_consensus( + bc_read_handle.clone(), cuprate_consensus::ContextConfig::main_net(), ) .await .unwrap(); - //blockchain::init_blockchain_manager() + let net = cuprate_p2p::initialize_network( + p2p::request_handler::P2pProtocolRequestHandler, + p2p::core_sync_svc::CoreSyncService(context_svc.clone()), + p2p::dummy_config(), + ) + .await + .unwrap(); + + blockchain::init_blockchain_manager( + net, + BlockDownloaderConfig { + buffer_size: 50_000_000, + in_progress_queue_size: 50_000_000, + check_client_pool_interval: Duration::from_secs(45), + target_batch_size: 10_000_000, + initial_batch_size: 1, + }, + bc_write_handle, + bc_read_handle, + context_svc, + block_verifier, + ); + + tokio::time::sleep(Duration::MAX).await; }); } diff --git a/binaries/cuprated/src/p2p.rs b/binaries/cuprated/src/p2p.rs index f5b72ba3..0560320b 100644 --- a/binaries/cuprated/src/p2p.rs +++ b/binaries/cuprated/src/p2p.rs @@ -2,4 +2,28 @@ //! //! Will handle initiating the P2P and contains a protocol request handler. -mod request_handler; +use cuprate_p2p::AddressBookConfig; +use cuprate_p2p_core::Network; +use std::time::Duration; + +pub mod core_sync_svc; +pub mod request_handler; + +pub fn dummy_config() -> cuprate_p2p::P2PConfig { + cuprate_p2p::P2PConfig { + network: Network::Mainnet, + outbound_connections: 64, + extra_outbound_connections: 0, + max_inbound_connections: 0, + gray_peers_percent: 0.7, + server_config: None, + p2p_port: 0, + rpc_port: 0, + address_book_config: AddressBookConfig { + max_white_list_length: 1000, + max_gray_list_length: 5000, + peer_store_file: "p2p_state.bin".into(), + peer_save_period: Duration::from_secs(60), + }, + } +} diff --git a/binaries/cuprated/src/p2p/core_sync_svc.rs b/binaries/cuprated/src/p2p/core_sync_svc.rs new file mode 100644 index 00000000..34c91e47 --- /dev/null +++ b/binaries/cuprated/src/p2p/core_sync_svc.rs @@ -0,0 +1,51 @@ +use cuprate_blockchain::cuprate_database::RuntimeError; +use cuprate_blockchain::service::BlockchainReadHandle; +use cuprate_consensus::{ + BlockChainContextRequest, BlockChainContextResponse, BlockChainContextService, +}; +use cuprate_p2p_core::services::{CoreSyncDataRequest, CoreSyncDataResponse}; +use cuprate_p2p_core::CoreSyncData; +use cuprate_types::blockchain::BlockchainReadRequest; +use futures::future::{BoxFuture, MapErr, MapOk}; +use futures::{FutureExt, TryFutureExt}; +use std::task::{Context, Poll}; +use tower::Service; + +#[derive(Clone)] +pub struct CoreSyncService(pub BlockChainContextService); + +impl Service for CoreSyncService { + type Response = CoreSyncDataResponse; + type Error = tower::BoxError; + type Future = MapOk< + >::Future, + fn(BlockChainContextResponse) -> CoreSyncDataResponse, + >; + + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + self.0.poll_ready(cx) + } + + fn call(&mut self, _: CoreSyncDataRequest) -> Self::Future { + self.0 + .call(BlockChainContextRequest::GetContext) + .map_ok(|res| { + let BlockChainContextResponse::Context(ctx) = res else { + panic!("blockchain context service returned wrong response."); + }; + + let raw_ctx = ctx.unchecked_blockchain_context(); + + // TODO: the hardfork here should be the version of the top block not the current HF, + // on HF boundaries these will be different. + CoreSyncDataResponse(CoreSyncData::new( + raw_ctx.cumulative_difficulty, + // TODO: + raw_ctx.chain_height as u64, + 0, + raw_ctx.top_hash, + raw_ctx.current_hf.as_u8(), + )) + }) + } +} diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index 8b137891..76554e92 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -1 +1,33 @@ +use cuprate_p2p_core::{ProtocolRequest, ProtocolResponse}; +use futures::future::BoxFuture; +use futures::FutureExt; +use std::task::{Context, Poll}; +use tower::Service; +use tracing::trace; +#[derive(Clone)] +pub struct P2pProtocolRequestHandler; + +impl Service for P2pProtocolRequestHandler { + type Response = ProtocolResponse; + type Error = tower::BoxError; + type Future = BoxFuture<'static, Result>; + + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { + Poll::Ready(Ok(())) + } + + fn call(&mut self, req: ProtocolRequest) -> Self::Future { + match req { + ProtocolRequest::GetObjects(_) => trace!("TODO: GetObjects"), + ProtocolRequest::GetChain(_) => trace!("TODO: GetChain"), + ProtocolRequest::FluffyMissingTxs(_) => trace!("TODO: FluffyMissingTxs"), + ProtocolRequest::GetTxPoolCompliment(_) => trace!("TODO: GetTxPoolCompliment"), + ProtocolRequest::NewBlock(_) => trace!("TODO: NewBlock"), + ProtocolRequest::NewFluffyBlock(_) => trace!("TODO: NewFluffyBlock"), + ProtocolRequest::NewTransactions(_) => trace!("TODO: NewTransactions"), + } + + async { Ok(ProtocolResponse::NA) }.boxed() + } +} diff --git a/consensus/src/block.rs b/consensus/src/block.rs index 7297a5a6..b33b5857 100644 --- a/consensus/src/block.rs +++ b/consensus/src/block.rs @@ -123,7 +123,7 @@ impl PreparedBlock { /// /// The randomX VM must be Some if RX is needed or this will panic. /// The randomX VM must also be initialised with the correct seed. - fn new( + pub fn new( block: Block, randomx_vm: Option<&R>, ) -> Result { diff --git a/consensus/src/lib.rs b/consensus/src/lib.rs index 2c69e667..29f59038 100644 --- a/consensus/src/lib.rs +++ b/consensus/src/lib.rs @@ -27,6 +27,7 @@ pub use context::{ pub use transactions::{TxVerifierService, VerifyTxRequest, VerifyTxResponse}; // re-export. +pub use cuprate_consensus_rules::genesis::generate_genesis_block; pub use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; /// An Error returned from one of the consensus services. diff --git a/consensus/src/transactions.rs b/consensus/src/transactions.rs index 91de67cd..82d3100e 100644 --- a/consensus/src/transactions.rs +++ b/consensus/src/transactions.rs @@ -393,6 +393,10 @@ async fn verify_transactions_decoy_info( where D: Database + Clone + Sync + Send + 'static, { + if hf == HardFork::V1 { + return Ok(()); + } + batch_get_decoy_info(&txs, hf, database) .await? .try_for_each(|decoy_info| decoy_info.and_then(|di| Ok(check_decoy_info(&di, &hf)?)))?; diff --git a/consensus/src/transactions/free.rs b/consensus/src/transactions/free.rs index 02c52358..67b675a4 100644 --- a/consensus/src/transactions/free.rs +++ b/consensus/src/transactions/free.rs @@ -78,7 +78,8 @@ pub fn tx_fee(tx: &Transaction) -> Result { } for output in &prefix.outputs { - fee.checked_sub(output.amount.unwrap_or(0)) + fee = fee + .checked_sub(output.amount.unwrap_or(0)) .ok_or(TransactionError::OutputsTooHigh)?; } } diff --git a/p2p/p2p-core/src/lib.rs b/p2p/p2p-core/src/lib.rs index 83cc4d2e..1f7e631a 100644 --- a/p2p/p2p-core/src/lib.rs +++ b/p2p/p2p-core/src/lib.rs @@ -79,6 +79,7 @@ pub use protocol::*; use services::*; //re-export pub use cuprate_helper::network::Network; +pub use cuprate_wire::CoreSyncData; /// The direction of a connection. #[derive(Debug, Copy, Clone, Eq, PartialEq)] diff --git a/p2p/p2p/src/config.rs b/p2p/p2p/src/config.rs index 90d7f8ff..98bef68e 100644 --- a/p2p/p2p/src/config.rs +++ b/p2p/p2p/src/config.rs @@ -1,8 +1,9 @@ -use cuprate_address_book::AddressBookConfig; use cuprate_helper::network::Network; use cuprate_p2p_core::NetworkZone; use cuprate_wire::{common::PeerSupportFlags, BasicNodeData}; +pub use cuprate_address_book::AddressBookConfig; + /// P2P config. #[derive(Clone, Debug)] pub struct P2PConfig { diff --git a/p2p/p2p/src/lib.rs b/p2p/p2p/src/lib.rs index 82ecfce7..6f95948f 100644 --- a/p2p/p2p/src/lib.rs +++ b/p2p/p2p/src/lib.rs @@ -33,7 +33,7 @@ mod sync_states; use block_downloader::{BlockBatch, BlockDownloaderConfig, ChainSvcRequest, ChainSvcResponse}; pub use broadcast::{BroadcastRequest, BroadcastSvc}; use client_pool::ClientPoolDropGuard; -pub use config::P2PConfig; +pub use config::{AddressBookConfig, P2PConfig}; use connection_maintainer::MakeConnectionRequest; /// Initializes the P2P [`NetworkInterface`] for a specific [`NetworkZone`]. diff --git a/p2p_state.bin b/p2p_state.bin new file mode 100644 index 0000000000000000000000000000000000000000..bf2d673dd8c3bca6473f8a64e5c96f5145cd2331 GIT binary patch literal 162918 zcmaeRd0b83^GRhXp|Yl3NhN8stEl@@BxR{kQIvL3B9s>GLM5SkT128n5t68+4Xs47 zg~(1wmfyVV&h7Qyr{DMeGw03BnX}EAGjqh;rvZc zYMj9$ieCg>C|p=GjFZAnZ*&N&VG+w7@>kqhIqNP`2MvZ4AO2%7^a>2~Si~69`CB8_ zzWjrDl4~gZJ57+N+A`w^7Lhrpx{yz(>pgNIv~A75$RY++s)f3pvK^0D%xnE8=sk<5 z=t#PdYg9d&rc#N}!Xp7JV)UZy4@u{IY>`Tq&yW8Yj4(;5M5v{Ku6x9~;XLIp{pJR3 zkPvstlzx*c)0gXCYWejK(JZ1eDb~Ta(&sBTb;gL69W3Hh{Ib-%x%GEwD%EaJ7 zgxQy8NB6w6eoIrSgq6x&sFioo%=*d;_1@f6mortpEMj?Y*u>eptk-f=1%4|HVG(|* z(MDaOvR&L%%?4Q~7NNJTy-jEHdk=1^TySC*i_k6DSF-Wkg+A(ue`B>cYEv_dn7&Ze zePv>m33uKm%|laIME3qW+9PHur*c!L#r}A}A_$kgmkxYXHAE^o8f?9xe#PAypIF4* zXTRkpDcej(EROf3&?TlUqOMA4`}2ScF-Rq42;e^kV+phQ5sR1_JnYnxjXAgb@c&ZA zcB{v*h(If`uIn1^e%w^kn_qlc#P?}WlkK0rr}duJS&CgW^*|GgI5O|Wdy{WDTTupg zThg-42eSy{(m}QtOV+COkV@#i8YItgc?0 zeO{{%|1YJvTxcDOsE&R?7RC=VTc~RUwU6(~%eS6@h#1qZ_mPQcrP~)(so{(n|?L^O^Lx;YXr8~B; zh{281LR{5?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=H@qwllh_{kr3-{uHmDf~8sn)KqHW zu6*ISmA=CSsrju*A#nS~-KxHG?PExM#Pmj&=r$u~sB97?_SP(PpHz9Epp4_2+Ct&o zi{h60|EQ!9f>if=v}ba4%;|m!E6qjh5QHE+dNEOtE@X>op%4>hv zHko_w4(RlkS@xQE`$CaH~aHtkG2DhZAXH;!+gCx0J}0V} zm?9P-eX`GuXMaGfwC&T~8;C_nuSl2i1{Z#ecu|wkfLMe%Nk_&fQKNppJH}i2-4U?} z4_y_5GG`VYpRK}AMI?bsVb>&;Qg1bRd9_@$bDboeVmLJBG=bl;ZjGwQ$xxM}BoXV? z*d|sifx92lDrWUivS5|0iE$8+aI&cRbeK}pS*B@Zh!76nto%=jzKh8 zAGT0dyJyQkIdmES`PbeLO@g=2-ziOT?D8fIn}f};c34GNZ<($7XLQB$e`IvgIC1Fl zG^$W)(%h8&&pB42RQ~%t*a=+A^PXr>T8=Uh7Ein44BysDTxDbzCU*d_2)BdebgI3l z;=q@Wj5%?W<5QvUa1VO%i;h#oH_PVz5 zkxPXFVu^OJ>jc;I55uZj$ceVkpM9?opB%aAUA;1%%+Xp8en*e(h()+r_ZHXzFaDuH zuj2c0%L@tEpO#N3Ujz}ne-+8+MDJA-~qfS9jd*^2_ z2#zXjz_fz8WXpIMTKoVnyHiWAA{RnK<10P?_eo35S@AGS)=kYhGfGWUaJBXS0A!s7 AQ2+n{ literal 0 HcmV?d00001 From 1c93ea14b46b033fe77568edcbe270bf4c8a98ab Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 29 Aug 2024 01:58:10 +0100 Subject: [PATCH 06/72] misc changes --- binaries/cuprated/Cargo.toml | 4 ++-- binaries/cuprated/src/blockchain.rs | 25 +++++++++++---------- binaries/cuprated/src/config.rs | 20 +++++++++++++++++ binaries/cuprated/src/main.rs | 34 +++++++++++++++++++---------- consensus/src/transactions.rs | 2 +- 5 files changed, 58 insertions(+), 27 deletions(-) diff --git a/binaries/cuprated/Cargo.toml b/binaries/cuprated/Cargo.toml index c01e2cca..a04c0be2 100644 --- a/binaries/cuprated/Cargo.toml +++ b/binaries/cuprated/Cargo.toml @@ -30,7 +30,7 @@ tracing-subscriber = { workspace = true, features = ["default"] } #workspace = true [profile.dev] -panic = 'abort' +panic = "abort" [profile.release] -panic = 'abort' +panic = "abort" diff --git a/binaries/cuprated/src/blockchain.rs b/binaries/cuprated/src/blockchain.rs index c0b7e6ce..366f9620 100644 --- a/binaries/cuprated/src/blockchain.rs +++ b/binaries/cuprated/src/blockchain.rs @@ -2,28 +2,29 @@ //! //! Will contain the chain manager and syncer. -use crate::blockchain::manager::BlockchainManager; -use crate::blockchain::types::{ - ChainService, ConcreteBlockVerifierService, ConcreteTxVerifierService, - ConsensusBlockchainReadHandle, -}; +use tokio::sync::mpsc; +use tower::{Service, ServiceExt}; + use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; use cuprate_consensus::{generate_genesis_block, BlockChainContextService, ContextConfig}; use cuprate_cryptonight::cryptonight_hash_v0; -use cuprate_p2p::block_downloader::BlockDownloaderConfig; -use cuprate_p2p::NetworkInterface; +use cuprate_p2p::{block_downloader::BlockDownloaderConfig, NetworkInterface}; use cuprate_p2p_core::{ClearNet, Network}; -use cuprate_types::blockchain::{ - BlockchainReadRequest, BlockchainResponse, BlockchainWriteRequest, +use cuprate_types::{ + blockchain::{BlockchainReadRequest, BlockchainWriteRequest}, + VerifiedBlockInformation, }; -use cuprate_types::VerifiedBlockInformation; -use tokio::sync::mpsc; -use tower::{Service, ServiceExt}; mod manager; mod syncer; mod types; +use manager::BlockchainManager; +use types::{ + ChainService, ConcreteBlockVerifierService, ConcreteTxVerifierService, + ConsensusBlockchainReadHandle, +}; + pub async fn check_add_genesis( blockchain_read_handle: &mut BlockchainReadHandle, blockchain_write_handle: &mut BlockchainWriteHandle, diff --git a/binaries/cuprated/src/config.rs b/binaries/cuprated/src/config.rs index d613c1fc..1fd02f74 100644 --- a/binaries/cuprated/src/config.rs +++ b/binaries/cuprated/src/config.rs @@ -1 +1,21 @@ //! cuprated config + +use cuprate_blockchain::config::{ + Config as BlockchainConfig, ConfigBuilder as BlockchainConfigBuilder, +}; + +pub fn config() -> CupratedConfig { + // TODO: read config options from the conf files & cli args. + + CupratedConfig {} +} + +pub struct CupratedConfig { + // TODO: expose config options we want to allow changing. +} + +impl CupratedConfig { + pub fn blockchain_config(&self) -> BlockchainConfig { + BlockchainConfigBuilder::new().fast().build() + } +} diff --git a/binaries/cuprated/src/main.rs b/binaries/cuprated/src/main.rs index 5ccb8382..023c3a81 100644 --- a/binaries/cuprated/src/main.rs +++ b/binaries/cuprated/src/main.rs @@ -1,9 +1,11 @@ use crate::blockchain::check_add_genesis; +use crate::config::CupratedConfig; use clap::Parser; use cuprate_p2p::block_downloader::BlockDownloaderConfig; use cuprate_p2p::P2PConfig; use cuprate_p2p_core::Network; use std::time::Duration; +use tokio::runtime::Runtime; use tracing::Level; mod blockchain; @@ -12,22 +14,15 @@ mod p2p; mod rpc; mod txpool; -#[derive(Parser)] -struct Args {} fn main() { - let _args = Args::parse(); + let config = config::config(); - tracing_subscriber::fmt() - .with_max_level(Level::DEBUG) - .init(); + init_log(&config); let (mut bc_read_handle, mut bc_write_handle, _) = - cuprate_blockchain::service::init(cuprate_blockchain::config::Config::default()).unwrap(); + cuprate_blockchain::service::init(config.blockchain_config()).unwrap(); - let async_rt = tokio::runtime::Builder::new_multi_thread() - .enable_all() - .build() - .unwrap(); + let async_rt = init_tokio_rt(&config); async_rt.block_on(async move { check_add_genesis(&mut bc_read_handle, &mut bc_write_handle, &Network::Mainnet).await; @@ -62,6 +57,21 @@ fn main() { block_verifier, ); - tokio::time::sleep(Duration::MAX).await; + futures::future::pending::<()>().await; }); + + // TODO: add command handling. +} + +fn init_log(_config: &CupratedConfig) { + tracing_subscriber::fmt() + .with_max_level(Level::DEBUG) + .init(); +} + +fn init_tokio_rt(_config: &CupratedConfig) -> Runtime { + tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build() + .unwrap() } diff --git a/consensus/src/transactions.rs b/consensus/src/transactions.rs index 82d3100e..23f7a4d1 100644 --- a/consensus/src/transactions.rs +++ b/consensus/src/transactions.rs @@ -393,7 +393,7 @@ async fn verify_transactions_decoy_info( where D: Database + Clone + Sync + Send + 'static, { - if hf == HardFork::V1 { + if hf == HardFork::V1 || txs.is_empty() { return Ok(()); } From 05d0cf2295e759801a67f12f5e190c7d0dfc5fdf Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 29 Aug 2024 16:04:17 +0100 Subject: [PATCH 07/72] move more config values --- binaries/cuprated/src/blockchain.rs | 7 +++-- binaries/cuprated/src/config.rs | 41 +++++++++++++++++++++++++++++ binaries/cuprated/src/main.rs | 34 +++++++++--------------- binaries/cuprated/src/p2p.rs | 23 ---------------- 4 files changed, 58 insertions(+), 47 deletions(-) diff --git a/binaries/cuprated/src/blockchain.rs b/binaries/cuprated/src/blockchain.rs index 366f9620..e1f5765b 100644 --- a/binaries/cuprated/src/blockchain.rs +++ b/binaries/cuprated/src/blockchain.rs @@ -1,7 +1,6 @@ //! Blockchain //! //! Will contain the chain manager and syncer. - use tokio::sync::mpsc; use tower::{Service, ServiceExt}; @@ -25,11 +24,13 @@ use types::{ ConsensusBlockchainReadHandle, }; +/// Checks if the genesis block is in the blockchain and adds it if not. pub async fn check_add_genesis( blockchain_read_handle: &mut BlockchainReadHandle, blockchain_write_handle: &mut BlockchainWriteHandle, network: &Network, ) { + // Try to get the chain height, will fail if the genesis block is not in the DB. if blockchain_read_handle .ready() .await @@ -67,6 +68,7 @@ pub async fn check_add_genesis( .unwrap(); } +/// Initializes the consensus services. pub async fn init_consensus( blockchain_read_handle: BlockchainReadHandle, context_config: ContextConfig, @@ -92,13 +94,14 @@ pub async fn init_consensus( Ok((block_verifier_svc, tx_verifier_svc, ctx_service)) } +/// Initializes the blockchain manager task and syncer. pub fn init_blockchain_manager( clearnet_interface: NetworkInterface, - block_downloader_config: BlockDownloaderConfig, blockchain_write_handle: BlockchainWriteHandle, blockchain_read_handle: BlockchainReadHandle, blockchain_context_service: BlockChainContextService, block_verifier_service: ConcreteBlockVerifierService, + block_downloader_config: BlockDownloaderConfig, ) { let (batch_tx, batch_rx) = mpsc::channel(1); diff --git a/binaries/cuprated/src/config.rs b/binaries/cuprated/src/config.rs index 1fd02f74..c71c40c8 100644 --- a/binaries/cuprated/src/config.rs +++ b/binaries/cuprated/src/config.rs @@ -1,8 +1,12 @@ //! cuprated config +use std::time::Duration; use cuprate_blockchain::config::{ Config as BlockchainConfig, ConfigBuilder as BlockchainConfigBuilder, }; +use cuprate_consensus::ContextConfig; +use cuprate_p2p::{block_downloader::BlockDownloaderConfig, AddressBookConfig, P2PConfig}; +use cuprate_p2p_core::{ClearNet, Network}; pub fn config() -> CupratedConfig { // TODO: read config options from the conf files & cli args. @@ -18,4 +22,41 @@ impl CupratedConfig { pub fn blockchain_config(&self) -> BlockchainConfig { BlockchainConfigBuilder::new().fast().build() } + + pub fn clearnet_config(&self) -> P2PConfig { + P2PConfig { + network: Network::Mainnet, + outbound_connections: 64, + extra_outbound_connections: 0, + max_inbound_connections: 0, + gray_peers_percent: 0.7, + server_config: None, + p2p_port: 0, + rpc_port: 0, + address_book_config: AddressBookConfig { + max_white_list_length: 1000, + max_gray_list_length: 5000, + peer_store_file: "p2p_state.bin".into(), + peer_save_period: Duration::from_secs(60), + }, + } + } + + 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(45), + target_batch_size: 10_000_000, + initial_batch_size: 1, + } + } + + pub fn network(&self) -> Network { + Network::Mainnet + } + + pub fn context_config(&self) -> ContextConfig { + ContextConfig::main_net() + } } diff --git a/binaries/cuprated/src/main.rs b/binaries/cuprated/src/main.rs index 023c3a81..87fc7aa5 100644 --- a/binaries/cuprated/src/main.rs +++ b/binaries/cuprated/src/main.rs @@ -1,10 +1,3 @@ -use crate::blockchain::check_add_genesis; -use crate::config::CupratedConfig; -use clap::Parser; -use cuprate_p2p::block_downloader::BlockDownloaderConfig; -use cuprate_p2p::P2PConfig; -use cuprate_p2p_core::Network; -use std::time::Duration; use tokio::runtime::Runtime; use tracing::Level; @@ -14,6 +7,9 @@ mod p2p; mod rpc; mod txpool; +use blockchain::check_add_genesis; +use config::CupratedConfig; + fn main() { let config = config::config(); @@ -25,38 +21,32 @@ fn main() { let async_rt = init_tokio_rt(&config); async_rt.block_on(async move { - check_add_genesis(&mut bc_read_handle, &mut bc_write_handle, &Network::Mainnet).await; + 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(), - cuprate_consensus::ContextConfig::main_net(), - ) - .await - .unwrap(); + 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::P2pProtocolRequestHandler, p2p::core_sync_svc::CoreSyncService(context_svc.clone()), - p2p::dummy_config(), + config.clearnet_config(), ) .await .unwrap(); blockchain::init_blockchain_manager( net, - BlockDownloaderConfig { - buffer_size: 50_000_000, - in_progress_queue_size: 50_000_000, - check_client_pool_interval: Duration::from_secs(45), - target_batch_size: 10_000_000, - initial_batch_size: 1, - }, bc_write_handle, bc_read_handle, context_svc, block_verifier, + config.block_downloader_config(), ); + // TODO: this can be removed as long as the main thread does not exit, so when command handling + // is added futures::future::pending::<()>().await; }); diff --git a/binaries/cuprated/src/p2p.rs b/binaries/cuprated/src/p2p.rs index 0560320b..7715be7c 100644 --- a/binaries/cuprated/src/p2p.rs +++ b/binaries/cuprated/src/p2p.rs @@ -2,28 +2,5 @@ //! //! Will handle initiating the P2P and contains a protocol request handler. -use cuprate_p2p::AddressBookConfig; -use cuprate_p2p_core::Network; -use std::time::Duration; - pub mod core_sync_svc; pub mod request_handler; - -pub fn dummy_config() -> cuprate_p2p::P2PConfig { - cuprate_p2p::P2PConfig { - network: Network::Mainnet, - outbound_connections: 64, - extra_outbound_connections: 0, - max_inbound_connections: 0, - gray_peers_percent: 0.7, - server_config: None, - p2p_port: 0, - rpc_port: 0, - address_book_config: AddressBookConfig { - max_white_list_length: 1000, - max_gray_list_length: 5000, - peer_store_file: "p2p_state.bin".into(), - peer_save_period: Duration::from_secs(60), - }, - } -} From d6488719661f82461a24351ab41bfa2fcf3e2eb9 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 29 Aug 2024 18:44:34 +0100 Subject: [PATCH 08/72] add new tables & types --- storage/blockchain/src/lib.rs | 2 +- storage/blockchain/src/tables.rs | 25 ++++++-- storage/blockchain/src/types.rs | 101 ++++++++++++++++++++++++++++++- types/src/types.rs | 3 +- 4 files changed, 123 insertions(+), 8 deletions(-) diff --git a/storage/blockchain/src/lib.rs b/storage/blockchain/src/lib.rs index e544a69e..0dea345b 100644 --- a/storage/blockchain/src/lib.rs +++ b/storage/blockchain/src/lib.rs @@ -52,7 +52,7 @@ unused_crate_dependencies, unused_doc_comments, unused_mut, - missing_docs, + //missing_docs, deprecated, unused_comparisons, nonstandard_style diff --git a/storage/blockchain/src/tables.rs b/storage/blockchain/src/tables.rs index 122ac31b..6db76816 100644 --- a/storage/blockchain/src/tables.rs +++ b/storage/blockchain/src/tables.rs @@ -16,11 +16,7 @@ //! accessing _all_ tables defined here at once. //---------------------------------------------------------------------------------------------------- Import -use crate::types::{ - Amount, AmountIndex, AmountIndices, BlockBlob, BlockHash, BlockHeight, BlockInfo, KeyImage, - Output, PreRctOutputId, PrunableBlob, PrunableHash, PrunedBlob, RctOutput, TxBlob, TxHash, - TxId, UnlockTime, -}; +use crate::types::{Amount, AmountIndex, AmountIndices, BlockBlob, BlockHash, BlockHeight, BlockInfo, KeyImage, Output, PreRctOutputId, PrunableBlob, PrunableHash, PrunedBlob, RctOutput, TxBlob, TxHash, TxId, UnlockTime, RawChainId, AltChainInfo, AltBlockHeight, CompactAltBlockInfo, AltTransactionInfo}; //---------------------------------------------------------------------------------------------------- Tables // Notes: @@ -129,6 +125,25 @@ cuprate_database::define_tables! { /// Transactions without unlock times will not exist in this table. 14 => TxUnlockTime, TxId => UnlockTime, + + 15 => AltChainInfos, + RawChainId => AltChainInfo, + + 16 => AltBlockHeights, + BlockHash => AltBlockHeight, + + 17 => AltBlocksInfo, + AltBlockHeight => CompactAltBlockInfo, + + 18 => AltBlockBlobs, + AltBlockHeight => BlockBlob, + + 19 => AltTransactionBlobs, + TxHash => TxBlob, + + 20 => AltTransactionInfos, + TxHash => AltTransactionInfo, + } //---------------------------------------------------------------------------------------------------- Tests diff --git a/storage/blockchain/src/types.rs b/storage/blockchain/src/types.rs index eb1dc647..73c7614f 100644 --- a/storage/blockchain/src/types.rs +++ b/storage/blockchain/src/types.rs @@ -41,13 +41,15 @@ #![forbid(unsafe_code)] // if you remove this line i will steal your monero //---------------------------------------------------------------------------------------------------- Import +use std::num::NonZero; + use bytemuck::{Pod, Zeroable}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use cuprate_database::{Key, StorableVec}; - +use cuprate_types::{Chain, ChainId}; //---------------------------------------------------------------------------------------------------- Aliases // These type aliases exist as many Monero-related types are the exact same. // For clarity, they're given type aliases as to not confuse them. @@ -324,6 +326,103 @@ pub struct RctOutput { } // TODO: local_index? +//---------------------------------------------------------------------------------------------------- RawChain +#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] +#[repr(transparent)] +pub struct RawChain(u64); + +impl From for RawChain { + fn from(value: Chain) -> Self { + match value { + Chain::Main => RawChain(0), + Chain::Alt(chain_id) => RawChain(chain_id.0.get()), + } + } +} + +impl From for Chain { + fn from(value: RawChain) -> Self { + NonZero::new(value.0) + .map(|id| Chain::Alt(ChainId(id))) + .unwrap_or(Chain::Main) + } +} + +//---------------------------------------------------------------------------------------------------- RawChainId +#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] +#[repr(transparent)] +pub struct RawChainId(u64); + +impl From for RawChainId { + fn from(value: ChainId) -> Self { + RawChainId(value.0.get()) + } +} + +impl From for ChainId { + fn from(value: RawChainId) -> Self { + ChainId(NonZero::new(value.0).expect("RawChainId mut not have a value of `0`")) + } +} + +impl Key for RawChainId {} + +//---------------------------------------------------------------------------------------------------- AltChainInfo +#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] +#[repr(C)] +pub struct AltChainInfo { + parent_chain: RawChain, + common_ancestor_height: u64 +} + +//---------------------------------------------------------------------------------------------------- AltBlockHeight +#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] +#[repr(C)] +pub struct AltBlockHeight { + chain_id: u64, + height: u64, +} + +impl Key for AltBlockHeight {} + +//---------------------------------------------------------------------------------------------------- CompactAltBlockInfo +#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] +#[repr(C)] +pub struct CompactAltBlockInfo { + /// The block's hash. + /// + /// [`Block::hash`]. + pub block_hash: [u8; 32], + /// The block's proof-of-work hash. + pub pow_hash: [u8; 32], + /// The block's height. + pub height: u64, + /// The adjusted block size, in bytes. + pub weight: usize, + /// The long term block weight, which is the weight factored in with previous block weights. + pub long_term_weight: usize, + /// The cumulative difficulty of all blocks up until and including this block. + pub cumulative_difficulty_low: u64, + pub cumulative_difficulty_high: u64, + +} + +//---------------------------------------------------------------------------------------------------- AltTransactionInfo +#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] +#[repr(C)] +pub struct AltTransactionInfo { + /// The transaction's weight. + /// + /// [`Transaction::weight`]. + pub tx_weight: usize, + /// The transaction's total fees. + pub fee: u64, + /// The transaction's hash. + /// + /// [`Transaction::hash`]. + pub tx_hash: [u8; 32], +} + //---------------------------------------------------------------------------------------------------- Tests #[cfg(test)] mod test { diff --git a/types/src/types.rs b/types/src/types.rs index 4b6e2e12..da4422a1 100644 --- a/types/src/types.rs +++ b/types/src/types.rs @@ -1,5 +1,6 @@ //! Various shared data types in Cuprate. +use std::num::NonZero; //---------------------------------------------------------------------------------------------------- Import use curve25519_dalek::edwards::EdwardsPoint; use monero_serai::{ @@ -97,7 +98,7 @@ pub struct VerifiedBlockInformation { /// /// The inner value is meaningless. #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] -pub struct ChainId(pub u64); +pub struct ChainId(pub NonZero); //---------------------------------------------------------------------------------------------------- Chain /// An identifier for a chain. From e1ae84836911acab79fe3eb853725ca94fc4ff3e Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 30 Aug 2024 03:01:23 +0100 Subject: [PATCH 09/72] add function to fully add an alt block --- storage/blockchain/src/ops/alt_block.rs | 104 ++++++++++++++++++++++++ storage/blockchain/src/ops/mod.rs | 1 + storage/blockchain/src/tables.rs | 7 +- storage/blockchain/src/types.rs | 19 +++-- 4 files changed, 124 insertions(+), 7 deletions(-) create mode 100644 storage/blockchain/src/ops/alt_block.rs diff --git a/storage/blockchain/src/ops/alt_block.rs b/storage/blockchain/src/ops/alt_block.rs new file mode 100644 index 00000000..d04899ef --- /dev/null +++ b/storage/blockchain/src/ops/alt_block.rs @@ -0,0 +1,104 @@ +use bytemuck::TransparentWrapper; + +use cuprate_database::{DatabaseRw, RuntimeError, StorableVec, DatabaseRo}; +use cuprate_helper::map::split_u128_into_low_high_bits; +use cuprate_types::{AltBlockInformation, Chain, VerifiedTransactionInformation}; + +use crate::{ + tables::TablesMut, + types::{AltBlockHeight, AltChainInfo, AltTransactionInfo, BlockHash, CompactAltBlockInfo}, +}; + +pub fn add_alt_block( + alt_block: &AltBlockInformation, + tables: &mut impl TablesMut, +) -> Result<(), RuntimeError> { + let alt_block_height = AltBlockHeight { + chain_id: alt_block.chain_id.into(), + height: alt_block.height, + }; + + tables + .alt_block_heights_mut() + .put(&alt_block.block_hash, &alt_block_height)?; + + check_add_alt_chain_info(&alt_block_height, &alt_block.block.header.previous, tables)?; + + let (cumulative_difficulty_low, cumulative_difficulty_high) = + split_u128_into_low_high_bits(alt_block.cumulative_difficulty); + + let alt_block_info = CompactAltBlockInfo { + block_hash: alt_block.block_hash, + pow_hash: alt_block.pow_hash, + height: alt_block.height, + weight: alt_block.weight, + long_term_weight: alt_block.long_term_weight, + cumulative_difficulty_low, + cumulative_difficulty_high, + }; + + tables + .alt_blocks_info_mut() + .put(&alt_block_height, &alt_block_info)?; + + tables.alt_block_blobs_mut().put( + &alt_block_height, + StorableVec::wrap_ref(&alt_block.block_blob), + )?; + + for tx in &alt_block.txs { + add_alt_transaction(&tx, tables)?; + } + + Ok(()) +} + +pub fn add_alt_transaction( + tx: &VerifiedTransactionInformation, + tables: &mut impl TablesMut, +) -> Result<(), RuntimeError> { + if tables.tx_ids().get(&tx.tx_hash).is_ok() + || tables.alt_transaction_infos().get(&tx.tx_hash).is_ok() + { + return Ok(()); + } + + tables.alt_transaction_infos_mut().put( + &tx.tx_hash, + &AltTransactionInfo { + tx_weight: tx.tx_weight, + fee: tx.fee, + tx_hash: tx.tx_hash, + }, + )?; + + tables + .alt_transaction_blobs_mut() + .put(&tx.tx_hash, StorableVec::wrap_ref(&tx.tx_blob)) +} + +pub fn check_add_alt_chain_info( + alt_block_height: &AltBlockHeight, + prev_hash: &BlockHash, + tables: &mut impl TablesMut, +) -> Result<(), RuntimeError> { + match tables.alt_chain_infos().get(&alt_block_height.chain_id) { + Ok(_) => return Ok(()), + Err(RuntimeError::KeyNotFound) => (), + Err(e) => return Err(e), + } + + let parent_chain = match tables.alt_block_heights().get(prev_hash) { + Ok(alt_parent_height) => Chain::Alt(alt_parent_height.chain_id.into()), + Err(RuntimeError::KeyNotFound) => Chain::Main, + Err(e) => return Err(e), + }; + + tables.alt_chain_infos_mut().put( + &alt_block_height.chain_id, + &AltChainInfo { + parent_chain: parent_chain.into(), + common_ancestor_height: alt_block_height.height - 1, + }, + ) +} diff --git a/storage/blockchain/src/ops/mod.rs b/storage/blockchain/src/ops/mod.rs index 4ff7dff1..1ec9c237 100644 --- a/storage/blockchain/src/ops/mod.rs +++ b/storage/blockchain/src/ops/mod.rs @@ -108,5 +108,6 @@ pub mod key_image; pub mod output; pub mod property; pub mod tx; +pub mod alt_block; mod macros; diff --git a/storage/blockchain/src/tables.rs b/storage/blockchain/src/tables.rs index 6db76816..381430d7 100644 --- a/storage/blockchain/src/tables.rs +++ b/storage/blockchain/src/tables.rs @@ -16,7 +16,12 @@ //! accessing _all_ tables defined here at once. //---------------------------------------------------------------------------------------------------- Import -use crate::types::{Amount, AmountIndex, AmountIndices, BlockBlob, BlockHash, BlockHeight, BlockInfo, KeyImage, Output, PreRctOutputId, PrunableBlob, PrunableHash, PrunedBlob, RctOutput, TxBlob, TxHash, TxId, UnlockTime, RawChainId, AltChainInfo, AltBlockHeight, CompactAltBlockInfo, AltTransactionInfo}; +use crate::types::{ + AltBlockHeight, AltChainInfo, AltTransactionInfo, Amount, AmountIndex, AmountIndices, + BlockBlob, BlockHash, BlockHeight, BlockInfo, CompactAltBlockInfo, KeyImage, Output, + PreRctOutputId, PrunableBlob, PrunableHash, PrunedBlob, RawChainId, RctOutput, TxBlob, TxHash, + TxId, UnlockTime, +}; //---------------------------------------------------------------------------------------------------- Tables // Notes: diff --git a/storage/blockchain/src/types.rs b/storage/blockchain/src/types.rs index 73c7614f..88ece10b 100644 --- a/storage/blockchain/src/types.rs +++ b/storage/blockchain/src/types.rs @@ -348,6 +348,14 @@ impl From for Chain { } } +impl From for RawChain { + fn from(value: RawChainId) -> Self { + assert_ne!(value.0, 0); + + RawChain(value.0) + } +} + //---------------------------------------------------------------------------------------------------- RawChainId #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] #[repr(transparent)] @@ -371,16 +379,16 @@ impl Key for RawChainId {} #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] #[repr(C)] pub struct AltChainInfo { - parent_chain: RawChain, - common_ancestor_height: u64 + pub parent_chain: RawChain, + pub common_ancestor_height: usize, } //---------------------------------------------------------------------------------------------------- AltBlockHeight #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] #[repr(C)] pub struct AltBlockHeight { - chain_id: u64, - height: u64, + pub chain_id: RawChainId, + pub height: usize, } impl Key for AltBlockHeight {} @@ -396,7 +404,7 @@ pub struct CompactAltBlockInfo { /// The block's proof-of-work hash. pub pow_hash: [u8; 32], /// The block's height. - pub height: u64, + pub height: usize, /// The adjusted block size, in bytes. pub weight: usize, /// The long term block weight, which is the weight factored in with previous block weights. @@ -404,7 +412,6 @@ pub struct CompactAltBlockInfo { /// The cumulative difficulty of all blocks up until and including this block. pub cumulative_difficulty_low: u64, pub cumulative_difficulty_high: u64, - } //---------------------------------------------------------------------------------------------------- AltTransactionInfo From ed887a7c859d45fce68cbf4e70f56e4b46449492 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 30 Aug 2024 23:06:30 +0100 Subject: [PATCH 10/72] resolve current todo!s --- storage/blockchain/src/lib.rs | 2 + storage/blockchain/src/ops/alt_block.rs | 137 ++++++++++++++++++++++-- storage/blockchain/src/ops/block.rs | 10 +- storage/blockchain/src/ops/mod.rs | 2 +- storage/blockchain/src/service/read.rs | 43 +++++++- 5 files changed, 178 insertions(+), 16 deletions(-) diff --git a/storage/blockchain/src/lib.rs b/storage/blockchain/src/lib.rs index 0dea345b..8a6f96b6 100644 --- a/storage/blockchain/src/lib.rs +++ b/storage/blockchain/src/lib.rs @@ -98,6 +98,8 @@ clippy::too_many_lines ) )] +extern crate core; + // Only allow building 64-bit targets. // // This allows us to assume 64-bit diff --git a/storage/blockchain/src/ops/alt_block.rs b/storage/blockchain/src/ops/alt_block.rs index d04899ef..82a37ba8 100644 --- a/storage/blockchain/src/ops/alt_block.rs +++ b/storage/blockchain/src/ops/alt_block.rs @@ -1,12 +1,21 @@ -use bytemuck::TransparentWrapper; +use std::cmp::max; -use cuprate_database::{DatabaseRw, RuntimeError, StorableVec, DatabaseRo}; -use cuprate_helper::map::split_u128_into_low_high_bits; -use cuprate_types::{AltBlockInformation, Chain, VerifiedTransactionInformation}; +use bytemuck::TransparentWrapper; +use cuprate_database::{DatabaseRo, DatabaseRw, RuntimeError, StorableVec}; +use cuprate_helper::map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}; +use cuprate_types::{ + AltBlockInformation, Chain, ChainId, ExtendedBlockHeader, HardFork, + VerifiedTransactionInformation, +}; +use monero_serai::block::BlockHeader; use crate::{ - tables::TablesMut, - types::{AltBlockHeight, AltChainInfo, AltTransactionInfo, BlockHash, CompactAltBlockInfo}, + ops::block::{get_block_extended_header_from_height, get_block_info}, + tables::{Tables, TablesMut}, + types::{ + AltBlockHeight, AltChainInfo, AltTransactionInfo, BlockHash, BlockHeight, + CompactAltBlockInfo, + }, }; pub fn add_alt_block( @@ -102,3 +111,119 @@ pub fn check_add_alt_chain_info( }, ) } + +pub fn alt_block_hash( + block_height: &BlockHeight, + alt_chain: ChainId, + tables: &mut impl Tables, +) -> Result { + let alt_chains = tables.alt_chain_infos(); + + let original_chain = { + let mut chain = alt_chain.into(); + loop { + let chain_info = alt_chains.get(&chain)?; + + if chain_info.common_ancestor_height < *block_height { + break Chain::Alt(chain.into()); + } + + match chain_info.parent_chain.into() { + Chain::Main => break Chain::Main, + Chain::Alt(alt_chain_id) => { + chain = alt_chain_id.into(); + continue; + } + } + } + }; + + match original_chain { + Chain::Main => { + get_block_info(&block_height, tables.block_infos()).map(|info| info.block_hash) + } + Chain::Alt(chain_id) => tables + .alt_blocks_info() + .get(&AltBlockHeight { + chain_id: chain_id.into(), + height: *block_height, + }) + .map(|info| info.block_hash), + } +} + +pub fn alt_extended_headers_in_range( + range: std::ops::Range, + alt_chain: ChainId, + tables: &impl Tables, +) -> Result, RuntimeError> { + // TODO: this function does not use rayon, however it probably should. + + let mut ranges = Vec::with_capacity(5); + let alt_chains = tables.alt_chain_infos(); + + let mut i = range.end; + let mut current_chain_id = alt_chain.into(); + while i > range.start { + let chain_info = alt_chains.get(¤t_chain_id)?; + + let start_height = max(range.start, chain_info.common_ancestor_height + 1); + + ranges.push((chain_info.parent_chain.into(), start_height..i)); + i = chain_info.common_ancestor_height; + + match chain_info.parent_chain.into() { + Chain::Main => { + ranges.push((Chain::Main, range.start..i)); + break; + } + Chain::Alt(alt_chain_id) => { + current_chain_id = alt_chain_id.into(); + continue; + } + } + } + + let res = ranges + .into_iter() + .rev() + .map(|(chain, range)| { + range.into_iter().map(move |height| match chain { + Chain::Main => get_block_extended_header_from_height(&height, tables), + Chain::Alt(chain_id) => get_alt_block_extended_header_from_height( + &AltBlockHeight { + chain_id: chain_id.into(), + height, + }, + tables, + ), + }) + }) + .flatten() + .collect::>()?; + + Ok(res) +} + +pub fn get_alt_block_extended_header_from_height( + height: &AltBlockHeight, + table: &impl Tables, +) -> Result { + let block_info = table.alt_blocks_info().get(height)?; + + let block_blob = table.alt_block_blobs().get(height)?.0; + + let block_header = BlockHeader::read(&mut block_blob.as_slice())?; + + Ok(ExtendedBlockHeader { + version: HardFork::from_version(0).expect("Block in DB must have correct version"), + vote: block_header.hardfork_version, + timestamp: block_header.timestamp, + cumulative_difficulty: combine_low_high_bits_to_u128( + block_info.cumulative_difficulty_low, + block_info.cumulative_difficulty_high, + ), + block_weight: block_info.weight, + long_term_weight: block_info.long_term_weight, + }) +} diff --git a/storage/blockchain/src/ops/block.rs b/storage/blockchain/src/ops/block.rs index 4f77d736..2e110fed 100644 --- a/storage/blockchain/src/ops/block.rs +++ b/storage/blockchain/src/ops/block.rs @@ -2,7 +2,7 @@ //---------------------------------------------------------------------------------------------------- Import use bytemuck::TransparentWrapper; -use monero_serai::block::Block; +use monero_serai::block::{Block, BlockHeader}; use cuprate_database::{ RuntimeError, StorableVec, {DatabaseRo, DatabaseRw}, @@ -190,7 +190,7 @@ pub fn get_block_extended_header_from_height( ) -> Result { let block_info = tables.block_infos().get(block_height)?; let block_blob = tables.block_blobs().get(block_height)?.0; - let block = Block::read(&mut block_blob.as_slice())?; + let block_header = BlockHeader::read(&mut block_blob.as_slice())?; let cumulative_difficulty = combine_low_high_bits_to_u128( block_info.cumulative_difficulty_low, @@ -201,10 +201,10 @@ pub fn get_block_extended_header_from_height( #[allow(clippy::cast_possible_truncation)] Ok(ExtendedBlockHeader { cumulative_difficulty, - version: HardFork::from_version(block.header.hardfork_version) + version: HardFork::from_version(block_header.hardfork_version) .expect("Stored block must have a valid hard-fork"), - vote: block.header.hardfork_signal, - timestamp: block.header.timestamp, + vote: block_header.hardfork_signal, + timestamp: block_header.timestamp, block_weight: block_info.weight as usize, long_term_weight: block_info.long_term_weight as usize, }) diff --git a/storage/blockchain/src/ops/mod.rs b/storage/blockchain/src/ops/mod.rs index 1ec9c237..8a8f0f15 100644 --- a/storage/blockchain/src/ops/mod.rs +++ b/storage/blockchain/src/ops/mod.rs @@ -102,12 +102,12 @@ //! # Ok(()) } //! ``` +pub mod alt_block; pub mod block; pub mod blockchain; pub mod key_image; pub mod output; pub mod property; pub mod tx; -pub mod alt_block; mod macros; diff --git a/storage/blockchain/src/service/read.rs b/storage/blockchain/src/service/read.rs index 207da416..eef40b5e 100644 --- a/storage/blockchain/src/service/read.rs +++ b/storage/blockchain/src/service/read.rs @@ -22,6 +22,7 @@ use cuprate_types::{ use crate::{ ops::{ + alt_block::{alt_block_hash, alt_extended_headers_in_range}, block::{ block_exists, get_block_extended_header_from_height, get_block_height, get_block_info, }, @@ -33,7 +34,7 @@ use crate::{ free::{compact_history_genesis_not_included, compact_history_index_to_height_offset}, types::{BlockchainReadHandle, ResponseResult}, }, - tables::{BlockHeights, BlockInfos, OpenTables, Tables}, + tables::{AltBlockHeights, BlockHeights, BlockInfos, OpenTables, Tables}, types::{Amount, AmountIndex, BlockHash, BlockHeight, KeyImage, PreRctOutputId}, }; @@ -87,7 +88,7 @@ fn map_request( match request { R::BlockExtendedHeader(block) => block_extended_header(env, block), R::BlockHash(block, chain) => block_hash(env, block, chain), - R::FindBlock(_) => todo!("Add alt blocks to DB"), + R::FindBlock(block_hash) => find_block(env, block_hash), R::FilterUnknownHashes(hashes) => filter_unknown_hashes(env, hashes), R::BlockExtendedHeaderInRange(range, chain) => { block_extended_header_in_range(env, range, chain) @@ -198,12 +199,39 @@ fn block_hash(env: &ConcreteEnv, block_height: BlockHeight, chain: Chain) -> Res let block_hash = match chain { Chain::Main => get_block_info(&block_height, &table_block_infos)?.block_hash, - Chain::Alt(_) => todo!("Add alt blocks to DB"), + Chain::Alt(chain) => { + alt_block_hash(&block_height, chain, &mut env_inner.open_tables(&tx_ro)?)? + } }; Ok(BlockchainResponse::BlockHash(block_hash)) } +/// [`BlockchainReadRequest::FindBlock`] +fn find_block(env: &ConcreteEnv, block_hash: BlockHash) -> ResponseResult { + // Single-threaded, no `ThreadLocal` required. + let env_inner = env.env_inner(); + let tx_ro = env_inner.tx_ro()?; + + let table_block_heights = env_inner.open_db_ro::(&tx_ro)?; + + // Check the main chain first. + match table_block_heights.get(&block_hash) { + Ok(height) => return Ok(BlockchainResponse::FindBlock(Some((Chain::Main, height)))), + Err(RuntimeError::KeyNotFound) => (), + Err(e) => return Err(e), + } + + let table_alt_block_heights = env_inner.open_db_ro::(&tx_ro)?; + + let height = table_alt_block_heights.get(&block_hash)?; + + Ok(BlockchainResponse::FindBlock(Some(( + Chain::Alt(height.chain_id.into()), + height.height, + )))) +} + /// [`BlockchainReadRequest::FilterUnknownHashes`]. #[inline] fn filter_unknown_hashes(env: &ConcreteEnv, mut hashes: HashSet) -> ResponseResult { @@ -254,7 +282,14 @@ fn block_extended_header_in_range( get_block_extended_header_from_height(&block_height, tables) }) .collect::, RuntimeError>>()?, - Chain::Alt(_) => todo!("Add alt blocks to DB"), + Chain::Alt(chain_id) => { + let tx_ro = tx_ro.get_or_try(|| env_inner.tx_ro())?; + alt_extended_headers_in_range( + range, + chain_id, + get_tables!(env_inner, tx_ro, tables)?.as_ref(), + )? + } }; Ok(BlockchainResponse::BlockExtendedHeaderInRange(vec)) From bc619b61eb06d54647dbba14530ebba6e110697f Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sat, 31 Aug 2024 01:22:30 +0100 Subject: [PATCH 11/72] add new requests --- storage/blockchain/src/service/write.rs | 4 +++ types/src/blockchain.rs | 40 +++++++++++++++++++++---- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/storage/blockchain/src/service/write.rs b/storage/blockchain/src/service/write.rs index 816afc4f..a2cc71c7 100644 --- a/storage/blockchain/src/service/write.rs +++ b/storage/blockchain/src/service/write.rs @@ -29,6 +29,10 @@ fn handle_blockchain_request( ) -> Result { match req { BlockchainWriteRequest::WriteBlock(block) => write_block(env, block), + BlockchainWriteRequest::WriteAltBlock(_) => todo!(), + BlockchainWriteRequest::StartReorg(_) => todo!(), + BlockchainWriteRequest::ReverseReorg(_) => todo!(), + BlockchainWriteRequest::FlushAltBlocks => todo!(), } } diff --git a/types/src/blockchain.rs b/types/src/blockchain.rs index b502c3fa..48eab292 100644 --- a/types/src/blockchain.rs +++ b/types/src/blockchain.rs @@ -8,7 +8,7 @@ use std::{ collections::{HashMap, HashSet}, ops::Range, }; - +use crate::{AltBlockInformation, ChainId}; use crate::types::{Chain, ExtendedBlockHeader, OutputOnChain, VerifiedBlockInformation}; //---------------------------------------------------------------------------------------------------- ReadRequest @@ -112,6 +112,27 @@ pub enum BlockchainWriteRequest { /// /// Input is an already verified block. WriteBlock(VerifiedBlockInformation), + /// Write an alternative block to the database, + /// + /// Input is the alternative block. + WriteAltBlock(AltBlockInformation), + /// A request to start the re-org process. + /// + /// The inner value is the [`ChainId`] of the alt-chain we want to re-org to. + /// + /// This will: + /// - pop blocks from the main chain + /// - retrieve all alt-blocks in this alt-chain + /// - flush all other alt blocks + StartReorg(ChainId), + /// A request to reverse the re-org process. + /// + /// The inner value is the [`ChainId`] of the old main chain. + /// + /// It is invalid to call this with a [`ChainId`] that was not returned from [`BlockchainWriteRequest::StartReorg`]. + ReverseReorg(ChainId), + /// A request to flush all alternative blocks. + FlushAltBlocks, } //---------------------------------------------------------------------------------------------------- Response @@ -198,11 +219,20 @@ pub enum BlockchainResponse { FindFirstUnknown(Option<(usize, usize)>), //------------------------------------------------------ Writes - /// Response to [`BlockchainWriteRequest::WriteBlock`]. + /// A generic Ok response to indicate a request was successfully handled. /// - /// This response indicates that the requested block has - /// successfully been written to the database without error. - WriteBlockOk, + /// currently the response for: + /// - [`BlockchainWriteRequest::WriteBlock`] + /// - [`BlockchainWriteRequest::ReverseReorg`] + /// - [`BlockchainWriteRequest::FlushAltBlocks`] + Ok, + /// The response for [`BlockchainWriteRequest::StartReorg`]. + StartReorg { + /// The [`ChainId`] of the old main chain blocks that were popped. + old_main_chain_id: ChainId, + /// The next alt chain blocks. + alt_chain: Vec + }, } //---------------------------------------------------------------------------------------------------- Tests From 029f439f0b5e48230c34fb7598a2f7d4a149f11d Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sun, 1 Sep 2024 02:15:16 +0100 Subject: [PATCH 12/72] WIP: starting re-orgs --- .../ops/{alt_block.rs => alt_block/block.rs} | 130 ++++++------------ storage/blockchain/src/ops/alt_block/chain.rs | 63 +++++++++ storage/blockchain/src/ops/alt_block/mod.rs | 7 + storage/blockchain/src/ops/alt_block/tx.rs | 35 +++++ storage/blockchain/src/service/read.rs | 6 +- storage/blockchain/src/service/write.rs | 57 +++++++- storage/blockchain/src/tables.rs | 4 - types/src/blockchain.rs | 7 +- types/src/types.rs | 5 +- 9 files changed, 212 insertions(+), 102 deletions(-) rename storage/blockchain/src/ops/{alt_block.rs => alt_block/block.rs} (61%) create mode 100644 storage/blockchain/src/ops/alt_block/chain.rs create mode 100644 storage/blockchain/src/ops/alt_block/mod.rs create mode 100644 storage/blockchain/src/ops/alt_block/tx.rs diff --git a/storage/blockchain/src/ops/alt_block.rs b/storage/blockchain/src/ops/alt_block/block.rs similarity index 61% rename from storage/blockchain/src/ops/alt_block.rs rename to storage/blockchain/src/ops/alt_block/block.rs index 82a37ba8..171cdd7b 100644 --- a/storage/blockchain/src/ops/alt_block.rs +++ b/storage/blockchain/src/ops/alt_block/block.rs @@ -1,22 +1,20 @@ -use std::cmp::max; - +use crate::ops::alt_block::{ + add_alt_transaction_blob, check_add_alt_chain_info, get_alt_chain_history_ranges, + get_alt_transaction_blob, +}; +use crate::ops::block::{get_block_extended_header_from_height, get_block_info}; +use crate::tables::{Tables, TablesMut}; +use crate::types::{ + AltBlockHeight, AltTransactionInfo, BlockHash, BlockHeight, CompactAltBlockInfo, +}; use bytemuck::TransparentWrapper; -use cuprate_database::{DatabaseRo, DatabaseRw, RuntimeError, StorableVec}; +use cuprate_database::{RuntimeError, StorableVec}; use cuprate_helper::map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}; use cuprate_types::{ AltBlockInformation, Chain, ChainId, ExtendedBlockHeader, HardFork, VerifiedTransactionInformation, }; -use monero_serai::block::BlockHeader; - -use crate::{ - ops::block::{get_block_extended_header_from_height, get_block_info}, - tables::{Tables, TablesMut}, - types::{ - AltBlockHeight, AltChainInfo, AltTransactionInfo, BlockHash, BlockHeight, - CompactAltBlockInfo, - }, -}; +use monero_serai::block::{Block, BlockHeader}; pub fn add_alt_block( alt_block: &AltBlockInformation, @@ -55,64 +53,48 @@ pub fn add_alt_block( StorableVec::wrap_ref(&alt_block.block_blob), )?; - for tx in &alt_block.txs { - add_alt_transaction(&tx, tables)?; + assert_eq!(alt_block.txs.len(), alt_block.block.transactions.len()); + for (tx, tx_hash) in alt_block.txs.iter().zip(&alt_block.block.transactions) { + add_alt_transaction_blob(tx_hash, StorableVec::wrap_ref(tx), tables)?; } Ok(()) } -pub fn add_alt_transaction( - tx: &VerifiedTransactionInformation, - tables: &mut impl TablesMut, -) -> Result<(), RuntimeError> { - if tables.tx_ids().get(&tx.tx_hash).is_ok() - || tables.alt_transaction_infos().get(&tx.tx_hash).is_ok() - { - return Ok(()); - } - - tables.alt_transaction_infos_mut().put( - &tx.tx_hash, - &AltTransactionInfo { - tx_weight: tx.tx_weight, - fee: tx.fee, - tx_hash: tx.tx_hash, - }, - )?; - - tables - .alt_transaction_blobs_mut() - .put(&tx.tx_hash, StorableVec::wrap_ref(&tx.tx_blob)) -} - -pub fn check_add_alt_chain_info( +pub fn get_alt_block( alt_block_height: &AltBlockHeight, - prev_hash: &BlockHash, - tables: &mut impl TablesMut, -) -> Result<(), RuntimeError> { - match tables.alt_chain_infos().get(&alt_block_height.chain_id) { - Ok(_) => return Ok(()), - Err(RuntimeError::KeyNotFound) => (), - Err(e) => return Err(e), - } + tables: &impl Tables, +) -> Result { + let block_info = tables.alt_blocks_info().get(alt_block_height)?; - let parent_chain = match tables.alt_block_heights().get(prev_hash) { - Ok(alt_parent_height) => Chain::Alt(alt_parent_height.chain_id.into()), - Err(RuntimeError::KeyNotFound) => Chain::Main, - Err(e) => return Err(e), - }; + let block_blob = tables.alt_block_blobs().get(alt_block_height)?.0; - tables.alt_chain_infos_mut().put( - &alt_block_height.chain_id, - &AltChainInfo { - parent_chain: parent_chain.into(), - common_ancestor_height: alt_block_height.height - 1, - }, - ) + let block = Block::read(&mut block_blob.as_slice())?; + + let txs = block + .transactions + .iter() + .map(|tx_hash| get_alt_transaction_blob(tx_hash, tables)) + .collect()?; + + Ok(AltBlockInformation { + block, + block_blob, + txs, + block_hash: block_info.block_hash, + pow_hash: block_info.pow_hash, + height: block_info.height, + weight: block_info.weight, + long_term_weight: block_info.long_term_weight, + cumulative_difficulty: combine_low_high_bits_to_u128( + block_info.cumulative_difficulty_low, + block_info.cumulative_difficulty_high, + ), + chain_id: alt_block_height.chain_id.into(), + }) } -pub fn alt_block_hash( +pub fn get_alt_block_hash( block_height: &BlockHeight, alt_chain: ChainId, tables: &mut impl Tables, @@ -152,37 +134,15 @@ pub fn alt_block_hash( } } -pub fn alt_extended_headers_in_range( +pub fn get_alt_extended_headers_in_range( range: std::ops::Range, alt_chain: ChainId, tables: &impl Tables, ) -> Result, RuntimeError> { // TODO: this function does not use rayon, however it probably should. - let mut ranges = Vec::with_capacity(5); let alt_chains = tables.alt_chain_infos(); - - let mut i = range.end; - let mut current_chain_id = alt_chain.into(); - while i > range.start { - let chain_info = alt_chains.get(¤t_chain_id)?; - - let start_height = max(range.start, chain_info.common_ancestor_height + 1); - - ranges.push((chain_info.parent_chain.into(), start_height..i)); - i = chain_info.common_ancestor_height; - - match chain_info.parent_chain.into() { - Chain::Main => { - ranges.push((Chain::Main, range.start..i)); - break; - } - Chain::Alt(alt_chain_id) => { - current_chain_id = alt_chain_id.into(); - continue; - } - } - } + let ranges = get_alt_chain_history_ranges(range, alt_chain, alt_chains)?; let res = ranges .into_iter() diff --git a/storage/blockchain/src/ops/alt_block/chain.rs b/storage/blockchain/src/ops/alt_block/chain.rs new file mode 100644 index 00000000..4259d4dc --- /dev/null +++ b/storage/blockchain/src/ops/alt_block/chain.rs @@ -0,0 +1,63 @@ +use crate::tables::{AltChainInfos, TablesMut}; +use crate::types::{AltBlockHeight, AltChainInfo, BlockHash, BlockHeight}; +use cuprate_database::{DatabaseRo, RuntimeError}; +use cuprate_types::{Chain, ChainId}; +use std::cmp::max; + +pub fn check_add_alt_chain_info( + alt_block_height: &AltBlockHeight, + prev_hash: &BlockHash, + tables: &mut impl TablesMut, +) -> Result<(), RuntimeError> { + match tables.alt_chain_infos().get(&alt_block_height.chain_id) { + Ok(_) => return Ok(()), + Err(RuntimeError::KeyNotFound) => (), + Err(e) => return Err(e), + } + + let parent_chain = match tables.alt_block_heights().get(prev_hash) { + Ok(alt_parent_height) => Chain::Alt(alt_parent_height.chain_id.into()), + Err(RuntimeError::KeyNotFound) => Chain::Main, + Err(e) => return Err(e), + }; + + tables.alt_chain_infos_mut().put( + &alt_block_height.chain_id, + &AltChainInfo { + parent_chain: parent_chain.into(), + common_ancestor_height: alt_block_height.height - 1, + }, + ) +} + +pub fn get_alt_chain_history_ranges( + range: std::ops::Range, + alt_chain: ChainId, + alt_chain_infos: &impl DatabaseRo, +) -> Result)>, RuntimeError> { + let mut ranges = Vec::with_capacity(5); + + let mut i = range.end; + let mut current_chain_id = alt_chain.into(); + while i > range.start { + let chain_info = alt_chain_infos.get(¤t_chain_id)?; + + let start_height = max(range.start, chain_info.common_ancestor_height + 1); + + ranges.push((chain_info.parent_chain.into(), start_height..i)); + i = chain_info.common_ancestor_height; + + match chain_info.parent_chain.into() { + Chain::Main => { + ranges.push((Chain::Main, range.start..i)); + break; + } + Chain::Alt(alt_chain_id) => { + current_chain_id = alt_chain_id.into(); + continue; + } + } + } + + Ok(ranges) +} diff --git a/storage/blockchain/src/ops/alt_block/mod.rs b/storage/blockchain/src/ops/alt_block/mod.rs new file mode 100644 index 00000000..8b2d1f17 --- /dev/null +++ b/storage/blockchain/src/ops/alt_block/mod.rs @@ -0,0 +1,7 @@ +mod block; +mod chain; +mod tx; + +pub use block::*; +pub use chain::*; +pub use tx::*; diff --git a/storage/blockchain/src/ops/alt_block/tx.rs b/storage/blockchain/src/ops/alt_block/tx.rs new file mode 100644 index 00000000..aad4dc3d --- /dev/null +++ b/storage/blockchain/src/ops/alt_block/tx.rs @@ -0,0 +1,35 @@ +use crate::tables::{Tables, TablesMut}; +use crate::types::{AltTransactionInfo, TxHash}; +use bytemuck::TransparentWrapper; +use cuprate_database::{RuntimeError, StorableVec}; +use cuprate_types::VerifiedTransactionInformation; + +pub fn add_alt_transaction_blob( + tx_hash: &TxHash, + tx_block: &StorableVec, + tables: &mut impl TablesMut, +) -> Result<(), RuntimeError> { + if tables.tx_ids().get(&tx_hash).is_ok() || tables.alt_transaction_blobs().get(&tx_hash).is_ok() + { + return Ok(()); + } + + tables.alt_transaction_blobs_mut().put(&tx_hash, tx_block) +} + +pub fn get_alt_transaction_blob( + tx_hash: &TxHash, + tables: &impl Tables, +) -> Result, RuntimeError> { + match tables.alt_transaction_blobs().get(tx_hash) { + Ok(blob) => Ok(blob.0), + Err(RuntimeError::KeyNotFound) => { + let tx_id = tables.tx_ids().get(tx_hash)?; + + let blob = tables.tx_blobs().get(&tx_id)?; + + Ok(blob.0) + } + Err(e) => return Err(e), + } +} diff --git a/storage/blockchain/src/service/read.rs b/storage/blockchain/src/service/read.rs index eef40b5e..70da01b3 100644 --- a/storage/blockchain/src/service/read.rs +++ b/storage/blockchain/src/service/read.rs @@ -22,7 +22,7 @@ use cuprate_types::{ use crate::{ ops::{ - alt_block::{alt_block_hash, alt_extended_headers_in_range}, + alt_block::{get_alt_block_hash, get_alt_extended_headers_in_range}, block::{ block_exists, get_block_extended_header_from_height, get_block_height, get_block_info, }, @@ -200,7 +200,7 @@ fn block_hash(env: &ConcreteEnv, block_height: BlockHeight, chain: Chain) -> Res let block_hash = match chain { Chain::Main => get_block_info(&block_height, &table_block_infos)?.block_hash, Chain::Alt(chain) => { - alt_block_hash(&block_height, chain, &mut env_inner.open_tables(&tx_ro)?)? + get_alt_block_hash(&block_height, chain, &mut env_inner.open_tables(&tx_ro)?)? } }; @@ -284,7 +284,7 @@ fn block_extended_header_in_range( .collect::, RuntimeError>>()?, Chain::Alt(chain_id) => { let tx_ro = tx_ro.get_or_try(|| env_inner.tx_ro())?; - alt_extended_headers_in_range( + get_alt_extended_headers_in_range( range, chain_id, get_tables!(env_inner, tx_ro, tables)?.as_ref(), diff --git a/storage/blockchain/src/service/write.rs b/storage/blockchain/src/service/write.rs index a2cc71c7..067ba7f1 100644 --- a/storage/blockchain/src/service/write.rs +++ b/storage/blockchain/src/service/write.rs @@ -7,7 +7,7 @@ use cuprate_database::{ConcreteEnv, Env, EnvInner, RuntimeError, TxRw}; use cuprate_database_service::DatabaseWriteHandle; use cuprate_types::{ blockchain::{BlockchainResponse, BlockchainWriteRequest}, - VerifiedBlockInformation, + AltBlockInformation, VerifiedBlockInformation, }; use crate::{ @@ -29,10 +29,10 @@ fn handle_blockchain_request( ) -> Result { match req { BlockchainWriteRequest::WriteBlock(block) => write_block(env, block), - BlockchainWriteRequest::WriteAltBlock(_) => todo!(), + BlockchainWriteRequest::WriteAltBlock(alt_block) => write_alt_block(env, alt_block), BlockchainWriteRequest::StartReorg(_) => todo!(), BlockchainWriteRequest::ReverseReorg(_) => todo!(), - BlockchainWriteRequest::FlushAltBlocks => todo!(), + BlockchainWriteRequest::FlushAltBlocks => flush_alt_blocks(env), } } @@ -59,7 +59,56 @@ fn write_block(env: &ConcreteEnv, block: &VerifiedBlockInformation) -> ResponseR match result { Ok(()) => { TxRw::commit(tx_rw)?; - Ok(BlockchainResponse::WriteBlockOk) + Ok(BlockchainResponse::Ok) + } + Err(e) => { + // INVARIANT: ensure database atomicity by aborting + // the transaction on `add_block()` failures. + TxRw::abort(tx_rw) + .expect("could not maintain database atomicity by aborting write transaction"); + Err(e) + } + } +} + +/// [`BlockchainWriteRequest::WriteAltBlock`]. +#[inline] +fn write_alt_block(env: &ConcreteEnv, block: &AltBlockInformation) -> ResponseResult { + let env_inner = env.env_inner(); + let tx_rw = env_inner.tx_rw()?; + + let result = { + let mut tables_mut = env_inner.open_tables_mut(&tx_rw)?; + crate::ops::alt_block::add_alt_block(block, &mut tables_mut) + }; + + match result { + Ok(()) => { + TxRw::commit(tx_rw)?; + Ok(BlockchainResponse::Ok) + } + Err(e) => { + // INVARIANT: ensure database atomicity by aborting + // the transaction on `add_block()` failures. + TxRw::abort(tx_rw) + .expect("could not maintain database atomicity by aborting write transaction"); + Err(e) + } + } +} + +/// [`BlockchainWriteRequest::FlushAltBlocks`]. +#[inline] +fn flush_alt_blocks(env: &ConcreteEnv) -> ResponseResult { + let env_inner = env.env_inner(); + let mut tx_rw = env_inner.tx_rw()?; + + let result = { crate::ops::alt_block::flush_alt_blocks(&env_inner, &mut tx_rw) }; + + match result { + Ok(()) => { + TxRw::commit(tx_rw)?; + Ok(BlockchainResponse::Ok) } Err(e) => { // INVARIANT: ensure database atomicity by aborting diff --git a/storage/blockchain/src/tables.rs b/storage/blockchain/src/tables.rs index 381430d7..deb957ea 100644 --- a/storage/blockchain/src/tables.rs +++ b/storage/blockchain/src/tables.rs @@ -145,10 +145,6 @@ cuprate_database::define_tables! { 19 => AltTransactionBlobs, TxHash => TxBlob, - - 20 => AltTransactionInfos, - TxHash => AltTransactionInfo, - } //---------------------------------------------------------------------------------------------------- Tests diff --git a/types/src/blockchain.rs b/types/src/blockchain.rs index 48eab292..33c3e8bd 100644 --- a/types/src/blockchain.rs +++ b/types/src/blockchain.rs @@ -4,12 +4,12 @@ //! responses are also tested in Cuprate's blockchain database crate. //---------------------------------------------------------------------------------------------------- Import +use crate::types::{Chain, ExtendedBlockHeader, OutputOnChain, VerifiedBlockInformation}; +use crate::{AltBlockInformation, ChainId}; use std::{ collections::{HashMap, HashSet}, ops::Range, }; -use crate::{AltBlockInformation, ChainId}; -use crate::types::{Chain, ExtendedBlockHeader, OutputOnChain, VerifiedBlockInformation}; //---------------------------------------------------------------------------------------------------- ReadRequest /// A read request to the blockchain database. @@ -223,6 +223,7 @@ pub enum BlockchainResponse { /// /// currently the response for: /// - [`BlockchainWriteRequest::WriteBlock`] + /// - [`BlockchainWriteRequest::WriteAltBlock`] /// - [`BlockchainWriteRequest::ReverseReorg`] /// - [`BlockchainWriteRequest::FlushAltBlocks`] Ok, @@ -231,7 +232,7 @@ pub enum BlockchainResponse { /// The [`ChainId`] of the old main chain blocks that were popped. old_main_chain_id: ChainId, /// The next alt chain blocks. - alt_chain: Vec + alt_chain: Vec, }, } diff --git a/types/src/types.rs b/types/src/types.rs index da4422a1..cc4543e6 100644 --- a/types/src/types.rs +++ b/types/src/types.rs @@ -39,8 +39,7 @@ pub struct ExtendedBlockHeader { //---------------------------------------------------------------------------------------------------- VerifiedTransactionInformation /// Verified information of a transaction. /// -/// - If this is in a [`VerifiedBlockInformation`] this represents a valid transaction -/// - If this is in an [`AltBlockInformation`] this represents a potentially valid transaction +/// This represents a valid transaction #[derive(Clone, Debug, PartialEq, Eq)] pub struct VerifiedTransactionInformation { /// The transaction itself. @@ -121,7 +120,7 @@ pub struct AltBlockInformation { /// [`Block::serialize`]. pub block_blob: Vec, /// All the transactions in the block, excluding the [`Block::miner_transaction`]. - pub txs: Vec, + pub txs: Vec>, /// The block's hash. /// /// [`Block::hash`]. From 6927b05f81c0de3a82a406d11ff365bb3a4aa826 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 6 Sep 2024 00:23:55 +0100 Subject: [PATCH 13/72] add last service request --- Cargo.lock | 1 + storage/blockchain/Cargo.toml | 3 +- storage/blockchain/src/free.rs | 32 +++++ storage/blockchain/src/ops/alt_block/block.rs | 21 ++-- storage/blockchain/src/ops/alt_block/chain.rs | 3 +- storage/blockchain/src/ops/alt_block/mod.rs | 17 +++ storage/blockchain/src/ops/alt_block/tx.rs | 44 +++++-- storage/blockchain/src/ops/block.rs | 61 ++++++--- storage/blockchain/src/service/free.rs | 37 +++++- storage/blockchain/src/service/write.rs | 118 +++++++++++++++++- storage/blockchain/src/tables.rs | 3 + storage/blockchain/src/types.rs | 5 +- types/src/blockchain.rs | 24 ++-- types/src/types.rs | 3 +- 14 files changed, 306 insertions(+), 66 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 77531897..d5d64902 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -531,6 +531,7 @@ dependencies = [ "monero-serai", "pretty_assertions", "proptest", + "rand", "rayon", "serde", "tempfile", diff --git a/storage/blockchain/Cargo.toml b/storage/blockchain/Cargo.toml index 7e79305a..b03ef038 100644 --- a/storage/blockchain/Cargo.toml +++ b/storage/blockchain/Cargo.toml @@ -25,11 +25,12 @@ cuprate-database = { path = "../database" } cuprate-database-service = { path = "../service" } cuprate-helper = { path = "../../helper", features = ["fs", "thread", "map"] } cuprate-types = { path = "../../types", features = ["blockchain"] } +cuprate-pruning = { path = "../../pruning" } bitflags = { workspace = true, features = ["std", "serde", "bytemuck"] } bytemuck = { workspace = true, features = ["must_cast", "derive", "min_const_generics", "extern_crate_alloc"] } curve25519-dalek = { workspace = true } -cuprate-pruning = { path = "../../pruning" } +rand = { workspace = true } monero-serai = { workspace = true, features = ["std"] } serde = { workspace = true, optional = true } diff --git a/storage/blockchain/src/free.rs b/storage/blockchain/src/free.rs index 8288e65f..20d56226 100644 --- a/storage/blockchain/src/free.rs +++ b/storage/blockchain/src/free.rs @@ -1,5 +1,6 @@ //! General free functions (related to the database). +use monero_serai::transaction::{Input, Transaction}; //---------------------------------------------------------------------------------------------------- Import use cuprate_database::{ConcreteEnv, Env, EnvInner, InitError, RuntimeError, TxRw}; @@ -61,6 +62,37 @@ pub fn open(config: Config) -> Result { Ok(env) } +//---------------------------------------------------------------------------------------------------- Tx Fee +/// Calculates the fee of the [`Transaction`]. +/// +/// # Panics +/// This will panic if the inputs overflow or the transaction outputs too much. +pub(crate) fn tx_fee(tx: &Transaction) -> u64 { + let mut fee = 0_u64; + + match &tx { + Transaction::V1 { prefix, .. } => { + for input in &prefix.inputs { + match input { + Input::Gen(_) => return 0, + Input::ToKey { amount, .. } => { + fee = fee.checked_add(amount.unwrap_or(0)).unwrap(); + } + } + } + + for output in &prefix.outputs { + fee.checked_sub(output.amount.unwrap_or(0)).unwrap(); + } + } + Transaction::V2 { proofs, .. } => { + fee = proofs.as_ref().unwrap().base.fee; + } + }; + + fee +} + //---------------------------------------------------------------------------------------------------- Tests #[cfg(test)] mod test { diff --git a/storage/blockchain/src/ops/alt_block/block.rs b/storage/blockchain/src/ops/alt_block/block.rs index 171cdd7b..a429eab8 100644 --- a/storage/blockchain/src/ops/alt_block/block.rs +++ b/storage/blockchain/src/ops/alt_block/block.rs @@ -1,19 +1,14 @@ use crate::ops::alt_block::{ add_alt_transaction_blob, check_add_alt_chain_info, get_alt_chain_history_ranges, - get_alt_transaction_blob, + get_alt_transaction, }; use crate::ops::block::{get_block_extended_header_from_height, get_block_info}; use crate::tables::{Tables, TablesMut}; -use crate::types::{ - AltBlockHeight, AltTransactionInfo, BlockHash, BlockHeight, CompactAltBlockInfo, -}; +use crate::types::{AltBlockHeight, BlockHash, BlockHeight, CompactAltBlockInfo}; use bytemuck::TransparentWrapper; -use cuprate_database::{RuntimeError, StorableVec}; +use cuprate_database::{DatabaseRo, DatabaseRw, RuntimeError, StorableVec}; use cuprate_helper::map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}; -use cuprate_types::{ - AltBlockInformation, Chain, ChainId, ExtendedBlockHeader, HardFork, - VerifiedTransactionInformation, -}; +use cuprate_types::{AltBlockInformation, Chain, ChainId, ExtendedBlockHeader, HardFork}; use monero_serai::block::{Block, BlockHeader}; pub fn add_alt_block( @@ -54,8 +49,8 @@ pub fn add_alt_block( )?; assert_eq!(alt_block.txs.len(), alt_block.block.transactions.len()); - for (tx, tx_hash) in alt_block.txs.iter().zip(&alt_block.block.transactions) { - add_alt_transaction_blob(tx_hash, StorableVec::wrap_ref(tx), tables)?; + for tx in alt_block.txs.iter() { + add_alt_transaction_blob(tx, tables)?; } Ok(()) @@ -74,8 +69,8 @@ pub fn get_alt_block( let txs = block .transactions .iter() - .map(|tx_hash| get_alt_transaction_blob(tx_hash, tables)) - .collect()?; + .map(|tx_hash| get_alt_transaction(tx_hash, tables)) + .collect::>()?; Ok(AltBlockInformation { block, diff --git a/storage/blockchain/src/ops/alt_block/chain.rs b/storage/blockchain/src/ops/alt_block/chain.rs index 4259d4dc..1162a9cd 100644 --- a/storage/blockchain/src/ops/alt_block/chain.rs +++ b/storage/blockchain/src/ops/alt_block/chain.rs @@ -1,6 +1,6 @@ use crate::tables::{AltChainInfos, TablesMut}; use crate::types::{AltBlockHeight, AltChainInfo, BlockHash, BlockHeight}; -use cuprate_database::{DatabaseRo, RuntimeError}; +use cuprate_database::{DatabaseRo, DatabaseRw, RuntimeError}; use cuprate_types::{Chain, ChainId}; use std::cmp::max; @@ -26,6 +26,7 @@ pub fn check_add_alt_chain_info( &AltChainInfo { parent_chain: parent_chain.into(), common_ancestor_height: alt_block_height.height - 1, + chain_height: alt_block_height.height, }, ) } diff --git a/storage/blockchain/src/ops/alt_block/mod.rs b/storage/blockchain/src/ops/alt_block/mod.rs index 8b2d1f17..72e0933e 100644 --- a/storage/blockchain/src/ops/alt_block/mod.rs +++ b/storage/blockchain/src/ops/alt_block/mod.rs @@ -5,3 +5,20 @@ mod tx; pub use block::*; pub use chain::*; pub use tx::*; + +pub fn flush_alt_blocks<'a, E: cuprate_database::EnvInner<'a>>( + env_inner: &E, + tx_rw: &mut E::Rw<'_>, +) -> Result<(), cuprate_database::RuntimeError> { + use crate::tables::{ + AltBlockBlobs, AltBlockHeights, AltBlocksInfo, AltChainInfos, AltTransactionBlobs, + AltTransactionInfos, + }; + + env_inner.clear_db::(tx_rw)?; + env_inner.clear_db::(tx_rw)?; + env_inner.clear_db::(tx_rw)?; + env_inner.clear_db::(tx_rw)?; + env_inner.clear_db::(tx_rw)?; + env_inner.clear_db::(tx_rw) +} diff --git a/storage/blockchain/src/ops/alt_block/tx.rs b/storage/blockchain/src/ops/alt_block/tx.rs index aad4dc3d..a49c72ae 100644 --- a/storage/blockchain/src/ops/alt_block/tx.rs +++ b/storage/blockchain/src/ops/alt_block/tx.rs @@ -1,35 +1,57 @@ use crate::tables::{Tables, TablesMut}; use crate::types::{AltTransactionInfo, TxHash}; use bytemuck::TransparentWrapper; -use cuprate_database::{RuntimeError, StorableVec}; +use cuprate_database::{DatabaseRo, DatabaseRw, RuntimeError, StorableVec}; use cuprate_types::VerifiedTransactionInformation; +use monero_serai::transaction::Transaction; pub fn add_alt_transaction_blob( - tx_hash: &TxHash, - tx_block: &StorableVec, + tx: &VerifiedTransactionInformation, tables: &mut impl TablesMut, ) -> Result<(), RuntimeError> { - if tables.tx_ids().get(&tx_hash).is_ok() || tables.alt_transaction_blobs().get(&tx_hash).is_ok() + tables.alt_transaction_infos_mut().put( + &tx.tx_hash, + &AltTransactionInfo { + tx_weight: tx.tx_weight, + fee: tx.fee, + tx_hash: tx.tx_hash, + }, + )?; + + if tables.tx_ids().get(&tx.tx_hash).is_ok() + || tables.alt_transaction_blobs().get(&tx.tx_hash).is_ok() { return Ok(()); } - tables.alt_transaction_blobs_mut().put(&tx_hash, tx_block) + tables + .alt_transaction_blobs_mut() + .put(&tx.tx_hash, StorableVec::wrap_ref(&tx.tx_blob)) } -pub fn get_alt_transaction_blob( +pub fn get_alt_transaction( tx_hash: &TxHash, tables: &impl Tables, -) -> Result, RuntimeError> { - match tables.alt_transaction_blobs().get(tx_hash) { - Ok(blob) => Ok(blob.0), +) -> Result { + let tx_info = tables.alt_transaction_infos().get(tx_hash)?; + + let tx_blob = match tables.alt_transaction_blobs().get(tx_hash) { + Ok(blob) => blob.0, Err(RuntimeError::KeyNotFound) => { let tx_id = tables.tx_ids().get(tx_hash)?; let blob = tables.tx_blobs().get(&tx_id)?; - Ok(blob.0) + blob.0 } Err(e) => return Err(e), - } + }; + + Ok(VerifiedTransactionInformation { + tx: Transaction::read(&mut tx_blob.as_slice()).unwrap(), + tx_blob, + tx_weight: tx_info.tx_weight, + fee: tx_info.fee, + tx_hash: tx_info.tx_hash, + }) } diff --git a/storage/blockchain/src/ops/block.rs b/storage/blockchain/src/ops/block.rs index 2e110fed..5cb3b4bc 100644 --- a/storage/blockchain/src/ops/block.rs +++ b/storage/blockchain/src/ops/block.rs @@ -8,8 +8,13 @@ use cuprate_database::{ RuntimeError, StorableVec, {DatabaseRo, DatabaseRw}, }; use cuprate_helper::map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}; -use cuprate_types::{ExtendedBlockHeader, HardFork, VerifiedBlockInformation}; +use cuprate_types::{ + AltBlockInformation, ChainId, ExtendedBlockHeader, HardFork, VerifiedBlockInformation, + VerifiedTransactionInformation, +}; +use crate::free::tx_fee; +use crate::ops::alt_block; use crate::{ ops::{ blockchain::{chain_height, cumulative_generated_coins}, @@ -106,9 +111,8 @@ pub fn add_block( cumulative_rct_outs, timestamp: block.block.header.timestamp, block_hash: block.block_hash, - // INVARIANT: #[cfg] @ lib.rs asserts `usize == u64` - weight: block.weight as u64, - long_term_weight: block.long_term_weight as u64, + weight: block.weight, + long_term_weight: block.long_term_weight, }, )?; @@ -135,17 +139,15 @@ pub fn add_block( /// will be returned if there are no blocks left. // no inline, too big pub fn pop_block( + move_to_alt_chain: Option, tables: &mut impl TablesMut, ) -> Result<(BlockHeight, BlockHash, Block), RuntimeError> { //------------------------------------------------------ Block Info // Remove block data from tables. - let (block_height, block_hash) = { - let (block_height, block_info) = tables.block_infos_mut().pop_last()?; - (block_height, block_info.block_hash) - }; + let (block_height, block_info) = tables.block_infos_mut().pop_last()?; // Block heights. - tables.block_heights_mut().delete(&block_hash)?; + tables.block_heights_mut().delete(&block_info.block_hash)?; // Block blobs. // We deserialize the block blob into a `Block`, such @@ -154,12 +156,42 @@ pub fn pop_block( let block = Block::read(&mut block_blob.as_slice())?; //------------------------------------------------------ Transaction / Outputs / Key Images + let mut txs = Vec::with_capacity(block.transactions.len()); + remove_tx(&block.miner_transaction.hash(), tables)?; for tx_hash in &block.transactions { - remove_tx(tx_hash, tables)?; + let (_, tx) = remove_tx(tx_hash, tables)?; + + if move_to_alt_chain.is_some() { + txs.push(VerifiedTransactionInformation { + tx_weight: tx.weight(), + tx_blob: tx.serialize(), + tx_hash: tx.hash(), + fee: tx_fee(&tx), + tx, + }) + } } - Ok((block_height, block_hash, block)) + if let Some(chain_id) = move_to_alt_chain { + alt_block::add_alt_block( + &AltBlockInformation { + block: block.clone(), + block_blob, + txs, + block_hash: block_info.block_hash, + pow_hash: [255; 32], + height: block_height, + weight: block_info.weight, + long_term_weight: block_info.long_term_weight, + cumulative_difficulty: 0, + chain_id, + }, + tables, + )?; + } + + Ok((block_height, block_info.block_hash, block)) } //---------------------------------------------------------------------------------------------------- `get_block_extended_header_*` @@ -205,8 +237,8 @@ pub fn get_block_extended_header_from_height( .expect("Stored block must have a valid hard-fork"), vote: block_header.hardfork_signal, timestamp: block_header.timestamp, - block_weight: block_info.weight as usize, - long_term_weight: block_info.long_term_weight as usize, + block_weight: block_info.weight, + long_term_weight: block_info.long_term_weight, }) } @@ -412,7 +444,8 @@ mod test { for block_hash in block_hashes.into_iter().rev() { println!("pop_block(): block_hash: {}", hex::encode(block_hash)); - let (_popped_height, popped_hash, _popped_block) = pop_block(&mut tables).unwrap(); + let (_popped_height, popped_hash, _popped_block) = + pop_block(None, &mut tables).unwrap(); assert_eq!(block_hash, popped_hash); diff --git a/storage/blockchain/src/service/free.rs b/storage/blockchain/src/service/free.rs index e748bbbe..aa8238f9 100644 --- a/storage/blockchain/src/service/free.rs +++ b/storage/blockchain/src/service/free.rs @@ -3,13 +3,13 @@ //---------------------------------------------------------------------------------------------------- Import use std::sync::Arc; -use cuprate_database::{ConcreteEnv, InitError}; - use crate::service::{init_read_service, init_write_service}; use crate::{ config::Config, service::types::{BlockchainReadHandle, BlockchainWriteHandle}, }; +use cuprate_database::{ConcreteEnv, InitError}; +use cuprate_types::{AltBlockInformation, VerifiedBlockInformation}; //---------------------------------------------------------------------------------------------------- Init #[cold] @@ -81,6 +81,39 @@ pub(super) const fn compact_history_genesis_not_included INITIAL_BLOCKS && !(top_block_height - INITIAL_BLOCKS + 2).is_power_of_two() } +//---------------------------------------------------------------------------------------------------- Compact history +pub(super) fn map_valid_alt_block_to_verified_block( + alt_block: AltBlockInformation, +) -> VerifiedBlockInformation { + let total_fees = alt_block.txs.iter().map(|tx| tx.fee).sum::(); + let total_miner_output = alt_block + .block + .miner_transaction + .prefix() + .outputs + .iter() + .map(|out| out.amount.unwrap_or(0)) + .sum::(); + + VerifiedBlockInformation { + block: alt_block.block, + block_blob: alt_block.block_blob, + txs: alt_block + .txs + .into_iter() + .map(TryInto::try_into) + .collect::>() + .unwrap(), + block_hash: alt_block.block_hash, + pow_hash: alt_block.pow_hash, + height: alt_block.height, + generated_coins: total_miner_output - total_fees, + weight: alt_block.weight, + long_term_weight: alt_block.long_term_weight, + cumulative_difficulty: alt_block.cumulative_difficulty, + } +} + //---------------------------------------------------------------------------------------------------- Tests #[cfg(test)] diff --git a/storage/blockchain/src/service/write.rs b/storage/blockchain/src/service/write.rs index 067ba7f1..95124d41 100644 --- a/storage/blockchain/src/service/write.rs +++ b/storage/blockchain/src/service/write.rs @@ -1,18 +1,20 @@ //! Database writer thread definitions and logic. - //---------------------------------------------------------------------------------------------------- Import use std::sync::Arc; -use cuprate_database::{ConcreteEnv, Env, EnvInner, RuntimeError, TxRw}; +use cuprate_database::{ConcreteEnv, DatabaseRo, DatabaseRw, Env, EnvInner, RuntimeError, TxRw}; use cuprate_database_service::DatabaseWriteHandle; use cuprate_types::{ blockchain::{BlockchainResponse, BlockchainWriteRequest}, - AltBlockInformation, VerifiedBlockInformation, + AltBlockInformation, Chain, ChainId, VerifiedBlockInformation, }; +use crate::service::free::map_valid_alt_block_to_verified_block; +use crate::types::AltBlockHeight; use crate::{ service::types::{BlockchainWriteHandle, ResponseResult}, - tables::OpenTables, + tables::{OpenTables, Tables, TablesMut}, + types::AltChainInfo, }; //---------------------------------------------------------------------------------------------------- init_write_service @@ -30,8 +32,10 @@ fn handle_blockchain_request( match req { BlockchainWriteRequest::WriteBlock(block) => write_block(env, block), BlockchainWriteRequest::WriteAltBlock(alt_block) => write_alt_block(env, alt_block), - BlockchainWriteRequest::StartReorg(_) => todo!(), - BlockchainWriteRequest::ReverseReorg(_) => todo!(), + BlockchainWriteRequest::PopBlocks(numb_blocks) => pop_blocks(env, *numb_blocks), + BlockchainWriteRequest::ReverseReorg(old_main_chain_id) => { + reverse_reorg(env, *old_main_chain_id) + } BlockchainWriteRequest::FlushAltBlocks => flush_alt_blocks(env), } } @@ -97,6 +101,108 @@ fn write_alt_block(env: &ConcreteEnv, block: &AltBlockInformation) -> ResponseRe } } +/// [`BlockchainWriteRequest::PopBlocks`]. +fn pop_blocks(env: &ConcreteEnv, numb_blocks: usize) -> ResponseResult { + let env_inner = env.env_inner(); + let mut tx_rw = env_inner.tx_rw()?; + + let result = { + crate::ops::alt_block::flush_alt_blocks(&env_inner, &mut tx_rw)?; + + let mut tables_mut = env_inner.open_tables_mut(&tx_rw)?; + + let old_main_chain_id = ChainId(rand::random()); + + let mut last_block_height = 0; + for _ in 0..numb_blocks { + (last_block_height, _, _) = + crate::ops::block::pop_block(Some(old_main_chain_id), &mut tables_mut)?; + } + + tables_mut.alt_chain_infos_mut().put( + &old_main_chain_id.into(), + &AltChainInfo { + parent_chain: Chain::Main.into(), + common_ancestor_height: last_block_height - 1, + chain_height: last_block_height + numb_blocks, + }, + )?; + + Ok(old_main_chain_id) + }; + + match result { + Ok(old_main_chain_id) => { + TxRw::commit(tx_rw)?; + Ok(BlockchainResponse::PopBlocks(old_main_chain_id)) + } + Err(e) => { + // INVARIANT: ensure database atomicity by aborting + // the transaction on `add_block()` failures. + TxRw::abort(tx_rw) + .expect("could not maintain database atomicity by aborting write transaction"); + Err(e) + } + } +} + +/// [`BlockchainWriteRequest::ReverseReorg`]. +fn reverse_reorg(env: &ConcreteEnv, chain_id: ChainId) -> ResponseResult { + let env_inner = env.env_inner(); + let tx_rw = env_inner.tx_rw()?; + + let result = { + let mut tables_mut = env_inner.open_tables_mut(&tx_rw)?; + + let chain_info = tables_mut.alt_chain_infos().get(&chain_id.into())?; + assert_eq!(Chain::from(chain_info.parent_chain), Chain::Main); + + let tob_block_height = + crate::ops::blockchain::top_block_height(tables_mut.block_heights())?; + + for _ in chain_info.common_ancestor_height..tob_block_height { + crate::ops::block::pop_block(None, &mut tables_mut)?; + } + + // Rust borrow rules requires us to collect into a Vec first before looping over the Vec. + let alt_blocks = (chain_info.common_ancestor_height..chain_info.chain_height) + .map(|height| { + crate::ops::alt_block::get_alt_block( + &AltBlockHeight { + chain_id: chain_id.into(), + height, + }, + &tables_mut, + ) + }) + .collect::>(); + + for res_alt_block in alt_blocks { + let alt_block = res_alt_block?; + + let verified_block = map_valid_alt_block_to_verified_block(alt_block); + + crate::ops::block::add_block(&verified_block, &mut tables_mut)?; + } + + Ok(()) + }; + + match result { + Ok(()) => { + TxRw::commit(tx_rw)?; + Ok(BlockchainResponse::Ok) + } + Err(e) => { + // INVARIANT: ensure database atomicity by aborting + // the transaction on `add_block()` failures. + TxRw::abort(tx_rw) + .expect("could not maintain database atomicity by aborting write transaction"); + Err(e) + } + } +} + /// [`BlockchainWriteRequest::FlushAltBlocks`]. #[inline] fn flush_alt_blocks(env: &ConcreteEnv) -> ResponseResult { diff --git a/storage/blockchain/src/tables.rs b/storage/blockchain/src/tables.rs index deb957ea..fa568ae6 100644 --- a/storage/blockchain/src/tables.rs +++ b/storage/blockchain/src/tables.rs @@ -145,6 +145,9 @@ cuprate_database::define_tables! { 19 => AltTransactionBlobs, TxHash => TxBlob, + + 20 => AltTransactionInfos, + TxHash => AltTransactionInfo, } //---------------------------------------------------------------------------------------------------- Tests diff --git a/storage/blockchain/src/types.rs b/storage/blockchain/src/types.rs index 88ece10b..14917249 100644 --- a/storage/blockchain/src/types.rs +++ b/storage/blockchain/src/types.rs @@ -189,7 +189,7 @@ pub struct BlockInfo { /// The adjusted block size, in bytes. /// /// See [`block_weight`](https://monero-book.cuprate.org/consensus_rules/blocks/weights.html#blocks-weight). - pub weight: u64, + pub weight: usize, /// Least-significant 64 bits of the 128-bit cumulative difficulty. pub cumulative_difficulty_low: u64, /// Most-significant 64 bits of the 128-bit cumulative difficulty. @@ -201,7 +201,7 @@ pub struct BlockInfo { /// The long term block weight, based on the median weight of the preceding `100_000` blocks. /// /// See [`long_term_weight`](https://monero-book.cuprate.org/consensus_rules/blocks/weights.html#long-term-block-weight). - pub long_term_weight: u64, + pub long_term_weight: usize, } //---------------------------------------------------------------------------------------------------- OutputFlags @@ -381,6 +381,7 @@ impl Key for RawChainId {} pub struct AltChainInfo { pub parent_chain: RawChain, pub common_ancestor_height: usize, + pub chain_height: usize, } //---------------------------------------------------------------------------------------------------- AltBlockHeight diff --git a/types/src/blockchain.rs b/types/src/blockchain.rs index 33c3e8bd..c2a5517d 100644 --- a/types/src/blockchain.rs +++ b/types/src/blockchain.rs @@ -116,20 +116,17 @@ pub enum BlockchainWriteRequest { /// /// Input is the alternative block. WriteAltBlock(AltBlockInformation), - /// A request to start the re-org process. + /// A request to pop some blocks from the top of the main chain /// - /// The inner value is the [`ChainId`] of the alt-chain we want to re-org to. + /// Input is the amount of blocks to pop. /// - /// This will: - /// - pop blocks from the main chain - /// - retrieve all alt-blocks in this alt-chain - /// - flush all other alt blocks - StartReorg(ChainId), + /// This request flush all alt-chains from the cache before adding the popped blocks to the alt cache. + PopBlocks(usize), /// A request to reverse the re-org process. /// /// The inner value is the [`ChainId`] of the old main chain. /// - /// It is invalid to call this with a [`ChainId`] that was not returned from [`BlockchainWriteRequest::StartReorg`]. + /// It is invalid to call this with a [`ChainId`] that was not returned from [`BlockchainWriteRequest::PopBlocks`]. ReverseReorg(ChainId), /// A request to flush all alternative blocks. FlushAltBlocks, @@ -227,13 +224,10 @@ pub enum BlockchainResponse { /// - [`BlockchainWriteRequest::ReverseReorg`] /// - [`BlockchainWriteRequest::FlushAltBlocks`] Ok, - /// The response for [`BlockchainWriteRequest::StartReorg`]. - StartReorg { - /// The [`ChainId`] of the old main chain blocks that were popped. - old_main_chain_id: ChainId, - /// The next alt chain blocks. - alt_chain: Vec, - }, + /// The response for [`BlockchainWriteRequest::PopBlocks`]. + /// + /// The inner value is the alt-chain ID for the old main chain blocks. + PopBlocks(ChainId), } //---------------------------------------------------------------------------------------------------- Tests diff --git a/types/src/types.rs b/types/src/types.rs index cc4543e6..c6e83d09 100644 --- a/types/src/types.rs +++ b/types/src/types.rs @@ -79,6 +79,7 @@ pub struct VerifiedBlockInformation { /// [`Block::hash`]. pub block_hash: [u8; 32], /// The block's proof-of-work hash. + // TODO: make this an option. pub pow_hash: [u8; 32], /// The block's height. pub height: usize, @@ -120,7 +121,7 @@ pub struct AltBlockInformation { /// [`Block::serialize`]. pub block_blob: Vec, /// All the transactions in the block, excluding the [`Block::miner_transaction`]. - pub txs: Vec>, + pub txs: Vec, /// The block's hash. /// /// [`Block::hash`]. From 21e4b3a20a56323961f65e100ca826f0677a41e5 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 6 Sep 2024 00:26:36 +0100 Subject: [PATCH 14/72] commit Cargo.lock --- Cargo.lock | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d5d64902..e277e3f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "ahash" version = "0.8.11" @@ -160,7 +166,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.7.3", "object", "rustc-demangle", ] @@ -1080,12 +1086,12 @@ checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "flate2" -version = "1.0.30" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.8.0", ] [[package]] @@ -1239,9 +1245,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" dependencies = [ "atomic-waker", "bytes", @@ -1735,6 +1741,15 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + [[package]] name = "mio" version = "0.8.11" @@ -2397,9 +2412,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" +checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" [[package]] name = "rustls-webpki" @@ -2958,9 +2973,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "ureq" -version = "2.10.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72139d247e5f97a3eff96229a7ae85ead5328a39efe76f8bf5a06313d505b6ea" +checksum = "b74fc6b57825be3373f7054754755f03ac3a8f5d70015ccad699ba2029956f4a" dependencies = [ "base64", "flate2", @@ -3083,9 +3098,9 @@ checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "webpki-roots" -version = "0.26.3" +version = "0.26.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" +checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a" dependencies = [ "rustls-pki-types", ] From 123aedd6a986f7884efdc922eca046c86b7169ae Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 6 Sep 2024 02:39:40 +0100 Subject: [PATCH 15/72] add test --- storage/blockchain/src/ops/alt_block/block.rs | 100 +++++++++++++++++- storage/blockchain/src/ops/alt_block/chain.rs | 2 +- storage/blockchain/src/ops/block.rs | 2 +- storage/blockchain/src/ops/mod.rs | 2 +- storage/blockchain/src/service/mod.rs | 2 +- storage/blockchain/src/service/tests.rs | 2 +- storage/blockchain/src/tests.rs | 16 +++ 7 files changed, 120 insertions(+), 6 deletions(-) diff --git a/storage/blockchain/src/ops/alt_block/block.rs b/storage/blockchain/src/ops/alt_block/block.rs index a429eab8..83d04ba7 100644 --- a/storage/blockchain/src/ops/alt_block/block.rs +++ b/storage/blockchain/src/ops/alt_block/block.rs @@ -171,7 +171,7 @@ pub fn get_alt_block_extended_header_from_height( let block_header = BlockHeader::read(&mut block_blob.as_slice())?; Ok(ExtendedBlockHeader { - version: HardFork::from_version(0).expect("Block in DB must have correct version"), + version: HardFork::from_version(block_header.hardfork_version).expect("Block in DB must have correct version"), vote: block_header.hardfork_version, timestamp: block_header.timestamp, cumulative_difficulty: combine_low_high_bits_to_u128( @@ -182,3 +182,101 @@ pub fn get_alt_block_extended_header_from_height( long_term_weight: block_info.long_term_weight, }) } + +#[cfg(test)] +mod tests { + use std::num::NonZero; + use cuprate_database::{Env, EnvInner, TxRw}; + use cuprate_test_utils::data::{BLOCK_V1_TX2, BLOCK_V9_TX3, BLOCK_V16_TX0}; + use cuprate_types::ChainId; + use crate::ops::alt_block::{add_alt_block, flush_alt_blocks, get_alt_block, get_alt_extended_headers_in_range}; + use crate::ops::block::{add_block, pop_block}; + use crate::tables::OpenTables; + use crate::tests::{assert_all_tables_are_empty, map_verified_block_to_alt, tmp_concrete_env}; + use crate::types::AltBlockHeight; + + #[test] + fn all_alt_blocks() { + let (env, _tmp) = tmp_concrete_env(); + let env_inner = env.env_inner(); + assert_all_tables_are_empty(&env); + + let chain_id = ChainId(NonZero::new(1).unwrap()).into(); + + // Add initial block. + { + let tx_rw = env_inner.tx_rw().unwrap(); + let mut tables = env_inner.open_tables_mut(&tx_rw).unwrap(); + + let mut initial_block = BLOCK_V1_TX2.clone(); + initial_block.height = 0; + + add_block(&initial_block, &mut tables).unwrap(); + + drop(tables); + TxRw::commit(tx_rw).unwrap(); + } + + let alt_blocks = [ + map_verified_block_to_alt(BLOCK_V9_TX3.clone(), chain_id), + map_verified_block_to_alt(BLOCK_V16_TX0.clone(), chain_id), + ]; + + // Add alt-blocks + { + let tx_rw = env_inner.tx_rw().unwrap(); + let mut tables = env_inner.open_tables_mut(&tx_rw).unwrap(); + + let mut prev_hash = BLOCK_V1_TX2.block_hash; + for (i, mut alt_block) in alt_blocks.into_iter().enumerate() { + let height = i + 1; + + alt_block.height = height; + alt_block.block.header.previous = prev_hash; + alt_block.block_blob = alt_block.block.serialize(); + + add_alt_block(&alt_block, &mut tables).unwrap(); + + let alt_height = AltBlockHeight { + chain_id: chain_id.into(), + height, + }; + + let alt_block_2 = get_alt_block(&alt_height, &tables).unwrap(); + assert_eq!(alt_block.block, alt_block_2.block); + + let headers = get_alt_extended_headers_in_range(0..(height + 1), chain_id, &tables).unwrap(); + assert_eq!(headers.len(), height); + + let last_header = headers.last().unwrap(); + assert_eq!(last_header.timestamp, alt_block.block.header.timestamp); + assert_eq!(last_header.block_weight, alt_block.weight); + assert_eq!(last_header.long_term_weight, alt_block.long_term_weight); + assert_eq!(last_header.cumulative_difficulty, alt_block.cumulative_difficulty); + assert_eq!(last_header.version.as_u8(), alt_block.block.header.hardfork_version); + assert_eq!(last_header.vote, alt_block.block.header.hardfork_signal); + + prev_hash = alt_block.block_hash; + } + + drop(tables); + TxRw::commit(tx_rw).unwrap(); + } + + + { + let mut tx_rw = env_inner.tx_rw().unwrap(); + + flush_alt_blocks(&env_inner, &mut tx_rw).unwrap(); + + let mut tables = env_inner.open_tables_mut(&tx_rw).unwrap(); + pop_block(None, &mut tables).unwrap(); + + drop(tables); + TxRw::commit(tx_rw).unwrap(); + } + + assert_all_tables_are_empty(&env); + } + +} diff --git a/storage/blockchain/src/ops/alt_block/chain.rs b/storage/blockchain/src/ops/alt_block/chain.rs index 1162a9cd..166a294a 100644 --- a/storage/blockchain/src/ops/alt_block/chain.rs +++ b/storage/blockchain/src/ops/alt_block/chain.rs @@ -45,7 +45,7 @@ pub fn get_alt_chain_history_ranges( let start_height = max(range.start, chain_info.common_ancestor_height + 1); - ranges.push((chain_info.parent_chain.into(), start_height..i)); + ranges.push((Chain::Alt(current_chain_id.into()), start_height..i)); i = chain_info.common_ancestor_height; match chain_info.parent_chain.into() { diff --git a/storage/blockchain/src/ops/block.rs b/storage/blockchain/src/ops/block.rs index 229d35e1..b0997f76 100644 --- a/storage/blockchain/src/ops/block.rs +++ b/storage/blockchain/src/ops/block.rs @@ -180,7 +180,7 @@ pub fn pop_block( block_blob, txs, block_hash: block_info.block_hash, - pow_hash: [255; 32], + pow_hash: [0; 32], height: block_height, weight: block_info.weight, long_term_weight: block_info.long_term_weight, diff --git a/storage/blockchain/src/ops/mod.rs b/storage/blockchain/src/ops/mod.rs index 8a8f0f15..285aa244 100644 --- a/storage/blockchain/src/ops/mod.rs +++ b/storage/blockchain/src/ops/mod.rs @@ -94,7 +94,7 @@ //! // Read the data, assert it is correct. //! let tx_rw = env_inner.tx_rw()?; //! let mut tables = env_inner.open_tables_mut(&tx_rw)?; -//! let (height, hash, serai_block) = pop_block(&mut tables)?; +//! let (height, hash, serai_block) = pop_block(None, &mut tables)?; //! //! assert_eq!(height, 0); //! assert_eq!(serai_block, block.block); diff --git a/storage/blockchain/src/service/mod.rs b/storage/blockchain/src/service/mod.rs index c774ee49..aa322d06 100644 --- a/storage/blockchain/src/service/mod.rs +++ b/storage/blockchain/src/service/mod.rs @@ -98,7 +98,7 @@ //! //! // Block write was OK. //! let response = response_channel.await?; -//! assert_eq!(response, BlockchainResponse::WriteBlockOk); +//! assert_eq!(response, BlockchainResponse::Ok); //! //! // Now, let's try getting the block hash //! // of the block we just wrote. diff --git a/storage/blockchain/src/service/tests.rs b/storage/blockchain/src/service/tests.rs index b68b5444..78cb6944 100644 --- a/storage/blockchain/src/service/tests.rs +++ b/storage/blockchain/src/service/tests.rs @@ -84,7 +84,7 @@ async fn test_template( let request = BlockchainWriteRequest::WriteBlock(block); let response_channel = writer.call(request); let response = response_channel.await.unwrap(); - assert_eq!(response, BlockchainResponse::WriteBlockOk); + assert_eq!(response, BlockchainResponse::Ok); } //----------------------------------------------------------------------- Reset the transaction diff --git a/storage/blockchain/src/tests.rs b/storage/blockchain/src/tests.rs index 65527e10..60239127 100644 --- a/storage/blockchain/src/tests.rs +++ b/storage/blockchain/src/tests.rs @@ -10,6 +10,7 @@ use std::{borrow::Cow, fmt::Debug}; use pretty_assertions::assert_eq; use cuprate_database::{ConcreteEnv, DatabaseRo, Env, EnvInner}; +use cuprate_types::{AltBlockInformation, ChainId, VerifiedBlockInformation}; use crate::{ config::ConfigBuilder, @@ -88,3 +89,18 @@ pub(crate) fn assert_all_tables_are_empty(env: &ConcreteEnv) { assert!(tables.all_tables_empty().unwrap()); assert_eq!(crate::ops::tx::get_num_tx(tables.tx_ids()).unwrap(), 0); } + +pub(crate) fn map_verified_block_to_alt(verified_block: VerifiedBlockInformation, chain_id: ChainId) -> AltBlockInformation { + AltBlockInformation { + block: verified_block.block, + block_blob: verified_block.block_blob, + txs: verified_block.txs, + block_hash: verified_block.block_hash, + pow_hash: verified_block.pow_hash, + height: verified_block.height, + weight: verified_block.weight, + long_term_weight: verified_block.long_term_weight, + cumulative_difficulty: verified_block.cumulative_difficulty, + chain_id, + } +} \ No newline at end of file From ba5c5ac45d958f43382df21dd12eeca520a7c870 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sat, 7 Sep 2024 02:02:19 +0100 Subject: [PATCH 16/72] more docs + cleanup + alt blocks request --- storage/blockchain/src/ops/alt_block/block.rs | 166 +++++++++++------- storage/blockchain/src/ops/alt_block/chain.rs | 49 ++++-- storage/blockchain/src/ops/alt_block/mod.rs | 59 ++++++- storage/blockchain/src/ops/alt_block/tx.rs | 23 ++- storage/blockchain/src/ops/block.rs | 23 +-- storage/blockchain/src/ops/macros.rs | 21 +++ storage/blockchain/src/service/read.rs | 98 +++++++++-- storage/blockchain/src/service/write.rs | 19 +- storage/blockchain/src/tests.rs | 7 +- types/src/blockchain.rs | 20 ++- 10 files changed, 368 insertions(+), 117 deletions(-) diff --git a/storage/blockchain/src/ops/alt_block/block.rs b/storage/blockchain/src/ops/alt_block/block.rs index 83d04ba7..07878d55 100644 --- a/storage/blockchain/src/ops/alt_block/block.rs +++ b/storage/blockchain/src/ops/alt_block/block.rs @@ -1,16 +1,35 @@ -use crate::ops::alt_block::{ - add_alt_transaction_blob, check_add_alt_chain_info, get_alt_chain_history_ranges, - get_alt_transaction, -}; -use crate::ops::block::{get_block_extended_header_from_height, get_block_info}; -use crate::tables::{Tables, TablesMut}; -use crate::types::{AltBlockHeight, BlockHash, BlockHeight, CompactAltBlockInfo}; use bytemuck::TransparentWrapper; +use monero_serai::block::{Block, BlockHeader}; + use cuprate_database::{DatabaseRo, DatabaseRw, RuntimeError, StorableVec}; use cuprate_helper::map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}; use cuprate_types::{AltBlockInformation, Chain, ChainId, ExtendedBlockHeader, HardFork}; -use monero_serai::block::{Block, BlockHeader}; +use crate::{ + ops::{ + alt_block::{add_alt_transaction_blob, get_alt_transaction, update_alt_chain_info}, + block::get_block_info, + macros::doc_error, + }, + tables::{Tables, TablesMut}, + types::{AltBlockHeight, BlockHash, BlockHeight, CompactAltBlockInfo}, +}; + +/// Add a [`AltBlockInformation`] to the database. +/// +/// This extracts all the data from the input block and +/// maps/adds them to the appropriate database tables. +/// +#[doc = doc_error!()] +/// +/// # Panics +/// This function will panic if: +/// - `block.height` is == `0` +/// +/// # Already exists +/// This function will operate normally even if `block` already +/// exists, i.e., this function will not return `Err` even if you +/// call this function infinitely with the same block. pub fn add_alt_block( alt_block: &AltBlockInformation, tables: &mut impl TablesMut, @@ -24,7 +43,7 @@ pub fn add_alt_block( .alt_block_heights_mut() .put(&alt_block.block_hash, &alt_block_height)?; - check_add_alt_chain_info(&alt_block_height, &alt_block.block.header.previous, tables)?; + update_alt_chain_info(&alt_block_height, &alt_block.block.header.previous, tables)?; let (cumulative_difficulty_low, cumulative_difficulty_high) = split_u128_into_low_high_bits(alt_block.cumulative_difficulty); @@ -49,13 +68,18 @@ pub fn add_alt_block( )?; assert_eq!(alt_block.txs.len(), alt_block.block.transactions.len()); - for tx in alt_block.txs.iter() { + for tx in &alt_block.txs { add_alt_transaction_blob(tx, tables)?; } Ok(()) } +/// Retrieves an [`AltBlockInformation`] from the database. +/// +/// This function will look at only the blocks with the given [`AltBlockHeight::chain_id`], no others +/// even if they are technically part of this chain. +#[doc = doc_error!()] pub fn get_alt_block( alt_block_height: &AltBlockHeight, tables: &impl Tables, @@ -89,13 +113,21 @@ pub fn get_alt_block( }) } +/// Retrieves the hash of the block at the given `block_height` on the alt chain with +/// the given [`ChainId`]. +/// +/// This function will get blocks from the whole chain, for example if you were to ask for height +/// `0` with any [`ChainId`] (as long that chain actually exists) you will get the main chain genesis. +/// +#[doc = doc_error!()] pub fn get_alt_block_hash( block_height: &BlockHeight, alt_chain: ChainId, - tables: &mut impl Tables, + tables: &impl Tables, ) -> Result { let alt_chains = tables.alt_chain_infos(); + // First find what [`ChainId`] this block would be stored under. let original_chain = { let mut chain = alt_chain.into(); loop { @@ -115,9 +147,10 @@ pub fn get_alt_block_hash( } }; + // Get the block hash. match original_chain { Chain::Main => { - get_block_info(&block_height, tables.block_infos()).map(|info| info.block_hash) + get_block_info(block_height, tables.block_infos()).map(|info| info.block_hash) } Chain::Alt(chain_id) => tables .alt_blocks_info() @@ -129,37 +162,12 @@ pub fn get_alt_block_hash( } } -pub fn get_alt_extended_headers_in_range( - range: std::ops::Range, - alt_chain: ChainId, - tables: &impl Tables, -) -> Result, RuntimeError> { - // TODO: this function does not use rayon, however it probably should. - - let alt_chains = tables.alt_chain_infos(); - let ranges = get_alt_chain_history_ranges(range, alt_chain, alt_chains)?; - - let res = ranges - .into_iter() - .rev() - .map(|(chain, range)| { - range.into_iter().map(move |height| match chain { - Chain::Main => get_block_extended_header_from_height(&height, tables), - Chain::Alt(chain_id) => get_alt_block_extended_header_from_height( - &AltBlockHeight { - chain_id: chain_id.into(), - height, - }, - tables, - ), - }) - }) - .flatten() - .collect::>()?; - - Ok(res) -} - +/// Retrieves the [`ExtendedBlockHeader`] of the alt-block with an exact [`AltBlockHeight`]. +/// +/// This function will look at only the blocks with the given [`AltBlockHeight::chain_id`], no others +/// even if they are technically part of this chain. +/// +#[doc = doc_error!()] pub fn get_alt_block_extended_header_from_height( height: &AltBlockHeight, table: &impl Tables, @@ -171,7 +179,8 @@ pub fn get_alt_block_extended_header_from_height( let block_header = BlockHeader::read(&mut block_blob.as_slice())?; Ok(ExtendedBlockHeader { - version: HardFork::from_version(block_header.hardfork_version).expect("Block in DB must have correct version"), + version: HardFork::from_version(block_header.hardfork_version) + .expect("Block in DB must have correct version"), vote: block_header.hardfork_version, timestamp: block_header.timestamp, cumulative_difficulty: combine_low_high_bits_to_u128( @@ -186,22 +195,33 @@ pub fn get_alt_block_extended_header_from_height( #[cfg(test)] mod tests { use std::num::NonZero; - use cuprate_database::{Env, EnvInner, TxRw}; - use cuprate_test_utils::data::{BLOCK_V1_TX2, BLOCK_V9_TX3, BLOCK_V16_TX0}; - use cuprate_types::ChainId; - use crate::ops::alt_block::{add_alt_block, flush_alt_blocks, get_alt_block, get_alt_extended_headers_in_range}; - use crate::ops::block::{add_block, pop_block}; - use crate::tables::OpenTables; - use crate::tests::{assert_all_tables_are_empty, map_verified_block_to_alt, tmp_concrete_env}; - use crate::types::AltBlockHeight; + use cuprate_database::{Env, EnvInner, TxRw}; + use cuprate_test_utils::data::{BLOCK_V16_TX0, BLOCK_V1_TX2, BLOCK_V9_TX3}; + use cuprate_types::{Chain, ChainId}; + + use crate::{ + ops::{ + alt_block::{ + add_alt_block, flush_alt_blocks, get_alt_block, + get_alt_block_extended_header_from_height, get_alt_block_hash, + get_alt_chain_history_ranges, + }, + block::{add_block, pop_block}, + }, + tables::{OpenTables, Tables}, + tests::{assert_all_tables_are_empty, map_verified_block_to_alt, tmp_concrete_env}, + types::AltBlockHeight, + }; + + #[allow(clippy::range_plus_one)] #[test] fn all_alt_blocks() { let (env, _tmp) = tmp_concrete_env(); let env_inner = env.env_inner(); assert_all_tables_are_empty(&env); - let chain_id = ChainId(NonZero::new(1).unwrap()).into(); + let chain_id = ChainId(NonZero::new(1).unwrap()); // Add initial block. { @@ -245,25 +265,44 @@ mod tests { let alt_block_2 = get_alt_block(&alt_height, &tables).unwrap(); assert_eq!(alt_block.block, alt_block_2.block); - let headers = get_alt_extended_headers_in_range(0..(height + 1), chain_id, &tables).unwrap(); - assert_eq!(headers.len(), height); + let headers = get_alt_chain_history_ranges( + 0..(height + 1), + chain_id, + tables.alt_chain_infos(), + ) + .unwrap(); - let last_header = headers.last().unwrap(); - assert_eq!(last_header.timestamp, alt_block.block.header.timestamp); - assert_eq!(last_header.block_weight, alt_block.weight); - assert_eq!(last_header.long_term_weight, alt_block.long_term_weight); - assert_eq!(last_header.cumulative_difficulty, alt_block.cumulative_difficulty); - assert_eq!(last_header.version.as_u8(), alt_block.block.header.hardfork_version); - assert_eq!(last_header.vote, alt_block.block.header.hardfork_signal); + assert_eq!(headers.len(), 2); + assert_eq!(headers[1], (Chain::Main, 0..1)); + assert_eq!(headers[0], (Chain::Alt(chain_id), 1..(height + 1))); prev_hash = alt_block.block_hash; + + let header = + get_alt_block_extended_header_from_height(&alt_height, &tables).unwrap(); + + assert_eq!(header.timestamp, alt_block.block.header.timestamp); + assert_eq!(header.block_weight, alt_block.weight); + assert_eq!(header.long_term_weight, alt_block.long_term_weight); + assert_eq!( + header.cumulative_difficulty, + alt_block.cumulative_difficulty + ); + assert_eq!( + header.version.as_u8(), + alt_block.block.header.hardfork_version + ); + assert_eq!(header.vote, alt_block.block.header.hardfork_signal); + + let block_hash = get_alt_block_hash(&height, chain_id, &tables).unwrap(); + + assert_eq!(block_hash, alt_block.block_hash); } drop(tables); TxRw::commit(tx_rw).unwrap(); } - { let mut tx_rw = env_inner.tx_rw().unwrap(); @@ -278,5 +317,4 @@ mod tests { assert_all_tables_are_empty(&env); } - } diff --git a/storage/blockchain/src/ops/alt_block/chain.rs b/storage/blockchain/src/ops/alt_block/chain.rs index 166a294a..3e27d7d4 100644 --- a/storage/blockchain/src/ops/alt_block/chain.rs +++ b/storage/blockchain/src/ops/alt_block/chain.rs @@ -1,20 +1,43 @@ -use crate::tables::{AltChainInfos, TablesMut}; -use crate::types::{AltBlockHeight, AltChainInfo, BlockHash, BlockHeight}; -use cuprate_database::{DatabaseRo, DatabaseRw, RuntimeError}; -use cuprate_types::{Chain, ChainId}; use std::cmp::max; -pub fn check_add_alt_chain_info( +use cuprate_database::{DatabaseRo, DatabaseRw, RuntimeError}; +use cuprate_types::{Chain, ChainId}; + +use crate::{ + ops::macros::{doc_add_alt_block_inner_invariant, doc_error}, + tables::{AltChainInfos, TablesMut}, + types::{AltBlockHeight, AltChainInfo, BlockHash, BlockHeight}, +}; + +/// Updates the [`AltChainInfo`] with information on a new alt-block. +/// +#[doc = doc_add_alt_block_inner_invariant!()] +#[doc = doc_error!()] +/// +/// # Panics +/// +/// This will panic if [`AltBlockHeight::height`] == `0`. +pub fn update_alt_chain_info( alt_block_height: &AltBlockHeight, prev_hash: &BlockHash, tables: &mut impl TablesMut, ) -> Result<(), RuntimeError> { - match tables.alt_chain_infos().get(&alt_block_height.chain_id) { - Ok(_) => return Ok(()), + // try update the info if one exists for this chain. + let update = tables + .alt_chain_infos_mut() + .update(&alt_block_height.chain_id, |mut info| { + info.chain_height = alt_block_height.height + 1; + Some(info) + }); + + match update { + Ok(()) => return Ok(()), Err(RuntimeError::KeyNotFound) => (), Err(e) => return Err(e), } + // If one doesn't already exist add it. + let parent_chain = match tables.alt_block_heights().get(prev_hash) { Ok(alt_parent_height) => Chain::Alt(alt_parent_height.chain_id.into()), Err(RuntimeError::KeyNotFound) => Chain::Main, @@ -25,12 +48,18 @@ pub fn check_add_alt_chain_info( &alt_block_height.chain_id, &AltChainInfo { parent_chain: parent_chain.into(), - common_ancestor_height: alt_block_height.height - 1, - chain_height: alt_block_height.height, + common_ancestor_height: alt_block_height.height.checked_sub(1).unwrap(), + chain_height: alt_block_height.height + 1, }, ) } +/// Get the height history of an alt-chain in reverse chronological order. +/// +/// Height history is a list of height ranges with the corresponding [`Chain`] they are stored under. +/// For example if your range goes from height `0` the last entry in the list will be [`Chain::Main`] +/// upto the height where the first split occurs. +#[doc = doc_error!()] pub fn get_alt_chain_history_ranges( range: std::ops::Range, alt_chain: ChainId, @@ -46,7 +75,7 @@ pub fn get_alt_chain_history_ranges( let start_height = max(range.start, chain_info.common_ancestor_height + 1); ranges.push((Chain::Alt(current_chain_id.into()), start_height..i)); - i = chain_info.common_ancestor_height; + i = chain_info.common_ancestor_height + 1; match chain_info.parent_chain.into() { Chain::Main => { diff --git a/storage/blockchain/src/ops/alt_block/mod.rs b/storage/blockchain/src/ops/alt_block/mod.rs index 72e0933e..36e4768e 100644 --- a/storage/blockchain/src/ops/alt_block/mod.rs +++ b/storage/blockchain/src/ops/alt_block/mod.rs @@ -1,11 +1,62 @@ -mod block; -mod chain; -mod tx; - +//! Alternative Block/Chain Ops +//! +//! Alternative chains are chains that potentially have more proof-of-work than the main-chain +//! which we are tracking to potentially re-org to. +//! +//! Cuprate uses an ID system for alt-chains. When a split is made from the main-chain we generate +//! a random [`ChainID`](cuprate_types::ChainId) and assign it to the chain: +//! +//! ```text +//! | +//! | +//! | split +//! |------------- +//! | | +//! | | +//! \|/ \|/ +//! main-chain ChainID(X) +//! ``` +//! +//! In that example if we were to receive an alt-block which immediately follows the top block of `ChainID(X)` +//! then that block will also be stored under `ChainID(X)`. However if it follows from another block from `ChainID(X)` +//! we will split into a chain with a different ID. +//! +//! ```text +//! | +//! | +//! | split +//! |------------- +//! | | split +//! | |-------------| +//! | | | +//! | | | +//! | | | +//! \|/ \|/ \|/ +//! main-chain ChainID(X) ChainID(Z) +//! ``` +//! +//! As you can see if we wanted to get all the alt-blocks in `ChainID(Z)` that now includes some blocks from `ChainID(X)` as well. +//! [`get_alt_chain_history_ranges`] covers this and is the method to get the ranges of heights needed from each [`ChainID`](cuprate_types::ChainId) +//! to get all the alt-blocks in a given [`ChainID`](cuprate_types::ChainId). +//! +//! Although this should be kept in mind as a possibility because Cuprate's block downloader will only track a single chain it is +//! unlikely that we will be tracking [`ChainID`](cuprate_types::ChainId) that don't immediately connect to the main-chain. +//! +//! ## Why not use block's previous field? +//! +//! Although that would be easier, it makes getting a range of block extremely slow, as we have to build the weight cache to verify +//! blocks, roughly 100,000 block headers needed, this cost was seen as too high. pub use block::*; pub use chain::*; pub use tx::*; +mod block; +mod chain; +mod tx; + +/// Flush all alt-block data from all the alt-block tables. +/// +/// This function completely empties the alt block tables. pub fn flush_alt_blocks<'a, E: cuprate_database::EnvInner<'a>>( env_inner: &E, tx_rw: &mut E::Rw<'_>, diff --git a/storage/blockchain/src/ops/alt_block/tx.rs b/storage/blockchain/src/ops/alt_block/tx.rs index a49c72ae..5671e4b4 100644 --- a/storage/blockchain/src/ops/alt_block/tx.rs +++ b/storage/blockchain/src/ops/alt_block/tx.rs @@ -1,10 +1,22 @@ -use crate::tables::{Tables, TablesMut}; -use crate::types::{AltTransactionInfo, TxHash}; use bytemuck::TransparentWrapper; -use cuprate_database::{DatabaseRo, DatabaseRw, RuntimeError, StorableVec}; -use cuprate_types::VerifiedTransactionInformation; use monero_serai::transaction::Transaction; +use cuprate_database::{DatabaseRo, DatabaseRw, RuntimeError, StorableVec}; +use cuprate_types::VerifiedTransactionInformation; + +use crate::ops::macros::{doc_add_alt_block_inner_invariant, doc_error}; +use crate::tables::{Tables, TablesMut}; +use crate::types::{AltTransactionInfo, TxHash}; + +/// Adds a [`VerifiedTransactionInformation`] form an alt-block to the DB, if +/// that transaction is not already in the DB. +/// +/// If the transaction is in the main-chain this function will still fill in the +/// [`AltTransactionInfos`](crate::tables::AltTransactionInfos) table, as that +/// table holds data which we don't keep around for main-chain txs. +/// +#[doc = doc_add_alt_block_inner_invariant!()] +#[doc = doc_error!()] pub fn add_alt_transaction_blob( tx: &VerifiedTransactionInformation, tables: &mut impl TablesMut, @@ -29,6 +41,9 @@ pub fn add_alt_transaction_blob( .put(&tx.tx_hash, StorableVec::wrap_ref(&tx.tx_blob)) } +/// Retrieve a [`VerifiedTransactionInformation`] from the database. +/// +#[doc = doc_error!()] pub fn get_alt_transaction( tx_hash: &TxHash, tables: &impl Tables, diff --git a/storage/blockchain/src/ops/block.rs b/storage/blockchain/src/ops/block.rs index b0997f76..45bab41c 100644 --- a/storage/blockchain/src/ops/block.rs +++ b/storage/blockchain/src/ops/block.rs @@ -38,11 +38,6 @@ use crate::{ /// This function will panic if: /// - `block.height > u32::MAX` (not normally possible) /// - `block.height` is not != [`chain_height`] -/// -/// # Already exists -/// This function will operate normally even if `block` already -/// exists, i.e., this function will not return `Err` even if you -/// call this function infinitely with the same block. // no inline, too big. pub fn add_block( block: &VerifiedBlockInformation, @@ -133,6 +128,9 @@ pub fn add_block( /// Remove the top/latest block from the database. /// /// The removed block's data is returned. +/// +/// If a [`ChainId`] is specified the popped block will be added to the alt block tables under +/// that [`ChainId`]. Otherwise, the block will be completely removed from the DB. #[doc = doc_error!()] /// /// In `pop_block()`'s case, [`RuntimeError::KeyNotFound`] @@ -169,7 +167,7 @@ pub fn pop_block( tx_hash: tx.hash(), fee: tx_fee(&tx), tx, - }) + }); } } @@ -180,11 +178,16 @@ pub fn pop_block( block_blob, txs, block_hash: block_info.block_hash, + // We know the PoW is valid for this block so just set it so it will always verify as + // valid. pow_hash: [0; 32], height: block_height, weight: block_info.weight, long_term_weight: block_info.long_term_weight, - cumulative_difficulty: 0, + cumulative_difficulty: combine_low_high_bits_to_u128( + block_info.cumulative_difficulty_low, + block_info.cumulative_difficulty_high, + ), chain_id, }, tables, @@ -229,8 +232,6 @@ pub fn get_block_extended_header_from_height( block_info.cumulative_difficulty_high, ); - // INVARIANT: #[cfg] @ lib.rs asserts `usize == u64` - #[allow(clippy::cast_possible_truncation)] Ok(ExtendedBlockHeader { cumulative_difficulty, version: HardFork::from_version(block_header.hardfork_version) @@ -302,14 +303,14 @@ mod test { use cuprate_database::{Env, EnvInner, TxRw}; use cuprate_test_utils::data::{BLOCK_V16_TX0, BLOCK_V1_TX2, BLOCK_V9_TX3}; - use super::*; - use crate::{ ops::tx::{get_tx, tx_exists}, tables::OpenTables, tests::{assert_all_tables_are_empty, tmp_concrete_env, AssertTableLen}, }; + use super::*; + /// Tests all above block functions. /// /// Note that this doesn't test the correctness of values added, as the diff --git a/storage/blockchain/src/ops/macros.rs b/storage/blockchain/src/ops/macros.rs index b7cdba47..e547c7f2 100644 --- a/storage/blockchain/src/ops/macros.rs +++ b/storage/blockchain/src/ops/macros.rs @@ -31,3 +31,24 @@ When calling this function, ensure that either: }; } pub(super) use doc_add_block_inner_invariant; + +// This is pretty much the same as [`doc_add_block_inner_invariant`], it's not worth the effort to reduce +// the duplication. +/// Generate `# Invariant` documentation for internal alt block `fn`'s +/// that should be called directly with caution. +macro_rules! doc_add_alt_block_inner_invariant { + () => { + r#"# ⚠️ Invariant ⚠️ +This function mainly exists to be used internally by the parent function [`crate::ops::alt_block::add_alt_block`]. + +`add_alt_block()` makes sure all data related to the input is mutated, while +this function _does not_, it specifically mutates _particular_ tables. + +This is usually undesired - although this function is still available to call directly. + +When calling this function, ensure that either: +1. This effect (incomplete database mutation) is what is desired, or that... +2. ...the other tables will also be mutated to a correct state"# + }; +} +pub(super) use doc_add_alt_block_inner_invariant; diff --git a/storage/blockchain/src/service/read.rs b/storage/blockchain/src/service/read.rs index 70da01b3..416e6137 100644 --- a/storage/blockchain/src/service/read.rs +++ b/storage/blockchain/src/service/read.rs @@ -1,28 +1,32 @@ //! Database reader thread-pool definitions and logic. -//---------------------------------------------------------------------------------------------------- Import use std::{ collections::{HashMap, HashSet}, sync::Arc, }; +//---------------------------------------------------------------------------------------------------- Import use rayon::{ iter::{IntoParallelIterator, ParallelIterator}, + prelude::*, ThreadPool, }; use thread_local::ThreadLocal; use cuprate_database::{ConcreteEnv, DatabaseRo, Env, EnvInner, RuntimeError}; -use cuprate_database_service::{init_thread_pool, DatabaseReadService, ReaderThreads}; +use cuprate_database_service::{DatabaseReadService, init_thread_pool, ReaderThreads}; use cuprate_helper::map::combine_low_high_bits_to_u128; use cuprate_types::{ blockchain::{BlockchainReadRequest, BlockchainResponse}, - Chain, ExtendedBlockHeader, OutputOnChain, + Chain, ChainId, ExtendedBlockHeader, OutputOnChain, }; use crate::{ ops::{ - alt_block::{get_alt_block_hash, get_alt_extended_headers_in_range}, + alt_block::{ + get_alt_block_extended_header_from_height, get_alt_block_hash, + get_alt_chain_history_ranges, + }, block::{ block_exists, get_block_extended_header_from_height, get_block_height, get_block_info, }, @@ -35,8 +39,11 @@ use crate::{ types::{BlockchainReadHandle, ResponseResult}, }, tables::{AltBlockHeights, BlockHeights, BlockInfos, OpenTables, Tables}, - types::{Amount, AmountIndex, BlockHash, BlockHeight, KeyImage, PreRctOutputId}, + types::{ + AltBlockHeight, Amount, AmountIndex, BlockHash, BlockHeight, KeyImage, PreRctOutputId, + }, }; +use crate::ops::alt_block::get_alt_block; //---------------------------------------------------------------------------------------------------- init_read_service /// Initialize the [`BlockchainReadHandle`] thread-pool backed by [`rayon`]. @@ -100,6 +107,7 @@ fn map_request( R::KeyImagesSpent(set) => key_images_spent(env, set), R::CompactChainHistory => compact_chain_history(env), R::FindFirstUnknown(block_ids) => find_first_unknown(env, &block_ids), + R::AltBlocksInChain(chain_id) => alt_blocks_in_chain(env, chain_id), } /* SOMEDAY: post-request handling, run some code for each request? */ @@ -200,7 +208,7 @@ fn block_hash(env: &ConcreteEnv, block_height: BlockHeight, chain: Chain) -> Res let block_hash = match chain { Chain::Main => get_block_info(&block_height, &table_block_infos)?.block_hash, Chain::Alt(chain) => { - get_alt_block_hash(&block_height, chain, &mut env_inner.open_tables(&tx_ro)?)? + get_alt_block_hash(&block_height, chain, &env_inner.open_tables(&tx_ro)?)? } }; @@ -283,12 +291,36 @@ fn block_extended_header_in_range( }) .collect::, RuntimeError>>()?, Chain::Alt(chain_id) => { - let tx_ro = tx_ro.get_or_try(|| env_inner.tx_ro())?; - get_alt_extended_headers_in_range( - range, - chain_id, - get_tables!(env_inner, tx_ro, tables)?.as_ref(), - )? + let ranges = { + let tx_ro = tx_ro.get_or_try(|| env_inner.tx_ro())?; + let tables = get_tables!(env_inner, tx_ro, tables)?.as_ref(); + let alt_chains = tables.alt_chain_infos(); + + get_alt_chain_history_ranges(range, chain_id, alt_chains)? + }; + + ranges + .par_iter() + .rev() + .map(|(chain, range)| { + range.clone().into_par_iter().map(|height| { + let tx_ro = tx_ro.get_or_try(|| env_inner.tx_ro())?; + let tables = get_tables!(env_inner, tx_ro, tables)?.as_ref(); + + match *chain { + Chain::Main => get_block_extended_header_from_height(&height, tables), + Chain::Alt(chain_id) => get_alt_block_extended_header_from_height( + &AltBlockHeight { + chain_id: chain_id.into(), + height, + }, + tables, + ), + } + }) + }) + .flatten() + .collect::, _>>()? } }; @@ -524,3 +556,45 @@ fn find_first_unknown(env: &ConcreteEnv, block_ids: &[BlockHash]) -> ResponseRes BlockchainResponse::FindFirstUnknown(Some((idx, last_known_height + 1))) }) } + +/// [`BlockchainReadRequest::AltBlocksInChain`] +fn alt_blocks_in_chain(env: &ConcreteEnv, chain_id: ChainId) -> ResponseResult { + // Prepare tx/tables in `ThreadLocal`. + let env_inner = env.env_inner(); + let tx_ro = thread_local(env); + let tables = thread_local(env); + + // Get the history of this alt-chain. + let history = { + let tx_ro = tx_ro.get_or_try(|| env_inner.tx_ro())?; + let tables = get_tables!(env_inner, tx_ro, tables)?.as_ref(); + get_alt_chain_history_ranges(0..usize::MAX, chain_id, tables.alt_chain_infos())? + }; + + // Get all the blocks until we join the main-chain. + let blocks = history + .par_iter() + .rev() + .skip(1) + .flat_map(|(chain_id, range)| { + let Chain::Alt(chain_id) = chain_id else { + panic!("Should not have main chain blocks here we skipped last range"); + }; + + range.clone().into_par_iter().map(|height| { + let tx_ro = tx_ro.get_or_try(|| env_inner.tx_ro())?; + let tables = get_tables!(env_inner, tx_ro, tables)?.as_ref(); + + get_alt_block( + &AltBlockHeight { + chain_id: (*chain_id).into(), + height, + }, + tables, + ) + }) + }) + .collect::>()?; + + Ok(BlockchainResponse::AltBlocksInChain(blocks)) +} diff --git a/storage/blockchain/src/service/write.rs b/storage/blockchain/src/service/write.rs index 95124d41..849a3030 100644 --- a/storage/blockchain/src/service/write.rs +++ b/storage/blockchain/src/service/write.rs @@ -9,12 +9,13 @@ use cuprate_types::{ AltBlockInformation, Chain, ChainId, VerifiedBlockInformation, }; -use crate::service::free::map_valid_alt_block_to_verified_block; -use crate::types::AltBlockHeight; use crate::{ - service::types::{BlockchainWriteHandle, ResponseResult}, + service::{ + free::map_valid_alt_block_to_verified_block, + types::{BlockchainWriteHandle, ResponseResult}, + }, tables::{OpenTables, Tables, TablesMut}, - types::AltChainInfo, + types::{AltBlockHeight, AltChainInfo}, }; //---------------------------------------------------------------------------------------------------- init_write_service @@ -106,19 +107,23 @@ fn pop_blocks(env: &ConcreteEnv, numb_blocks: usize) -> ResponseResult { let env_inner = env.env_inner(); let mut tx_rw = env_inner.tx_rw()?; + // TODO: try blocks let result = { + // flush all the current alt blocks as they may reference blocks to be popped. crate::ops::alt_block::flush_alt_blocks(&env_inner, &mut tx_rw)?; let mut tables_mut = env_inner.open_tables_mut(&tx_rw)?; - + // generate a `ChainId` for the popped blocks. let old_main_chain_id = ChainId(rand::random()); + // pop the blocks let mut last_block_height = 0; for _ in 0..numb_blocks { (last_block_height, _, _) = crate::ops::block::pop_block(Some(old_main_chain_id), &mut tables_mut)?; } + // Update the alt_chain_info with the correct information. tables_mut.alt_chain_infos_mut().put( &old_main_chain_id.into(), &AltChainInfo { @@ -155,11 +160,14 @@ fn reverse_reorg(env: &ConcreteEnv, chain_id: ChainId) -> ResponseResult { let mut tables_mut = env_inner.open_tables_mut(&tx_rw)?; let chain_info = tables_mut.alt_chain_infos().get(&chain_id.into())?; + // Although this doesn't guarantee the chain was popped from the main-chain, it's an easy + // thing for us to check. assert_eq!(Chain::from(chain_info.parent_chain), Chain::Main); let tob_block_height = crate::ops::blockchain::top_block_height(tables_mut.block_heights())?; + // pop any blocks that were added as part of a re-org. for _ in chain_info.common_ancestor_height..tob_block_height { crate::ops::block::pop_block(None, &mut tables_mut)?; } @@ -177,6 +185,7 @@ fn reverse_reorg(env: &ConcreteEnv, chain_id: ChainId) -> ResponseResult { }) .collect::>(); + // Add the old main chain blocks back to the main chain. for res_alt_block in alt_blocks { let alt_block = res_alt_block?; diff --git a/storage/blockchain/src/tests.rs b/storage/blockchain/src/tests.rs index 60239127..d57a3715 100644 --- a/storage/blockchain/src/tests.rs +++ b/storage/blockchain/src/tests.rs @@ -90,7 +90,10 @@ pub(crate) fn assert_all_tables_are_empty(env: &ConcreteEnv) { assert_eq!(crate::ops::tx::get_num_tx(tables.tx_ids()).unwrap(), 0); } -pub(crate) fn map_verified_block_to_alt(verified_block: VerifiedBlockInformation, chain_id: ChainId) -> AltBlockInformation { +pub(crate) fn map_verified_block_to_alt( + verified_block: VerifiedBlockInformation, + chain_id: ChainId, +) -> AltBlockInformation { AltBlockInformation { block: verified_block.block, block_blob: verified_block.block_blob, @@ -103,4 +106,4 @@ pub(crate) fn map_verified_block_to_alt(verified_block: VerifiedBlockInformation cumulative_difficulty: verified_block.cumulative_difficulty, chain_id, } -} \ No newline at end of file +} diff --git a/types/src/blockchain.rs b/types/src/blockchain.rs index c2a5517d..9f79c3a3 100644 --- a/types/src/blockchain.rs +++ b/types/src/blockchain.rs @@ -3,14 +3,15 @@ //! Tests that assert particular requests lead to particular //! responses are also tested in Cuprate's blockchain database crate. -//---------------------------------------------------------------------------------------------------- Import -use crate::types::{Chain, ExtendedBlockHeader, OutputOnChain, VerifiedBlockInformation}; -use crate::{AltBlockInformation, ChainId}; use std::{ collections::{HashMap, HashSet}, ops::Range, }; +use crate::{AltBlockInformation, ChainId}; +//---------------------------------------------------------------------------------------------------- Import +use crate::types::{Chain, ExtendedBlockHeader, OutputOnChain, VerifiedBlockInformation}; + //---------------------------------------------------------------------------------------------------- ReadRequest /// A read request to the blockchain database. /// @@ -92,12 +93,14 @@ pub enum BlockchainReadRequest { CompactChainHistory, /// A request to find the first unknown block ID in a list of block IDs. - //// + /// /// # Invariant /// The [`Vec`] containing the block IDs must be sorted in chronological block /// order, or else the returned response is unspecified and meaningless, /// as this request performs a binary search. FindFirstUnknown(Vec<[u8; 32]>), + /// A request for all alt blocks in the chain with the given [`ChainId`]. + AltBlocksInChain(ChainId), } //---------------------------------------------------------------------------------------------------- WriteRequest @@ -120,12 +123,14 @@ pub enum BlockchainWriteRequest { /// /// Input is the amount of blocks to pop. /// - /// This request flush all alt-chains from the cache before adding the popped blocks to the alt cache. + /// This request flushes all alt-chains from the cache before adding the popped blocks to the + /// alt cache. PopBlocks(usize), /// A request to reverse the re-org process. /// /// The inner value is the [`ChainId`] of the old main chain. /// + /// # Invariant /// It is invalid to call this with a [`ChainId`] that was not returned from [`BlockchainWriteRequest::PopBlocks`]. ReverseReorg(ChainId), /// A request to flush all alternative blocks. @@ -215,6 +220,11 @@ pub enum BlockchainResponse { /// This will be [`None`] if all blocks were known. FindFirstUnknown(Option<(usize, usize)>), + /// The response for [`BlockchainReadRequest::AltBlocksInChain`]. + /// + /// Contains all the alt blocks in the alt-chain in chronological order. + AltBlocksInChain(Vec), + //------------------------------------------------------ Writes /// A generic Ok response to indicate a request was successfully handled. /// From f92375f6a61d72fa802e4a75ca7cba3f8d968363 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sat, 7 Sep 2024 02:07:23 +0100 Subject: [PATCH 17/72] clippy + fmt --- storage/blockchain/src/service/read.rs | 4 ++-- storage/blockchain/src/types.rs | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/storage/blockchain/src/service/read.rs b/storage/blockchain/src/service/read.rs index 416e6137..835f2d6a 100644 --- a/storage/blockchain/src/service/read.rs +++ b/storage/blockchain/src/service/read.rs @@ -14,13 +14,14 @@ use rayon::{ use thread_local::ThreadLocal; use cuprate_database::{ConcreteEnv, DatabaseRo, Env, EnvInner, RuntimeError}; -use cuprate_database_service::{DatabaseReadService, init_thread_pool, ReaderThreads}; +use cuprate_database_service::{init_thread_pool, DatabaseReadService, ReaderThreads}; use cuprate_helper::map::combine_low_high_bits_to_u128; use cuprate_types::{ blockchain::{BlockchainReadRequest, BlockchainResponse}, Chain, ChainId, ExtendedBlockHeader, OutputOnChain, }; +use crate::ops::alt_block::get_alt_block; use crate::{ ops::{ alt_block::{ @@ -43,7 +44,6 @@ use crate::{ AltBlockHeight, Amount, AmountIndex, BlockHash, BlockHeight, KeyImage, PreRctOutputId, }, }; -use crate::ops::alt_block::get_alt_block; //---------------------------------------------------------------------------------------------------- init_read_service /// Initialize the [`BlockchainReadHandle`] thread-pool backed by [`rayon`]. diff --git a/storage/blockchain/src/types.rs b/storage/blockchain/src/types.rs index 14917249..13c44994 100644 --- a/storage/blockchain/src/types.rs +++ b/storage/blockchain/src/types.rs @@ -44,12 +44,12 @@ use std::num::NonZero; use bytemuck::{Pod, Zeroable}; - #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use cuprate_database::{Key, StorableVec}; use cuprate_types::{Chain, ChainId}; + //---------------------------------------------------------------------------------------------------- Aliases // These type aliases exist as many Monero-related types are the exact same. // For clarity, they're given type aliases as to not confuse them. @@ -334,17 +334,15 @@ pub struct RawChain(u64); impl From for RawChain { fn from(value: Chain) -> Self { match value { - Chain::Main => RawChain(0), - Chain::Alt(chain_id) => RawChain(chain_id.0.get()), + Chain::Main => Self(0), + Chain::Alt(chain_id) => Self(chain_id.0.get()), } } } impl From for Chain { fn from(value: RawChain) -> Self { - NonZero::new(value.0) - .map(|id| Chain::Alt(ChainId(id))) - .unwrap_or(Chain::Main) + NonZero::new(value.0).map_or(Self::Main, |id| Self::Alt(ChainId(id))) } } @@ -352,7 +350,7 @@ impl From for RawChain { fn from(value: RawChainId) -> Self { assert_ne!(value.0, 0); - RawChain(value.0) + Self(value.0) } } @@ -363,13 +361,13 @@ pub struct RawChainId(u64); impl From for RawChainId { fn from(value: ChainId) -> Self { - RawChainId(value.0.get()) + Self(value.0.get()) } } impl From for ChainId { fn from(value: RawChainId) -> Self { - ChainId(NonZero::new(value.0).expect("RawChainId mut not have a value of `0`")) + Self(NonZero::new(value.0).expect("RawChainId mut not have a value of `0`")) } } From a864f934be9f2e42cbda24d66dfb83ee9ff84f91 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sat, 7 Sep 2024 02:45:45 +0100 Subject: [PATCH 18/72] document types --- storage/blockchain/src/types.rs | 164 ++++++++++++++++++++++++++++++-- types/src/blockchain.rs | 4 - 2 files changed, 157 insertions(+), 11 deletions(-) diff --git a/storage/blockchain/src/types.rs b/storage/blockchain/src/types.rs index 13c44994..e9665695 100644 --- a/storage/blockchain/src/types.rs +++ b/storage/blockchain/src/types.rs @@ -327,6 +327,29 @@ pub struct RctOutput { // TODO: local_index? //---------------------------------------------------------------------------------------------------- RawChain +/// [`Chain`] in a format which can be stored in the DB. +/// +/// Implements [`Into`] and [`From`] for [`Chain`]. +/// +/// ```rust +/// # use std::borrow::*; +/// # use cuprate_blockchain::{*, types::*}; +/// use cuprate_database::Storable; +/// use cuprate_types::Chain; +/// +/// // Assert Storable is correct. +/// let a: RawChain = Chain::Main.into(); +/// let b = Storable::as_bytes(&a); +/// let c: RawChain = Storable::from_bytes(b); +/// assert_eq!(a, c); +/// ``` +/// +/// # Size & Alignment +/// ```rust +/// # use cuprate_blockchain::types::*; +/// assert_eq!(size_of::(), 8); +/// assert_eq!(align_of::(), 8); +/// ``` #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] #[repr(transparent)] pub struct RawChain(u64); @@ -348,6 +371,7 @@ impl From for Chain { impl From for RawChain { fn from(value: RawChainId) -> Self { + // A [`ChainID`] with an inner value of `0` is invalid. assert_ne!(value.0, 0); Self(value.0) @@ -355,6 +379,29 @@ impl From for RawChain { } //---------------------------------------------------------------------------------------------------- RawChainId +/// [`ChainId`] in a format which can be stored in the DB. +/// +/// Implements [`Into`] and [`From`] for [`ChainId`]. +/// +/// ```rust +/// # use std::borrow::*; +/// # use cuprate_blockchain::{*, types::*}; +/// use cuprate_database::Storable; +/// use cuprate_types::ChainId; +/// +/// // Assert Storable is correct. +/// let a: RawChainId = ChainId(10.try_into().unwrap()).into(); +/// let b = Storable::as_bytes(&a); +/// let c: RawChainId = Storable::from_bytes(b); +/// assert_eq!(a, c); +/// ``` +/// +/// # Size & Alignment +/// ```rust +/// # use cuprate_blockchain::types::*; +/// assert_eq!(size_of::(), 8); +/// assert_eq!(align_of::(), 8); +/// ``` #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] #[repr(transparent)] pub struct RawChainId(u64); @@ -374,31 +421,112 @@ impl From for ChainId { impl Key for RawChainId {} //---------------------------------------------------------------------------------------------------- AltChainInfo +/// Information on an alternative chain. +/// +/// ```rust +/// # use std::borrow::*; +/// # use cuprate_blockchain::{*, types::*}; +/// use cuprate_database::Storable; +/// use cuprate_types::Chain; +/// +/// // Assert Storable is correct. +/// let a: AltChainInfo = AltChainInfo { +/// parent_chain: Chain::Main.into(), +/// common_ancestor_height: 0, +/// chain_height: 1, +/// }; +/// let b = Storable::as_bytes(&a); +/// let c: AltChainInfo = Storable::from_bytes(b); +/// assert_eq!(a, c); +/// ``` +/// +/// # Size & Alignment +/// ```rust +/// # use cuprate_blockchain::types::*; +/// assert_eq!(size_of::(), 24); +/// assert_eq!(align_of::(), 8); +/// ``` #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] #[repr(C)] pub struct AltChainInfo { + /// The chain this alt chain forks from. pub parent_chain: RawChain, + /// The height of the first block we share with the parent chain. pub common_ancestor_height: usize, + /// The chain height of the blocks in this alt chain. pub chain_height: usize, } //---------------------------------------------------------------------------------------------------- AltBlockHeight +/// Represents the height of a block on an alt-chain. +/// +/// ```rust +/// # use std::borrow::*; +/// # use cuprate_blockchain::{*, types::*}; +/// use cuprate_database::Storable; +/// use cuprate_types::ChainId; +/// +/// // Assert Storable is correct. +/// let a: AltBlockHeight = AltBlockHeight { +/// chain_id: ChainId(1.try_into().unwrap()).into(), +/// height: 1, +/// }; +/// let b = Storable::as_bytes(&a); +/// let c: AltBlockHeight = Storable::from_bytes(b); +/// assert_eq!(a, c); +/// ``` +/// +/// # Size & Alignment +/// ```rust +/// # use cuprate_blockchain::types::*; +/// assert_eq!(size_of::(), 16); +/// assert_eq!(align_of::(), 8); +/// ``` #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] #[repr(C)] pub struct AltBlockHeight { + /// The [`ChainId`] of the chain this alt block is on, in raw form. pub chain_id: RawChainId, + /// The height of this alt-block. pub height: usize, } impl Key for AltBlockHeight {} //---------------------------------------------------------------------------------------------------- CompactAltBlockInfo +/// Represents information on an alt-chain. +/// +/// ```rust +/// # use std::borrow::*; +/// # use cuprate_blockchain::{*, types::*}; +/// use cuprate_database::Storable; +/// +/// // Assert Storable is correct. +/// let a: CompactAltBlockInfo = CompactAltBlockInfo { +/// block_hash: [1; 32], +/// pow_hash: [2; 32], +/// height: 10, +/// weight: 20, +/// long_term_weight: 30, +/// cumulative_difficulty_low: 40, +/// cumulative_difficulty_high: 50, +/// }; +/// +/// let b = Storable::as_bytes(&a); +/// let c: CompactAltBlockInfo = Storable::from_bytes(b); +/// assert_eq!(a, c); +/// ``` +/// +/// # Size & Alignment +/// ```rust +/// # use cuprate_blockchain::types::*; +/// assert_eq!(size_of::(), 104); +/// assert_eq!(align_of::(), 8); +/// ``` #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] #[repr(C)] pub struct CompactAltBlockInfo { /// The block's hash. - /// - /// [`Block::hash`]. pub block_hash: [u8; 32], /// The block's proof-of-work hash. pub pow_hash: [u8; 32], @@ -408,24 +536,46 @@ pub struct CompactAltBlockInfo { pub weight: usize, /// The long term block weight, which is the weight factored in with previous block weights. pub long_term_weight: usize, - /// The cumulative difficulty of all blocks up until and including this block. + /// The low 64 bits of the cumulative difficulty. pub cumulative_difficulty_low: u64, + /// The high 64 bits of the cumulative difficulty. pub cumulative_difficulty_high: u64, } //---------------------------------------------------------------------------------------------------- AltTransactionInfo +/// Represents information on an alt transaction. +/// +/// ```rust +/// # use std::borrow::*; +/// # use cuprate_blockchain::{*, types::*}; +/// use cuprate_database::Storable; +/// +/// // Assert Storable is correct. +/// let a: AltTransactionInfo = AltTransactionInfo { +/// tx_weight: 1, +/// fee: 6, +/// tx_hash: [6; 32], +/// }; +/// +/// let b = Storable::as_bytes(&a); +/// let c: AltTransactionInfo = Storable::from_bytes(b); +/// assert_eq!(a, c); +/// ``` +/// +/// # Size & Alignment +/// ```rust +/// # use cuprate_blockchain::types::*; +/// assert_eq!(size_of::(), 48); +/// assert_eq!(align_of::(), 8); +/// ``` #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] #[repr(C)] pub struct AltTransactionInfo { /// The transaction's weight. - /// - /// [`Transaction::weight`]. pub tx_weight: usize, /// The transaction's total fees. pub fee: u64, /// The transaction's hash. - /// - /// [`Transaction::hash`]. pub tx_hash: [u8; 32], } diff --git a/types/src/blockchain.rs b/types/src/blockchain.rs index 9f79c3a3..6c7ecf37 100644 --- a/types/src/blockchain.rs +++ b/types/src/blockchain.rs @@ -105,10 +105,6 @@ pub enum BlockchainReadRequest { //---------------------------------------------------------------------------------------------------- WriteRequest /// A write request to the blockchain database. -/// -/// There is currently only 1 write request to the database, -/// as such, the only valid [`BlockchainResponse`] to this request is -/// the proper response for a [`BlockchainResponse::WriteBlockOk`]. #[derive(Debug, Clone, PartialEq, Eq)] pub enum BlockchainWriteRequest { /// Request that a block be written to the database. From 6119972fe81ff9969a64cc07cbcb2f8bd7fc9220 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sun, 8 Sep 2024 02:08:20 +0100 Subject: [PATCH 19/72] move tx_fee to helper --- helper/Cargo.toml | 4 ++- helper/src/lib.rs | 2 ++ helper/src/tx_utils.rs | 34 ++++++++++++++++++++++++ storage/blockchain/src/free.rs | 32 ----------------------- storage/blockchain/src/ops/block.rs | 8 +++--- test-utils/Cargo.toml | 2 +- test-utils/src/data/statics.rs | 40 ++++------------------------- 7 files changed, 50 insertions(+), 72 deletions(-) create mode 100644 helper/src/tx_utils.rs diff --git a/helper/Cargo.toml b/helper/Cargo.toml index c74e40fd..4bd17ca8 100644 --- a/helper/Cargo.toml +++ b/helper/Cargo.toml @@ -9,8 +9,9 @@ repository = "https://github.com/Cuprate/cuprate/tree/main/consensus" [features] +# TODO: I don't think this is a good idea # All features on by default. -default = ["std", "atomic", "asynch", "cast", "fs", "num", "map", "time", "thread", "constants"] +default = ["std", "atomic", "asynch", "cast", "fs", "num", "map", "time", "thread", "constants", "tx-utils"] std = [] atomic = ["dep:crossbeam"] asynch = ["dep:futures", "dep:rayon"] @@ -21,6 +22,7 @@ num = [] map = ["cast", "dep:monero-serai"] time = ["dep:chrono", "std"] thread = ["std", "dep:target_os_lib"] +tx-utils = ["dep:monero-serai"] [dependencies] crossbeam = { workspace = true, optional = true } diff --git a/helper/src/lib.rs b/helper/src/lib.rs index de0d9555..e82ec827 100644 --- a/helper/src/lib.rs +++ b/helper/src/lib.rs @@ -31,6 +31,8 @@ pub mod thread; #[cfg(feature = "time")] pub mod time; +#[cfg(feature = "tx-utils")] +pub mod tx_utils; //---------------------------------------------------------------------------------------------------- Private Usage //---------------------------------------------------------------------------------------------------- diff --git a/helper/src/tx_utils.rs b/helper/src/tx_utils.rs new file mode 100644 index 00000000..aeccf32b --- /dev/null +++ b/helper/src/tx_utils.rs @@ -0,0 +1,34 @@ +//! Utils for working with [`Transaction`] + +use monero_serai::transaction::{Input, Transaction}; + +/// Calculates the fee of the [`Transaction`]. +/// +/// # Panics +/// This will panic if the inputs overflow or the transaction outputs too much, so should only +/// be used on known to be valid txs. +pub fn tx_fee(tx: &Transaction) -> u64 { + let mut fee = 0_u64; + + match &tx { + Transaction::V1 { prefix, .. } => { + for input in &prefix.inputs { + match input { + Input::Gen(_) => return 0, + Input::ToKey { amount, .. } => { + fee = fee.checked_add(amount.unwrap_or(0)).unwrap(); + } + } + } + + for output in &prefix.outputs { + fee.checked_sub(output.amount.unwrap_or(0)).unwrap(); + } + } + Transaction::V2 { proofs, .. } => { + fee = proofs.as_ref().unwrap().base.fee; + } + }; + + fee +} diff --git a/storage/blockchain/src/free.rs b/storage/blockchain/src/free.rs index 20d56226..8288e65f 100644 --- a/storage/blockchain/src/free.rs +++ b/storage/blockchain/src/free.rs @@ -1,6 +1,5 @@ //! General free functions (related to the database). -use monero_serai::transaction::{Input, Transaction}; //---------------------------------------------------------------------------------------------------- Import use cuprate_database::{ConcreteEnv, Env, EnvInner, InitError, RuntimeError, TxRw}; @@ -62,37 +61,6 @@ pub fn open(config: Config) -> Result { Ok(env) } -//---------------------------------------------------------------------------------------------------- Tx Fee -/// Calculates the fee of the [`Transaction`]. -/// -/// # Panics -/// This will panic if the inputs overflow or the transaction outputs too much. -pub(crate) fn tx_fee(tx: &Transaction) -> u64 { - let mut fee = 0_u64; - - match &tx { - Transaction::V1 { prefix, .. } => { - for input in &prefix.inputs { - match input { - Input::Gen(_) => return 0, - Input::ToKey { amount, .. } => { - fee = fee.checked_add(amount.unwrap_or(0)).unwrap(); - } - } - } - - for output in &prefix.outputs { - fee.checked_sub(output.amount.unwrap_or(0)).unwrap(); - } - } - Transaction::V2 { proofs, .. } => { - fee = proofs.as_ref().unwrap().base.fee; - } - }; - - fee -} - //---------------------------------------------------------------------------------------------------- Tests #[cfg(test)] mod test { diff --git a/storage/blockchain/src/ops/block.rs b/storage/blockchain/src/ops/block.rs index 45bab41c..29586925 100644 --- a/storage/blockchain/src/ops/block.rs +++ b/storage/blockchain/src/ops/block.rs @@ -7,16 +7,18 @@ use monero_serai::block::{Block, BlockHeader}; use cuprate_database::{ RuntimeError, StorableVec, {DatabaseRo, DatabaseRw}, }; -use cuprate_helper::map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}; +use cuprate_helper::{ + map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}, + tx_utils::tx_fee, +}; use cuprate_types::{ AltBlockInformation, ChainId, ExtendedBlockHeader, HardFork, VerifiedBlockInformation, VerifiedTransactionInformation, }; -use crate::free::tx_fee; -use crate::ops::alt_block; use crate::{ ops::{ + alt_block, blockchain::{chain_height, cumulative_generated_coins}, macros::doc_error, output::get_rct_num_outputs, diff --git a/test-utils/Cargo.toml b/test-utils/Cargo.toml index a96a9cfc..9c64bd81 100644 --- a/test-utils/Cargo.toml +++ b/test-utils/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Boog900", "hinto-janai"] [dependencies] cuprate-types = { path = "../types" } -cuprate-helper = { path = "../helper", features = ["map"] } +cuprate-helper = { path = "../helper", features = ["map", "tx-utils"] } cuprate-wire = { path = "../net/wire" } cuprate-p2p-core = { path = "../p2p/p2p-core", features = ["borsh"] } diff --git a/test-utils/src/data/statics.rs b/test-utils/src/data/statics.rs index 8b98171a..a45cc13f 100644 --- a/test-utils/src/data/statics.rs +++ b/test-utils/src/data/statics.rs @@ -8,12 +8,12 @@ //---------------------------------------------------------------------------------------------------- Import use std::sync::LazyLock; -use cuprate_helper::map::combine_low_high_bits_to_u128; -use cuprate_types::{VerifiedBlockInformation, VerifiedTransactionInformation}; use hex_literal::hex; -use monero_serai::transaction::Input; use monero_serai::{block::Block, transaction::Transaction}; +use cuprate_helper::{map::combine_low_high_bits_to_u128, tx_utils::tx_fee}; +use cuprate_types::{VerifiedBlockInformation, VerifiedTransactionInformation}; + use crate::data::constants::{ BLOCK_43BD1F, BLOCK_5ECB7E, BLOCK_F91043, TX_2180A8, TX_3BC7FF, TX_84D48D, TX_9E3F73, TX_B6B439, TX_D7FEBD, TX_E2D393, TX_E57440, @@ -110,36 +110,6 @@ fn to_tx_verification_data(tx_blob: impl AsRef<[u8]>) -> VerifiedTransactionInfo } } -/// Calculates the fee of the [`Transaction`]. -/// -/// # Panics -/// This will panic if the inputs overflow or the transaction outputs too much. -pub fn tx_fee(tx: &Transaction) -> u64 { - let mut fee = 0_u64; - - match &tx { - Transaction::V1 { prefix, .. } => { - for input in &prefix.inputs { - match input { - Input::Gen(_) => return 0, - Input::ToKey { amount, .. } => { - fee = fee.checked_add(amount.unwrap_or(0)).unwrap(); - } - } - } - - for output in &prefix.outputs { - fee.checked_sub(output.amount.unwrap_or(0)).unwrap(); - } - } - Transaction::V2 { proofs, .. } => { - fee = proofs.as_ref().unwrap().base.fee; - } - }; - - fee -} - //---------------------------------------------------------------------------------------------------- Blocks /// Generate a `static LazyLock`. /// @@ -311,12 +281,12 @@ transaction_verification_data! { //---------------------------------------------------------------------------------------------------- TESTS #[cfg(test)] mod tests { - use super::*; - use pretty_assertions::assert_eq; use crate::rpc::client::HttpRpcClient; + use super::*; + /// Assert the defined blocks are the same compared to ones received from a local RPC call. #[ignore] // FIXME: doesn't work in CI, we need a real unrestricted node #[tokio::test] From b211210fa24c220dac1c46824430e1a1accaaebf Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sun, 8 Sep 2024 15:34:30 +0100 Subject: [PATCH 20/72] more doc updates --- storage/blockchain/src/ops/alt_block/block.rs | 7 ++----- storage/blockchain/src/ops/alt_block/mod.rs | 6 +++--- storage/blockchain/src/ops/alt_block/tx.rs | 8 +++++--- storage/blockchain/src/service/free.rs | 14 ++++++++++---- storage/blockchain/src/service/read.rs | 7 +++---- storage/blockchain/src/service/write.rs | 17 +++++++++-------- storage/blockchain/src/tables.rs | 16 ++++++++++++++++ test-utils/src/data/mod.rs | 6 ++---- test-utils/src/rpc/client.rs | 13 ++++++------- 9 files changed, 56 insertions(+), 38 deletions(-) diff --git a/storage/blockchain/src/ops/alt_block/block.rs b/storage/blockchain/src/ops/alt_block/block.rs index 07878d55..5bc052b7 100644 --- a/storage/blockchain/src/ops/alt_block/block.rs +++ b/storage/blockchain/src/ops/alt_block/block.rs @@ -24,12 +24,9 @@ use crate::{ /// /// # Panics /// This function will panic if: -/// - `block.height` is == `0` +/// - `alt_block.height` is == `0` +/// - `alt_block.txs.len()` != `alt_block.block.transactions.len()` /// -/// # Already exists -/// This function will operate normally even if `block` already -/// exists, i.e., this function will not return `Err` even if you -/// call this function infinitely with the same block. pub fn add_alt_block( alt_block: &AltBlockInformation, tables: &mut impl TablesMut, diff --git a/storage/blockchain/src/ops/alt_block/mod.rs b/storage/blockchain/src/ops/alt_block/mod.rs index 36e4768e..96c1cecf 100644 --- a/storage/blockchain/src/ops/alt_block/mod.rs +++ b/storage/blockchain/src/ops/alt_block/mod.rs @@ -18,8 +18,8 @@ //! ``` //! //! In that example if we were to receive an alt-block which immediately follows the top block of `ChainID(X)` -//! then that block will also be stored under `ChainID(X)`. However if it follows from another block from `ChainID(X)` -//! we will split into a chain with a different ID. +//! then that block will also be stored under `ChainID(X)`. However, if it follows from another block from `ChainID(X)` +//! we will split into a chain with a different ID: //! //! ```text //! | @@ -39,7 +39,7 @@ //! [`get_alt_chain_history_ranges`] covers this and is the method to get the ranges of heights needed from each [`ChainID`](cuprate_types::ChainId) //! to get all the alt-blocks in a given [`ChainID`](cuprate_types::ChainId). //! -//! Although this should be kept in mind as a possibility because Cuprate's block downloader will only track a single chain it is +//! Although this should be kept in mind as a possibility, because Cuprate's block downloader will only track a single chain it is //! unlikely that we will be tracking [`ChainID`](cuprate_types::ChainId) that don't immediately connect to the main-chain. //! //! ## Why not use block's previous field? diff --git a/storage/blockchain/src/ops/alt_block/tx.rs b/storage/blockchain/src/ops/alt_block/tx.rs index 5671e4b4..aa2e82f4 100644 --- a/storage/blockchain/src/ops/alt_block/tx.rs +++ b/storage/blockchain/src/ops/alt_block/tx.rs @@ -4,9 +4,11 @@ use monero_serai::transaction::Transaction; use cuprate_database::{DatabaseRo, DatabaseRw, RuntimeError, StorableVec}; use cuprate_types::VerifiedTransactionInformation; -use crate::ops::macros::{doc_add_alt_block_inner_invariant, doc_error}; -use crate::tables::{Tables, TablesMut}; -use crate::types::{AltTransactionInfo, TxHash}; +use crate::{ + ops::macros::{doc_add_alt_block_inner_invariant, doc_error}, + tables::{Tables, TablesMut}, + types::{AltTransactionInfo, TxHash}, +}; /// Adds a [`VerifiedTransactionInformation`] form an alt-block to the DB, if /// that transaction is not already in the DB. diff --git a/storage/blockchain/src/service/free.rs b/storage/blockchain/src/service/free.rs index 7a4e6ce6..d12844f3 100644 --- a/storage/blockchain/src/service/free.rs +++ b/storage/blockchain/src/service/free.rs @@ -3,13 +3,14 @@ //---------------------------------------------------------------------------------------------------- Import use std::sync::Arc; -use crate::service::{init_read_service, init_write_service}; +use cuprate_database::{ConcreteEnv, InitError}; +use cuprate_types::{AltBlockInformation, VerifiedBlockInformation}; + use crate::{ config::Config, service::types::{BlockchainReadHandle, BlockchainWriteHandle}, }; -use cuprate_database::{ConcreteEnv, InitError}; -use cuprate_types::{AltBlockInformation, VerifiedBlockInformation}; +use crate::service::{init_read_service, init_write_service}; //---------------------------------------------------------------------------------------------------- Init #[cold] @@ -81,7 +82,12 @@ pub(super) const fn compact_history_genesis_not_included INITIAL_BLOCKS && !(top_block_height - INITIAL_BLOCKS + 2).is_power_of_two() } -//---------------------------------------------------------------------------------------------------- Compact history +//---------------------------------------------------------------------------------------------------- Map Block +/// Maps [`AltBlockInformation`] to [`VerifiedBlockInformation`] +/// +/// # Panics +/// This will panic if the block is invalid, so should only be used on blocks that have been popped from +/// the main-chain. pub(super) fn map_valid_alt_block_to_verified_block( alt_block: AltBlockInformation, ) -> VerifiedBlockInformation { diff --git a/storage/blockchain/src/service/read.rs b/storage/blockchain/src/service/read.rs index 835f2d6a..3d0379e0 100644 --- a/storage/blockchain/src/service/read.rs +++ b/storage/blockchain/src/service/read.rs @@ -1,11 +1,11 @@ //! Database reader thread-pool definitions and logic. +//---------------------------------------------------------------------------------------------------- Import use std::{ collections::{HashMap, HashSet}, sync::Arc, }; -//---------------------------------------------------------------------------------------------------- Import use rayon::{ iter::{IntoParallelIterator, ParallelIterator}, prelude::*, @@ -14,18 +14,17 @@ use rayon::{ use thread_local::ThreadLocal; use cuprate_database::{ConcreteEnv, DatabaseRo, Env, EnvInner, RuntimeError}; -use cuprate_database_service::{init_thread_pool, DatabaseReadService, ReaderThreads}; +use cuprate_database_service::{DatabaseReadService, init_thread_pool, ReaderThreads}; use cuprate_helper::map::combine_low_high_bits_to_u128; use cuprate_types::{ blockchain::{BlockchainReadRequest, BlockchainResponse}, Chain, ChainId, ExtendedBlockHeader, OutputOnChain, }; -use crate::ops::alt_block::get_alt_block; use crate::{ ops::{ alt_block::{ - get_alt_block_extended_header_from_height, get_alt_block_hash, + get_alt_block, get_alt_block_extended_header_from_height, get_alt_block_hash, get_alt_chain_history_ranges, }, block::{ diff --git a/storage/blockchain/src/service/write.rs b/storage/blockchain/src/service/write.rs index 849a3030..723843f5 100644 --- a/storage/blockchain/src/service/write.rs +++ b/storage/blockchain/src/service/write.rs @@ -5,8 +5,8 @@ use std::sync::Arc; use cuprate_database::{ConcreteEnv, DatabaseRo, DatabaseRw, Env, EnvInner, RuntimeError, TxRw}; use cuprate_database_service::DatabaseWriteHandle; use cuprate_types::{ - blockchain::{BlockchainResponse, BlockchainWriteRequest}, - AltBlockInformation, Chain, ChainId, VerifiedBlockInformation, + AltBlockInformation, + blockchain::{BlockchainResponse, BlockchainWriteRequest}, Chain, ChainId, VerifiedBlockInformation, }; use crate::{ @@ -107,8 +107,8 @@ fn pop_blocks(env: &ConcreteEnv, numb_blocks: usize) -> ResponseResult { let env_inner = env.env_inner(); let mut tx_rw = env_inner.tx_rw()?; - // TODO: try blocks - let result = { + // TODO: turn this function into a try block once stable. + let mut result = || { // flush all the current alt blocks as they may reference blocks to be popped. crate::ops::alt_block::flush_alt_blocks(&env_inner, &mut tx_rw)?; @@ -136,7 +136,7 @@ fn pop_blocks(env: &ConcreteEnv, numb_blocks: usize) -> ResponseResult { Ok(old_main_chain_id) }; - match result { + match result() { Ok(old_main_chain_id) => { TxRw::commit(tx_rw)?; Ok(BlockchainResponse::PopBlocks(old_main_chain_id)) @@ -156,7 +156,8 @@ fn reverse_reorg(env: &ConcreteEnv, chain_id: ChainId) -> ResponseResult { let env_inner = env.env_inner(); let tx_rw = env_inner.tx_rw()?; - let result = { + // TODO: turn this function into a try block once stable. + let result = || { let mut tables_mut = env_inner.open_tables_mut(&tx_rw)?; let chain_info = tables_mut.alt_chain_infos().get(&chain_id.into())?; @@ -197,7 +198,7 @@ fn reverse_reorg(env: &ConcreteEnv, chain_id: ChainId) -> ResponseResult { Ok(()) }; - match result { + match result() { Ok(()) => { TxRw::commit(tx_rw)?; Ok(BlockchainResponse::Ok) @@ -218,7 +219,7 @@ fn flush_alt_blocks(env: &ConcreteEnv) -> ResponseResult { let env_inner = env.env_inner(); let mut tx_rw = env_inner.tx_rw()?; - let result = { crate::ops::alt_block::flush_alt_blocks(&env_inner, &mut tx_rw) }; + let result = crate::ops::alt_block::flush_alt_blocks(&env_inner, &mut tx_rw); match result { Ok(()) => { diff --git a/storage/blockchain/src/tables.rs b/storage/blockchain/src/tables.rs index fa568ae6..74d2e591 100644 --- a/storage/blockchain/src/tables.rs +++ b/storage/blockchain/src/tables.rs @@ -131,21 +131,37 @@ cuprate_database::define_tables! { 14 => TxUnlockTime, TxId => UnlockTime, + /// Information on alt-chains. 15 => AltChainInfos, RawChainId => AltChainInfo, + /// Alt-block heights. + /// + /// Contains the height of all alt-blocks. 16 => AltBlockHeights, BlockHash => AltBlockHeight, + /// Alt-block information. + /// + /// Contains information on all alt-blocks. 17 => AltBlocksInfo, AltBlockHeight => CompactAltBlockInfo, + /// Alt-block blobs. + /// + /// Contains the raw bytes of all alt-blocks. 18 => AltBlockBlobs, AltBlockHeight => BlockBlob, + /// Alt-Block transactions blobs. + /// + /// Contains the raw bytes of alt transactions, if those transactions are not in the main-chain. 19 => AltTransactionBlobs, TxHash => TxBlob, + /// Alt-Block transactions information. + /// + /// Contains information on all alt transactions, even if they are in the main-chain. 20 => AltTransactionInfos, TxHash => AltTransactionInfo, } diff --git a/test-utils/src/data/mod.rs b/test-utils/src/data/mod.rs index b9d42fb8..3be409fe 100644 --- a/test-utils/src/data/mod.rs +++ b/test-utils/src/data/mod.rs @@ -25,13 +25,11 @@ //! let tx: VerifiedTransactionInformation = TX_V1_SIG0.clone(); //! ``` -mod constants; pub use constants::{ BLOCK_43BD1F, BLOCK_5ECB7E, BLOCK_BBD604, BLOCK_F91043, TX_2180A8, TX_3BC7FF, TX_84D48D, TX_9E3F73, TX_B6B439, TX_D7FEBD, TX_E2D393, TX_E57440, }; +pub use statics::{BLOCK_V16_TX0, BLOCK_V1_TX2, BLOCK_V9_TX3, TX_V1_SIG0, TX_V1_SIG2, TX_V2_RCT3}; +mod constants; mod statics; -pub use statics::{ - tx_fee, BLOCK_V16_TX0, BLOCK_V1_TX2, BLOCK_V9_TX3, TX_V1_SIG0, TX_V1_SIG2, TX_V2_RCT3, -}; diff --git a/test-utils/src/rpc/client.rs b/test-utils/src/rpc/client.rs index fbe6fb9e..3711334b 100644 --- a/test-utils/src/rpc/client.rs +++ b/test-utils/src/rpc/client.rs @@ -1,18 +1,16 @@ //! HTTP RPC client. //---------------------------------------------------------------------------------------------------- Use +use monero_rpc::Rpc; +use monero_serai::block::Block; +use monero_simple_request_rpc::SimpleRequestRpc; use serde::Deserialize; use serde_json::json; use tokio::task::spawn_blocking; -use monero_rpc::Rpc; -use monero_serai::block::Block; -use monero_simple_request_rpc::SimpleRequestRpc; - +use cuprate_helper::tx_utils::tx_fee; use cuprate_types::{VerifiedBlockInformation, VerifiedTransactionInformation}; -use crate::data::tx_fee; - //---------------------------------------------------------------------------------------------------- Constants /// The default URL used for Monero RPC connections. pub const LOCALHOST_RPC_URL: &str = "http://127.0.0.1:18081"; @@ -184,9 +182,10 @@ impl HttpRpcClient { //---------------------------------------------------------------------------------------------------- TESTS #[cfg(test)] mod tests { - use super::*; use hex_literal::hex; + use super::*; + /// Assert the default address is localhost. #[tokio::test] async fn localhost() { From 68807e7563a86ac189b005797a687dd513a3b10d Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sun, 8 Sep 2024 15:37:01 +0100 Subject: [PATCH 21/72] fmt --- storage/blockchain/src/service/free.rs | 6 ++++-- storage/blockchain/src/service/read.rs | 2 +- storage/blockchain/src/service/write.rs | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/storage/blockchain/src/service/free.rs b/storage/blockchain/src/service/free.rs index d12844f3..d8a878c9 100644 --- a/storage/blockchain/src/service/free.rs +++ b/storage/blockchain/src/service/free.rs @@ -8,9 +8,11 @@ use cuprate_types::{AltBlockInformation, VerifiedBlockInformation}; use crate::{ config::Config, - service::types::{BlockchainReadHandle, BlockchainWriteHandle}, + service::{ + init_read_service, init_write_service, + types::{BlockchainReadHandle, BlockchainWriteHandle}, + }, }; -use crate::service::{init_read_service, init_write_service}; //---------------------------------------------------------------------------------------------------- Init #[cold] diff --git a/storage/blockchain/src/service/read.rs b/storage/blockchain/src/service/read.rs index 3d0379e0..73b2d220 100644 --- a/storage/blockchain/src/service/read.rs +++ b/storage/blockchain/src/service/read.rs @@ -14,7 +14,7 @@ use rayon::{ use thread_local::ThreadLocal; use cuprate_database::{ConcreteEnv, DatabaseRo, Env, EnvInner, RuntimeError}; -use cuprate_database_service::{DatabaseReadService, init_thread_pool, ReaderThreads}; +use cuprate_database_service::{init_thread_pool, DatabaseReadService, ReaderThreads}; use cuprate_helper::map::combine_low_high_bits_to_u128; use cuprate_types::{ blockchain::{BlockchainReadRequest, BlockchainResponse}, diff --git a/storage/blockchain/src/service/write.rs b/storage/blockchain/src/service/write.rs index 723843f5..4038d94a 100644 --- a/storage/blockchain/src/service/write.rs +++ b/storage/blockchain/src/service/write.rs @@ -5,8 +5,8 @@ use std::sync::Arc; use cuprate_database::{ConcreteEnv, DatabaseRo, DatabaseRw, Env, EnvInner, RuntimeError, TxRw}; use cuprate_database_service::DatabaseWriteHandle; use cuprate_types::{ - AltBlockInformation, - blockchain::{BlockchainResponse, BlockchainWriteRequest}, Chain, ChainId, VerifiedBlockInformation, + blockchain::{BlockchainResponse, BlockchainWriteRequest}, + AltBlockInformation, Chain, ChainId, VerifiedBlockInformation, }; use crate::{ From c03065bcd5569a631cc28687667445bfd0e5e151 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sun, 8 Sep 2024 18:42:25 +0100 Subject: [PATCH 22/72] fix imports --- types/src/blockchain.rs | 10 ++++++---- types/src/types.rs | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/types/src/blockchain.rs b/types/src/blockchain.rs index 6c7ecf37..f246e59a 100644 --- a/types/src/blockchain.rs +++ b/types/src/blockchain.rs @@ -2,15 +2,17 @@ //! //! Tests that assert particular requests lead to particular //! responses are also tested in Cuprate's blockchain database crate. - +//! +//---------------------------------------------------------------------------------------------------- Import use std::{ collections::{HashMap, HashSet}, ops::Range, }; -use crate::{AltBlockInformation, ChainId}; -//---------------------------------------------------------------------------------------------------- Import -use crate::types::{Chain, ExtendedBlockHeader, OutputOnChain, VerifiedBlockInformation}; +use crate::{ + types::{Chain, ExtendedBlockHeader, OutputOnChain, VerifiedBlockInformation}, + AltBlockInformation, ChainId, +}; //---------------------------------------------------------------------------------------------------- ReadRequest /// A read request to the blockchain database. diff --git a/types/src/types.rs b/types/src/types.rs index c6e83d09..a60ce6c6 100644 --- a/types/src/types.rs +++ b/types/src/types.rs @@ -1,7 +1,8 @@ //! Various shared data types in Cuprate. -use std::num::NonZero; //---------------------------------------------------------------------------------------------------- Import +use std::num::NonZero; + use curve25519_dalek::edwards::EdwardsPoint; use monero_serai::{ block::Block, From 1831fa62747eec6a6a09b4f39c8af67e02892ae2 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Mon, 9 Sep 2024 01:14:00 +0100 Subject: [PATCH 23/72] remove config files --- .idea/vcs.xml | 6 - .idea/workspace.xml | 637 -------------------------------------------- 2 files changed, 643 deletions(-) delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/workspace.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddf..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 8ddf4f0e..00000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,637 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { - "associatedIndex": 4 -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1722869508802 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From da78cbdb7aaabf659508811a557f9eb2afed65db Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Mon, 9 Sep 2024 17:04:45 +0100 Subject: [PATCH 24/72] fix merge errors --- Cargo.lock | 41 +++++++++++++++++++++++------------- binaries/cuprated/Cargo.toml | 2 +- consensus/src/lib.rs | 2 +- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0bb4612a..7ccfc6be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1010,7 +1010,7 @@ dependencies = [ [[package]] name = "dalek-ff-group" version = "0.4.1" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "crypto-bigint", "curve25519-dalek", @@ -1165,7 +1165,7 @@ dependencies = [ [[package]] name = "flexible-transcript" version = "0.3.2" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "blake2", "digest", @@ -1832,7 +1832,7 @@ dependencies = [ [[package]] name = "monero-address" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "monero-io", @@ -1845,7 +1845,7 @@ dependencies = [ [[package]] name = "monero-borromean" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "monero-generators", @@ -1858,7 +1858,7 @@ dependencies = [ [[package]] name = "monero-bulletproofs" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "monero-generators", @@ -1873,7 +1873,7 @@ dependencies = [ [[package]] name = "monero-clsag" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "dalek-ff-group", @@ -1893,7 +1893,7 @@ dependencies = [ [[package]] name = "monero-generators" version = "0.4.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "dalek-ff-group", @@ -1907,7 +1907,7 @@ dependencies = [ [[package]] name = "monero-io" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "std-shims", @@ -1916,7 +1916,7 @@ dependencies = [ [[package]] name = "monero-mlsag" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "monero-generators", @@ -1930,7 +1930,7 @@ dependencies = [ [[package]] name = "monero-primitives" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "monero-generators", @@ -1943,7 +1943,7 @@ dependencies = [ [[package]] name = "monero-rpc" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "async-trait", "curve25519-dalek", @@ -1960,7 +1960,7 @@ dependencies = [ [[package]] name = "monero-serai" version = "0.1.4-alpha" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "curve25519-dalek", "hex-literal", @@ -1978,7 +1978,7 @@ dependencies = [ [[package]] name = "monero-simple-request-rpc" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "async-trait", "digest_auth", @@ -2646,6 +2646,15 @@ dependencies = [ "keccak", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -2658,7 +2667,7 @@ dependencies = [ [[package]] name = "simple-request" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "http-body-util", "hyper", @@ -2714,7 +2723,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "std-shims" version = "0.1.1" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8" dependencies = [ "hashbrown", "spin", @@ -3015,6 +3024,8 @@ version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ + "sharded-slab", + "thread_local", "tracing-core", ] diff --git a/binaries/cuprated/Cargo.toml b/binaries/cuprated/Cargo.toml index 0c70a31d..e74dd043 100644 --- a/binaries/cuprated/Cargo.toml +++ b/binaries/cuprated/Cargo.toml @@ -69,7 +69,7 @@ tokio-util = { workspace = true } tokio-stream = { workspace = true } tokio = { workspace = true } tower = { workspace = true } -tracing-subscriber = { workspace = true } +tracing-subscriber = { workspace = true, features = ["std", "fmt"] } tracing = { workspace = true } #[lints] diff --git a/consensus/src/lib.rs b/consensus/src/lib.rs index 18de7dc4..e9752367 100644 --- a/consensus/src/lib.rs +++ b/consensus/src/lib.rs @@ -28,7 +28,7 @@ pub use transactions::{TxVerifierService, VerifyTxRequest, VerifyTxResponse}; // re-export. pub use cuprate_consensus_rules::genesis::generate_genesis_block; -pub use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; +pub use cuprate_types::{blockchain::{BlockchainReadRequest, BlockchainResponse}, HardFork}; /// An Error returned from one of the consensus services. #[derive(Debug, thiserror::Error)] From d4e0e301333026bc599f52bc031b9594a04ac67d Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Mon, 9 Sep 2024 20:13:22 +0100 Subject: [PATCH 25/72] fix generated coins --- Cargo.lock | 37 +++++++++++++++++++++++++++++ binaries/cuprated/Cargo.toml | 2 +- consensus/src/lib.rs | 5 +++- storage/blockchain/src/ops/block.rs | 2 +- 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0035f074..3300a978 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1989,6 +1989,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -2036,6 +2046,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "page_size" version = "0.6.0" @@ -3017,6 +3033,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", ] [[package]] @@ -3025,9 +3053,12 @@ version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ + "nu-ansi-term", "sharded-slab", + "smallvec", "thread_local", "tracing-core", + "tracing-log", ] [[package]] @@ -3101,6 +3132,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "version_check" version = "0.9.4" diff --git a/binaries/cuprated/Cargo.toml b/binaries/cuprated/Cargo.toml index e74dd043..125961b4 100644 --- a/binaries/cuprated/Cargo.toml +++ b/binaries/cuprated/Cargo.toml @@ -69,7 +69,7 @@ tokio-util = { workspace = true } tokio-stream = { workspace = true } tokio = { workspace = true } tower = { workspace = true } -tracing-subscriber = { workspace = true, features = ["std", "fmt"] } +tracing-subscriber = { workspace = true, features = ["std", "fmt", "default"] } tracing = { workspace = true } #[lints] diff --git a/consensus/src/lib.rs b/consensus/src/lib.rs index e9752367..3753fcc9 100644 --- a/consensus/src/lib.rs +++ b/consensus/src/lib.rs @@ -28,7 +28,10 @@ pub use transactions::{TxVerifierService, VerifyTxRequest, VerifyTxResponse}; // re-export. pub use cuprate_consensus_rules::genesis::generate_genesis_block; -pub use cuprate_types::{blockchain::{BlockchainReadRequest, BlockchainResponse}, HardFork}; +pub use cuprate_types::{ + blockchain::{BlockchainReadRequest, BlockchainResponse}, + HardFork, +}; /// An Error returned from one of the consensus services. #[derive(Debug, thiserror::Error)] diff --git a/storage/blockchain/src/ops/block.rs b/storage/blockchain/src/ops/block.rs index 29586925..8e046520 100644 --- a/storage/blockchain/src/ops/block.rs +++ b/storage/blockchain/src/ops/block.rs @@ -93,7 +93,7 @@ pub fn add_block( let cumulative_generated_coins = cumulative_generated_coins(&block.height.saturating_sub(1), tables.block_infos())? - + block.generated_coins; + .saturating_add(block.generated_coins); let (cumulative_difficulty_low, cumulative_difficulty_high) = split_u128_into_low_high_bits(block.cumulative_difficulty); From 915633fe70a356f0452be675e4f3fce37ba2d6d7 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 12 Sep 2024 02:24:07 +0100 Subject: [PATCH 26/72] handle more p2p requests + alt blocks --- Cargo.lock | 1 + binaries/cuprated/Cargo.toml | 2 +- binaries/cuprated/src/blockchain/manager.rs | 90 +++++++++- .../src/blockchain/manager/batch_handler.rs | 105 ++++------- .../src/blockchain/manager/handler.rs | 163 ++++++++++++++++++ binaries/cuprated/src/main.rs | 4 +- binaries/cuprated/src/p2p/request_handler.rs | 116 +++++++++++-- consensus/src/block.rs | 14 ++ p2p/address-book/src/lib.rs | 11 +- p2p/p2p/src/constants.rs | 7 +- p2p/p2p/src/lib.rs | 2 +- storage/blockchain/Cargo.toml | 1 + storage/blockchain/src/ops/block.rs | 45 ++++- storage/blockchain/src/service/read.rs | 109 +++++++++++- types/src/blockchain.rs | 42 ++++- 15 files changed, 602 insertions(+), 110 deletions(-) create mode 100644 binaries/cuprated/src/blockchain/manager/handler.rs diff --git a/Cargo.lock b/Cargo.lock index 3300a978..e6b61758 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -531,6 +531,7 @@ version = "0.0.0" dependencies = [ "bitflags 2.5.0", "bytemuck", + "bytes", "cuprate-database", "cuprate-database-service", "cuprate-helper", diff --git a/binaries/cuprated/Cargo.toml b/binaries/cuprated/Cargo.toml index 125961b4..43daabfb 100644 --- a/binaries/cuprated/Cargo.toml +++ b/binaries/cuprated/Cargo.toml @@ -23,7 +23,7 @@ cuprate-p2p-core = { path = "../../p2p/p2p-core" } cuprate-dandelion-tower = { path = "../../p2p/dandelion-tower" } cuprate-async-buffer = { path = "../../p2p/async-buffer" } cuprate-address-book = { path = "../../p2p/address-book" } -cuprate-blockchain = { path = "../../storage/blockchain" } +cuprate-blockchain = { path = "../../storage/blockchain", features = ["service"] } cuprate-database-service = { path = "../../storage/service" } cuprate-txpool = { path = "../../storage/txpool" } cuprate-database = { path = "../../storage/database" } diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index e13c9073..eaf8669f 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -1,17 +1,27 @@ mod batch_handler; +mod handler; -use crate::blockchain::manager::batch_handler::handle_incoming_block_batch; use crate::blockchain::types::ConsensusBlockchainReadHandle; use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; -use cuprate_consensus::{BlockChainContextService, BlockVerifierService, TxVerifierService}; +use cuprate_consensus::context::RawBlockChainContext; +use cuprate_consensus::{ + BlockChainContextRequest, BlockChainContextResponse, BlockChainContextService, + BlockVerifierService, ExtendedConsensusError, TxVerifierService, VerifyBlockRequest, + VerifyBlockResponse, VerifyTxRequest, VerifyTxResponse, +}; use cuprate_p2p::block_downloader::BlockBatch; +use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; +use cuprate_types::Chain; use futures::StreamExt; use tokio::sync::mpsc::Receiver; +use tower::{Service, ServiceExt}; +use tracing::error; pub struct BlockchainManager { blockchain_write_handle: BlockchainWriteHandle, blockchain_read_handle: BlockchainReadHandle, blockchain_context_service: BlockChainContextService, + cached_blockchain_context: RawBlockChainContext, block_verifier_service: BlockVerifierService< BlockChainContextService, TxVerifierService, @@ -34,20 +44,86 @@ impl BlockchainManager { blockchain_write_handle, blockchain_read_handle, blockchain_context_service, + cached_blockchain_context: todo!(), block_verifier_service, } } + async fn handle_incoming_main_chain_batch( + &mut self, + batch: BlockBatch, + ) -> Result<(), anyhow::Error> { + let VerifyBlockResponse::MainChainBatchPrepped(prepped) = self + .block_verifier_service + .ready() + .await + .expect("TODO") + .call(VerifyBlockRequest::MainChainBatchPrepareBlocks { + blocks: batch.blocks, + }) + .await? + else { + panic!("Incorrect response!"); + }; + + for (block, txs) in prepped { + let VerifyBlockResponse::MainChain(verified_block) = block_verifier_service + .ready() + .await + .expect("TODO") + .call(VerifyBlockRequest::MainChainPrepped { block, txs }) + .await + .unwrap() + else { + panic!("Incorrect response!"); + }; + + blockchain_context_service + .ready() + .await + .expect("TODO") + .call(BlockChainContextRequest::Update(NewBlockData { + block_hash: verified_block.block_hash, + height: verified_block.height, + timestamp: verified_block.block.header.timestamp, + weight: verified_block.weight, + long_term_weight: verified_block.long_term_weight, + generated_coins: verified_block.generated_coins, + vote: HardFork::from_vote(verified_block.block.header.hardfork_signal), + cumulative_difficulty: verified_block.cumulative_difficulty, + })) + .await + .expect("TODO"); + + blockchain_write_handle + .ready() + .await + .expect("TODO") + .call(BlockchainWriteRequest::WriteBlock(verified_block)) + .await + .expect("TODO"); + } + } + + async fn handle_incoming_block_batch(&mut self, batch: BlockBatch) { + let (first_block, _) = batch + .blocks + .first() + .expect("Block batch should not be empty"); + + if first_block.header.previous == self.cached_blockchain_context.top_hash { + todo!("Main chain") + } else { + todo!("Alt chain") + } + } + pub async fn run(mut self, mut batch_rx: Receiver) { loop { tokio::select! { Some(batch) = batch_rx.recv() => { - handle_incoming_block_batch( + self.handle_incoming_block_batch( batch, - &mut self.block_verifier_service, - &mut self.blockchain_context_service, - &mut self.blockchain_read_handle, - &mut self.blockchain_write_handle ).await; } else => { diff --git a/binaries/cuprated/src/blockchain/manager/batch_handler.rs b/binaries/cuprated/src/blockchain/manager/batch_handler.rs index c4a3d6e5..ea08af42 100644 --- a/binaries/cuprated/src/blockchain/manager/batch_handler.rs +++ b/binaries/cuprated/src/blockchain/manager/batch_handler.rs @@ -3,6 +3,7 @@ use crate::blockchain::types::ConsensusBlockchainReadHandle; use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; use cuprate_consensus::context::NewBlockData; +use cuprate_consensus::transactions::new_tx_verification_data; use cuprate_consensus::{ BlockChainContextRequest, BlockChainContextResponse, BlockChainContextService, BlockVerifierService, BlockchainReadRequest, BlockchainResponse, ExtendedConsensusError, @@ -11,82 +12,17 @@ use cuprate_consensus::{ use cuprate_p2p::block_downloader::BlockBatch; use cuprate_types::blockchain::BlockchainWriteRequest; use cuprate_types::{Chain, HardFork}; +use rayon::prelude::*; use tower::{Service, ServiceExt}; use tracing::{debug, error, info}; -pub async fn handle_incoming_block_batch( - batch: BlockBatch, - block_verifier_service: &mut BlockVerifierService, - blockchain_context_service: &mut C, - blockchain_read_handle: &mut BlockchainReadHandle, - blockchain_write_handle: &mut BlockchainWriteHandle, -) where - C: Service< - BlockChainContextRequest, - Response = BlockChainContextResponse, - Error = tower::BoxError, - > + Clone - + Send - + 'static, - C::Future: Send + 'static, - - TxV: Service - + Clone - + Send - + 'static, - TxV::Future: Send + 'static, -{ - let (first_block, _) = batch - .blocks - .first() - .expect("Block batch should not be empty"); - - handle_incoming_block_batch_main_chain( - batch, - block_verifier_service, - blockchain_context_service, - blockchain_write_handle, - ) - .await; - - // TODO: alt block to the DB - /* - match blockchain_read_handle - .oneshot(BlockchainReadRequest::FindBlock( - first_block.header.previous, - )) - .await - { - Err(_) | Ok(BlockchainResponse::FindBlock(None)) => { - // The block downloader shouldn't be downloading orphan blocks - error!("Failed to find parent block for first block in batch."); - return; - } - Ok(BlockchainResponse::FindBlock(Some((chain, _)))) => match chain { - Chain::Main => { - handle_incoming_block_batch_main_chain( - batch, - block_verifier_service, - blockchain_context_service, - blockchain_write_handle, - ) - .await; - } - Chain::Alt(_) => todo!(), - }, - - Ok(_) => panic!("Blockchain service returned incorrect response"), - } - - */ -} - async fn handle_incoming_block_batch_main_chain( batch: BlockBatch, block_verifier_service: &mut BlockVerifierService, blockchain_context_service: &mut C, blockchain_write_handle: &mut BlockchainWriteHandle, -) where +) -> Result<(), anyhow::Error> +where C: Service< BlockChainContextRequest, Response = BlockChainContextResponse, @@ -114,8 +50,7 @@ async fn handle_incoming_block_batch_main_chain( .call(VerifyBlockRequest::MainChainBatchPrepareBlocks { blocks: batch.blocks, }) - .await - .unwrap() + .await? else { panic!("Incorrect response!"); }; @@ -126,8 +61,7 @@ async fn handle_incoming_block_batch_main_chain( .await .expect("TODO") .call(VerifyBlockRequest::MainChainPrepped { block, txs }) - .await - .unwrap() + .await? else { panic!("Incorrect response!"); }; @@ -158,3 +92,30 @@ async fn handle_incoming_block_batch_main_chain( .expect("TODO"); } } + +async fn handle_incoming_block_batch_alt_chain( + batch: BlockBatch, + block_verifier_service: &mut BlockVerifierService, + blockchain_context_service: &mut C, + blockchain_write_handle: &mut BlockchainWriteHandle, +) -> Result<(), anyhow::Error> +where + C: Service< + BlockChainContextRequest, + Response = BlockChainContextResponse, + Error = tower::BoxError, + > + Clone + + Send + + 'static, + C::Future: Send + 'static, + + TxV: Service + + Clone + + Send + + 'static, + TxV::Future: Send + 'static, +{ + for (block, txs) in batch.blocks { + alt_block_info.cumulative_difficulty + } +} diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs new file mode 100644 index 00000000..221acb81 --- /dev/null +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -0,0 +1,163 @@ +use crate::blockchain::types::ConsensusBlockchainReadHandle; +use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; +use cuprate_consensus::transactions::new_tx_verification_data; +use cuprate_consensus::{ + BlockChainContextRequest, BlockChainContextResponse, BlockVerifierService, + ExtendedConsensusError, VerifyBlockRequest, VerifyBlockResponse, VerifyTxRequest, + VerifyTxResponse, +}; +use cuprate_p2p::block_downloader::BlockBatch; +use cuprate_types::blockchain::{ + BlockchainReadRequest, BlockchainResponse, BlockchainWriteRequest, +}; +use cuprate_types::AltBlockInformation; +use monero_serai::block::Block; +use monero_serai::transaction::Transaction; +use rayon::prelude::*; +use tower::{Service, ServiceExt}; + +async fn handle_incoming_alt_block( + block: Block, + txs: Vec, + current_cumulative_difficulty: u128, + block_verifier_service: &mut BlockVerifierService, + blockchain_context_service: &mut C, + blockchain_write_handle: &mut BlockchainWriteHandle, +) -> Result<(), anyhow::Error> +where + C: Service< + BlockChainContextRequest, + Response = BlockChainContextResponse, + Error = tower::BoxError, + > + Clone + + Send + + 'static, + C::Future: Send + 'static, + + TxV: Service + + Clone + + Send + + 'static, + TxV::Future: Send + 'static, +{ + let prepared_txs = txs + .into_par_iter() + .map(|tx| { + let tx = new_tx_verification_data(tx)?; + (tx.tx_hash, tx) + }) + .collect::>()?; + + let VerifyBlockResponse::AltChain(alt_block_info) = block_verifier_service + .ready() + .await + .expect("TODO") + .call(VerifyBlockRequest::AltChain { + block, + prepared_txs, + }) + .await? + else { + panic!("Incorrect response!"); + }; + + if alt_block_info.cumulative_difficulty > current_cumulative_difficulty { + todo!("do re-org"); + } + + blockchain_write_handle + .ready() + .await + .expect("TODO") + .call(BlockchainWriteRequest::WriteAltBlock(alt_block_info))?; + + Ok(()) +} + +async fn try_do_reorg( + top_alt_block: AltBlockInformation, + chain_height: usize, + block_verifier_service: &mut BlockVerifierService, + blockchain_context_service: &mut C, + blockchain_write_handle: &mut BlockchainWriteHandle, + blockchain_read_handle: &mut BlockchainReadHandle, +) -> Result<(), anyhow::Error> +where + C: Service< + BlockChainContextRequest, + Response = BlockChainContextResponse, + Error = tower::BoxError, + > + Clone + + Send + + 'static, + C::Future: Send + 'static, + + TxV: Service + + Clone + + Send + + 'static, + TxV::Future: Send + 'static, +{ + let BlockchainResponse::AltBlocksInChain(mut alt_blocks) = blockchain_read_handle + .ready() + .await + .expect("TODO") + .call(BlockchainReadRequest::AltBlocksInChain( + top_alt_block.chain_id, + )) + .await? + else { + panic!("Incorrect response!"); + }; + + alt_blocks.push(top_alt_block); + + let split_height = alt_blocks[0].height; + + let BlockchainResponse::PopBlocks(old_main_chain_id) = blockchain_write_handle + .ready() + .await + .expect("TODO") + .call(BlockchainWriteRequest::PopBlocks( + chain_height - split_height + 1, + )) + .await? + else { + panic!("Incorrect response!"); + }; + + todo!() +} + +async fn verify_add_alt_blocks_to_main_chain( + alt_blocks: Vec, + block_verifier_service: &mut BlockVerifierService, + blockchain_context_service: &mut C, + blockchain_write_handle: &mut BlockchainWriteHandle, +) -> Result<(), anyhow::Error> +where + C: Service< + BlockChainContextRequest, + Response = BlockChainContextResponse, + Error = tower::BoxError, + > + Clone + + Send + + 'static, + C::Future: Send + 'static, + + TxV: Service + + Clone + + Send + + 'static, + TxV::Future: Send + 'static, +{ + let VerifyBlockResponse::AltChain(alt_block_info) = block_verifier_service + .ready() + .await + .expect("TODO") + .call(VerifyBlockRequest::MainChainPrepped { block, txs }) + .await? + else { + panic!("Incorrect response!"); + }; +} diff --git a/binaries/cuprated/src/main.rs b/binaries/cuprated/src/main.rs index 62a7056a..0e706b93 100644 --- a/binaries/cuprated/src/main.rs +++ b/binaries/cuprated/src/main.rs @@ -42,7 +42,9 @@ fn main() { .unwrap(); let net = cuprate_p2p::initialize_network( - p2p::request_handler::P2pProtocolRequestHandler, + p2p::request_handler::P2pProtocolRequestHandler { + blockchain_read_handle: bc_read_handle.clone(), + }, p2p::core_sync_svc::CoreSyncService(context_svc.clone()), config.clearnet_config(), ) diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index 76554e92..0a4412fa 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -1,12 +1,23 @@ +use bytes::Bytes; use cuprate_p2p_core::{ProtocolRequest, ProtocolResponse}; use futures::future::BoxFuture; use futures::FutureExt; use std::task::{Context, Poll}; -use tower::Service; +use tower::{Service, ServiceExt}; use tracing::trace; +use cuprate_blockchain::service::BlockchainReadHandle; +use cuprate_helper::cast::usize_to_u64; +use cuprate_helper::map::split_u128_into_low_high_bits; +use cuprate_p2p::constants::{MAX_BLOCKCHAIN_SUPPLEMENT_LEN, MAX_BLOCK_BATCH_LEN}; +use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; +use cuprate_types::BlockCompleteEntry; +use cuprate_wire::protocol::{ChainRequest, ChainResponse, GetObjectsRequest, GetObjectsResponse}; + #[derive(Clone)] -pub struct P2pProtocolRequestHandler; +pub struct P2pProtocolRequestHandler { + pub(crate) blockchain_read_handle: BlockchainReadHandle, +} impl Service for P2pProtocolRequestHandler { type Response = ProtocolResponse; @@ -19,15 +30,98 @@ impl Service for P2pProtocolRequestHandler { fn call(&mut self, req: ProtocolRequest) -> Self::Future { match req { - ProtocolRequest::GetObjects(_) => trace!("TODO: GetObjects"), - ProtocolRequest::GetChain(_) => trace!("TODO: GetChain"), - ProtocolRequest::FluffyMissingTxs(_) => trace!("TODO: FluffyMissingTxs"), - ProtocolRequest::GetTxPoolCompliment(_) => trace!("TODO: GetTxPoolCompliment"), - ProtocolRequest::NewBlock(_) => trace!("TODO: NewBlock"), - ProtocolRequest::NewFluffyBlock(_) => trace!("TODO: NewFluffyBlock"), - ProtocolRequest::NewTransactions(_) => trace!("TODO: NewTransactions"), + ProtocolRequest::GetObjects(req) => { + get_objects(self.blockchain_read_handle.clone(), req).boxed() + } + ProtocolRequest::GetChain(req) => { + get_chain(self.blockchain_read_handle.clone(), req).boxed() + } + ProtocolRequest::FluffyMissingTxs(_) => async { Ok(ProtocolResponse::NA) }.boxed(), + ProtocolRequest::GetTxPoolCompliment(_) => async { Ok(ProtocolResponse::NA) }.boxed(), + ProtocolRequest::NewBlock(_) => async { Ok(ProtocolResponse::NA) }.boxed(), + ProtocolRequest::NewFluffyBlock(_) => async { Ok(ProtocolResponse::NA) }.boxed(), + ProtocolRequest::NewTransactions(_) => async { Ok(ProtocolResponse::NA) }.boxed(), } - - async { Ok(ProtocolResponse::NA) }.boxed() } } + +async fn get_objects( + blockchain_read_handle: BlockchainReadHandle, + req: GetObjectsRequest, +) -> Result { + if req.blocks.is_empty() { + Err("No blocks requested in a GetObjectsRequest")?; + } + + if req.blocks.len() > MAX_BLOCK_BATCH_LEN { + Err("Too many blocks requested in a GetObjectsRequest")?; + } + + let block_ids: Vec<[u8; 32]> = (&req.blocks).into(); + // de-allocate the backing [`Bytes`] + drop(req); + + let res = blockchain_read_handle + .oneshot(BlockchainReadRequest::BlockCompleteEntries(block_ids)) + .await?; + + let BlockchainResponse::BlockCompleteEntries { + blocks, + missed_ids, + current_blockchain_height, + } = res + else { + panic!("Blockchain service returned wrong response!"); + }; + + Ok(ProtocolResponse::GetObjects(GetObjectsResponse { + blocks, + missed_ids: missed_ids.into(), + current_blockchain_height: usize_to_u64(current_blockchain_height), + })) +} + +async fn get_chain( + blockchain_read_handle: BlockchainReadHandle, + req: ChainRequest, +) -> Result { + if req.block_ids.is_empty() { + Err("No block hashes sent in a `ChainRequest`")?; + } + + if req.block_ids.len() > MAX_BLOCKCHAIN_SUPPLEMENT_LEN { + Err("Too many block hashes in a `ChainRequest`")?; + } + + let block_ids: Vec<[u8; 32]> = (&req.block_ids).into(); + // de-allocate the backing [`Bytes`] + drop(req); + + let res = blockchain_read_handle + .oneshot(BlockchainReadRequest::NextMissingChainEntry(block_ids)) + .await?; + + let BlockchainResponse::NextMissingChainEntry { + next_entry, + first_missing_block, + start_height, + chain_height, + cumulative_difficulty, + } = res + else { + panic!("Blockchain service returned wrong response!"); + }; + + let (cumulative_difficulty_low64, cumulative_difficulty_top64) = + split_u128_into_low_high_bits(cumulative_difficulty); + + Ok(ProtocolResponse::GetChain(ChainResponse { + start_height: usize_to_u64(start_height), + total_height: usize_to_u64(chain_height), + cumulative_difficulty_low64, + cumulative_difficulty_top64, + m_block_ids: next_entry.into(), + m_block_weights: vec![], + first_block: first_missing_block.map_or(Bytes::new(), Bytes::from), + })) +} diff --git a/consensus/src/block.rs b/consensus/src/block.rs index b33b5857..727b072b 100644 --- a/consensus/src/block.rs +++ b/consensus/src/block.rs @@ -8,6 +8,7 @@ use std::{ }; use futures::FutureExt; +use monero_serai::generators::H; use monero_serai::{ block::Block, transaction::{Input, Transaction}, @@ -183,6 +184,19 @@ impl PreparedBlock { block: block.block, }) } + + pub fn new_alt_block(block: AltBlockInformation) -> Result { + Ok(PreparedBlock { + block_blob: block.block_blob, + hf_vote: HardFork::from_version(block.block.header.hardfork_version) + .map_err(|_| BlockError::HardForkError(HardForkError::HardForkUnknown))?, + hf_version: HardFork::from_vote(block.block.header.hardfork_signal), + block_hash: block.block_hash, + pow_hash: block.pow_hash, + miner_tx_weight: block.block.miner_transaction.weight(), + block: block.block, + }) + } } /// A request to verify a block. diff --git a/p2p/address-book/src/lib.rs b/p2p/address-book/src/lib.rs index c0903485..8c531e75 100644 --- a/p2p/address-book/src/lib.rs +++ b/p2p/address-book/src/lib.rs @@ -88,14 +88,19 @@ mod sealed { /// An internal trait for the address book for a [`NetworkZone`] that adds the requirement of [`borsh`] traits /// onto the network address. - pub trait BorshNetworkZone: NetworkZone { - type BorshAddr: NetZoneAddress + borsh::BorshDeserialize + borsh::BorshSerialize; + pub trait BorshNetworkZone: + NetworkZone< + Addr: NetZoneAddress + + borsh::BorshDeserialize + + borsh::BorshSerialize, + > + { } impl BorshNetworkZone for T where T::Addr: borsh::BorshDeserialize + borsh::BorshSerialize, + ::BanID: borsh::BorshDeserialize + borsh::BorshSerialize, { - type BorshAddr = T::Addr; } } diff --git a/p2p/p2p/src/constants.rs b/p2p/p2p/src/constants.rs index 44dba917..4e6daa73 100644 --- a/p2p/p2p/src/constants.rs +++ b/p2p/p2p/src/constants.rs @@ -46,7 +46,12 @@ pub(crate) const INITIAL_CHAIN_REQUESTS_TO_SEND: usize = 3; /// The enforced maximum amount of blocks to request in a batch. /// /// Requesting more than this will cause the peer to disconnect and potentially lead to bans. -pub(crate) const MAX_BLOCK_BATCH_LEN: usize = 100; +pub const MAX_BLOCK_BATCH_LEN: usize = 100; + +/// The enforced maximum amount of block hashes in a blockchain supplement request. +/// +/// Requesting more than this might cause the peer to disconnect and potentially lead to bans. +pub const MAX_BLOCKCHAIN_SUPPLEMENT_LEN: usize = 250; /// The timeout that the block downloader will use for requests. pub(crate) const BLOCK_DOWNLOADER_REQUEST_TIMEOUT: Duration = Duration::from_secs(30); diff --git a/p2p/p2p/src/lib.rs b/p2p/p2p/src/lib.rs index 6f95948f..5355df26 100644 --- a/p2p/p2p/src/lib.rs +++ b/p2p/p2p/src/lib.rs @@ -26,7 +26,7 @@ mod broadcast; mod client_pool; pub mod config; pub mod connection_maintainer; -mod constants; +pub mod constants; mod inbound_server; mod sync_states; diff --git a/storage/blockchain/Cargo.toml b/storage/blockchain/Cargo.toml index 46b8414d..594521ac 100644 --- a/storage/blockchain/Cargo.toml +++ b/storage/blockchain/Cargo.toml @@ -38,6 +38,7 @@ serde = { workspace = true, optional = true } tower = { workspace = true } thread_local = { workspace = true, optional = true } rayon = { workspace = true, optional = true } +bytes = "1.6.0" [dev-dependencies] cuprate-helper = { path = "../../helper", features = ["thread", "cast"] } diff --git a/storage/blockchain/src/ops/block.rs b/storage/blockchain/src/ops/block.rs index 8e046520..01023495 100644 --- a/storage/blockchain/src/ops/block.rs +++ b/storage/blockchain/src/ops/block.rs @@ -2,20 +2,23 @@ //---------------------------------------------------------------------------------------------------- Import use bytemuck::TransparentWrapper; -use monero_serai::block::{Block, BlockHeader}; +use bytes::Bytes; use cuprate_database::{ - RuntimeError, StorableVec, {DatabaseRo, DatabaseRw}, + RuntimeError, StorableVec, {DatabaseIter, DatabaseRo, DatabaseRw}, }; +use cuprate_helper::cast::usize_to_u64; use cuprate_helper::{ map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}, tx_utils::tx_fee, }; use cuprate_types::{ - AltBlockInformation, ChainId, ExtendedBlockHeader, HardFork, VerifiedBlockInformation, - VerifiedTransactionInformation, + AltBlockInformation, BlockCompleteEntry, ChainId, ExtendedBlockHeader, HardFork, + TransactionBlobs, VerifiedBlockInformation, VerifiedTransactionInformation, }; +use monero_serai::block::{Block, BlockHeader}; +use crate::tables::TablesIter; use crate::{ ops::{ alt_block, @@ -256,6 +259,40 @@ pub fn get_block_extended_header_top( Ok((header, height)) } +//---------------------------------------------------------------------------------------------------- `get_block_complete_entry` + +pub fn get_block_complete_entry( + block_hash: &BlockHash, + tables: &impl TablesIter, +) -> Result { + let height = tables.block_heights().get(block_hash)?; + + let block_blob = tables.block_blobs().get(&height)?.0; + + let block = Block::read(&mut block_blob.as_slice()).expect("Valid block failed to be read"); + + let txs = if let Some(first_tx) = block.transactions.first() { + let first_tx_idx = tables.tx_ids().get(first_tx)?; + let end_tx_idx = first_tx_idx + usize_to_u64(block.transactions.len()); + + let tx_blobs = tables.tx_blobs_iter().get_range(first_tx_idx..end_tx_idx)?; + + tx_blobs + .map(|res| Ok(Bytes::from(res?.0))) + .collect::>()? + } else { + vec![] + }; + + Ok(BlockCompleteEntry { + block: Bytes::from(block_blob), + txs: TransactionBlobs::Normal(txs), + pruned: false, + // This is only needed when pruned. + block_weight: 0, + }) +} + //---------------------------------------------------------------------------------------------------- Misc /// Retrieve a [`BlockInfo`] via its [`BlockHeight`]. #[doc = doc_error!()] diff --git a/storage/blockchain/src/service/read.rs b/storage/blockchain/src/service/read.rs index 73b2d220..07fa8253 100644 --- a/storage/blockchain/src/service/read.rs +++ b/storage/blockchain/src/service/read.rs @@ -1,19 +1,20 @@ //! Database reader thread-pool definitions and logic. //---------------------------------------------------------------------------------------------------- Import +use rayon::{ + iter::{Either, IntoParallelIterator, ParallelIterator}, + prelude::*, + ThreadPool, +}; +use std::cmp::min; +use std::ops::Index; use std::{ collections::{HashMap, HashSet}, sync::Arc, }; - -use rayon::{ - iter::{IntoParallelIterator, ParallelIterator}, - prelude::*, - ThreadPool, -}; use thread_local::ThreadLocal; -use cuprate_database::{ConcreteEnv, DatabaseRo, Env, EnvInner, RuntimeError}; +use cuprate_database::{ConcreteEnv, DatabaseIter, DatabaseRo, Env, EnvInner, RuntimeError}; use cuprate_database_service::{init_thread_pool, DatabaseReadService, ReaderThreads}; use cuprate_helper::map::combine_low_high_bits_to_u128; use cuprate_types::{ @@ -21,6 +22,8 @@ use cuprate_types::{ Chain, ChainId, ExtendedBlockHeader, OutputOnChain, }; +use crate::ops::block::get_block_complete_entry; +use crate::tables::{BlockBlobs, TxIds}; use crate::{ ops::{ alt_block::{ @@ -92,6 +95,7 @@ fn map_request( /* SOMEDAY: pre-request handling, run some code for each request? */ match request { + R::BlockCompleteEntries(blocks) => block_complete_entries(env, blocks), R::BlockExtendedHeader(block) => block_extended_header(env, block), R::BlockHash(block, chain) => block_hash(env, block, chain), R::FindBlock(block_hash) => find_block(env, block_hash), @@ -106,6 +110,7 @@ fn map_request( R::KeyImagesSpent(set) => key_images_spent(env, set), R::CompactChainHistory => compact_chain_history(env), R::FindFirstUnknown(block_ids) => find_first_unknown(env, &block_ids), + R::NextMissingChainEntry(block_hashes) => next_missing_chain_entry(env, block_hashes), R::AltBlocksInChain(chain_id) => alt_blocks_in_chain(env, chain_id), } @@ -180,9 +185,41 @@ macro_rules! get_tables { // FIXME: implement multi-transaction read atomicity. // . -// TODO: The overhead of parallelism may be too much for every request, perfomace test to find optimal +// TODO: The overhead of parallelism may be too much for every request, performance test to find optimal // amount of parallelism. +/// [`BlockchainReadRequest::BlockCompleteEntries`]. +fn block_complete_entries(env: &ConcreteEnv, block_hashes: Vec) -> ResponseResult { + // Prepare tx/tables in `ThreadLocal`. + let env_inner = env.env_inner(); + let tx_ro = thread_local(env); + let tables = thread_local(env); + + let (missed_ids, blocks) = block_hashes + .into_par_iter() + .map(|block_hash| { + let tx_ro = tx_ro.get_or_try(|| env_inner.tx_ro())?; + let tables = get_tables!(env_inner, tx_ro, tables)?.as_ref(); + + match get_block_complete_entry(&block_hash, tables) { + Err(RuntimeError::KeyNotFound) => Ok(Either::Left(block_hash)), + res => res.map(Either::Right), + } + }) + .collect::>()?; + + let tx_ro = tx_ro.get_or_try(|| env_inner.tx_ro())?; + let tables = get_tables!(env_inner, tx_ro, tables)?.as_ref(); + + let chain_height = crate::ops::blockchain::chain_height(tables.block_heights())?; + + Ok(BlockchainResponse::BlockCompleteEntries { + blocks, + missed_ids, + current_blockchain_height: chain_height, + }) +} + /// [`BlockchainReadRequest::BlockExtendedHeader`]. #[inline] fn block_extended_header(env: &ConcreteEnv, block_height: BlockHeight) -> ResponseResult { @@ -556,6 +593,62 @@ fn find_first_unknown(env: &ConcreteEnv, block_ids: &[BlockHash]) -> ResponseRes }) } +/// [`BlockchainReadRequest::NextMissingChainEntry`] +fn next_missing_chain_entry(env: &ConcreteEnv, block_hashes: Vec<[u8; 32]>) -> ResponseResult { + let env_inner = env.env_inner(); + let tx_ro = env_inner.tx_ro()?; + + let table_block_heights = env_inner.open_db_ro::(&tx_ro)?; + let table_block_infos = env_inner.open_db_ro::(&tx_ro)?; + + let (top_block_height, top_block_info) = table_block_infos.last()?; + + let mut start_height = 0; + + for block_hash in block_hashes { + match table_block_heights.get(&block_hash) { + Ok(height) => { + start_height = height; + break; + } + Err(RuntimeError::KeyNotFound) => continue, + Err(e) => return Err(e), + } + } + + let table_block_infos = env_inner.open_db_ro::(&tx_ro)?; + + const DEFAULT_CHAIN_ENTRY_SIZE: usize = 10_000; + + let end_height = min( + start_height + DEFAULT_CHAIN_ENTRY_SIZE, + top_block_height + 1, + ); + + let block_hashes: Vec<_> = table_block_infos + .get_range(start_height..end_height)? + .map(|block_info| Ok(block_info?.block_hash)) + .collect::>()?; + + let first_missing_block = if block_hashes.len() > 1 { + let table_block_blobs = env_inner.open_db_ro::(&tx_ro)?; + Some(table_block_blobs.get(&(start_height + 1))?.0) + } else { + None + }; + + Ok(BlockchainResponse::NextMissingChainEntry { + next_entry: block_hashes, + first_missing_block, + start_height, + chain_height: top_block_height + 1, + cumulative_difficulty: combine_low_high_bits_to_u128( + top_block_info.cumulative_difficulty_low, + top_block_info.cumulative_difficulty_high, + ), + }) +} + /// [`BlockchainReadRequest::AltBlocksInChain`] fn alt_blocks_in_chain(env: &ConcreteEnv, chain_id: ChainId) -> ResponseResult { // Prepare tx/tables in `ThreadLocal`. diff --git a/types/src/blockchain.rs b/types/src/blockchain.rs index f246e59a..1595ec60 100644 --- a/types/src/blockchain.rs +++ b/types/src/blockchain.rs @@ -11,7 +11,7 @@ use std::{ use crate::{ types::{Chain, ExtendedBlockHeader, OutputOnChain, VerifiedBlockInformation}, - AltBlockInformation, ChainId, + AltBlockInformation, BlockCompleteEntry, ChainId, }; //---------------------------------------------------------------------------------------------------- ReadRequest @@ -25,6 +25,11 @@ use crate::{ /// See `Response` for the expected responses per `Request`. #[derive(Debug, Clone, PartialEq, Eq)] pub enum BlockchainReadRequest { + /// Request for [`BlockCompleteEntry`]s. + /// + /// The input is the hashes of the blocks wanted. + BlockCompleteEntries(Vec<[u8; 32]>), + /// Request a block's extended header. /// /// The input is the block's height. @@ -101,6 +106,13 @@ pub enum BlockchainReadRequest { /// order, or else the returned response is unspecified and meaningless, /// as this request performs a binary search. FindFirstUnknown(Vec<[u8; 32]>), + + /// A request for the next missing chain entry. + /// + /// The input is a list of block hashes in reverse chronological order that do not necessarily + /// directly follow each other. + NextMissingChainEntry(Vec<[u8; 32]>), + /// A request for all alt blocks in the chain with the given [`ChainId`]. AltBlocksInChain(ChainId), } @@ -145,6 +157,16 @@ pub enum BlockchainWriteRequest { #[derive(Debug, Clone, PartialEq, Eq)] pub enum BlockchainResponse { //------------------------------------------------------ Reads + /// Response to [`BlockchainReadRequest::BlockCompleteEntries`] + BlockCompleteEntries { + /// The blocks requested that we had. + blocks: Vec, + /// The hashes of the blocks we did not have. + missed_ids: Vec<[u8; 32]>, + /// The current height of our blockchain. + current_blockchain_height: usize, + }, + /// Response to [`BlockchainReadRequest::BlockExtendedHeader`]. /// /// Inner value is the extended headed of the requested block. @@ -218,6 +240,24 @@ pub enum BlockchainResponse { /// This will be [`None`] if all blocks were known. FindFirstUnknown(Option<(usize, usize)>), + /// The response for [`BlockchainReadRequest::NextMissingChainEntry`] + NextMissingChainEntry { + /// A list of block hashes that should be next from the requested chain. + /// + /// The first block hash will overlap with one of the blocks in the request. + next_entry: Vec<[u8; 32]>, + /// The block blob of the second block in `next_entry`. + /// + /// If there is only 1 block in `next_entry` then this will be [`None`]. + first_missing_block: Option>, + /// The height of the first block in `next_entry`. + start_height: usize, + /// The current height of our chain. + chain_height: usize, + /// The cumulative difficulty of our chain. + cumulative_difficulty: u128, + }, + /// The response for [`BlockchainReadRequest::AltBlocksInChain`]. /// /// Contains all the alt blocks in the alt-chain in chronological order. From 01a3065cc837a23ae76c31a9b756d5a3ea3bb706 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 12 Sep 2024 22:17:44 +0100 Subject: [PATCH 27/72] clean up handler code --- binaries/cuprated/src/blockchain.rs | 6 +- binaries/cuprated/src/blockchain/manager.rs | 115 ++--- .../src/blockchain/manager/batch_handler.rs | 121 ----- .../src/blockchain/manager/handler.rs | 419 ++++++++++++------ binaries/cuprated/src/main.rs | 3 +- binaries/cuprated/src/signals.rs | 3 + p2p/address-book/src/lib.rs | 12 +- p2p_state.bin | Bin 162918 -> 172430 bytes storage/blockchain/src/service/read.rs | 2 +- 9 files changed, 332 insertions(+), 349 deletions(-) delete mode 100644 binaries/cuprated/src/blockchain/manager/batch_handler.rs create mode 100644 binaries/cuprated/src/signals.rs diff --git a/binaries/cuprated/src/blockchain.rs b/binaries/cuprated/src/blockchain.rs index e1f5765b..eb23224e 100644 --- a/binaries/cuprated/src/blockchain.rs +++ b/binaries/cuprated/src/blockchain.rs @@ -1,6 +1,8 @@ //! Blockchain //! //! Will contain the chain manager and syncer. + +use futures::FutureExt; use tokio::sync::mpsc; use tower::{Service, ServiceExt}; @@ -95,7 +97,7 @@ pub async fn init_consensus( } /// Initializes the blockchain manager task and syncer. -pub fn init_blockchain_manager( +pub async fn init_blockchain_manager( clearnet_interface: NetworkInterface, blockchain_write_handle: BlockchainWriteHandle, blockchain_read_handle: BlockchainReadHandle, @@ -118,7 +120,7 @@ pub fn init_blockchain_manager( blockchain_read_handle, blockchain_context_service, block_verifier_service, - ); + ).await; tokio::spawn(manager.run(batch_rx)); } diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index eaf8669f..e1e78d46 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -1,6 +1,6 @@ -mod batch_handler; mod handler; +use std::collections::HashMap; use crate::blockchain::types::ConsensusBlockchainReadHandle; use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; use cuprate_consensus::context::RawBlockChainContext; @@ -11,12 +11,20 @@ use cuprate_consensus::{ }; use cuprate_p2p::block_downloader::BlockBatch; use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; -use cuprate_types::Chain; +use cuprate_types::{Chain, TransactionVerificationData}; use futures::StreamExt; -use tokio::sync::mpsc::Receiver; +use monero_serai::block::Block; +use tokio::sync::mpsc; +use tokio::sync::{Notify, oneshot}; use tower::{Service, ServiceExt}; use tracing::error; +pub struct IncomingBlock { + block: Block, + prepped_txs: HashMap<[u8; 32], TransactionVerificationData>, + response_tx: oneshot::Sender>, +} + pub struct BlockchainManager { blockchain_write_handle: BlockchainWriteHandle, blockchain_read_handle: BlockchainReadHandle, @@ -27,105 +35,58 @@ pub struct BlockchainManager { TxVerifierService, ConsensusBlockchainReadHandle, >, + + // TODO: stop_current_block_downloader: Notify, } impl BlockchainManager { - pub const fn new( + pub async fn new( blockchain_write_handle: BlockchainWriteHandle, blockchain_read_handle: BlockchainReadHandle, - blockchain_context_service: BlockChainContextService, + mut blockchain_context_service: BlockChainContextService, block_verifier_service: BlockVerifierService< BlockChainContextService, TxVerifierService, ConsensusBlockchainReadHandle, >, ) -> Self { + let BlockChainContextResponse::Context(blockchain_context) = blockchain_context_service + .ready() + .await + .expect("TODO") + .call(BlockChainContextRequest::GetContext) + .await + .expect("TODO") else { + panic!("Blockchain context service returned wrong response!"); + }; + Self { blockchain_write_handle, blockchain_read_handle, blockchain_context_service, - cached_blockchain_context: todo!(), + cached_blockchain_context: blockchain_context.unchecked_blockchain_context().clone(), block_verifier_service, } } - async fn handle_incoming_main_chain_batch( - &mut self, - batch: BlockBatch, - ) -> Result<(), anyhow::Error> { - let VerifyBlockResponse::MainChainBatchPrepped(prepped) = self - .block_verifier_service - .ready() - .await - .expect("TODO") - .call(VerifyBlockRequest::MainChainBatchPrepareBlocks { - blocks: batch.blocks, - }) - .await? - else { - panic!("Incorrect response!"); - }; - - for (block, txs) in prepped { - let VerifyBlockResponse::MainChain(verified_block) = block_verifier_service - .ready() - .await - .expect("TODO") - .call(VerifyBlockRequest::MainChainPrepped { block, txs }) - .await - .unwrap() - else { - panic!("Incorrect response!"); - }; - - blockchain_context_service - .ready() - .await - .expect("TODO") - .call(BlockChainContextRequest::Update(NewBlockData { - block_hash: verified_block.block_hash, - height: verified_block.height, - timestamp: verified_block.block.header.timestamp, - weight: verified_block.weight, - long_term_weight: verified_block.long_term_weight, - generated_coins: verified_block.generated_coins, - vote: HardFork::from_vote(verified_block.block.header.hardfork_signal), - cumulative_difficulty: verified_block.cumulative_difficulty, - })) - .await - .expect("TODO"); - - blockchain_write_handle - .ready() - .await - .expect("TODO") - .call(BlockchainWriteRequest::WriteBlock(verified_block)) - .await - .expect("TODO"); - } - } - - async fn handle_incoming_block_batch(&mut self, batch: BlockBatch) { - let (first_block, _) = batch - .blocks - .first() - .expect("Block batch should not be empty"); - - if first_block.header.previous == self.cached_blockchain_context.top_hash { - todo!("Main chain") - } else { - todo!("Alt chain") - } - } - - pub async fn run(mut self, mut batch_rx: Receiver) { + pub async fn run(mut self, mut block_batch_rx: mpsc::Receiver, mut block_single_rx: mpsc::Receiver) { loop { tokio::select! { - Some(batch) = batch_rx.recv() => { + Some(batch) = block_batch_rx.recv() => { self.handle_incoming_block_batch( batch, ).await; } + Some(incoming_block) = block_single_rx.recv() => { + let IncomingBlock { + block, + prepped_txs, + response_tx + } = incoming_block; + + let res = self.handle_incoming_block(block, prepped_txs).await; + let _ = response_tx.send(res); + } else => { todo!("TODO: exit the BC manager") } diff --git a/binaries/cuprated/src/blockchain/manager/batch_handler.rs b/binaries/cuprated/src/blockchain/manager/batch_handler.rs deleted file mode 100644 index ea08af42..00000000 --- a/binaries/cuprated/src/blockchain/manager/batch_handler.rs +++ /dev/null @@ -1,121 +0,0 @@ -//! Block batch handling functions. - -use crate::blockchain::types::ConsensusBlockchainReadHandle; -use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; -use cuprate_consensus::context::NewBlockData; -use cuprate_consensus::transactions::new_tx_verification_data; -use cuprate_consensus::{ - BlockChainContextRequest, BlockChainContextResponse, BlockChainContextService, - BlockVerifierService, BlockchainReadRequest, BlockchainResponse, ExtendedConsensusError, - VerifyBlockRequest, VerifyBlockResponse, VerifyTxRequest, VerifyTxResponse, -}; -use cuprate_p2p::block_downloader::BlockBatch; -use cuprate_types::blockchain::BlockchainWriteRequest; -use cuprate_types::{Chain, HardFork}; -use rayon::prelude::*; -use tower::{Service, ServiceExt}; -use tracing::{debug, error, info}; - -async fn handle_incoming_block_batch_main_chain( - batch: BlockBatch, - block_verifier_service: &mut BlockVerifierService, - blockchain_context_service: &mut C, - blockchain_write_handle: &mut BlockchainWriteHandle, -) -> Result<(), anyhow::Error> -where - C: Service< - BlockChainContextRequest, - Response = BlockChainContextResponse, - Error = tower::BoxError, - > + Clone - + Send - + 'static, - C::Future: Send + 'static, - - TxV: Service - + Clone - + Send - + 'static, - TxV::Future: Send + 'static, -{ - info!( - "Handling batch to main chain height: {}", - batch.blocks.first().unwrap().0.number().unwrap() - ); - - let VerifyBlockResponse::MainChainBatchPrepped(prepped) = block_verifier_service - .ready() - .await - .expect("TODO") - .call(VerifyBlockRequest::MainChainBatchPrepareBlocks { - blocks: batch.blocks, - }) - .await? - else { - panic!("Incorrect response!"); - }; - - for (block, txs) in prepped { - let VerifyBlockResponse::MainChain(verified_block) = block_verifier_service - .ready() - .await - .expect("TODO") - .call(VerifyBlockRequest::MainChainPrepped { block, txs }) - .await? - else { - panic!("Incorrect response!"); - }; - - blockchain_context_service - .ready() - .await - .expect("TODO") - .call(BlockChainContextRequest::Update(NewBlockData { - block_hash: verified_block.block_hash, - height: verified_block.height, - timestamp: verified_block.block.header.timestamp, - weight: verified_block.weight, - long_term_weight: verified_block.long_term_weight, - generated_coins: verified_block.generated_coins, - vote: HardFork::from_vote(verified_block.block.header.hardfork_signal), - cumulative_difficulty: verified_block.cumulative_difficulty, - })) - .await - .expect("TODO"); - - blockchain_write_handle - .ready() - .await - .expect("TODO") - .call(BlockchainWriteRequest::WriteBlock(verified_block)) - .await - .expect("TODO"); - } -} - -async fn handle_incoming_block_batch_alt_chain( - batch: BlockBatch, - block_verifier_service: &mut BlockVerifierService, - blockchain_context_service: &mut C, - blockchain_write_handle: &mut BlockchainWriteHandle, -) -> Result<(), anyhow::Error> -where - C: Service< - BlockChainContextRequest, - Response = BlockChainContextResponse, - Error = tower::BoxError, - > + Clone - + Send - + 'static, - C::Future: Send + 'static, - - TxV: Service - + Clone - + Send - + 'static, - TxV::Future: Send + 'static, -{ - for (block, txs) in batch.blocks { - alt_block_info.cumulative_difficulty - } -} diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs index 221acb81..6dcffef7 100644 --- a/binaries/cuprated/src/blockchain/manager/handler.rs +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -1,5 +1,8 @@ use crate::blockchain::types::ConsensusBlockchainReadHandle; +use crate::signals::REORG_LOCK; use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; +use cuprate_consensus::block::PreparedBlock; +use cuprate_consensus::context::NewBlockData; use cuprate_consensus::transactions::new_tx_verification_data; use cuprate_consensus::{ BlockChainContextRequest, BlockChainContextResponse, BlockVerifierService, @@ -10,154 +13,292 @@ use cuprate_p2p::block_downloader::BlockBatch; use cuprate_types::blockchain::{ BlockchainReadRequest, BlockchainResponse, BlockchainWriteRequest, }; -use cuprate_types::AltBlockInformation; +use cuprate_types::{ + AltBlockInformation, HardFork, TransactionVerificationData, VerifiedBlockInformation, +}; +use futures::{TryFutureExt, TryStreamExt}; use monero_serai::block::Block; use monero_serai::transaction::Transaction; use rayon::prelude::*; +use std::collections::HashMap; +use std::sync::Arc; use tower::{Service, ServiceExt}; +use tracing::info; -async fn handle_incoming_alt_block( - block: Block, - txs: Vec, - current_cumulative_difficulty: u128, - block_verifier_service: &mut BlockVerifierService, - blockchain_context_service: &mut C, - blockchain_write_handle: &mut BlockchainWriteHandle, -) -> Result<(), anyhow::Error> -where - C: Service< - BlockChainContextRequest, - Response = BlockChainContextResponse, - Error = tower::BoxError, - > + Clone - + Send - + 'static, - C::Future: Send + 'static, +impl super::BlockchainManager { + pub async fn handle_incoming_block( + &mut self, + block: Block, + prepared_txs: HashMap<[u8; 32], TransactionVerificationData>, + ) -> Result<(), anyhow::Error> { + if block.header.previous != self.cached_blockchain_context.top_hash { + self.handle_incoming_alt_block(block, prepared_txs).await?; - TxV: Service - + Clone - + Send - + 'static, - TxV::Future: Send + 'static, -{ - let prepared_txs = txs - .into_par_iter() - .map(|tx| { - let tx = new_tx_verification_data(tx)?; - (tx.tx_hash, tx) - }) - .collect::>()?; + return Ok(()); + } - let VerifyBlockResponse::AltChain(alt_block_info) = block_verifier_service - .ready() - .await - .expect("TODO") - .call(VerifyBlockRequest::AltChain { - block, - prepared_txs, - }) - .await? - else { - panic!("Incorrect response!"); - }; + let VerifyBlockResponse::MainChain(verified_block) = self + .block_verifier_service + .ready() + .await + .expect("TODO") + .call(VerifyBlockRequest::MainChain { + block, + prepared_txs, + }) + .await? + else { + panic!("Incorrect response!"); + }; - if alt_block_info.cumulative_difficulty > current_cumulative_difficulty { - todo!("do re-org"); + self.add_valid_block_to_main_chain(verified_block).await; + + Ok(()) } - blockchain_write_handle - .ready() - .await - .expect("TODO") - .call(BlockchainWriteRequest::WriteAltBlock(alt_block_info))?; + pub async fn handle_incoming_block_batch(&mut self, batch: BlockBatch) { + let (first_block, _) = batch + .blocks + .first() + .expect("Block batch should not be empty"); - Ok(()) -} - -async fn try_do_reorg( - top_alt_block: AltBlockInformation, - chain_height: usize, - block_verifier_service: &mut BlockVerifierService, - blockchain_context_service: &mut C, - blockchain_write_handle: &mut BlockchainWriteHandle, - blockchain_read_handle: &mut BlockchainReadHandle, -) -> Result<(), anyhow::Error> -where - C: Service< - BlockChainContextRequest, - Response = BlockChainContextResponse, - Error = tower::BoxError, - > + Clone - + Send - + 'static, - C::Future: Send + 'static, - - TxV: Service - + Clone - + Send - + 'static, - TxV::Future: Send + 'static, -{ - let BlockchainResponse::AltBlocksInChain(mut alt_blocks) = blockchain_read_handle - .ready() - .await - .expect("TODO") - .call(BlockchainReadRequest::AltBlocksInChain( - top_alt_block.chain_id, - )) - .await? - else { - panic!("Incorrect response!"); - }; - - alt_blocks.push(top_alt_block); - - let split_height = alt_blocks[0].height; - - let BlockchainResponse::PopBlocks(old_main_chain_id) = blockchain_write_handle - .ready() - .await - .expect("TODO") - .call(BlockchainWriteRequest::PopBlocks( - chain_height - split_height + 1, - )) - .await? - else { - panic!("Incorrect response!"); - }; - - todo!() -} - -async fn verify_add_alt_blocks_to_main_chain( - alt_blocks: Vec, - block_verifier_service: &mut BlockVerifierService, - blockchain_context_service: &mut C, - blockchain_write_handle: &mut BlockchainWriteHandle, -) -> Result<(), anyhow::Error> -where - C: Service< - BlockChainContextRequest, - Response = BlockChainContextResponse, - Error = tower::BoxError, - > + Clone - + Send - + 'static, - C::Future: Send + 'static, - - TxV: Service - + Clone - + Send - + 'static, - TxV::Future: Send + 'static, -{ - let VerifyBlockResponse::AltChain(alt_block_info) = block_verifier_service - .ready() - .await - .expect("TODO") - .call(VerifyBlockRequest::MainChainPrepped { block, txs }) - .await? - else { - panic!("Incorrect response!"); - }; + if first_block.header.previous == self.cached_blockchain_context.top_hash { + self.handle_incoming_block_batch_main_chain(batch).await.expect("TODO"); + } else { + self.handle_incoming_block_batch_alt_chain(batch).await.expect("TODO"); + } + } + + async fn handle_incoming_block_batch_main_chain( + &mut self, + batch: BlockBatch, + ) -> Result<(), anyhow::Error> { + info!( + "Handling batch to main chain height: {}", + batch.blocks.first().unwrap().0.number().unwrap() + ); + + let VerifyBlockResponse::MainChainBatchPrepped(prepped) = self + .block_verifier_service + .ready() + .await + .expect("TODO") + .call(VerifyBlockRequest::MainChainBatchPrepareBlocks { + blocks: batch.blocks, + }) + .await? + else { + panic!("Incorrect response!"); + }; + + for (block, txs) in prepped { + let VerifyBlockResponse::MainChain(verified_block) = self + .block_verifier_service + .ready() + .await + .expect("TODO") + .call(VerifyBlockRequest::MainChainPrepped { block, txs }) + .await? + else { + panic!("Incorrect response!"); + }; + + self.add_valid_block_to_main_chain(verified_block).await; + } + + Ok(()) + } + + async fn handle_incoming_block_batch_alt_chain( + &mut self, + batch: BlockBatch, + ) -> Result<(), anyhow::Error> { + for (block, txs) in batch.blocks { + let txs = txs + .into_par_iter() + .map(|tx| { + let tx = new_tx_verification_data(tx)?; + Ok((tx.tx_hash, tx)) + }) + .collect::>()?; + + self.handle_incoming_alt_block(block, txs).await?; + } + + Ok(()) + } + + pub async fn handle_incoming_alt_block( + &mut self, + block: Block, + prepared_txs: HashMap<[u8; 32], TransactionVerificationData>, + ) -> Result<(), anyhow::Error> { + let VerifyBlockResponse::AltChain(alt_block_info) = self + .block_verifier_service + .ready() + .await + .expect("TODO") + .call(VerifyBlockRequest::AltChain { + block, + prepared_txs, + }) + .await? + else { + panic!("Incorrect response!"); + }; + + // TODO: check in consensus crate if alt block already exists. + + if alt_block_info.cumulative_difficulty + > self.cached_blockchain_context.cumulative_difficulty + { + self.try_do_reorg(alt_block_info).await?; + // TODO: ban the peer if the reorg failed. + + return Ok(()); + } + + self.blockchain_write_handle + .ready() + .await + .expect("TODO") + .call(BlockchainWriteRequest::WriteAltBlock(alt_block_info)) + .await?; + + Ok(()) + } + + async fn try_do_reorg( + &mut self, + top_alt_block: AltBlockInformation, + ) -> Result<(), anyhow::Error> { + let _guard = REORG_LOCK.write().await; + + let BlockchainResponse::AltBlocksInChain(mut alt_blocks) = self + .blockchain_read_handle + .ready() + .await + .expect("TODO") + .call(BlockchainReadRequest::AltBlocksInChain( + top_alt_block.chain_id, + )) + .await? + else { + panic!("Incorrect response!"); + }; + + alt_blocks.push(top_alt_block); + + let split_height = alt_blocks[0].height; + let current_main_chain_height = self.cached_blockchain_context.chain_height; + + let BlockchainResponse::PopBlocks(old_main_chain_id) = self + .blockchain_write_handle + .ready() + .await + .expect("TODO") + .call(BlockchainWriteRequest::PopBlocks( + current_main_chain_height - split_height + 1, + )) + .await + .expect("TODO") + else { + panic!("Incorrect response!"); + }; + + self.blockchain_context_service + .ready() + .await + .expect("TODO") + .call(BlockChainContextRequest::PopBlocks { + numb_blocks: current_main_chain_height - split_height + 1, + }) + .await + .expect("TODO"); + + let reorg_res = self.verify_add_alt_blocks_to_main_chain(alt_blocks).await; + + match reorg_res { + Ok(()) => Ok(()), + Err(e) => { + todo!("Reverse reorg") + } + } + } + + async fn verify_add_alt_blocks_to_main_chain( + &mut self, + alt_blocks: Vec, + ) -> Result<(), anyhow::Error> { + for mut alt_block in alt_blocks { + let prepped_txs = alt_block + .txs + .drain(..) + .map(|tx| Ok(Arc::new(tx.try_into()?))) + .collect::>()?; + + let prepped_block = PreparedBlock::new_alt_block(alt_block)?; + + let VerifyBlockResponse::MainChain(verified_block) = self + .block_verifier_service + .ready() + .await + .expect("TODO") + .call(VerifyBlockRequest::MainChainPrepped { + block: prepped_block, + txs: prepped_txs, + }) + .await? + else { + panic!("Incorrect response!"); + }; + + self.add_valid_block_to_main_chain(verified_block).await; + } + + Ok(()) + } + + pub async fn add_valid_block_to_main_chain( + &mut self, + verified_block: VerifiedBlockInformation, + ) { + self.blockchain_context_service + .ready() + .await + .expect("TODO") + .call(BlockChainContextRequest::Update(NewBlockData { + block_hash: verified_block.block_hash, + height: verified_block.height, + timestamp: verified_block.block.header.timestamp, + weight: verified_block.weight, + long_term_weight: verified_block.long_term_weight, + generated_coins: verified_block.generated_coins, + vote: HardFork::from_vote(verified_block.block.header.hardfork_signal), + cumulative_difficulty: verified_block.cumulative_difficulty, + })) + .await + .expect("TODO"); + + self.blockchain_write_handle + .ready() + .await + .expect("TODO") + .call(BlockchainWriteRequest::WriteBlock(verified_block)) + .await + .expect("TODO"); + + let BlockChainContextResponse::Context(blockchain_context) = self + .blockchain_context_service + .ready() + .await + .expect("TODO") + .call(BlockChainContextRequest::GetContext) + .await + .expect("TODO") else { + panic!("Incorrect response!"); + }; + + self.cached_blockchain_context = blockchain_context.unchecked_blockchain_context().clone(); + } } diff --git a/binaries/cuprated/src/main.rs b/binaries/cuprated/src/main.rs index 0e706b93..0a885363 100644 --- a/binaries/cuprated/src/main.rs +++ b/binaries/cuprated/src/main.rs @@ -18,6 +18,7 @@ mod blockchain; mod config; mod p2p; mod rpc; +mod signals; mod txpool; use blockchain::check_add_genesis; @@ -58,7 +59,7 @@ fn main() { 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 diff --git a/binaries/cuprated/src/signals.rs b/binaries/cuprated/src/signals.rs new file mode 100644 index 00000000..cafd8cdb --- /dev/null +++ b/binaries/cuprated/src/signals.rs @@ -0,0 +1,3 @@ +use tokio::sync::RwLock; + +pub static REORG_LOCK: RwLock<()> = RwLock::const_new(()); diff --git a/p2p/address-book/src/lib.rs b/p2p/address-book/src/lib.rs index 8c531e75..ae35a1bb 100644 --- a/p2p/address-book/src/lib.rs +++ b/p2p/address-book/src/lib.rs @@ -88,19 +88,15 @@ mod sealed { /// An internal trait for the address book for a [`NetworkZone`] that adds the requirement of [`borsh`] traits /// onto the network address. - pub trait BorshNetworkZone: - NetworkZone< - Addr: NetZoneAddress - + borsh::BorshDeserialize - + borsh::BorshSerialize, - > - { + pub trait BorshNetworkZone: NetworkZone { + type BorshAddr: NetZoneAddress + borsh::BorshDeserialize + borsh::BorshSerialize; } impl BorshNetworkZone for T where T::Addr: borsh::BorshDeserialize + borsh::BorshSerialize, - ::BanID: borsh::BorshDeserialize + borsh::BorshSerialize, { + type BorshAddr = T::Addr; } + } diff --git a/p2p_state.bin b/p2p_state.bin index bf2d673dd8c3bca6473f8a64e5c96f5145cd2331..281771cac6fd217c1d42942fc5489e431caa63a0 100644 GIT binary patch delta 72123 zcmZ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l)!78x7@uLCDsskaV$;KZwjZ06rSx2_6;cTHmyg_%y;1D(8Uia{~IxU>%+F&3^f+jx{{I z;v}uG6p_7s8bV6fTgUw;TVYd8zPJf%_Yy8>$~=OpQ3<3B)&f`ayBQ(x4fre0hTIZT z#@5j7(S8E`r7tKWHiSoVu2_4=+v%HZsEGO6Xl*XRw5R*y&FXeHJU6qeCYryZCKwtH z+o(08!0SxkI5*KjXr`HUJLKa$lMkJ|hdz3c3+LK%Ce!j3{u@oZ^R5qks2XZpxxH{eqGry6l6; zmxgSto%#*ibsn*^Pr+#>HCPy zjJjkU1@zpVkY!vdIUh|KZX2mkxn^Pg4TCJ=I~Qg4HhPVF|YOB zG;7z)JtKyvEMW+s5uw3EXItQMknJ-IN81B!y4wnN87t}0V2I4l`MFoyItLtjR{2qp z?|7=DLIjoKFE7^teBW=oe#F(U#_2q{IH`me+ly%DzC&}(mhbs6q|aD4`12v>^~l&sA#5I$0_) z0m6WS4I5d9gXDH`BXo3qQUGjrEiV(1L56EP7KjeO<_W7&L(+25XN^L|!k$AqXQ9^et3fwwv_>{ivlaos>!COjU*MRGS-RfnzWv zw__`Df3BweGbmbV;*5rap!yV7Rg?y?gcvJUDPE!G3dvI9D^+Ex8s0PE=Bw5_`K9hW zNGgb+U1fqAl)W!gu}-r87Cgtal@(xQSl7lsbhReeHlU`(AXY4oqOA~51o|oYXR=iI zUraIDEv%Rno!k)n(DOEa=+v;m;GiBD(@y>9>kGLyPIROn`)Ov0AMf;K4-s6~BitYg zasX~Rwla~a8ldDu^G*ZY98gv67`LnXH7z?*@oyn6i|I9h19))?hR%w;4k$~Wkohk* CT8b0^ diff --git a/storage/blockchain/src/service/read.rs b/storage/blockchain/src/service/read.rs index 07fa8253..e502c9f1 100644 --- a/storage/blockchain/src/service/read.rs +++ b/storage/blockchain/src/service/read.rs @@ -628,7 +628,7 @@ fn next_missing_chain_entry(env: &ConcreteEnv, block_hashes: Vec<[u8; 32]>) -> R let block_hashes: Vec<_> = table_block_infos .get_range(start_height..end_height)? .map(|block_info| Ok(block_info?.block_hash)) - .collect::>()?; + .collect::>()?; let first_missing_block = if block_hashes.len() > 1 { let table_block_blobs = env_inner.open_db_ro::(&tx_ro)?; From 6ec5bc37a94ae236a31fe29fea79c971ddae6ebc Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 13 Sep 2024 00:03:03 +0100 Subject: [PATCH 28/72] add function for incoming blocks --- binaries/cuprated/src/blockchain.rs | 4 +- binaries/cuprated/src/blockchain/free.rs | 93 ++++++++++++++++++ binaries/cuprated/src/blockchain/manager.rs | 20 ++-- .../src/blockchain/manager/handler.rs | 11 ++- binaries/cuprated/src/main.rs | 3 +- p2p/address-book/src/lib.rs | 1 - p2p_state.bin | Bin 172430 -> 172852 bytes 7 files changed, 118 insertions(+), 14 deletions(-) create mode 100644 binaries/cuprated/src/blockchain/free.rs diff --git a/binaries/cuprated/src/blockchain.rs b/binaries/cuprated/src/blockchain.rs index eb23224e..46cc6a43 100644 --- a/binaries/cuprated/src/blockchain.rs +++ b/binaries/cuprated/src/blockchain.rs @@ -16,6 +16,7 @@ use cuprate_types::{ VerifiedBlockInformation, }; +mod free; mod manager; mod syncer; mod types; @@ -120,7 +121,8 @@ pub async fn init_blockchain_manager( blockchain_read_handle, blockchain_context_service, block_verifier_service, - ).await; + ) + .await; tokio::spawn(manager.run(batch_rx)); } diff --git a/binaries/cuprated/src/blockchain/free.rs b/binaries/cuprated/src/blockchain/free.rs new file mode 100644 index 00000000..becdf307 --- /dev/null +++ b/binaries/cuprated/src/blockchain/free.rs @@ -0,0 +1,93 @@ +use crate::blockchain::manager::IncomingBlock; +use cuprate_blockchain::service::BlockchainReadHandle; +use cuprate_consensus::transactions::new_tx_verification_data; +use cuprate_helper::cast::usize_to_u64; +use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; +use cuprate_types::Chain; +use monero_serai::block::Block; +use monero_serai::transaction::Transaction; +use rayon::prelude::*; +use std::collections::HashMap; +use std::sync::OnceLock; +use tokio::sync::{mpsc, oneshot}; +use tower::{Service, ServiceExt}; + +static INCOMING_BLOCK_TX: OnceLock> = OnceLock::new(); + +#[derive(thiserror::Error)] +pub enum IncomingBlockError { + #[error("Unknown transactions in block.")] + UnknownTransactions(Vec), + #[error("The block has an unknown parent.")] + Orphan, + #[error(transparent)] + InvalidBlock(anyhow::Error), +} + +pub async fn handle_incoming_block( + block: Block, + given_txs: Vec, + blockchain_read_handle: &mut BlockchainReadHandle, +) -> Result<(), IncomingBlockError> { + if !block_exists(block.header.previous, blockchain_read_handle).expect("TODO") { + return Err(IncomingBlockError::Orphan); + } + + let block_hash = block.hash(); + + if block_exists(block_hash, blockchain_read_handle) + .await + .expect("TODO") + { + return Ok(()); + } + + let prepped_txs = given_txs + .into_par_iter() + .map(|tx| { + let tx = new_tx_verification_data(tx)?; + Ok((tx.tx_hash, tx)) + }) + .collect::>() + .map_err(IncomingBlockError::InvalidBlock)?; + + // TODO: Get transactions from the tx pool first. + if given_txs.len() != block.transactions.len() { + return Err(IncomingBlockError::UnknownTransactions( + (0..usize_to_u64(block.transactions.len())).collect(), + )); + } + + let Some(incoming_block_tx) = INCOMING_BLOCK_TX.get() else { + return Ok(()); + }; + + let (response_tx, response_rx) = oneshot::channel(); + + incoming_block_tx + .send(IncomingBlock { + block, + prepped_txs, + response_tx, + }) + .await + .expect("TODO: don't actually panic here"); + + response_rx.await.map_err(IncomingBlockError::InvalidBlock) +} + +async fn block_exists( + block_hash: [u8; 32], + blockchain_read_handle: &mut BlockchainReadHandle, +) -> Result { + let BlockchainResponse::FindBlock(chain) = blockchain_read_handle + .ready() + .await? + .call(BlockchainReadRequest::FindBlock(block_hash)) + .await? + else { + panic!("Invalid blockchain response!"); + }; + + Ok(chain.is_some()) +} diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index e1e78d46..69de3399 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -1,6 +1,5 @@ mod handler; -use std::collections::HashMap; use crate::blockchain::types::ConsensusBlockchainReadHandle; use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; use cuprate_consensus::context::RawBlockChainContext; @@ -14,15 +13,16 @@ use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; use cuprate_types::{Chain, TransactionVerificationData}; use futures::StreamExt; use monero_serai::block::Block; +use std::collections::HashMap; use tokio::sync::mpsc; -use tokio::sync::{Notify, oneshot}; +use tokio::sync::{oneshot, Notify}; use tower::{Service, ServiceExt}; use tracing::error; pub struct IncomingBlock { - block: Block, - prepped_txs: HashMap<[u8; 32], TransactionVerificationData>, - response_tx: oneshot::Sender>, + pub block: Block, + pub prepped_txs: HashMap<[u8; 32], TransactionVerificationData>, + pub response_tx: oneshot::Sender>, } pub struct BlockchainManager { @@ -35,7 +35,6 @@ pub struct BlockchainManager { TxVerifierService, ConsensusBlockchainReadHandle, >, - // TODO: stop_current_block_downloader: Notify, } @@ -56,7 +55,8 @@ impl BlockchainManager { .expect("TODO") .call(BlockChainContextRequest::GetContext) .await - .expect("TODO") else { + .expect("TODO") + else { panic!("Blockchain context service returned wrong response!"); }; @@ -69,7 +69,11 @@ impl BlockchainManager { } } - pub async fn run(mut self, mut block_batch_rx: mpsc::Receiver, mut block_single_rx: mpsc::Receiver) { + pub async fn run( + mut self, + mut block_batch_rx: mpsc::Receiver, + mut block_single_rx: mpsc::Receiver, + ) { loop { tokio::select! { Some(batch) = block_batch_rx.recv() => { diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs index 6dcffef7..f9f6ce80 100644 --- a/binaries/cuprated/src/blockchain/manager/handler.rs +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -63,9 +63,13 @@ impl super::BlockchainManager { .expect("Block batch should not be empty"); if first_block.header.previous == self.cached_blockchain_context.top_hash { - self.handle_incoming_block_batch_main_chain(batch).await.expect("TODO"); + self.handle_incoming_block_batch_main_chain(batch) + .await + .expect("TODO"); } else { - self.handle_incoming_block_batch_alt_chain(batch).await.expect("TODO"); + self.handle_incoming_block_batch_alt_chain(batch) + .await + .expect("TODO"); } } @@ -295,7 +299,8 @@ impl super::BlockchainManager { .expect("TODO") .call(BlockChainContextRequest::GetContext) .await - .expect("TODO") else { + .expect("TODO") + else { panic!("Incorrect response!"); }; diff --git a/binaries/cuprated/src/main.rs b/binaries/cuprated/src/main.rs index 0a885363..2c26c118 100644 --- a/binaries/cuprated/src/main.rs +++ b/binaries/cuprated/src/main.rs @@ -59,7 +59,8 @@ fn main() { context_svc, block_verifier, config.block_downloader_config(), - ).await; + ) + .await; // TODO: this can be removed as long as the main thread does not exit, so when command handling // is added diff --git a/p2p/address-book/src/lib.rs b/p2p/address-book/src/lib.rs index ae35a1bb..c0903485 100644 --- a/p2p/address-book/src/lib.rs +++ b/p2p/address-book/src/lib.rs @@ -98,5 +98,4 @@ mod sealed { { type BorshAddr = T::Addr; } - } diff --git a/p2p_state.bin b/p2p_state.bin index 281771cac6fd217c1d42942fc5489e431caa63a0..fc17e050f72079bd7b70ecf81a388975afba2996 100644 GIT binary patch delta 4664 zcmZ`+3pi9;`?vROcQztsCWb~PGOk5RpF^=Gbf=4SJxN4$R7!oRlw7)yZ`HReC-z9W zL@ql`qEm7?6+%&|j!TErk#3~Bf4()-n0lP&?|D4yedb-i_kGuIy_dC5)Eh0pIG3~b5;O?D=9Q9Ok?rx_v=ZaO@y4h> zy)Xex=knkOA&+^?{TYLwNFEbtoQJ_O6&_>3tHLNvOLRh2vuW^yG-$H~44&2!Fgkpm z3iP$&K|jlBFhG?D^DWchRW6SSwG!fRh8d4xtUWQ}g0o*cv^&9NM%%o>A*Y;2iE(6Z zwgC^?SPEdJrU1^+=D~j%^I)F_qS+e#t}NgL-%T)~LE2NVUGej$vJ_$G02r=pPMF`q z&EOs}7shZ+<|gPP^}E5gra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*j(oZsQSR zg|>KWn*X?3g+|9wlVw{cHTT7LRlymZB7`EEy<&sEur^jUbT{dxTXNRdh(khJK4|zJ z1VZ$F(OkbN;YaRvJ&{OIN8M&N!{D6~ZsYHS8v)-C4EM(kLc1R=JEHo4dU`a;uD&~Z zI)8S;d&E!r;xU*Olw$QSyZ^4WHmzSn1xu z4c|D%0qV;Uz#aICwAX--EE(>ZEjf#(oyG^@))8}}EOOO?*caT)ugM)0o%lExZ`vB3 zD{Ego$ei!)oX%*{K}=t0TzwXS*2Wk8EsliEP>ly}<}7k04Rf^^t}To-G^ACJmvBY- z%RfEJ$Ce)CG=3m|5{lOiIhlaKTbmH=hzWBZ_GOU|xSX|QiI8>aT_^INK0_y*&zMF3fLNET)gUd}N%k=3n zt+z0^U>m8 DW~I!Y From 90beed15905ac1d45e237bf87bcdbe40eb871ab7 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 13 Sep 2024 03:17:30 +0100 Subject: [PATCH 29/72] add docs to handler functions --- binaries/cuprated/src/blockchain/manager.rs | 4 +- .../src/blockchain/manager/handler.rs | 218 +++++++++++++----- binaries/cuprated/src/blockchain/syncer.rs | 23 +- p2p/p2p/src/constants.rs | 6 +- p2p_state.bin | Bin 172852 -> 172906 bytes 5 files changed, 186 insertions(+), 65 deletions(-) diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index 69de3399..ae5a1d3d 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -22,7 +22,7 @@ use tracing::error; pub struct IncomingBlock { pub block: Block, pub prepped_txs: HashMap<[u8; 32], TransactionVerificationData>, - pub response_tx: oneshot::Sender>, + pub response_tx: oneshot::Sender>, } pub struct BlockchainManager { @@ -35,7 +35,7 @@ pub struct BlockchainManager { TxVerifierService, ConsensusBlockchainReadHandle, >, - // TODO: stop_current_block_downloader: Notify, + stop_current_block_downloader: Notify, } impl BlockchainManager { diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs index f9f6ce80..1bdae16c 100644 --- a/binaries/cuprated/src/blockchain/manager/handler.rs +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -1,40 +1,45 @@ -use crate::blockchain::types::ConsensusBlockchainReadHandle; -use crate::signals::REORG_LOCK; +use std::{collections::HashMap, sync::Arc}; + +use futures::{TryFutureExt, TryStreamExt}; +use monero_serai::{block::Block, transaction::Transaction}; +use rayon::prelude::*; +use tower::{Service, ServiceExt}; +use tracing::info; + use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; -use cuprate_consensus::block::PreparedBlock; -use cuprate_consensus::context::NewBlockData; -use cuprate_consensus::transactions::new_tx_verification_data; use cuprate_consensus::{ + block::PreparedBlock, context::NewBlockData, transactions::new_tx_verification_data, BlockChainContextRequest, BlockChainContextResponse, BlockVerifierService, ExtendedConsensusError, VerifyBlockRequest, VerifyBlockResponse, VerifyTxRequest, VerifyTxResponse, }; -use cuprate_p2p::block_downloader::BlockBatch; -use cuprate_types::blockchain::{ - BlockchainReadRequest, BlockchainResponse, BlockchainWriteRequest, -}; +use cuprate_p2p::{block_downloader::BlockBatch, constants::LONG_BAN}; use cuprate_types::{ + blockchain::{BlockchainReadRequest, BlockchainResponse, BlockchainWriteRequest}, AltBlockInformation, HardFork, TransactionVerificationData, VerifiedBlockInformation, }; -use futures::{TryFutureExt, TryStreamExt}; -use monero_serai::block::Block; -use monero_serai::transaction::Transaction; -use rayon::prelude::*; -use std::collections::HashMap; -use std::sync::Arc; -use tower::{Service, ServiceExt}; -use tracing::info; + +use crate::{blockchain::types::ConsensusBlockchainReadHandle, signals::REORG_LOCK}; impl super::BlockchainManager { + /// Handle an incoming [`Block`]. + /// + /// This function will route to [`Self::handle_incoming_alt_block`] if the block does not follow + /// the top of the main chain. + /// + /// Otherwise, this function will validate and add the block to the main chain. + /// + /// On success returns a [`bool`] indicating if the block was added to the main chain ([`true`]) + /// of an alt-chain ([`false`]). pub async fn handle_incoming_block( &mut self, block: Block, prepared_txs: HashMap<[u8; 32], TransactionVerificationData>, - ) -> Result<(), anyhow::Error> { + ) -> Result { if block.header.previous != self.cached_blockchain_context.top_hash { self.handle_incoming_alt_block(block, prepared_txs).await?; - return Ok(()); + return Ok(false); } let VerifyBlockResponse::MainChain(verified_block) = self @@ -53,9 +58,18 @@ impl super::BlockchainManager { self.add_valid_block_to_main_chain(verified_block).await; - Ok(()) + Ok(true) } + /// Handle an incoming [`BlockBatch`]. + /// + /// This function will route to [`Self::handle_incoming_block_batch_main_chain`] or [`Self::handle_incoming_block_batch_alt_chain`] + /// depending on if the first block in the batch follows from the top of our chain. + /// + /// # Panics + /// + /// This function will panic if the batch is empty or if any internal service returns an unexpected + /// error that we cannot recover from. pub async fn handle_incoming_block_batch(&mut self, batch: BlockBatch) { let (first_block, _) = batch .blocks @@ -63,26 +77,36 @@ impl super::BlockchainManager { .expect("Block batch should not be empty"); if first_block.header.previous == self.cached_blockchain_context.top_hash { - self.handle_incoming_block_batch_main_chain(batch) - .await - .expect("TODO"); + self.handle_incoming_block_batch_main_chain(batch).await; } else { - self.handle_incoming_block_batch_alt_chain(batch) - .await - .expect("TODO"); + self.handle_incoming_block_batch_alt_chain(batch).await; } } - async fn handle_incoming_block_batch_main_chain( - &mut self, - batch: BlockBatch, - ) -> Result<(), anyhow::Error> { + /// Handles an incoming [`BlockBatch`] that follows the main chain. + /// + /// This function will handle validating the blocks in the batch and adding them to the blockchain + /// database and context cache. + /// + /// This function will also handle banning the peer and canceling the block downloader if the + /// block is invalid. + /// + /// # Panics + /// + /// This function will panic if any internal service returns an unexpected error that we cannot + /// recover from. + async fn handle_incoming_block_batch_main_chain(&mut self, batch: BlockBatch) { info!( "Handling batch to main chain height: {}", batch.blocks.first().unwrap().0.number().unwrap() ); - let VerifyBlockResponse::MainChainBatchPrepped(prepped) = self + let ban_cancel_download = || { + batch.peer_handle.ban_peer(LONG_BAN); + self.stop_current_block_downloader.notify_one(); + }; + + let batch_prep_res = self .block_verifier_service .ready() .await @@ -90,21 +114,33 @@ impl super::BlockchainManager { .call(VerifyBlockRequest::MainChainBatchPrepareBlocks { blocks: batch.blocks, }) - .await? - else { - panic!("Incorrect response!"); + .await; + + let prepped_blocks = match batch_prep_res { + Ok(VerifyBlockResponse::MainChainBatchPrepped(prepped_blocks)) => prepped_blocks, + Err(_) => { + ban_cancel_download(); + return; + } + _ => panic!("Incorrect response!"), }; - for (block, txs) in prepped { - let VerifyBlockResponse::MainChain(verified_block) = self + for (block, txs) in prepped_blocks { + let verify_res = self .block_verifier_service .ready() .await .expect("TODO") .call(VerifyBlockRequest::MainChainPrepped { block, txs }) - .await? - else { - panic!("Incorrect response!"); + .await; + + let VerifyBlockResponse::MainChain(verified_block) = match verify_res { + Ok(VerifyBlockResponse::MainChain(verified_block)) => verified_block, + Err(_) => { + ban_cancel_download(); + return; + } + _ => panic!("Incorrect response!"), }; self.add_valid_block_to_main_chain(verified_block).await; @@ -113,25 +149,60 @@ impl super::BlockchainManager { Ok(()) } - async fn handle_incoming_block_batch_alt_chain( - &mut self, - batch: BlockBatch, - ) -> Result<(), anyhow::Error> { + /// Handles an incoming [`BlockBatch`] that does not follow the main-chain. + /// + /// This function will handle validating the alt-blocks to add them to our cache and reorging the + /// chain if the alt-chain has a higher cumulative difficulty. + /// + /// This function will also handle banning the peer and canceling the block downloader if the + /// alt block is invalid or if a reorg fails. + /// + /// # Panics + /// + /// This function will panic if any internal service returns an unexpected error that we cannot + /// recover from. + async fn handle_incoming_block_batch_alt_chain(&mut self, batch: BlockBatch) { for (block, txs) in batch.blocks { - let txs = txs - .into_par_iter() - .map(|tx| { - let tx = new_tx_verification_data(tx)?; - Ok((tx.tx_hash, tx)) - }) - .collect::>()?; + // async blocks work as try blocks. + let res = async { + let txs = txs + .into_par_iter() + .map(|tx| { + let tx = new_tx_verification_data(tx)?; + Ok((tx.tx_hash, tx)) + }) + .collect::>()?; - self.handle_incoming_alt_block(block, txs).await?; + self.handle_incoming_alt_block(block, txs).await?; + + Ok(()) + } + .await; + + if let Err(e) = res { + batch.peer_handle.ban_peer(LONG_BAN); + self.stop_current_block_downloader.notify_one(); + return; + } } - - Ok(()) } + /// Handles an incoming alt [`Block`]. + /// + /// This function will do some pre-validation of the alt block, then if the cumulative difficulty + /// of the alt chain is higher than the main chain it will attempt a reorg otherwise it will add + /// the alt block to the alt block cache. + /// + /// # Errors + /// + /// This will return an [`Err`] if: + /// - The alt block was invalid. + /// - An attempt to reorg the chain failed. + /// + /// # Panics + /// + /// This function will panic if any internal service returns an unexpected error that we cannot + /// recover from. pub async fn handle_incoming_alt_block( &mut self, block: Block, @@ -157,8 +228,6 @@ impl super::BlockchainManager { > self.cached_blockchain_context.cumulative_difficulty { self.try_do_reorg(alt_block_info).await?; - // TODO: ban the peer if the reorg failed. - return Ok(()); } @@ -172,6 +241,21 @@ impl super::BlockchainManager { Ok(()) } + /// Attempt a re-org with the given top block of the alt-chain. + /// + /// This function will take a write lock on [`REORG_LOCK`] and then set up the blockchain database + /// and context cache to verify the alt-chain. It will then attempt to verify and add each block + /// in the alt-chain to tha main-chain. Releasing the lock on [`REORG_LOCK`] when finished. + /// + /// # Errors + /// + /// This function will return an [`Err`] if the re-org was unsuccessful, if this happens the chain + /// will be returned back into its state it was at when then function was called. + /// + /// # Panics + /// + /// This function will panic if any internal service returns an unexpected error that we cannot + /// recover from. async fn try_do_reorg( &mut self, top_alt_block: AltBlockInformation, @@ -230,6 +314,21 @@ impl super::BlockchainManager { } } + /// Verify and add a list of [`AltBlockInformation`]s to the main-chain. + /// + /// This function assumes the first [`AltBlockInformation`] is the next block in the blockchain + /// for the blockchain database and the context cache, or in other words that the blockchain database + /// and context cache has had the top blocks popped to where the alt-chain meets the main-chain. + /// + /// # Errors + /// + /// This function will return an [`Err`] if the alt-blocks were invalid, in this case the re-org should + /// be aborted and the chain should be returned to its previous state. + /// + /// # Panics + /// + /// This function will panic if any internal service returns an unexpected error that we cannot + /// recover from. async fn verify_add_alt_blocks_to_main_chain( &mut self, alt_blocks: Vec, @@ -263,6 +362,15 @@ impl super::BlockchainManager { Ok(()) } + /// Adds a [`VerifiedBlockInformation`] to the main-chain. + /// + /// This function will update the blockchain database and the context cache, it will also + /// update [`Self::cached_blockchain_context`]. + /// + /// # Panics + /// + /// This function will panic if any internal service returns an unexpected error that we cannot + /// recover from. pub async fn add_valid_block_to_main_chain( &mut self, verified_block: VerifiedBlockInformation, diff --git a/binaries/cuprated/src/blockchain/syncer.rs b/binaries/cuprated/src/blockchain/syncer.rs index dc738123..fbf4a88f 100644 --- a/binaries/cuprated/src/blockchain/syncer.rs +++ b/binaries/cuprated/src/blockchain/syncer.rs @@ -1,7 +1,11 @@ +use std::pin::pin; use std::time::Duration; use futures::StreamExt; -use tokio::{sync::mpsc, time::sleep}; +use tokio::{ + sync::{mpsc, Notify}, + time::sleep, +}; use tower::{Service, ServiceExt}; use tracing::instrument; @@ -27,6 +31,7 @@ pub async fn syncer( our_chain: CN, clearnet_interface: NetworkInterface, incoming_block_batch_tx: mpsc::Sender, + stop_current_block_downloader: Notify, block_downloader_config: BlockDownloaderConfig, ) -> Result<(), SyncerError> where @@ -82,10 +87,18 @@ where let mut block_batch_stream = clearnet_interface.block_downloader(our_chain.clone(), block_downloader_config); - while let Some(batch) = block_batch_stream.next().await { - tracing::debug!("Got batch, len: {}", batch.blocks.len()); - if incoming_block_batch_tx.send(batch).await.is_err() { - return Err(SyncerError::IncomingBlockChannelClosed); + loop { + tokio::select! { + _ = stop_current_block_downloader.notified() => { + tracing::info!("Stopping block downloader"); + break; + } + Some(batch) = block_batch_stream.next() => { + tracing::debug!("Got batch, len: {}", batch.blocks.len()); + if incoming_block_batch_tx.send(batch).await.is_err() { + return Err(SyncerError::IncomingBlockChannelClosed); + } + } } } } diff --git a/p2p/p2p/src/constants.rs b/p2p/p2p/src/constants.rs index 4e6daa73..0dbd188e 100644 --- a/p2p/p2p/src/constants.rs +++ b/p2p/p2p/src/constants.rs @@ -10,13 +10,13 @@ pub(crate) const MAX_SEED_CONNECTIONS: usize = 3; pub(crate) const OUTBOUND_CONNECTION_ATTEMPT_TIMEOUT: Duration = Duration::from_secs(5); /// The durations of a short ban. -pub(crate) const SHORT_BAN: Duration = Duration::from_secs(60 * 10); +pub const SHORT_BAN: Duration = Duration::from_secs(60 * 10); /// The durations of a medium ban. -pub(crate) const MEDIUM_BAN: Duration = Duration::from_secs(60 * 60 * 24); +pub const MEDIUM_BAN: Duration = Duration::from_secs(60 * 60 * 24); /// The durations of a long ban. -pub(crate) const LONG_BAN: Duration = Duration::from_secs(60 * 60 * 24 * 7); +pub const LONG_BAN: Duration = Duration::from_secs(60 * 60 * 24 * 7); /// The default amount of time between inbound diffusion flushes. pub(crate) const DIFFUSION_FLUSH_AVERAGE_SECONDS_INBOUND: Duration = Duration::from_secs(5); diff --git a/p2p_state.bin b/p2p_state.bin index fc17e050f72079bd7b70ecf81a388975afba2996..9faaaff02d13da96127ed10c9c77a8ab0a7b45ff 100644 GIT binary patch delta 4976 zcmZXXeOyf08^AlaI~D4tq-G|DX%wkYN?I$0&Lk>QXwVx{(Gn3$df8Qy3b(pN=~iA! zMVWG~h*Gi?D{Hsd6_H*S zUBENc*PBSgVGL0hTfOnQg62c%Zrufd)I*y-)!RYs%)|uJom@Xa-ogda4?IGJyoQ`J z9DkBr$weWJHv)vYM!Y5s7Xd9>K9BD}ML@tM%?yr_NfQKQhk>5~CwuD5IHzZR1(jX- zdr}o!?Q@ce?sKN6P{PlEFO3zc0rIH%SZU#eQ-C=4SzAKGUvkem9Xfxff~-VF!_dx2 zC|b|S0_iQIL}jwTL?8{DYzatB1A+8clTr>jPuYmPrY0bZ(6Wa-0hyjJpela=0?H;7 z6Ohzs0U4++Am^zH$f??6N9`MhT=@9*pJW;u-)e4csS12V0y{3*J;TUDtvbpS(8NaVGzl?5(lkx{8?O!d#ET`@5V%oWm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K=#)+PBNlW-b^3Dz9!wI~kO`+; znCl&)27jA$6ncJ-x)$Q8iku}W)o9=L?kw1D96tC#8ZA_3ZOJ$bBSsJ-1*~3;*4fS3 p_?NKv9Nq+-*yM%Q6r3fbQ*aV42qT3IM~oD{T!fRtk(0Rb{{W@ru>=4B From a16381ea61ee25acad3eaae47d8e81e07b6e6333 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sat, 14 Sep 2024 13:49:41 +0100 Subject: [PATCH 30/72] broadcast new blocks + add commands --- binaries/cuprated/src/blockchain.rs | 15 ++++- binaries/cuprated/src/blockchain/free.rs | 32 +++++----- binaries/cuprated/src/blockchain/manager.rs | 32 +++++----- .../src/blockchain/manager/commands.rs | 17 ++++++ .../src/blockchain/manager/handler.rs | 57 +++++++++++++----- binaries/cuprated/src/blockchain/syncer.rs | 3 +- p2p_state.bin | Bin 172906 -> 0 bytes 7 files changed, 105 insertions(+), 51 deletions(-) create mode 100644 binaries/cuprated/src/blockchain/manager/commands.rs delete mode 100644 p2p_state.bin diff --git a/binaries/cuprated/src/blockchain.rs b/binaries/cuprated/src/blockchain.rs index 46cc6a43..f05878ac 100644 --- a/binaries/cuprated/src/blockchain.rs +++ b/binaries/cuprated/src/blockchain.rs @@ -3,7 +3,8 @@ //! Will contain the chain manager and syncer. use futures::FutureExt; -use tokio::sync::mpsc; +use std::sync::Arc; +use tokio::sync::{mpsc, Notify}; use tower::{Service, ServiceExt}; use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; @@ -26,6 +27,7 @@ use types::{ ChainService, ConcreteBlockVerifierService, ConcreteTxVerifierService, ConsensusBlockchainReadHandle, }; +use crate::blockchain::free::INCOMING_BLOCK_TX; /// Checks if the genesis block is in the blockchain and adds it if not. pub async fn check_add_genesis( @@ -107,12 +109,17 @@ pub async fn init_blockchain_manager( block_downloader_config: BlockDownloaderConfig, ) { let (batch_tx, batch_rx) = mpsc::channel(1); + let stop_current_block_downloader = Arc::new(Notify::new()); + let (command_tx, command_rx) = mpsc::channel(1); + + INCOMING_BLOCK_TX.set(command_tx).unwrap(); tokio::spawn(syncer::syncer( blockchain_context_service.clone(), ChainService(blockchain_read_handle.clone()), - clearnet_interface, + clearnet_interface.clone(), batch_tx, + stop_current_block_downloader.clone(), block_downloader_config, )); @@ -121,8 +128,10 @@ pub async fn init_blockchain_manager( blockchain_read_handle, blockchain_context_service, block_verifier_service, + stop_current_block_downloader, + clearnet_interface.broadcast_svc(), ) .await; - tokio::spawn(manager.run(batch_rx)); + tokio::spawn(manager.run(batch_rx, command_rx)); } diff --git a/binaries/cuprated/src/blockchain/free.rs b/binaries/cuprated/src/blockchain/free.rs index becdf307..eb80a31d 100644 --- a/binaries/cuprated/src/blockchain/free.rs +++ b/binaries/cuprated/src/blockchain/free.rs @@ -1,4 +1,3 @@ -use crate::blockchain::manager::IncomingBlock; use cuprate_blockchain::service::BlockchainReadHandle; use cuprate_consensus::transactions::new_tx_verification_data; use cuprate_helper::cast::usize_to_u64; @@ -11,10 +10,11 @@ use std::collections::HashMap; use std::sync::OnceLock; use tokio::sync::{mpsc, oneshot}; use tower::{Service, ServiceExt}; +use crate::blockchain::manager::commands::BlockchainManagerCommand; -static INCOMING_BLOCK_TX: OnceLock> = OnceLock::new(); +pub static INCOMING_BLOCK_TX: OnceLock> = OnceLock::new(); -#[derive(thiserror::Error)] +#[derive(Debug, thiserror::Error)] pub enum IncomingBlockError { #[error("Unknown transactions in block.")] UnknownTransactions(Vec), @@ -28,8 +28,8 @@ pub async fn handle_incoming_block( block: Block, given_txs: Vec, blockchain_read_handle: &mut BlockchainReadHandle, -) -> Result<(), IncomingBlockError> { - if !block_exists(block.header.previous, blockchain_read_handle).expect("TODO") { +) -> Result { + if !block_exists(block.header.previous, blockchain_read_handle).await.expect("TODO") { return Err(IncomingBlockError::Orphan); } @@ -39,7 +39,14 @@ pub async fn handle_incoming_block( .await .expect("TODO") { - return Ok(()); + return Ok(false); + } + + // TODO: Get transactions from the tx pool first. + if given_txs.len() != block.transactions.len() { + return Err(IncomingBlockError::UnknownTransactions( + (0..usize_to_u64(block.transactions.len())).collect(), + )); } let prepped_txs = given_txs @@ -51,21 +58,14 @@ pub async fn handle_incoming_block( .collect::>() .map_err(IncomingBlockError::InvalidBlock)?; - // TODO: Get transactions from the tx pool first. - if given_txs.len() != block.transactions.len() { - return Err(IncomingBlockError::UnknownTransactions( - (0..usize_to_u64(block.transactions.len())).collect(), - )); - } - let Some(incoming_block_tx) = INCOMING_BLOCK_TX.get() else { - return Ok(()); + return Ok(false); }; let (response_tx, response_rx) = oneshot::channel(); incoming_block_tx - .send(IncomingBlock { + .send( BlockchainManagerCommand::AddBlock { block, prepped_txs, response_tx, @@ -73,7 +73,7 @@ pub async fn handle_incoming_block( .await .expect("TODO: don't actually panic here"); - response_rx.await.map_err(IncomingBlockError::InvalidBlock) + response_rx.await.unwrap().map_err(IncomingBlockError::InvalidBlock) } async fn block_exists( diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index ae5a1d3d..b208436c 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -1,4 +1,5 @@ mod handler; +pub(super) mod commands; use crate::blockchain::types::ConsensusBlockchainReadHandle; use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; @@ -9,21 +10,20 @@ use cuprate_consensus::{ VerifyBlockResponse, VerifyTxRequest, VerifyTxResponse, }; use cuprate_p2p::block_downloader::BlockBatch; +use cuprate_p2p::BroadcastSvc; +use cuprate_p2p_core::ClearNet; use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; use cuprate_types::{Chain, TransactionVerificationData}; use futures::StreamExt; use monero_serai::block::Block; use std::collections::HashMap; +use std::sync::Arc; use tokio::sync::mpsc; use tokio::sync::{oneshot, Notify}; use tower::{Service, ServiceExt}; use tracing::error; - -pub struct IncomingBlock { - pub block: Block, - pub prepped_txs: HashMap<[u8; 32], TransactionVerificationData>, - pub response_tx: oneshot::Sender>, -} +use tracing_subscriber::fmt::time::FormatTime; +use crate::blockchain::manager::commands::BlockchainManagerCommand; pub struct BlockchainManager { blockchain_write_handle: BlockchainWriteHandle, @@ -35,7 +35,8 @@ pub struct BlockchainManager { TxVerifierService, ConsensusBlockchainReadHandle, >, - stop_current_block_downloader: Notify, + stop_current_block_downloader: Arc, + broadcast_svc: BroadcastSvc, } impl BlockchainManager { @@ -48,6 +49,8 @@ impl BlockchainManager { TxVerifierService, ConsensusBlockchainReadHandle, >, + stop_current_block_downloader: Arc, + broadcast_svc: BroadcastSvc, ) -> Self { let BlockChainContextResponse::Context(blockchain_context) = blockchain_context_service .ready() @@ -66,13 +69,15 @@ impl BlockchainManager { blockchain_context_service, cached_blockchain_context: blockchain_context.unchecked_blockchain_context().clone(), block_verifier_service, + stop_current_block_downloader, + broadcast_svc, } } pub async fn run( mut self, mut block_batch_rx: mpsc::Receiver, - mut block_single_rx: mpsc::Receiver, + mut command_rx: mpsc::Receiver, ) { loop { tokio::select! { @@ -81,15 +86,8 @@ impl BlockchainManager { batch, ).await; } - Some(incoming_block) = block_single_rx.recv() => { - let IncomingBlock { - block, - prepped_txs, - response_tx - } = incoming_block; - - let res = self.handle_incoming_block(block, prepped_txs).await; - let _ = response_tx.send(res); + Some(incoming_command) = command_rx.recv() => { + self.handle_command(incoming_command).await; } else => { todo!("TODO: exit the BC manager") diff --git a/binaries/cuprated/src/blockchain/manager/commands.rs b/binaries/cuprated/src/blockchain/manager/commands.rs new file mode 100644 index 00000000..1b6f4a48 --- /dev/null +++ b/binaries/cuprated/src/blockchain/manager/commands.rs @@ -0,0 +1,17 @@ +use std::collections::HashMap; + +use monero_serai::block::Block; +use tokio::sync::oneshot; + +use cuprate_types::TransactionVerificationData; + +pub enum BlockchainManagerCommand { + AddBlock { + block: Block, + prepped_txs: HashMap<[u8; 32], TransactionVerificationData>, + response_tx: oneshot::Sender>, + }, + + PopBlocks, +} + diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs index 1bdae16c..a925e710 100644 --- a/binaries/cuprated/src/blockchain/manager/handler.rs +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -1,8 +1,8 @@ -use std::{collections::HashMap, sync::Arc}; - +use bytes::Bytes; use futures::{TryFutureExt, TryStreamExt}; use monero_serai::{block::Block, transaction::Transaction}; use rayon::prelude::*; +use std::{collections::HashMap, sync::Arc}; use tower::{Service, ServiceExt}; use tracing::info; @@ -13,15 +13,45 @@ use cuprate_consensus::{ ExtendedConsensusError, VerifyBlockRequest, VerifyBlockResponse, VerifyTxRequest, VerifyTxResponse, }; -use cuprate_p2p::{block_downloader::BlockBatch, constants::LONG_BAN}; +use cuprate_helper::cast::usize_to_u64; +use cuprate_p2p::{block_downloader::BlockBatch, constants::LONG_BAN, BroadcastRequest}; use cuprate_types::{ blockchain::{BlockchainReadRequest, BlockchainResponse, BlockchainWriteRequest}, AltBlockInformation, HardFork, TransactionVerificationData, VerifiedBlockInformation, }; use crate::{blockchain::types::ConsensusBlockchainReadHandle, signals::REORG_LOCK}; +use crate::blockchain::manager::commands::BlockchainManagerCommand; impl super::BlockchainManager { + pub async fn handle_command(&mut self, command: BlockchainManagerCommand) { + match command { + BlockchainManagerCommand::AddBlock { + block, + prepped_txs, + response_tx + } => { + let res = self.handle_incoming_block(block, prepped_txs).await; + + drop(response_tx.send(res)); + } + BlockchainManagerCommand::PopBlocks => todo!() + } + } + + async fn broadcast_block(&mut self, block_bytes: Bytes, blockchain_height: usize) { + self.broadcast_svc + .ready() + .await + .expect("TODO") + .call(BroadcastRequest::Block { + block_bytes, + current_blockchain_height: usize_to_u64(blockchain_height), + }) + .await + .expect("TODO"); + } + /// Handle an incoming [`Block`]. /// /// This function will route to [`Self::handle_incoming_alt_block`] if the block does not follow @@ -56,8 +86,12 @@ impl super::BlockchainManager { panic!("Incorrect response!"); }; + let block_blob = Bytes::copy_from_slice(&verified_block.block_blob); self.add_valid_block_to_main_chain(verified_block).await; + self.broadcast_block(block_blob, self.cached_blockchain_context.chain_height) + .await; + Ok(true) } @@ -101,11 +135,6 @@ impl super::BlockchainManager { batch.blocks.first().unwrap().0.number().unwrap() ); - let ban_cancel_download = || { - batch.peer_handle.ban_peer(LONG_BAN); - self.stop_current_block_downloader.notify_one(); - }; - let batch_prep_res = self .block_verifier_service .ready() @@ -119,7 +148,8 @@ impl super::BlockchainManager { let prepped_blocks = match batch_prep_res { Ok(VerifyBlockResponse::MainChainBatchPrepped(prepped_blocks)) => prepped_blocks, Err(_) => { - ban_cancel_download(); + batch.peer_handle.ban_peer(LONG_BAN); + self.stop_current_block_downloader.notify_one(); return; } _ => panic!("Incorrect response!"), @@ -134,10 +164,11 @@ impl super::BlockchainManager { .call(VerifyBlockRequest::MainChainPrepped { block, txs }) .await; - let VerifyBlockResponse::MainChain(verified_block) = match verify_res { + let verified_block = match verify_res { Ok(VerifyBlockResponse::MainChain(verified_block)) => verified_block, Err(_) => { - ban_cancel_download(); + batch.peer_handle.ban_peer(LONG_BAN); + self.stop_current_block_downloader.notify_one(); return; } _ => panic!("Incorrect response!"), @@ -145,8 +176,6 @@ impl super::BlockchainManager { self.add_valid_block_to_main_chain(verified_block).await; } - - Ok(()) } /// Handles an incoming [`BlockBatch`] that does not follow the main-chain. @@ -175,7 +204,7 @@ impl super::BlockchainManager { self.handle_incoming_alt_block(block, txs).await?; - Ok(()) + Ok::<_, anyhow::Error>(()) } .await; diff --git a/binaries/cuprated/src/blockchain/syncer.rs b/binaries/cuprated/src/blockchain/syncer.rs index fbf4a88f..286d8a50 100644 --- a/binaries/cuprated/src/blockchain/syncer.rs +++ b/binaries/cuprated/src/blockchain/syncer.rs @@ -1,4 +1,5 @@ use std::pin::pin; +use std::sync::Arc; use std::time::Duration; use futures::StreamExt; @@ -31,7 +32,7 @@ pub async fn syncer( our_chain: CN, clearnet_interface: NetworkInterface, incoming_block_batch_tx: mpsc::Sender, - stop_current_block_downloader: Notify, + stop_current_block_downloader: Arc, block_downloader_config: BlockDownloaderConfig, ) -> Result<(), SyncerError> where diff --git a/p2p_state.bin b/p2p_state.bin deleted file mode 100644 index 9faaaff02d13da96127ed10c9c77a8ab0a7b45ff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 172906 zcmaeR2{=_{+suicqq&tE9zFS&9_bRtbfusHD=0q^Lxz zq_ita>p$;y=f3B?&-cIYtGQ<8%-QD5nVECmeFp~c@$schDbgc}*Rv)m9#O7+1PJOg zU?2e2zdVBa`*L=45J{Y|eI|N(n$8sp#qnSHcQTYDj_uq$>2IO-A0#j`XoRC@;Y5(771>ZWnh$O0YH8&N{R(gtD2seLM z8A=kJ?~OaAL{GOxEVqpF-5Q@s;?9fT^3qe>rXd&h*ez_x1CVifL$0RT-&}@DKQxod zBuPkIYJEON>hE)Is=@`;lO(Zd%iDQp>xU*V)XaZl*?c;3FG-9g6($d9UbLN|(hmiz zHVTu(tAn;XtR@_8W~g*o%`4Y?idI`k#~9UkP3uA`)iaJUROs1xnIyK?D22sYnd>7L zA1y;xdYmUoct@SN(w3hQ&rs=y`c%mxlDMz-=)1*9MH8e_H4K8kXni>EY*R%No8*T6 zxEJ*LAaWseb$_W#62vgOWwUoxoIotoN?L~HG^-gTAyj-eE+xcrcpom7V$!X(xjHO? zB!<{c+<9Db=cqnhEd8WE5~<&9Ny7EPhgVt)2R9-Xp;3j(5t4{GGNjf+`L0gQhloWutu7L@^wZRPH&f#Sz9AN&v8W-;!!^B2`5WVn?;@5O!@=+uJ%$B~ z=U*d}ZC@#BhFFAq zn}@w23H=J^!|Co)n-Po9#PwMONxYj*YNkKce}h% z=Idu87U9C3%Uwvqv^AqZKE0?Fu?W2{+R2l|JZZZHS$^%Qh($Phtcd_gwYjR)*d#!YqH!LcTMJ%pA!OUr}mRHV7Y0JE>rNT{Bl?yyW5*0u0+HMTxo6At? zhrRqO?~{bm!G#G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LMy?J(2Q4G zj4ITanI2OmL%AI8k?hXOn8D8&c|a<;kB?8B4cd|I>Q~9qLpi`(#Pt{T-u5d0e6KhC z&HafQabAh)1v>p5+c8Ik7k1uw1mD1gFF$vOv#J8IRGal0o&BkCIW016Xu83}YD|T2 zV{DEy=s}0&hqC8xW{q0z3`>a1Zu90HI#n%TSyrV+T43RCJ2ok|ecyy*m?Oe!YD|YN zbxGgow3!?ieSRfCO(rZg+j7@D=UGcDT6>j1s2$k1quu^@6P QLsy&BFD~>|7LKg^9}&O5%>V!Z From d2ab8e20c45cea6cb040c2e16ef792f47c5b1682 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sun, 15 Sep 2024 01:20:24 +0100 Subject: [PATCH 31/72] add fluffy block handler --- binaries/cuprated/src/blockchain.rs | 4 +- binaries/cuprated/src/blockchain/free.rs | 17 +++++-- binaries/cuprated/src/blockchain/manager.rs | 4 +- .../src/blockchain/manager/commands.rs | 1 - .../src/blockchain/manager/handler.rs | 6 +-- binaries/cuprated/src/p2p/request_handler.rs | 50 ++++++++++++++++++- p2p/p2p-core/src/protocol.rs | 2 + p2p/p2p-core/src/protocol/try_from.rs | 1 + 8 files changed, 71 insertions(+), 14 deletions(-) diff --git a/binaries/cuprated/src/blockchain.rs b/binaries/cuprated/src/blockchain.rs index f05878ac..2668dd8f 100644 --- a/binaries/cuprated/src/blockchain.rs +++ b/binaries/cuprated/src/blockchain.rs @@ -22,12 +22,14 @@ mod manager; mod syncer; mod types; +use crate::blockchain::free::INCOMING_BLOCK_TX; use manager::BlockchainManager; use types::{ ChainService, ConcreteBlockVerifierService, ConcreteTxVerifierService, ConsensusBlockchainReadHandle, }; -use crate::blockchain::free::INCOMING_BLOCK_TX; + +pub use free::{handle_incoming_block, IncomingBlockError}; /// Checks if the genesis block is in the blockchain and adds it if not. pub async fn check_add_genesis( diff --git a/binaries/cuprated/src/blockchain/free.rs b/binaries/cuprated/src/blockchain/free.rs index eb80a31d..6f44572c 100644 --- a/binaries/cuprated/src/blockchain/free.rs +++ b/binaries/cuprated/src/blockchain/free.rs @@ -1,3 +1,4 @@ +use crate::blockchain::manager::commands::BlockchainManagerCommand; use cuprate_blockchain::service::BlockchainReadHandle; use cuprate_consensus::transactions::new_tx_verification_data; use cuprate_helper::cast::usize_to_u64; @@ -10,14 +11,13 @@ use std::collections::HashMap; use std::sync::OnceLock; use tokio::sync::{mpsc, oneshot}; use tower::{Service, ServiceExt}; -use crate::blockchain::manager::commands::BlockchainManagerCommand; pub static INCOMING_BLOCK_TX: OnceLock> = OnceLock::new(); #[derive(Debug, thiserror::Error)] pub enum IncomingBlockError { #[error("Unknown transactions in block.")] - UnknownTransactions(Vec), + UnknownTransactions([u8; 32], Vec), #[error("The block has an unknown parent.")] Orphan, #[error(transparent)] @@ -29,7 +29,10 @@ pub async fn handle_incoming_block( given_txs: Vec, blockchain_read_handle: &mut BlockchainReadHandle, ) -> Result { - if !block_exists(block.header.previous, blockchain_read_handle).await.expect("TODO") { + if !block_exists(block.header.previous, blockchain_read_handle) + .await + .expect("TODO") + { return Err(IncomingBlockError::Orphan); } @@ -45,6 +48,7 @@ pub async fn handle_incoming_block( // TODO: Get transactions from the tx pool first. if given_txs.len() != block.transactions.len() { return Err(IncomingBlockError::UnknownTransactions( + block_hash, (0..usize_to_u64(block.transactions.len())).collect(), )); } @@ -65,7 +69,7 @@ pub async fn handle_incoming_block( let (response_tx, response_rx) = oneshot::channel(); incoming_block_tx - .send( BlockchainManagerCommand::AddBlock { + .send(BlockchainManagerCommand::AddBlock { block, prepped_txs, response_tx, @@ -73,7 +77,10 @@ pub async fn handle_incoming_block( .await .expect("TODO: don't actually panic here"); - response_rx.await.unwrap().map_err(IncomingBlockError::InvalidBlock) + response_rx + .await + .unwrap() + .map_err(IncomingBlockError::InvalidBlock) } async fn block_exists( diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index b208436c..d5a7ff9a 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -1,6 +1,7 @@ -mod handler; pub(super) mod commands; +mod handler; +use crate::blockchain::manager::commands::BlockchainManagerCommand; use crate::blockchain::types::ConsensusBlockchainReadHandle; use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; use cuprate_consensus::context::RawBlockChainContext; @@ -23,7 +24,6 @@ use tokio::sync::{oneshot, Notify}; use tower::{Service, ServiceExt}; use tracing::error; use tracing_subscriber::fmt::time::FormatTime; -use crate::blockchain::manager::commands::BlockchainManagerCommand; pub struct BlockchainManager { blockchain_write_handle: BlockchainWriteHandle, diff --git a/binaries/cuprated/src/blockchain/manager/commands.rs b/binaries/cuprated/src/blockchain/manager/commands.rs index 1b6f4a48..c60c7ef0 100644 --- a/binaries/cuprated/src/blockchain/manager/commands.rs +++ b/binaries/cuprated/src/blockchain/manager/commands.rs @@ -14,4 +14,3 @@ pub enum BlockchainManagerCommand { PopBlocks, } - diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs index a925e710..50268761 100644 --- a/binaries/cuprated/src/blockchain/manager/handler.rs +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -20,8 +20,8 @@ use cuprate_types::{ AltBlockInformation, HardFork, TransactionVerificationData, VerifiedBlockInformation, }; -use crate::{blockchain::types::ConsensusBlockchainReadHandle, signals::REORG_LOCK}; use crate::blockchain::manager::commands::BlockchainManagerCommand; +use crate::{blockchain::types::ConsensusBlockchainReadHandle, signals::REORG_LOCK}; impl super::BlockchainManager { pub async fn handle_command(&mut self, command: BlockchainManagerCommand) { @@ -29,13 +29,13 @@ impl super::BlockchainManager { BlockchainManagerCommand::AddBlock { block, prepped_txs, - response_tx + response_tx, } => { let res = self.handle_incoming_block(block, prepped_txs).await; drop(response_tx.send(res)); } - BlockchainManagerCommand::PopBlocks => todo!() + BlockchainManagerCommand::PopBlocks => todo!(), } } diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index 0a4412fa..ee219392 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -2,17 +2,24 @@ use bytes::Bytes; use cuprate_p2p_core::{ProtocolRequest, ProtocolResponse}; use futures::future::BoxFuture; use futures::FutureExt; +use monero_serai::block::Block; +use monero_serai::transaction::Transaction; +use rayon::prelude::*; use std::task::{Context, Poll}; use tower::{Service, ServiceExt}; use tracing::trace; +use crate::blockchain::{handle_incoming_block, IncomingBlockError}; use cuprate_blockchain::service::BlockchainReadHandle; +use cuprate_consensus::transactions::new_tx_verification_data; +use cuprate_fixed_bytes::ByteArray; +use cuprate_helper::asynch::rayon_spawn_async; use cuprate_helper::cast::usize_to_u64; use cuprate_helper::map::split_u128_into_low_high_bits; use cuprate_p2p::constants::{MAX_BLOCKCHAIN_SUPPLEMENT_LEN, MAX_BLOCK_BATCH_LEN}; use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; use cuprate_types::BlockCompleteEntry; -use cuprate_wire::protocol::{ChainRequest, ChainResponse, GetObjectsRequest, GetObjectsResponse}; +use cuprate_wire::protocol::{ChainRequest, ChainResponse, FluffyMissingTransactionsRequest, GetObjectsRequest, GetObjectsResponse, NewFluffyBlock}; #[derive(Clone)] pub struct P2pProtocolRequestHandler { @@ -39,7 +46,7 @@ impl Service for P2pProtocolRequestHandler { ProtocolRequest::FluffyMissingTxs(_) => async { Ok(ProtocolResponse::NA) }.boxed(), ProtocolRequest::GetTxPoolCompliment(_) => async { Ok(ProtocolResponse::NA) }.boxed(), ProtocolRequest::NewBlock(_) => async { Ok(ProtocolResponse::NA) }.boxed(), - ProtocolRequest::NewFluffyBlock(_) => async { Ok(ProtocolResponse::NA) }.boxed(), + ProtocolRequest::NewFluffyBlock(block) => new_fluffy_block(self.blockchain_read_handle.clone(), block).boxed(), ProtocolRequest::NewTransactions(_) => async { Ok(ProtocolResponse::NA) }.boxed(), } } @@ -125,3 +132,42 @@ async fn get_chain( first_block: first_missing_block.map_or(Bytes::new(), Bytes::from), })) } + +async fn new_fluffy_block( + mut blockchain_read_handle: BlockchainReadHandle, + incoming_block: NewFluffyBlock, +) -> Result { + let peer_blockchain_height = incoming_block.current_blockchain_height; + + let (block, txs) = rayon_spawn_async(move || { + let block = Block::read(&mut incoming_block.b.block.as_ref())?; + let txs = incoming_block + .b + .txs + .take_normal() + .expect("TODO") + .into_par_iter() + .map(|tx| { + let tx = Transaction::read(&mut tx.as_ref())?; + Ok(tx) + }) + .collect::>()?; + + Ok::<_, tower::BoxError>((block, txs)) + }) + .await?; + + let res = handle_incoming_block(block, txs, &mut blockchain_read_handle).await; + + match res { + Err(IncomingBlockError::UnknownTransactions(block_hash, tx_indexes)) => { + return Ok(ProtocolResponse::FluffyMissingTxs(FluffyMissingTransactionsRequest{ + block_hash: ByteArray::from(block_hash), + current_blockchain_height: peer_blockchain_height, + missing_tx_indices: tx_indexes, + })) + } + Err(IncomingBlockError::InvalidBlock(e)) => Err(e)?, + Err(IncomingBlockError::Orphan) | Ok(_) => Ok(ProtocolResponse::NA), + } +} diff --git a/p2p/p2p-core/src/protocol.rs b/p2p/p2p-core/src/protocol.rs index 5e4f4d7e..fc3cb7c8 100644 --- a/p2p/p2p-core/src/protocol.rs +++ b/p2p/p2p-core/src/protocol.rs @@ -116,6 +116,7 @@ pub enum ProtocolResponse { GetChain(ChainResponse), NewFluffyBlock(NewFluffyBlock), NewTransactions(NewTransactions), + FluffyMissingTxs(FluffyMissingTransactionsRequest), NA, } @@ -139,6 +140,7 @@ impl PeerResponse { ProtocolResponse::GetChain(_) => MessageID::GetChain, ProtocolResponse::NewFluffyBlock(_) => MessageID::NewBlock, ProtocolResponse::NewTransactions(_) => MessageID::NewFluffyBlock, + ProtocolResponse::FluffyMissingTxs(_) => MessageID::FluffyMissingTxs, ProtocolResponse::NA => return None, }, diff --git a/p2p/p2p-core/src/protocol/try_from.rs b/p2p/p2p-core/src/protocol/try_from.rs index 8a0b67d2..b3c5203d 100644 --- a/p2p/p2p-core/src/protocol/try_from.rs +++ b/p2p/p2p-core/src/protocol/try_from.rs @@ -75,6 +75,7 @@ impl TryFrom for ProtocolMessage { ProtocolResponse::NewFluffyBlock(val) => ProtocolMessage::NewFluffyBlock(val), ProtocolResponse::GetChain(val) => ProtocolMessage::ChainEntryResponse(val), ProtocolResponse::GetObjects(val) => ProtocolMessage::GetObjectsResponse(val), + ProtocolResponse::FluffyMissingTxs(val) => ProtocolMessage::FluffyMissingTransactionsRequest(val), ProtocolResponse::NA => return Err(MessageConversionError), }) } From 291ffe324d37c76f5dcf14be6709e183da60830b Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sun, 15 Sep 2024 01:59:05 +0100 Subject: [PATCH 32/72] fix new block handling --- binaries/cuprated/src/blockchain/free.rs | 18 ++++++++++---- binaries/cuprated/src/p2p/request_handler.rs | 25 +++++++++++++------- p2p/p2p-core/src/protocol/try_from.rs | 4 +++- storage/blockchain/src/service/read.rs | 14 ++++++----- 4 files changed, 41 insertions(+), 20 deletions(-) diff --git a/binaries/cuprated/src/blockchain/free.rs b/binaries/cuprated/src/blockchain/free.rs index 6f44572c..b32bb733 100644 --- a/binaries/cuprated/src/blockchain/free.rs +++ b/binaries/cuprated/src/blockchain/free.rs @@ -7,13 +7,15 @@ use cuprate_types::Chain; use monero_serai::block::Block; use monero_serai::transaction::Transaction; use rayon::prelude::*; -use std::collections::HashMap; -use std::sync::OnceLock; +use std::collections::{HashMap, HashSet}; +use std::sync::{Mutex, OnceLock}; use tokio::sync::{mpsc, oneshot}; use tower::{Service, ServiceExt}; pub static INCOMING_BLOCK_TX: OnceLock> = OnceLock::new(); +pub static BLOCKS_BEING_HANDLED: OnceLock>> = OnceLock::new(); + #[derive(Debug, thiserror::Error)] pub enum IncomingBlockError { #[error("Unknown transactions in block.")] @@ -62,6 +64,10 @@ pub async fn handle_incoming_block( .collect::>() .map_err(IncomingBlockError::InvalidBlock)?; + if !BLOCKS_BEING_HANDLED.get_or_init(|| Mutex::new(HashSet::new())).lock().unwrap().insert(block_hash) { + return Ok(false); + } + let Some(incoming_block_tx) = INCOMING_BLOCK_TX.get() else { return Ok(false); }; @@ -77,10 +83,14 @@ pub async fn handle_incoming_block( .await .expect("TODO: don't actually panic here"); - response_rx + let res =response_rx .await .unwrap() - .map_err(IncomingBlockError::InvalidBlock) + .map_err(IncomingBlockError::InvalidBlock); + + BLOCKS_BEING_HANDLED.get().unwrap().lock().unwrap().remove(&block_hash); + + res } async fn block_exists( diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index ee219392..e3245e7e 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -19,7 +19,10 @@ use cuprate_helper::map::split_u128_into_low_high_bits; use cuprate_p2p::constants::{MAX_BLOCKCHAIN_SUPPLEMENT_LEN, MAX_BLOCK_BATCH_LEN}; use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; use cuprate_types::BlockCompleteEntry; -use cuprate_wire::protocol::{ChainRequest, ChainResponse, FluffyMissingTransactionsRequest, GetObjectsRequest, GetObjectsResponse, NewFluffyBlock}; +use cuprate_wire::protocol::{ + ChainRequest, ChainResponse, FluffyMissingTransactionsRequest, GetObjectsRequest, + GetObjectsResponse, NewFluffyBlock, +}; #[derive(Clone)] pub struct P2pProtocolRequestHandler { @@ -46,7 +49,9 @@ impl Service for P2pProtocolRequestHandler { ProtocolRequest::FluffyMissingTxs(_) => async { Ok(ProtocolResponse::NA) }.boxed(), ProtocolRequest::GetTxPoolCompliment(_) => async { Ok(ProtocolResponse::NA) }.boxed(), ProtocolRequest::NewBlock(_) => async { Ok(ProtocolResponse::NA) }.boxed(), - ProtocolRequest::NewFluffyBlock(block) => new_fluffy_block(self.blockchain_read_handle.clone(), block).boxed(), + ProtocolRequest::NewFluffyBlock(block) => { + new_fluffy_block(self.blockchain_read_handle.clone(), block).boxed() + } ProtocolRequest::NewTransactions(_) => async { Ok(ProtocolResponse::NA) }.boxed(), } } @@ -158,14 +163,16 @@ async fn new_fluffy_block( .await?; let res = handle_incoming_block(block, txs, &mut blockchain_read_handle).await; - - match res { + + match res { Err(IncomingBlockError::UnknownTransactions(block_hash, tx_indexes)) => { - return Ok(ProtocolResponse::FluffyMissingTxs(FluffyMissingTransactionsRequest{ - block_hash: ByteArray::from(block_hash), - current_blockchain_height: peer_blockchain_height, - missing_tx_indices: tx_indexes, - })) + return Ok(ProtocolResponse::FluffyMissingTxs( + FluffyMissingTransactionsRequest { + block_hash: ByteArray::from(block_hash), + current_blockchain_height: peer_blockchain_height, + missing_tx_indices: tx_indexes, + }, + )) } Err(IncomingBlockError::InvalidBlock(e)) => Err(e)?, Err(IncomingBlockError::Orphan) | Ok(_) => Ok(ProtocolResponse::NA), diff --git a/p2p/p2p-core/src/protocol/try_from.rs b/p2p/p2p-core/src/protocol/try_from.rs index b3c5203d..ae21a07d 100644 --- a/p2p/p2p-core/src/protocol/try_from.rs +++ b/p2p/p2p-core/src/protocol/try_from.rs @@ -75,7 +75,9 @@ impl TryFrom for ProtocolMessage { ProtocolResponse::NewFluffyBlock(val) => ProtocolMessage::NewFluffyBlock(val), ProtocolResponse::GetChain(val) => ProtocolMessage::ChainEntryResponse(val), ProtocolResponse::GetObjects(val) => ProtocolMessage::GetObjectsResponse(val), - ProtocolResponse::FluffyMissingTxs(val) => ProtocolMessage::FluffyMissingTransactionsRequest(val), + ProtocolResponse::FluffyMissingTxs(val) => { + ProtocolMessage::FluffyMissingTransactionsRequest(val) + } ProtocolResponse::NA => return Err(MessageConversionError), }) } diff --git a/storage/blockchain/src/service/read.rs b/storage/blockchain/src/service/read.rs index e502c9f1..89f92424 100644 --- a/storage/blockchain/src/service/read.rs +++ b/storage/blockchain/src/service/read.rs @@ -268,12 +268,14 @@ fn find_block(env: &ConcreteEnv, block_hash: BlockHash) -> ResponseResult { let table_alt_block_heights = env_inner.open_db_ro::(&tx_ro)?; - let height = table_alt_block_heights.get(&block_hash)?; - - Ok(BlockchainResponse::FindBlock(Some(( - Chain::Alt(height.chain_id.into()), - height.height, - )))) + match table_alt_block_heights.get(&block_hash) { + Ok(height) => Ok(BlockchainResponse::FindBlock(Some(( + Chain::Alt(height.chain_id.into()), + height.height, + )))), + Err(RuntimeError::KeyNotFound) => Ok(BlockchainResponse::FindBlock(None)), + Err(e) => return Err(e), + } } /// [`BlockchainReadRequest::FilterUnknownHashes`]. From c0a3f7a71898b23398802aa06d91041261f38cae Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sun, 15 Sep 2024 18:08:49 +0100 Subject: [PATCH 33/72] small cleanup --- binaries/cuprated/src/blockchain/free.rs | 8 ++++---- binaries/cuprated/src/blockchain/manager/commands.rs | 2 -- binaries/cuprated/src/blockchain/manager/handler.rs | 1 - binaries/cuprated/src/config.rs | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/binaries/cuprated/src/blockchain/free.rs b/binaries/cuprated/src/blockchain/free.rs index b32bb733..d44d273c 100644 --- a/binaries/cuprated/src/blockchain/free.rs +++ b/binaries/cuprated/src/blockchain/free.rs @@ -64,14 +64,14 @@ pub async fn handle_incoming_block( .collect::>() .map_err(IncomingBlockError::InvalidBlock)?; - if !BLOCKS_BEING_HANDLED.get_or_init(|| Mutex::new(HashSet::new())).lock().unwrap().insert(block_hash) { - return Ok(false); - } - let Some(incoming_block_tx) = INCOMING_BLOCK_TX.get() else { return Ok(false); }; + if !BLOCKS_BEING_HANDLED.get_or_init(|| Mutex::new(HashSet::new())).lock().unwrap().insert(block_hash) { + return Ok(false); + } + let (response_tx, response_rx) = oneshot::channel(); incoming_block_tx diff --git a/binaries/cuprated/src/blockchain/manager/commands.rs b/binaries/cuprated/src/blockchain/manager/commands.rs index c60c7ef0..800144f0 100644 --- a/binaries/cuprated/src/blockchain/manager/commands.rs +++ b/binaries/cuprated/src/blockchain/manager/commands.rs @@ -11,6 +11,4 @@ pub enum BlockchainManagerCommand { prepped_txs: HashMap<[u8; 32], TransactionVerificationData>, response_tx: oneshot::Sender>, }, - - PopBlocks, } diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs index 50268761..6a92ba73 100644 --- a/binaries/cuprated/src/blockchain/manager/handler.rs +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -35,7 +35,6 @@ impl super::BlockchainManager { drop(response_tx.send(res)); } - BlockchainManagerCommand::PopBlocks => todo!(), } } diff --git a/binaries/cuprated/src/config.rs b/binaries/cuprated/src/config.rs index c71c40c8..0cbb0cdf 100644 --- a/binaries/cuprated/src/config.rs +++ b/binaries/cuprated/src/config.rs @@ -26,7 +26,7 @@ impl CupratedConfig { pub fn clearnet_config(&self) -> P2PConfig { P2PConfig { network: Network::Mainnet, - outbound_connections: 64, + outbound_connections: 16, extra_outbound_connections: 0, max_inbound_connections: 0, gray_peers_percent: 0.7, From fa54df27d330f26d417d3dd89d8b919936eccf9a Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Mon, 16 Sep 2024 01:39:01 +0100 Subject: [PATCH 34/72] increase outbound peer count --- binaries/cuprated/src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binaries/cuprated/src/config.rs b/binaries/cuprated/src/config.rs index 0cbb0cdf..c71c40c8 100644 --- a/binaries/cuprated/src/config.rs +++ b/binaries/cuprated/src/config.rs @@ -26,7 +26,7 @@ impl CupratedConfig { pub fn clearnet_config(&self) -> P2PConfig { P2PConfig { network: Network::Mainnet, - outbound_connections: 16, + outbound_connections: 64, extra_outbound_connections: 0, max_inbound_connections: 0, gray_peers_percent: 0.7, From 69f9d84ae1706310a9bf581ba2d4a28603541ac4 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 3 Oct 2024 01:53:47 +0100 Subject: [PATCH 35/72] fix merge --- Cargo.lock | 48 ++++++++++++++ binaries/cuprated/src/blockchain.rs | 2 +- binaries/cuprated/src/blockchain/free.rs | 16 ++++- binaries/cuprated/src/blockchain/syncer.rs | 26 ++++---- binaries/cuprated/src/main.rs | 1 + binaries/cuprated/src/p2p/request_handler.rs | 68 ++++++++++++++------ consensus/src/lib.rs | 14 ++-- p2p/p2p-core/src/protocol/try_from.rs | 1 + p2p/p2p/src/client_pool.rs | 13 ++++ p2p/p2p/src/constants.rs | 4 +- p2p/p2p/src/lib.rs | 7 +- storage/blockchain/Cargo.toml | 1 - 12 files changed, 147 insertions(+), 54 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ca5c1546..dd303bf6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1862,6 +1862,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -1899,6 +1909,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "page_size" version = "0.6.0" @@ -2514,6 +2530,15 @@ dependencies = [ "keccak", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "1.3.0" @@ -2894,6 +2919,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", ] [[package]] @@ -2902,7 +2939,12 @@ version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ + "nu-ansi-term", + "sharded-slab", + "smallvec", + "thread_local", "tracing-core", + "tracing-log", ] [[package]] @@ -2985,6 +3027,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "version_check" version = "0.9.5" diff --git a/binaries/cuprated/src/blockchain.rs b/binaries/cuprated/src/blockchain.rs index 2668dd8f..649dcef0 100644 --- a/binaries/cuprated/src/blockchain.rs +++ b/binaries/cuprated/src/blockchain.rs @@ -35,7 +35,7 @@ pub use free::{handle_incoming_block, IncomingBlockError}; pub async fn check_add_genesis( blockchain_read_handle: &mut BlockchainReadHandle, blockchain_write_handle: &mut BlockchainWriteHandle, - network: &Network, + network: Network, ) { // Try to get the chain height, will fail if the genesis block is not in the DB. if blockchain_read_handle diff --git a/binaries/cuprated/src/blockchain/free.rs b/binaries/cuprated/src/blockchain/free.rs index d44d273c..56c68edf 100644 --- a/binaries/cuprated/src/blockchain/free.rs +++ b/binaries/cuprated/src/blockchain/free.rs @@ -68,7 +68,12 @@ pub async fn handle_incoming_block( return Ok(false); }; - if !BLOCKS_BEING_HANDLED.get_or_init(|| Mutex::new(HashSet::new())).lock().unwrap().insert(block_hash) { + if !BLOCKS_BEING_HANDLED + .get_or_init(|| Mutex::new(HashSet::new())) + .lock() + .unwrap() + .insert(block_hash) + { return Ok(false); } @@ -83,12 +88,17 @@ pub async fn handle_incoming_block( .await .expect("TODO: don't actually panic here"); - let res =response_rx + let res = response_rx .await .unwrap() .map_err(IncomingBlockError::InvalidBlock); - BLOCKS_BEING_HANDLED.get().unwrap().lock().unwrap().remove(&block_hash); + BLOCKS_BEING_HANDLED + .get() + .unwrap() + .lock() + .unwrap() + .remove(&block_hash); res } diff --git a/binaries/cuprated/src/blockchain/syncer.rs b/binaries/cuprated/src/blockchain/syncer.rs index 286d8a50..4b286ceb 100644 --- a/binaries/cuprated/src/blockchain/syncer.rs +++ b/binaries/cuprated/src/blockchain/syncer.rs @@ -3,6 +3,7 @@ use std::sync::Arc; use std::time::Duration; use futures::StreamExt; +use tokio::time::interval; use tokio::{ sync::{mpsc, Notify}, time::sleep, @@ -17,6 +18,8 @@ use cuprate_p2p::{ }; use cuprate_p2p_core::ClearNet; +const CHECK_SYNC_FREQUENCY: Duration = Duration::from_secs(30); + /// An error returned from the [`syncer`]. #[derive(Debug, thiserror::Error)] pub enum SyncerError { @@ -50,6 +53,8 @@ where { tracing::info!("Starting blockchain syncer"); + let mut check_sync_interval = interval(CHECK_SYNC_FREQUENCY); + let BlockChainContextResponse::Context(mut blockchain_ctx) = context_svc .ready() .await? @@ -59,26 +64,21 @@ where panic!("Blockchain context service returned wrong response!"); }; - let mut peer_sync_watch = clearnet_interface.top_sync_stream(); + let client_pool = clearnet_interface.client_pool(); tracing::debug!("Waiting for new sync info in top sync channel"); - while let Some(top_sync_info) = peer_sync_watch.next().await { - tracing::info!( - "New sync info seen, top height: {}, top block hash: {}", - top_sync_info.chain_height, - hex::encode(top_sync_info.top_hash) - ); + loop { + check_sync_interval.tick().await; - // The new info could be from a peer giving us a block, so wait a couple seconds to allow the block to - // be added to our blockchain. - sleep(Duration::from_secs(2)).await; + tracing::trace!("Checking connected peers to see if we are behind",); check_update_blockchain_context(&mut context_svc, &mut blockchain_ctx).await?; let raw_blockchain_context = blockchain_ctx.unchecked_blockchain_context(); - if top_sync_info.cumulative_difficulty <= raw_blockchain_context.cumulative_difficulty { - tracing::debug!("New peer sync info is not ahead, nothing to do."); + if !client_pool.contains_client_with_more_cumulative_difficulty( + raw_blockchain_context.cumulative_difficulty, + ) { continue; } @@ -103,8 +103,6 @@ where } } } - - Ok(()) } async fn check_update_blockchain_context( diff --git a/binaries/cuprated/src/main.rs b/binaries/cuprated/src/main.rs index 775843df..ad7382d7 100644 --- a/binaries/cuprated/src/main.rs +++ b/binaries/cuprated/src/main.rs @@ -16,6 +16,7 @@ mod config; mod constants; mod p2p; mod rpc; +mod signals; mod statics; mod txpool; diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index e3245e7e..86507f1f 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -1,5 +1,5 @@ use bytes::Bytes; -use cuprate_p2p_core::{ProtocolRequest, ProtocolResponse}; +use cuprate_p2p_core::{NetworkZone, ProtocolRequest, ProtocolResponse}; use futures::future::BoxFuture; use futures::FutureExt; use monero_serai::block::Block; @@ -16,7 +16,8 @@ use cuprate_fixed_bytes::ByteArray; use cuprate_helper::asynch::rayon_spawn_async; use cuprate_helper::cast::usize_to_u64; use cuprate_helper::map::split_u128_into_low_high_bits; -use cuprate_p2p::constants::{MAX_BLOCKCHAIN_SUPPLEMENT_LEN, MAX_BLOCK_BATCH_LEN}; +use cuprate_p2p::constants::MAX_BLOCK_BATCH_LEN; +use cuprate_p2p_core::client::PeerInformation; use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; use cuprate_types::BlockCompleteEntry; use cuprate_wire::protocol::{ @@ -25,11 +26,41 @@ use cuprate_wire::protocol::{ }; #[derive(Clone)] -pub struct P2pProtocolRequestHandler { - pub(crate) blockchain_read_handle: BlockchainReadHandle, +pub struct P2pProtocolRequestHandlerMaker { + pub blockchain_read_handle: BlockchainReadHandle, } -impl Service for P2pProtocolRequestHandler { +impl Service> for P2pProtocolRequestHandlerMaker { + type Response = P2pProtocolRequestHandler; + type Error = tower::BoxError; + type Future = BoxFuture<'static, Result>; + + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { + Poll::Ready(Ok(())) + } + + fn call(&mut self, peer_information: PeerInformation) -> Self::Future { + // TODO: check peer info. + + let blockchain_read_handle = self.blockchain_read_handle.clone(); + + async { + Ok(P2pProtocolRequestHandler { + peer_information, + blockchain_read_handle, + }) + } + .boxed() + } +} + +#[derive(Clone)] +pub struct P2pProtocolRequestHandler { + peer_information: PeerInformation, + blockchain_read_handle: BlockchainReadHandle, +} + +impl Service for P2pProtocolRequestHandler { type Response = ProtocolResponse; type Error = tower::BoxError; type Future = BoxFuture<'static, Result>; @@ -38,22 +69,8 @@ impl Service for P2pProtocolRequestHandler { Poll::Ready(Ok(())) } - fn call(&mut self, req: ProtocolRequest) -> Self::Future { - match req { - ProtocolRequest::GetObjects(req) => { - get_objects(self.blockchain_read_handle.clone(), req).boxed() - } - ProtocolRequest::GetChain(req) => { - get_chain(self.blockchain_read_handle.clone(), req).boxed() - } - ProtocolRequest::FluffyMissingTxs(_) => async { Ok(ProtocolResponse::NA) }.boxed(), - ProtocolRequest::GetTxPoolCompliment(_) => async { Ok(ProtocolResponse::NA) }.boxed(), - ProtocolRequest::NewBlock(_) => async { Ok(ProtocolResponse::NA) }.boxed(), - ProtocolRequest::NewFluffyBlock(block) => { - new_fluffy_block(self.blockchain_read_handle.clone(), block).boxed() - } - ProtocolRequest::NewTransactions(_) => async { Ok(ProtocolResponse::NA) }.boxed(), - } + fn call(&mut self, _: ProtocolRequest) -> Self::Future { + async { Ok(ProtocolResponse::NA) }.boxed() } } @@ -73,6 +90,9 @@ async fn get_objects( // de-allocate the backing [`Bytes`] drop(req); + return Ok(ProtocolResponse::NA); + /* + let res = blockchain_read_handle .oneshot(BlockchainReadRequest::BlockCompleteEntries(block_ids)) .await?; @@ -91,6 +111,8 @@ async fn get_objects( missed_ids: missed_ids.into(), current_blockchain_height: usize_to_u64(current_blockchain_height), })) + + */ } async fn get_chain( @@ -100,7 +122,9 @@ async fn get_chain( if req.block_ids.is_empty() { Err("No block hashes sent in a `ChainRequest`")?; } + return Ok(ProtocolResponse::NA); + /* if req.block_ids.len() > MAX_BLOCKCHAIN_SUPPLEMENT_LEN { Err("Too many block hashes in a `ChainRequest`")?; } @@ -136,6 +160,8 @@ async fn get_chain( m_block_weights: vec![], first_block: first_missing_block.map_or(Bytes::new(), Bytes::from), })) + + */ } async fn new_fluffy_block( diff --git a/consensus/src/lib.rs b/consensus/src/lib.rs index e104cec9..1e473158 100644 --- a/consensus/src/lib.rs +++ b/consensus/src/lib.rs @@ -37,6 +37,7 @@ pub use context::{ pub use transactions::{TxVerifierService, VerifyTxRequest, VerifyTxResponse}; // re-export. +pub use cuprate_consensus_rules::genesis::generate_genesis_block; pub use cuprate_types::{ blockchain::{BlockchainReadRequest, BlockchainResponse}, HardFork, @@ -68,13 +69,10 @@ pub enum ExtendedConsensusError { pub fn initialize_verifier( database: D, ctx_svc: Ctx, -) -> Result< - ( - BlockVerifierService, D>, - TxVerifierService, - ), - ConsensusError, -> +) -> ( + BlockVerifierService, D>, + TxVerifierService, +) where D: Database + Clone + Send + Sync + 'static, D::Future: Send + 'static, @@ -90,7 +88,7 @@ where { let tx_svc = TxVerifierService::new(database.clone()); let block_svc = BlockVerifierService::new(ctx_svc, tx_svc.clone(), database); - Ok((block_svc, tx_svc)) + (block_svc, tx_svc) } use __private::Database; diff --git a/p2p/p2p-core/src/protocol/try_from.rs b/p2p/p2p-core/src/protocol/try_from.rs index d3a7260f..b3c1ae3d 100644 --- a/p2p/p2p-core/src/protocol/try_from.rs +++ b/p2p/p2p-core/src/protocol/try_from.rs @@ -71,6 +71,7 @@ impl TryFrom for ProtocolMessage { ProtocolResponse::NewFluffyBlock(val) => Self::NewFluffyBlock(val), ProtocolResponse::GetChain(val) => Self::ChainEntryResponse(val), ProtocolResponse::GetObjects(val) => Self::GetObjectsResponse(val), + ProtocolResponse::FluffyMissingTxs(val) => Self::FluffyMissingTransactionsRequest(val), ProtocolResponse::NA => return Err(MessageConversionError), }) } diff --git a/p2p/p2p/src/client_pool.rs b/p2p/p2p/src/client_pool.rs index 77d3b6e5..735be76d 100644 --- a/p2p/p2p/src/client_pool.rs +++ b/p2p/p2p/src/client_pool.rs @@ -153,6 +153,19 @@ impl ClientPool { self.borrow_clients(&peers).collect() } + + pub fn contains_client_with_more_cumulative_difficulty( + &self, + cumulative_difficulty: u128, + ) -> bool { + self.clients + .iter() + .find(|element| { + let sync_data = element.value().info.core_sync_data.lock().unwrap(); + sync_data.cumulative_difficulty() > cumulative_difficulty + }) + .is_some() + } } mod sealed { diff --git a/p2p/p2p/src/constants.rs b/p2p/p2p/src/constants.rs index f2349600..f79bcbf0 100644 --- a/p2p/p2p/src/constants.rs +++ b/p2p/p2p/src/constants.rs @@ -23,7 +23,7 @@ pub(crate) const SHORT_BAN: Duration = Duration::from_secs(60 * 10); pub(crate) const MEDIUM_BAN: Duration = Duration::from_secs(60 * 60 * 24); /// The durations of a long ban. -pub(crate) const LONG_BAN: Duration = Duration::from_secs(60 * 60 * 24 * 7); +pub const LONG_BAN: Duration = Duration::from_secs(60 * 60 * 24 * 7); /// The default amount of time between inbound diffusion flushes. pub(crate) const DIFFUSION_FLUSH_AVERAGE_SECONDS_INBOUND: Duration = Duration::from_secs(5); @@ -53,7 +53,7 @@ pub(crate) const INITIAL_CHAIN_REQUESTS_TO_SEND: usize = 3; /// The enforced maximum amount of blocks to request in a batch. /// /// Requesting more than this will cause the peer to disconnect and potentially lead to bans. -pub(crate) const MAX_BLOCK_BATCH_LEN: usize = 100; +pub const MAX_BLOCK_BATCH_LEN: usize = 100; /// The timeout that the block downloader will use for requests. pub(crate) const BLOCK_DOWNLOADER_REQUEST_TIMEOUT: Duration = Duration::from_secs(30); diff --git a/p2p/p2p/src/lib.rs b/p2p/p2p/src/lib.rs index dbff56d5..37416b2d 100644 --- a/p2p/p2p/src/lib.rs +++ b/p2p/p2p/src/lib.rs @@ -174,9 +174,8 @@ impl NetworkInterface { self.address_book.clone() } - /// Pulls a client from the client pool, returning it in a guard that will return it there when it's - /// dropped. - pub fn borrow_client(&self, peer: &InternalPeerID) -> Option> { - self.pool.borrow_client(peer) + /// TODO + pub fn client_pool(&self) -> &Arc> { + &self.pool } } diff --git a/storage/blockchain/Cargo.toml b/storage/blockchain/Cargo.toml index c1473b6d..6eecb892 100644 --- a/storage/blockchain/Cargo.toml +++ b/storage/blockchain/Cargo.toml @@ -35,7 +35,6 @@ serde = { workspace = true, optional = true } tower = { workspace = true } thread_local = { workspace = true, optional = true } rayon = { workspace = true, optional = true } -bytes = "1.6.0" [dev-dependencies] cuprate-helper = { path = "../../helper", features = ["thread", "cast"] } From caaeceda2ee22f712d9f88c73b0aafa4a537fab5 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 3 Oct 2024 03:36:33 +0100 Subject: [PATCH 36/72] clean up the blockchain manger --- binaries/cuprated/src/blockchain.rs | 43 +------ .../src/blockchain/{free.rs => interface.rs} | 0 binaries/cuprated/src/blockchain/manager.rs | 112 ++++++++++++------ .../src/blockchain/manager/handler.rs | 72 +++++++---- binaries/cuprated/src/constants.rs | 3 + 5 files changed, 126 insertions(+), 104 deletions(-) rename binaries/cuprated/src/blockchain/{free.rs => interface.rs} (100%) diff --git a/binaries/cuprated/src/blockchain.rs b/binaries/cuprated/src/blockchain.rs index 649dcef0..80d10bf2 100644 --- a/binaries/cuprated/src/blockchain.rs +++ b/binaries/cuprated/src/blockchain.rs @@ -17,19 +17,19 @@ use cuprate_types::{ VerifiedBlockInformation, }; -mod free; +mod interface; mod manager; mod syncer; mod types; -use crate::blockchain::free::INCOMING_BLOCK_TX; +use crate::blockchain::interface::INCOMING_BLOCK_TX; use manager::BlockchainManager; use types::{ ChainService, ConcreteBlockVerifierService, ConcreteTxVerifierService, ConsensusBlockchainReadHandle, }; -pub use free::{handle_incoming_block, IncomingBlockError}; +pub use interface::{handle_incoming_block, IncomingBlockError}; /// Checks if the genesis block is in the blockchain and adds it if not. pub async fn check_add_genesis( @@ -100,40 +100,3 @@ pub async fn init_consensus( Ok((block_verifier_svc, tx_verifier_svc, ctx_service)) } - -/// Initializes the blockchain manager task and syncer. -pub async fn init_blockchain_manager( - clearnet_interface: NetworkInterface, - blockchain_write_handle: BlockchainWriteHandle, - blockchain_read_handle: BlockchainReadHandle, - blockchain_context_service: BlockChainContextService, - block_verifier_service: ConcreteBlockVerifierService, - block_downloader_config: BlockDownloaderConfig, -) { - let (batch_tx, batch_rx) = mpsc::channel(1); - let stop_current_block_downloader = Arc::new(Notify::new()); - let (command_tx, command_rx) = mpsc::channel(1); - - INCOMING_BLOCK_TX.set(command_tx).unwrap(); - - tokio::spawn(syncer::syncer( - blockchain_context_service.clone(), - ChainService(blockchain_read_handle.clone()), - clearnet_interface.clone(), - batch_tx, - stop_current_block_downloader.clone(), - block_downloader_config, - )); - - let manager = BlockchainManager::new( - blockchain_write_handle, - blockchain_read_handle, - blockchain_context_service, - block_verifier_service, - stop_current_block_downloader, - clearnet_interface.broadcast_svc(), - ) - .await; - - tokio::spawn(manager.run(batch_rx, command_rx)); -} diff --git a/binaries/cuprated/src/blockchain/free.rs b/binaries/cuprated/src/blockchain/interface.rs similarity index 100% rename from binaries/cuprated/src/blockchain/free.rs rename to binaries/cuprated/src/blockchain/interface.rs diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index d5a7ff9a..314519d0 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -1,8 +1,13 @@ pub(super) mod commands; mod handler; +use crate::blockchain::interface::INCOMING_BLOCK_TX; use crate::blockchain::manager::commands::BlockchainManagerCommand; -use crate::blockchain::types::ConsensusBlockchainReadHandle; +use crate::blockchain::types::ChainService; +use crate::blockchain::{ + syncer, + types::{ConcreteBlockVerifierService, ConsensusBlockchainReadHandle}, +}; use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; use cuprate_consensus::context::RawBlockChainContext; use cuprate_consensus::{ @@ -10,8 +15,8 @@ use cuprate_consensus::{ BlockVerifierService, ExtendedConsensusError, TxVerifierService, VerifyBlockRequest, VerifyBlockResponse, VerifyTxRequest, VerifyTxResponse, }; -use cuprate_p2p::block_downloader::BlockBatch; -use cuprate_p2p::BroadcastSvc; +use cuprate_p2p::block_downloader::{BlockBatch, BlockDownloaderConfig}; +use cuprate_p2p::{BroadcastSvc, NetworkInterface}; use cuprate_p2p_core::ClearNet; use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; use cuprate_types::{Chain, TransactionVerificationData}; @@ -25,55 +30,86 @@ use tower::{Service, ServiceExt}; use tracing::error; use tracing_subscriber::fmt::time::FormatTime; -pub struct BlockchainManager { +pub async fn init_blockchain_manger( + clearnet_interface: NetworkInterface, blockchain_write_handle: BlockchainWriteHandle, blockchain_read_handle: BlockchainReadHandle, + mut blockchain_context_service: BlockChainContextService, + block_verifier_service: ConcreteBlockVerifierService, + block_downloader_config: BlockDownloaderConfig, +) { + let (batch_tx, batch_rx) = mpsc::channel(1); + let stop_current_block_downloader = Arc::new(Notify::new()); + let (command_tx, command_rx) = mpsc::channel(1); + + INCOMING_BLOCK_TX.set(command_tx).unwrap(); + + tokio::spawn(syncer::syncer( + blockchain_context_service.clone(), + ChainService(blockchain_read_handle.clone()), + clearnet_interface.clone(), + batch_tx, + stop_current_block_downloader.clone(), + block_downloader_config, + )); + + let BlockChainContextResponse::Context(blockchain_context) = blockchain_context_service + .ready() + .await + .expect("TODO") + .call(BlockChainContextRequest::GetContext) + .await + .expect("TODO") + else { + panic!("Blockchain context service returned wrong response!"); + }; + + let manger = BlockchainManager { + blockchain_write_handle, + blockchain_read_handle, + blockchain_context_service, + cached_blockchain_context: blockchain_context.unchecked_blockchain_context().clone(), + block_verifier_service, + stop_current_block_downloader, + broadcast_svc, + }; + + tokio::spawn(manger.run(batch_rx, command_rx)); +} + +/// The blockchain manager. +/// +/// This handles all mutation of the blockchain, anything that changes the state of the blockchain must +/// go through this. +/// +/// Other parts of Cuprate can interface with this by using the functions in [`interface`](super::interface). +pub struct BlockchainManager { + /// The [`BlockchainWriteHandle`], this is the _only_ part of Cuprate where a [`BlockchainWriteHandle`] + /// is held. + blockchain_write_handle: BlockchainWriteHandle, + /// A [`BlockchainReadHandle`]. + blockchain_read_handle: BlockchainReadHandle, + // TODO: Improve the API of the cache service. + // TODO: rename the cache service -> `BlockchainContextService`. + /// The blockchain context cache, this caches the current state of the blockchain to quickly calculate/retrieve + /// values without needing to go to a [`BlockchainReadHandle`]. blockchain_context_service: BlockChainContextService, + /// A cached context representing the current state. cached_blockchain_context: RawBlockChainContext, + /// The block verifier service, to verify incoming blocks. block_verifier_service: BlockVerifierService< BlockChainContextService, TxVerifierService, ConsensusBlockchainReadHandle, >, + /// A [`Notify`] to tell the [syncer](syncer::syncer) that we want to cancel this current download + /// attempt. stop_current_block_downloader: Arc, + /// The broadcast service, to broadcast new blocks. broadcast_svc: BroadcastSvc, } impl BlockchainManager { - pub async fn new( - blockchain_write_handle: BlockchainWriteHandle, - blockchain_read_handle: BlockchainReadHandle, - mut blockchain_context_service: BlockChainContextService, - block_verifier_service: BlockVerifierService< - BlockChainContextService, - TxVerifierService, - ConsensusBlockchainReadHandle, - >, - stop_current_block_downloader: Arc, - broadcast_svc: BroadcastSvc, - ) -> Self { - let BlockChainContextResponse::Context(blockchain_context) = blockchain_context_service - .ready() - .await - .expect("TODO") - .call(BlockChainContextRequest::GetContext) - .await - .expect("TODO") - else { - panic!("Blockchain context service returned wrong response!"); - }; - - Self { - blockchain_write_handle, - blockchain_read_handle, - blockchain_context_service, - cached_blockchain_context: blockchain_context.unchecked_blockchain_context().clone(), - block_verifier_service, - stop_current_block_downloader, - broadcast_svc, - } - } - pub async fn run( mut self, mut block_batch_rx: mpsc::Receiver, diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs index 6a92ba73..7d4c81c4 100644 --- a/binaries/cuprated/src/blockchain/manager/handler.rs +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -21,6 +21,7 @@ use cuprate_types::{ }; use crate::blockchain::manager::commands::BlockchainManagerCommand; +use crate::constants::PANIC_CRITICAL_SERVICE_ERROR; use crate::{blockchain::types::ConsensusBlockchainReadHandle, signals::REORG_LOCK}; impl super::BlockchainManager { @@ -42,13 +43,13 @@ impl super::BlockchainManager { self.broadcast_svc .ready() .await - .expect("TODO") + .expect("Broadcast service cannot error.") .call(BroadcastRequest::Block { block_bytes, current_blockchain_height: usize_to_u64(blockchain_height), }) .await - .expect("TODO"); + .expect("Broadcast service cannot error."); } /// Handle an incoming [`Block`]. @@ -75,7 +76,7 @@ impl super::BlockchainManager { .block_verifier_service .ready() .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) .call(VerifyBlockRequest::MainChain { block, prepared_txs, @@ -102,7 +103,7 @@ impl super::BlockchainManager { /// # Panics /// /// This function will panic if the batch is empty or if any internal service returns an unexpected - /// error that we cannot recover from. + /// error that we cannot recover from or if the incoming batch contains no blocks. pub async fn handle_incoming_block_batch(&mut self, batch: BlockBatch) { let (first_block, _) = batch .blocks @@ -127,7 +128,7 @@ impl super::BlockchainManager { /// # Panics /// /// This function will panic if any internal service returns an unexpected error that we cannot - /// recover from. + /// recover from or if the incoming batch contains no blocks. async fn handle_incoming_block_batch_main_chain(&mut self, batch: BlockBatch) { info!( "Handling batch to main chain height: {}", @@ -138,7 +139,7 @@ impl super::BlockchainManager { .block_verifier_service .ready() .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) .call(VerifyBlockRequest::MainChainBatchPrepareBlocks { blocks: batch.blocks, }) @@ -159,7 +160,7 @@ impl super::BlockchainManager { .block_verifier_service .ready() .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) .call(VerifyBlockRequest::MainChainPrepped { block, txs }) .await; @@ -189,8 +190,12 @@ impl super::BlockchainManager { /// /// This function will panic if any internal service returns an unexpected error that we cannot /// recover from. - async fn handle_incoming_block_batch_alt_chain(&mut self, batch: BlockBatch) { - for (block, txs) in batch.blocks { + async fn handle_incoming_block_batch_alt_chain(&mut self, mut batch: BlockBatch) { + // TODO: this needs testing (this whole section does but this specifically). + + let mut blocks = batch.blocks.into_iter(); + + while let Some((block, txs)) = blocks.next() { // async blocks work as try blocks. let res = async { let txs = txs @@ -201,16 +206,28 @@ impl super::BlockchainManager { }) .collect::>()?; - self.handle_incoming_alt_block(block, txs).await?; + let reorged = self.handle_incoming_alt_block(block, txs).await?; - Ok::<_, anyhow::Error>(()) + Ok::<_, anyhow::Error>(reorged) } .await; - if let Err(e) = res { - batch.peer_handle.ban_peer(LONG_BAN); - self.stop_current_block_downloader.notify_one(); - return; + match res { + Err(e) => { + batch.peer_handle.ban_peer(LONG_BAN); + self.stop_current_block_downloader.notify_one(); + return; + } + // the chain was reorged + Ok(true) => { + // Collect the remaining blocks and add them to the main chain instead. + batch.blocks = blocks.collect(); + self.handle_incoming_block_batch_main_chain(batch).await; + + return; + } + // continue adding alt blocks. + Ok(false) => (), } } } @@ -221,6 +238,8 @@ impl super::BlockchainManager { /// of the alt chain is higher than the main chain it will attempt a reorg otherwise it will add /// the alt block to the alt block cache. /// + /// This function returns a [`bool`] indicating if the chain was reorganised ([`true`]) or not ([`false`]). + /// /// # Errors /// /// This will return an [`Err`] if: @@ -235,12 +254,12 @@ impl super::BlockchainManager { &mut self, block: Block, prepared_txs: HashMap<[u8; 32], TransactionVerificationData>, - ) -> Result<(), anyhow::Error> { + ) -> Result { let VerifyBlockResponse::AltChain(alt_block_info) = self .block_verifier_service .ready() .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) .call(VerifyBlockRequest::AltChain { block, prepared_txs, @@ -250,23 +269,24 @@ impl super::BlockchainManager { panic!("Incorrect response!"); }; - // TODO: check in consensus crate if alt block already exists. + // TODO: check in consensus crate if alt block with this hash already exists. + // If this alt chain if alt_block_info.cumulative_difficulty > self.cached_blockchain_context.cumulative_difficulty { self.try_do_reorg(alt_block_info).await?; - return Ok(()); + return Ok(true); } self.blockchain_write_handle .ready() .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) .call(BlockchainWriteRequest::WriteAltBlock(alt_block_info)) .await?; - Ok(()) + Ok(false) } /// Attempt a re-org with the given top block of the alt-chain. @@ -294,7 +314,7 @@ impl super::BlockchainManager { .blockchain_read_handle .ready() .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) .call(BlockchainReadRequest::AltBlocksInChain( top_alt_block.chain_id, )) @@ -312,12 +332,12 @@ impl super::BlockchainManager { .blockchain_write_handle .ready() .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) .call(BlockchainWriteRequest::PopBlocks( current_main_chain_height - split_height + 1, )) .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) else { panic!("Incorrect response!"); }; @@ -325,12 +345,12 @@ impl super::BlockchainManager { self.blockchain_context_service .ready() .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) .call(BlockChainContextRequest::PopBlocks { numb_blocks: current_main_chain_height - split_height + 1, }) .await - .expect("TODO"); + .expect(PANIC_CRITICAL_SERVICE_ERROR); let reorg_res = self.verify_add_alt_blocks_to_main_chain(alt_blocks).await; diff --git a/binaries/cuprated/src/constants.rs b/binaries/cuprated/src/constants.rs index 9463d476..d4dfc1ad 100644 --- a/binaries/cuprated/src/constants.rs +++ b/binaries/cuprated/src/constants.rs @@ -14,6 +14,9 @@ pub const VERSION_BUILD: &str = if cfg!(debug_assertions) { formatcp!("{VERSION}-release") }; +pub const PANIC_CRITICAL_SERVICE_ERROR: &str = + "A service critical to Cuprate's function returned an unexpected error."; + #[cfg(test)] mod test { use super::*; From 8cff481227016e6c39e88d8ba0f041779eab20a0 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 3 Oct 2024 21:35:42 +0100 Subject: [PATCH 37/72] add more docs + cleanup imports --- binaries/cuprated/src/blockchain.rs | 28 ++++--- binaries/cuprated/src/blockchain/interface.rs | 78 +++++++++++++++---- binaries/cuprated/src/blockchain/manager.rs | 78 ++++++++++--------- .../src/blockchain/manager/handler.rs | 31 +++++--- binaries/cuprated/src/blockchain/syncer.rs | 5 +- binaries/cuprated/src/blockchain/types.rs | 44 +++++------ binaries/cuprated/src/p2p/request_handler.rs | 21 +++-- binaries/cuprated/src/signals.rs | 6 ++ consensus/src/block.rs | 10 +-- consensus/src/lib.rs | 1 - p2p/p2p/src/client_pool.rs | 11 +-- p2p/p2p/src/lib.rs | 4 +- 12 files changed, 180 insertions(+), 137 deletions(-) diff --git a/binaries/cuprated/src/blockchain.rs b/binaries/cuprated/src/blockchain.rs index 80d10bf2..52043a06 100644 --- a/binaries/cuprated/src/blockchain.rs +++ b/binaries/cuprated/src/blockchain.rs @@ -1,11 +1,11 @@ //! Blockchain //! //! Will contain the chain manager and syncer. +use std::sync::Arc; use futures::FutureExt; -use std::sync::Arc; use tokio::sync::{mpsc, Notify}; -use tower::{Service, ServiceExt}; +use tower::{BoxError, Service, ServiceExt}; use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; use cuprate_consensus::{generate_genesis_block, BlockChainContextService, ContextConfig}; @@ -22,11 +22,8 @@ mod manager; mod syncer; mod types; -use crate::blockchain::interface::INCOMING_BLOCK_TX; -use manager::BlockchainManager; use types::{ - ChainService, ConcreteBlockVerifierService, ConcreteTxVerifierService, - ConsensusBlockchainReadHandle, + ConcreteBlockVerifierService, ConcreteTxVerifierService, ConsensusBlockchainReadHandle, }; pub use interface::{handle_incoming_block, IncomingBlockError}; @@ -51,6 +48,9 @@ pub async fn check_add_genesis( let genesis = generate_genesis_block(network); + assert_eq!(genesis.miner_transaction.prefix().outputs.len(), 1); + assert!(genesis.transactions.is_empty()); + blockchain_write_handle .ready() .await @@ -87,16 +87,14 @@ pub async fn init_consensus( ), tower::BoxError, > { - let ctx_service = cuprate_consensus::initialize_blockchain_context( - context_config, - ConsensusBlockchainReadHandle(blockchain_read_handle.clone()), - ) - .await?; + let read_handle = ConsensusBlockchainReadHandle::new(blockchain_read_handle, BoxError::from); - let (block_verifier_svc, tx_verifier_svc) = cuprate_consensus::initialize_verifier( - ConsensusBlockchainReadHandle(blockchain_read_handle), - ctx_service.clone(), - ); + let ctx_service = + cuprate_consensus::initialize_blockchain_context(context_config, read_handle.clone()) + .await?; + + let (block_verifier_svc, tx_verifier_svc) = + cuprate_consensus::initialize_verifier(read_handle, ctx_service.clone()); Ok((block_verifier_svc, tx_verifier_svc, ctx_service)) } diff --git a/binaries/cuprated/src/blockchain/interface.rs b/binaries/cuprated/src/blockchain/interface.rs index 56c68edf..18376f39 100644 --- a/binaries/cuprated/src/blockchain/interface.rs +++ b/binaries/cuprated/src/blockchain/interface.rs @@ -1,39 +1,74 @@ -use crate::blockchain::manager::commands::BlockchainManagerCommand; -use cuprate_blockchain::service::BlockchainReadHandle; -use cuprate_consensus::transactions::new_tx_verification_data; -use cuprate_helper::cast::usize_to_u64; -use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; -use cuprate_types::Chain; -use monero_serai::block::Block; -use monero_serai::transaction::Transaction; +//! The blockchain manger interface. +//! +//! This module contains all the functions to mutate the blockchains state in any way, through the +//! blockchain manger. +use std::{ + collections::{HashMap, HashSet}, + sync::{Mutex, OnceLock}, +}; + +use monero_serai::{block::Block, transaction::Transaction}; use rayon::prelude::*; -use std::collections::{HashMap, HashSet}; -use std::sync::{Mutex, OnceLock}; use tokio::sync::{mpsc, oneshot}; use tower::{Service, ServiceExt}; -pub static INCOMING_BLOCK_TX: OnceLock> = OnceLock::new(); +use cuprate_blockchain::service::BlockchainReadHandle; +use cuprate_consensus::transactions::new_tx_verification_data; +use cuprate_helper::cast::usize_to_u64; +use cuprate_types::{ + blockchain::{BlockchainReadRequest, BlockchainResponse}, + Chain, +}; +use crate::{ + blockchain::manager::BlockchainManagerCommand, constants::PANIC_CRITICAL_SERVICE_ERROR, +}; + +/// The channel used to send [`BlockchainManagerCommand`]s to the blockchain manger. +pub static COMMAND_TX: OnceLock> = OnceLock::new(); + +/// A [`HashSet`] of block hashes that the blockchain manager is currently handling. pub static BLOCKS_BEING_HANDLED: OnceLock>> = OnceLock::new(); +/// An error that can be returned from [`handle_incoming_block`]. #[derive(Debug, thiserror::Error)] pub enum IncomingBlockError { + /// Some transactions in the block were unknown. + /// + /// The inner values are the block hash and the indexes of the missing txs in the block. #[error("Unknown transactions in block.")] UnknownTransactions([u8; 32], Vec), + /// We are missing the block's parent. #[error("The block has an unknown parent.")] Orphan, + /// The block was invalid. #[error(transparent)] InvalidBlock(anyhow::Error), } +/// Try to add a new block to the blockchain. +/// +/// This returns a [`bool`] indicating if the block was added to the main-chain ([`true`]) or an alt-chain +/// ([`false`]). +/// +/// If we already knew about this block or the blockchain manger is not setup yet `Ok(false)` is returned. +/// +/// # Errors +/// +/// This function will return an error if: +/// - the block was invalid +/// - we are missing transactions +/// - the block's parent is unknown pub async fn handle_incoming_block( block: Block, given_txs: Vec, blockchain_read_handle: &mut BlockchainReadHandle, ) -> Result { + // FIXME: we should look in the tx-pool for txs when that is ready. + if !block_exists(block.header.previous, blockchain_read_handle) .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) { return Err(IncomingBlockError::Orphan); } @@ -42,12 +77,12 @@ pub async fn handle_incoming_block( if block_exists(block_hash, blockchain_read_handle) .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) { return Ok(false); } - // TODO: Get transactions from the tx pool first. + // TODO: remove this when we have a working tx-pool. if given_txs.len() != block.transactions.len() { return Err(IncomingBlockError::UnknownTransactions( block_hash, @@ -55,6 +90,7 @@ pub async fn handle_incoming_block( )); } + // TODO: check we actually go given the right txs. let prepped_txs = given_txs .into_par_iter() .map(|tx| { @@ -64,19 +100,25 @@ pub async fn handle_incoming_block( .collect::>() .map_err(IncomingBlockError::InvalidBlock)?; - let Some(incoming_block_tx) = INCOMING_BLOCK_TX.get() else { + let Some(incoming_block_tx) = COMMAND_TX.get() else { + // We could still be starting up the blockchain manger, so just return this as there is nothing + // else we can do. return Ok(false); }; + // Add the blocks hash to the blocks being handled. if !BLOCKS_BEING_HANDLED .get_or_init(|| Mutex::new(HashSet::new())) .lock() .unwrap() .insert(block_hash) { + // If another place is already adding this block then we can stop. return Ok(false); } + // From this point on we MUST not early return without removing the block hash from `BLOCKS_BEING_HANDLED`. + let (response_tx, response_rx) = oneshot::channel(); incoming_block_tx @@ -86,13 +128,14 @@ pub async fn handle_incoming_block( response_tx, }) .await - .expect("TODO: don't actually panic here"); + .expect("TODO: don't actually panic here, an err means we are shutting down"); let res = response_rx .await - .unwrap() + .expect("The blockchain manager will always respond") .map_err(IncomingBlockError::InvalidBlock); + // Remove the block hash from the blocks being handled. BLOCKS_BEING_HANDLED .get() .unwrap() @@ -103,6 +146,7 @@ pub async fn handle_incoming_block( res } +/// Check if we have a block with the given hash. async fn block_exists( block_hash: [u8; 32], blockchain_read_handle: &mut BlockchainReadHandle, diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index 314519d0..2d3c1798 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -1,35 +1,46 @@ -pub(super) mod commands; -mod handler; +use std::{collections::HashMap, sync::Arc}; -use crate::blockchain::interface::INCOMING_BLOCK_TX; -use crate::blockchain::manager::commands::BlockchainManagerCommand; -use crate::blockchain::types::ChainService; -use crate::blockchain::{ - syncer, - types::{ConcreteBlockVerifierService, ConsensusBlockchainReadHandle}, -}; -use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; -use cuprate_consensus::context::RawBlockChainContext; -use cuprate_consensus::{ - BlockChainContextRequest, BlockChainContextResponse, BlockChainContextService, - BlockVerifierService, ExtendedConsensusError, TxVerifierService, VerifyBlockRequest, - VerifyBlockResponse, VerifyTxRequest, VerifyTxResponse, -}; -use cuprate_p2p::block_downloader::{BlockBatch, BlockDownloaderConfig}; -use cuprate_p2p::{BroadcastSvc, NetworkInterface}; -use cuprate_p2p_core::ClearNet; -use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; -use cuprate_types::{Chain, TransactionVerificationData}; use futures::StreamExt; use monero_serai::block::Block; -use std::collections::HashMap; -use std::sync::Arc; -use tokio::sync::mpsc; -use tokio::sync::{oneshot, Notify}; +use tokio::sync::{mpsc, oneshot, Notify}; use tower::{Service, ServiceExt}; use tracing::error; -use tracing_subscriber::fmt::time::FormatTime; +use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; +use cuprate_consensus::{ + context::RawBlockChainContext, BlockChainContextRequest, BlockChainContextResponse, + BlockChainContextService, BlockVerifierService, ExtendedConsensusError, TxVerifierService, + VerifyBlockRequest, VerifyBlockResponse, VerifyTxRequest, VerifyTxResponse, +}; +use cuprate_p2p::{ + block_downloader::{BlockBatch, BlockDownloaderConfig}, + BroadcastSvc, NetworkInterface, +}; +use cuprate_p2p_core::ClearNet; +use cuprate_types::{ + blockchain::{BlockchainReadRequest, BlockchainResponse}, + Chain, TransactionVerificationData, +}; + +use crate::{ + blockchain::{ + interface::COMMAND_TX, + syncer, + types::ChainService, + types::{ConcreteBlockVerifierService, ConsensusBlockchainReadHandle}, + }, + constants::PANIC_CRITICAL_SERVICE_ERROR, +}; + +mod commands; +mod handler; + +pub use commands::BlockchainManagerCommand; + +/// Initialize the blockchain manger. +/// +/// This function sets up the [`BlockchainManager`] and the [`syncer`] so that the functions in [`interface`](super::interface) +/// can be called. pub async fn init_blockchain_manger( clearnet_interface: NetworkInterface, blockchain_write_handle: BlockchainWriteHandle, @@ -42,7 +53,7 @@ pub async fn init_blockchain_manger( let stop_current_block_downloader = Arc::new(Notify::new()); let (command_tx, command_rx) = mpsc::channel(1); - INCOMING_BLOCK_TX.set(command_tx).unwrap(); + COMMAND_TX.set(command_tx).unwrap(); tokio::spawn(syncer::syncer( blockchain_context_service.clone(), @@ -56,10 +67,10 @@ pub async fn init_blockchain_manger( let BlockChainContextResponse::Context(blockchain_context) = blockchain_context_service .ready() .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) .call(BlockChainContextRequest::GetContext) .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) else { panic!("Blockchain context service returned wrong response!"); }; @@ -71,7 +82,7 @@ pub async fn init_blockchain_manger( cached_blockchain_context: blockchain_context.unchecked_blockchain_context().clone(), block_verifier_service, stop_current_block_downloader, - broadcast_svc, + broadcast_svc: clearnet_interface.broadcast_svc(), }; tokio::spawn(manger.run(batch_rx, command_rx)); @@ -97,11 +108,7 @@ pub struct BlockchainManager { /// A cached context representing the current state. cached_blockchain_context: RawBlockChainContext, /// The block verifier service, to verify incoming blocks. - block_verifier_service: BlockVerifierService< - BlockChainContextService, - TxVerifierService, - ConsensusBlockchainReadHandle, - >, + block_verifier_service: ConcreteBlockVerifierService, /// A [`Notify`] to tell the [syncer](syncer::syncer) that we want to cancel this current download /// attempt. stop_current_block_downloader: Arc, @@ -110,6 +117,7 @@ pub struct BlockchainManager { } impl BlockchainManager { + /// The [`BlockchainManager`] task. pub async fn run( mut self, mut block_batch_rx: mpsc::Receiver, diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs index 7d4c81c4..62b54d69 100644 --- a/binaries/cuprated/src/blockchain/manager/handler.rs +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -1,8 +1,9 @@ +use std::{collections::HashMap, sync::Arc}; + use bytes::Bytes; use futures::{TryFutureExt, TryStreamExt}; use monero_serai::{block::Block, transaction::Transaction}; use rayon::prelude::*; -use std::{collections::HashMap, sync::Arc}; use tower::{Service, ServiceExt}; use tracing::info; @@ -20,11 +21,16 @@ use cuprate_types::{ AltBlockInformation, HardFork, TransactionVerificationData, VerifiedBlockInformation, }; -use crate::blockchain::manager::commands::BlockchainManagerCommand; -use crate::constants::PANIC_CRITICAL_SERVICE_ERROR; -use crate::{blockchain::types::ConsensusBlockchainReadHandle, signals::REORG_LOCK}; +use crate::{ + blockchain::{ + manager::commands::BlockchainManagerCommand, types::ConsensusBlockchainReadHandle, + }, + constants::PANIC_CRITICAL_SERVICE_ERROR, + signals::REORG_LOCK, +}; impl super::BlockchainManager { + /// Handle an incoming command from another part of Cuprate. pub async fn handle_command(&mut self, command: BlockchainManagerCommand) { match command { BlockchainManagerCommand::AddBlock { @@ -39,6 +45,7 @@ impl super::BlockchainManager { } } + /// Broadcast a valid block to the network. async fn broadcast_block(&mut self, block_bytes: Bytes, blockchain_height: usize) { self.broadcast_svc .ready() @@ -191,7 +198,7 @@ impl super::BlockchainManager { /// This function will panic if any internal service returns an unexpected error that we cannot /// recover from. async fn handle_incoming_block_batch_alt_chain(&mut self, mut batch: BlockBatch) { - // TODO: this needs testing (this whole section does but this specifically). + // TODO: this needs testing (this whole section does but alt-blocks specifically). let mut blocks = batch.blocks.into_iter(); @@ -394,7 +401,7 @@ impl super::BlockchainManager { .block_verifier_service .ready() .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) .call(VerifyBlockRequest::MainChainPrepped { block: prepped_block, txs: prepped_txs, @@ -426,7 +433,7 @@ impl super::BlockchainManager { self.blockchain_context_service .ready() .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) .call(BlockChainContextRequest::Update(NewBlockData { block_hash: verified_block.block_hash, height: verified_block.height, @@ -438,24 +445,24 @@ impl super::BlockchainManager { cumulative_difficulty: verified_block.cumulative_difficulty, })) .await - .expect("TODO"); + .expect(PANIC_CRITICAL_SERVICE_ERROR); self.blockchain_write_handle .ready() .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) .call(BlockchainWriteRequest::WriteBlock(verified_block)) .await - .expect("TODO"); + .expect(PANIC_CRITICAL_SERVICE_ERROR); let BlockChainContextResponse::Context(blockchain_context) = self .blockchain_context_service .ready() .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) .call(BlockChainContextRequest::GetContext) .await - .expect("TODO") + .expect(PANIC_CRITICAL_SERVICE_ERROR) else { panic!("Incorrect response!"); }; diff --git a/binaries/cuprated/src/blockchain/syncer.rs b/binaries/cuprated/src/blockchain/syncer.rs index 4b286ceb..c772b128 100644 --- a/binaries/cuprated/src/blockchain/syncer.rs +++ b/binaries/cuprated/src/blockchain/syncer.rs @@ -1,6 +1,4 @@ -use std::pin::pin; -use std::sync::Arc; -use std::time::Duration; +use std::{pin::pin, sync::Arc, time::Duration}; use futures::StreamExt; use tokio::time::interval; @@ -18,6 +16,7 @@ use cuprate_p2p::{ }; use cuprate_p2p_core::ClearNet; +// FIXME: This whole module is not great and should be rewritten when the PeerSet is made. const CHECK_SYNC_FREQUENCY: Duration = Duration::from_secs(30); /// An error returned from the [`syncer`]. diff --git a/binaries/cuprated/src/blockchain/types.rs b/binaries/cuprated/src/blockchain/types.rs index 46576a46..1bf921ec 100644 --- a/binaries/cuprated/src/blockchain/types.rs +++ b/binaries/cuprated/src/blockchain/types.rs @@ -1,41 +1,32 @@ -use cuprate_blockchain::cuprate_database::RuntimeError; -use cuprate_blockchain::service::BlockchainReadHandle; +use std::task::{Context, Poll}; + +use futures::future::BoxFuture; +use futures::{FutureExt, TryFutureExt}; +use tower::{util::MapErr, Service}; + +use cuprate_blockchain::{cuprate_database::RuntimeError, service::BlockchainReadHandle}; use cuprate_consensus::{BlockChainContextService, BlockVerifierService, TxVerifierService}; use cuprate_p2p::block_downloader::{ChainSvcRequest, ChainSvcResponse}; use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; -use futures::future::{BoxFuture, MapErr}; -use futures::{FutureExt, TryFutureExt}; -use std::task::{Context, Poll}; -use tower::Service; +/// The [`BlockVerifierService`] with all generic types defined. pub type ConcreteBlockVerifierService = BlockVerifierService< BlockChainContextService, - TxVerifierService, + ConcreteTxVerifierService, ConsensusBlockchainReadHandle, >; +/// The [`TxVerifierService`] with all generic types defined. pub type ConcreteTxVerifierService = TxVerifierService; -#[derive(Clone)] -pub struct ConsensusBlockchainReadHandle(pub BlockchainReadHandle); - -impl Service for ConsensusBlockchainReadHandle { - type Response = BlockchainResponse; - type Error = tower::BoxError; - type Future = MapErr< - >::Future, - fn(RuntimeError) -> tower::BoxError, - >; - - fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { - self.0.poll_ready(cx).map_err(Into::into) - } - - fn call(&mut self, req: BlockchainReadRequest) -> Self::Future { - self.0.call(req).map_err(Into::into) - } -} +/// The [`BlockchainReadHandle`] with the [`tower::Service::Error`] mapped to conform to what the consensus crate requires. +pub type ConsensusBlockchainReadHandle = + MapErr tower::BoxError>; +/// That service that allows retrieving the chain state to give to the P2P crates, so we can figure out +/// what blocks we need. +/// +/// This has a more minimal interface than [`BlockchainReadRequest`] to make using the p2p crates easier. #[derive(Clone)] pub struct ChainService(pub BlockchainReadHandle); @@ -79,6 +70,7 @@ impl Service for ChainService { .call(BlockchainReadRequest::CompactChainHistory) .map_ok(|res| { // TODO create a custom request instead of hijacking this one. + // TODO: use the context cache. let BlockchainResponse::CompactChainHistory { cumulative_difficulty, .. diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index 86507f1f..419c3b42 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -90,7 +90,7 @@ async fn get_objects( // de-allocate the backing [`Bytes`] drop(req); - return Ok(ProtocolResponse::NA); + Ok(ProtocolResponse::NA) /* let res = blockchain_read_handle @@ -122,7 +122,8 @@ async fn get_chain( if req.block_ids.is_empty() { Err("No block hashes sent in a `ChainRequest`")?; } - return Ok(ProtocolResponse::NA); + + Ok(ProtocolResponse::NA) /* if req.block_ids.len() > MAX_BLOCKCHAIN_SUPPLEMENT_LEN { @@ -191,15 +192,13 @@ async fn new_fluffy_block( let res = handle_incoming_block(block, txs, &mut blockchain_read_handle).await; match res { - Err(IncomingBlockError::UnknownTransactions(block_hash, tx_indexes)) => { - return Ok(ProtocolResponse::FluffyMissingTxs( - FluffyMissingTransactionsRequest { - block_hash: ByteArray::from(block_hash), - current_blockchain_height: peer_blockchain_height, - missing_tx_indices: tx_indexes, - }, - )) - } + Err(IncomingBlockError::UnknownTransactions(block_hash, tx_indexes)) => Ok( + ProtocolResponse::FluffyMissingTxs(FluffyMissingTransactionsRequest { + block_hash: ByteArray::from(block_hash), + current_blockchain_height: peer_blockchain_height, + missing_tx_indices: tx_indexes, + }), + ), Err(IncomingBlockError::InvalidBlock(e)) => Err(e)?, Err(IncomingBlockError::Orphan) | Ok(_) => Ok(ProtocolResponse::NA), } diff --git a/binaries/cuprated/src/signals.rs b/binaries/cuprated/src/signals.rs index cafd8cdb..54467559 100644 --- a/binaries/cuprated/src/signals.rs +++ b/binaries/cuprated/src/signals.rs @@ -1,3 +1,9 @@ +//! Signals for Cuprate state used throughout the binary. + use tokio::sync::RwLock; +/// Reorg lock. +/// +/// A [`RwLock`] where a write lock is taken during a reorg and a read lock can be taken +/// for any operation which must complete without a reorg happening. pub static REORG_LOCK: RwLock<()> = RwLock::const_new(()); diff --git a/consensus/src/block.rs b/consensus/src/block.rs index 08e6cef0..53eb1469 100644 --- a/consensus/src/block.rs +++ b/consensus/src/block.rs @@ -8,7 +8,6 @@ use std::{ }; use futures::FutureExt; -use monero_serai::generators::H; use monero_serai::{ block::Block, transaction::{Input, Transaction}, @@ -124,10 +123,7 @@ impl PreparedBlock { /// /// The randomX VM must be Some if RX is needed or this will panic. /// The randomX VM must also be initialised with the correct seed. - pub fn new( - block: Block, - randomx_vm: Option<&R>, - ) -> Result { + pub fn new(block: Block, randomx_vm: Option<&R>) -> Result { let (hf_version, hf_vote) = HardFork::from_block_header(&block.header) .map_err(|_| BlockError::HardForkError(HardForkError::HardForkUnknown))?; @@ -185,8 +181,8 @@ impl PreparedBlock { }) } - pub fn new_alt_block(block: AltBlockInformation) -> Result { - Ok(PreparedBlock { + pub fn new_alt_block(block: AltBlockInformation) -> Result { + Ok(Self { block_blob: block.block_blob, hf_vote: HardFork::from_version(block.block.header.hardfork_version) .map_err(|_| BlockError::HardForkError(HardForkError::HardForkUnknown))?, diff --git a/consensus/src/lib.rs b/consensus/src/lib.rs index 1e473158..7280f2ff 100644 --- a/consensus/src/lib.rs +++ b/consensus/src/lib.rs @@ -65,7 +65,6 @@ pub enum ExtendedConsensusError { } /// Initialize the 2 verifier [`tower::Service`]s (block and transaction). -#[expect(clippy::type_complexity)] pub fn initialize_verifier( database: D, ctx_svc: Ctx, diff --git a/p2p/p2p/src/client_pool.rs b/p2p/p2p/src/client_pool.rs index 735be76d..99981f0c 100644 --- a/p2p/p2p/src/client_pool.rs +++ b/p2p/p2p/src/client_pool.rs @@ -158,13 +158,10 @@ impl ClientPool { &self, cumulative_difficulty: u128, ) -> bool { - self.clients - .iter() - .find(|element| { - let sync_data = element.value().info.core_sync_data.lock().unwrap(); - sync_data.cumulative_difficulty() > cumulative_difficulty - }) - .is_some() + self.clients.iter().any(|element| { + let sync_data = element.value().info.core_sync_data.lock().unwrap(); + sync_data.cumulative_difficulty() > cumulative_difficulty + }) } } diff --git a/p2p/p2p/src/lib.rs b/p2p/p2p/src/lib.rs index 37416b2d..ad082fc6 100644 --- a/p2p/p2p/src/lib.rs +++ b/p2p/p2p/src/lib.rs @@ -12,7 +12,6 @@ use tracing::{instrument, Instrument, Span}; use cuprate_async_buffer::BufferStream; use cuprate_p2p_core::{ client::Connector, - client::InternalPeerID, services::{AddressBookRequest, AddressBookResponse}, CoreSyncSvc, NetworkZone, ProtocolRequestHandlerMaker, }; @@ -27,7 +26,6 @@ mod inbound_server; use block_downloader::{BlockBatch, BlockDownloaderConfig, ChainSvcRequest, ChainSvcResponse}; pub use broadcast::{BroadcastRequest, BroadcastSvc}; -use client_pool::ClientPoolDropGuard; pub use config::{AddressBookConfig, P2PConfig}; use connection_maintainer::MakeConnectionRequest; @@ -175,7 +173,7 @@ impl NetworkInterface { } /// TODO - pub fn client_pool(&self) -> &Arc> { + pub const fn client_pool(&self) -> &Arc> { &self.pool } } From 4af0f896b00b74525419e375c69d9a9e56a0265c Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 3 Oct 2024 21:39:18 +0100 Subject: [PATCH 38/72] fix typo --- binaries/cuprated/src/blockchain/manager/handler.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs index 62b54d69..4406421f 100644 --- a/binaries/cuprated/src/blockchain/manager/handler.rs +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -300,7 +300,7 @@ impl super::BlockchainManager { /// /// This function will take a write lock on [`REORG_LOCK`] and then set up the blockchain database /// and context cache to verify the alt-chain. It will then attempt to verify and add each block - /// in the alt-chain to tha main-chain. Releasing the lock on [`REORG_LOCK`] when finished. + /// in the alt-chain to the main-chain. Releasing the lock on [`REORG_LOCK`] when finished. /// /// # Errors /// From 6702dbee11c45a0dce79ae647b0af3b90b917aff Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 3 Oct 2024 21:56:42 +0100 Subject: [PATCH 39/72] fix doc --- p2p/p2p/src/block_downloader.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/p2p/p2p/src/block_downloader.rs b/p2p/p2p/src/block_downloader.rs index eccb3850..b80b7aa4 100644 --- a/p2p/p2p/src/block_downloader.rs +++ b/p2p/p2p/src/block_downloader.rs @@ -1,6 +1,6 @@ //! # Block Downloader //! -//! This module contains the [`BlockDownloader`], which finds a chain to +//! This module contains the block downloader, which finds a chain to //! download from our connected peers and downloads it. See the actual //! `struct` documentation for implementation details. //! From 403964bc2216bd5f493358d9ccf10a0e6177172d Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 3 Oct 2024 22:52:47 +0100 Subject: [PATCH 40/72] remove unrelated changes --- binaries/cuprated/Cargo.toml | 4 +- binaries/cuprated/src/blockchain.rs | 16 +- binaries/cuprated/src/blockchain/interface.rs | 8 +- binaries/cuprated/src/blockchain/manager.rs | 5 +- .../src/blockchain/manager/commands.rs | 6 + .../src/blockchain/manager/handler.rs | 5 +- binaries/cuprated/src/blockchain/syncer.rs | 10 +- binaries/cuprated/src/config.rs | 61 ------ binaries/cuprated/src/p2p.rs | 1 - binaries/cuprated/src/p2p/core_sync_svc.rs | 51 ----- binaries/cuprated/src/p2p/request_handler.rs | 204 ------------------ binaries/cuprated/src/rpc/request_handler.rs | 1 - consensus/src/block.rs | 1 + helper/src/tx_utils.rs | 34 --- p2p/p2p-core/src/protocol.rs | 2 - p2p/p2p-core/src/protocol/try_from.rs | 1 - p2p/p2p/src/client_pool.rs | 2 + p2p/p2p/src/constants.rs | 7 +- p2p/p2p/src/lib.rs | 2 +- 19 files changed, 43 insertions(+), 378 deletions(-) delete mode 100644 binaries/cuprated/src/p2p/core_sync_svc.rs delete mode 100644 binaries/cuprated/src/rpc/request_handler.rs delete mode 100644 helper/src/tx_utils.rs diff --git a/binaries/cuprated/Cargo.toml b/binaries/cuprated/Cargo.toml index 080bb117..325406bf 100644 --- a/binaries/cuprated/Cargo.toml +++ b/binaries/cuprated/Cargo.toml @@ -73,8 +73,8 @@ tower = { workspace = true } tracing-subscriber = { workspace = true, features = ["std", "fmt", "default"] } tracing = { workspace = true } -#[lints] -#workspace = true +[lints] +workspace = true [profile.dev] panic = "abort" diff --git a/binaries/cuprated/src/blockchain.rs b/binaries/cuprated/src/blockchain.rs index 52043a06..1a9c0b7c 100644 --- a/binaries/cuprated/src/blockchain.rs +++ b/binaries/cuprated/src/blockchain.rs @@ -1,6 +1,6 @@ //! Blockchain //! -//! Will contain the chain manager and syncer. +//! Contains the blockchain manager, syncer and an interface to mutate the blockchain. use std::sync::Arc; use futures::FutureExt; @@ -17,7 +17,9 @@ use cuprate_types::{ VerifiedBlockInformation, }; -mod interface; +use crate::constants::PANIC_CRITICAL_SERVICE_ERROR; + +pub mod interface; mod manager; mod syncer; mod types; @@ -26,8 +28,6 @@ use types::{ ConcreteBlockVerifierService, ConcreteTxVerifierService, ConsensusBlockchainReadHandle, }; -pub use interface::{handle_incoming_block, IncomingBlockError}; - /// Checks if the genesis block is in the blockchain and adds it if not. pub async fn check_add_genesis( blockchain_read_handle: &mut BlockchainReadHandle, @@ -38,7 +38,7 @@ pub async fn check_add_genesis( if blockchain_read_handle .ready() .await - .unwrap() + .expect(PANIC_CRITICAL_SERVICE_ERROR) .call(BlockchainReadRequest::ChainHeight) .await .is_ok() @@ -54,7 +54,7 @@ pub async fn check_add_genesis( blockchain_write_handle .ready() .await - .unwrap() + .expect(PANIC_CRITICAL_SERVICE_ERROR) .call(BlockchainWriteRequest::WriteBlock( VerifiedBlockInformation { block_blob: genesis.serialize(), @@ -72,7 +72,7 @@ pub async fn check_add_genesis( }, )) .await - .unwrap(); + .expect(PANIC_CRITICAL_SERVICE_ERROR); } /// Initializes the consensus services. @@ -85,7 +85,7 @@ pub async fn init_consensus( ConcreteTxVerifierService, BlockChainContextService, ), - tower::BoxError, + BoxError, > { let read_handle = ConsensusBlockchainReadHandle::new(blockchain_read_handle, BoxError::from); diff --git a/binaries/cuprated/src/blockchain/interface.rs b/binaries/cuprated/src/blockchain/interface.rs index 18376f39..189828e9 100644 --- a/binaries/cuprated/src/blockchain/interface.rs +++ b/binaries/cuprated/src/blockchain/interface.rs @@ -1,6 +1,6 @@ //! The blockchain manger interface. //! -//! This module contains all the functions to mutate the blockchains state in any way, through the +//! This module contains all the functions to mutate the blockchain's state in any way, through the //! blockchain manger. use std::{ collections::{HashMap, HashSet}, @@ -28,6 +28,10 @@ use crate::{ pub static COMMAND_TX: OnceLock> = OnceLock::new(); /// A [`HashSet`] of block hashes that the blockchain manager is currently handling. +/// +/// This is used over something like a dashmap as we expect a lot of collisions in a short amount of +/// time for new blocks so we would lose the benefit of sharded locks. A dashmap is made up of `RwLocks` +/// which are also more expensive than `Mutex`s. pub static BLOCKS_BEING_HANDLED: OnceLock>> = OnceLock::new(); /// An error that can be returned from [`handle_incoming_block`]. @@ -90,7 +94,7 @@ pub async fn handle_incoming_block( )); } - // TODO: check we actually go given the right txs. + // TODO: check we actually got given the right txs. let prepped_txs = given_txs .into_par_iter() .map(|tx| { diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index 2d3c1798..8725aeca 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -49,9 +49,10 @@ pub async fn init_blockchain_manger( block_verifier_service: ConcreteBlockVerifierService, block_downloader_config: BlockDownloaderConfig, ) { + // TODO: find good values for these size limits let (batch_tx, batch_rx) = mpsc::channel(1); let stop_current_block_downloader = Arc::new(Notify::new()); - let (command_tx, command_rx) = mpsc::channel(1); + let (command_tx, command_rx) = mpsc::channel(3); COMMAND_TX.set(command_tx).unwrap(); @@ -60,7 +61,7 @@ pub async fn init_blockchain_manger( ChainService(blockchain_read_handle.clone()), clearnet_interface.clone(), batch_tx, - stop_current_block_downloader.clone(), + Arc::clone(&stop_current_block_downloader), block_downloader_config, )); diff --git a/binaries/cuprated/src/blockchain/manager/commands.rs b/binaries/cuprated/src/blockchain/manager/commands.rs index 800144f0..a8d84733 100644 --- a/binaries/cuprated/src/blockchain/manager/commands.rs +++ b/binaries/cuprated/src/blockchain/manager/commands.rs @@ -1,3 +1,4 @@ +//! This module contains the commands for th blockchain manager. use std::collections::HashMap; use monero_serai::block::Block; @@ -5,10 +6,15 @@ use tokio::sync::oneshot; use cuprate_types::TransactionVerificationData; +/// The blockchain manager commands. pub enum BlockchainManagerCommand { + /// Attempt to add a new block to the blockchain. AddBlock { + /// The [`Block`] to add. block: Block, + /// All the transactions defined in [`Block::transactions`]. prepped_txs: HashMap<[u8; 32], TransactionVerificationData>, + /// The channel to send the response down. response_tx: oneshot::Sender>, }, } diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs index 4406421f..14073062 100644 --- a/binaries/cuprated/src/blockchain/manager/handler.rs +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -1,3 +1,4 @@ +//! The blockchain manger handler functions. use std::{collections::HashMap, sync::Arc}; use bytes::Bytes; @@ -67,7 +68,7 @@ impl super::BlockchainManager { /// Otherwise, this function will validate and add the block to the main chain. /// /// On success returns a [`bool`] indicating if the block was added to the main chain ([`true`]) - /// of an alt-chain ([`false`]). + /// or an alt-chain ([`false`]). pub async fn handle_incoming_block( &mut self, block: Block, @@ -373,7 +374,7 @@ impl super::BlockchainManager { /// /// This function assumes the first [`AltBlockInformation`] is the next block in the blockchain /// for the blockchain database and the context cache, or in other words that the blockchain database - /// and context cache has had the top blocks popped to where the alt-chain meets the main-chain. + /// and context cache have already had the top blocks popped to where the alt-chain meets the main-chain. /// /// # Errors /// diff --git a/binaries/cuprated/src/blockchain/syncer.rs b/binaries/cuprated/src/blockchain/syncer.rs index c772b128..8c58c54e 100644 --- a/binaries/cuprated/src/blockchain/syncer.rs +++ b/binaries/cuprated/src/blockchain/syncer.rs @@ -1,3 +1,4 @@ +// FIXME: This whole module is not great and should be rewritten when the PeerSet is made. use std::{pin::pin, sync::Arc, time::Duration}; use futures::StreamExt; @@ -16,7 +17,6 @@ use cuprate_p2p::{ }; use cuprate_p2p_core::ClearNet; -// FIXME: This whole module is not great and should be rewritten when the PeerSet is made. const CHECK_SYNC_FREQUENCY: Duration = Duration::from_secs(30); /// An error returned from the [`syncer`]. @@ -28,6 +28,11 @@ pub enum SyncerError { ServiceError(#[from] tower::BoxError), } +/// The syncer tasks that makes sure we are fully synchronised with our connected peers. +#[expect( + clippy::significant_drop_tightening, + reason = "Client pool which will be removed" +)] #[instrument(level = "debug", skip_all)] pub async fn syncer( mut context_svc: C, @@ -89,7 +94,7 @@ where loop { tokio::select! { - _ = stop_current_block_downloader.notified() => { + () = stop_current_block_downloader.notified() => { tracing::info!("Stopping block downloader"); break; } @@ -104,6 +109,7 @@ where } } +/// Checks if we should update the given [`BlockChainContext`] and updates it if needed. async fn check_update_blockchain_context( context_svc: C, old_context: &mut BlockChainContext, diff --git a/binaries/cuprated/src/config.rs b/binaries/cuprated/src/config.rs index c71c40c8..d613c1fc 100644 --- a/binaries/cuprated/src/config.rs +++ b/binaries/cuprated/src/config.rs @@ -1,62 +1 @@ //! cuprated config -use std::time::Duration; - -use cuprate_blockchain::config::{ - Config as BlockchainConfig, ConfigBuilder as BlockchainConfigBuilder, -}; -use cuprate_consensus::ContextConfig; -use cuprate_p2p::{block_downloader::BlockDownloaderConfig, AddressBookConfig, P2PConfig}; -use cuprate_p2p_core::{ClearNet, Network}; - -pub fn config() -> CupratedConfig { - // TODO: read config options from the conf files & cli args. - - CupratedConfig {} -} - -pub struct CupratedConfig { - // TODO: expose config options we want to allow changing. -} - -impl CupratedConfig { - pub fn blockchain_config(&self) -> BlockchainConfig { - BlockchainConfigBuilder::new().fast().build() - } - - pub fn clearnet_config(&self) -> P2PConfig { - P2PConfig { - network: Network::Mainnet, - outbound_connections: 64, - extra_outbound_connections: 0, - max_inbound_connections: 0, - gray_peers_percent: 0.7, - server_config: None, - p2p_port: 0, - rpc_port: 0, - address_book_config: AddressBookConfig { - max_white_list_length: 1000, - max_gray_list_length: 5000, - peer_store_file: "p2p_state.bin".into(), - peer_save_period: Duration::from_secs(60), - }, - } - } - - 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(45), - target_batch_size: 10_000_000, - initial_batch_size: 1, - } - } - - pub fn network(&self) -> Network { - Network::Mainnet - } - - pub fn context_config(&self) -> ContextConfig { - ContextConfig::main_net() - } -} diff --git a/binaries/cuprated/src/p2p.rs b/binaries/cuprated/src/p2p.rs index 7715be7c..f55d41db 100644 --- a/binaries/cuprated/src/p2p.rs +++ b/binaries/cuprated/src/p2p.rs @@ -2,5 +2,4 @@ //! //! Will handle initiating the P2P and contains a protocol request handler. -pub mod core_sync_svc; pub mod request_handler; diff --git a/binaries/cuprated/src/p2p/core_sync_svc.rs b/binaries/cuprated/src/p2p/core_sync_svc.rs deleted file mode 100644 index 34c91e47..00000000 --- a/binaries/cuprated/src/p2p/core_sync_svc.rs +++ /dev/null @@ -1,51 +0,0 @@ -use cuprate_blockchain::cuprate_database::RuntimeError; -use cuprate_blockchain::service::BlockchainReadHandle; -use cuprate_consensus::{ - BlockChainContextRequest, BlockChainContextResponse, BlockChainContextService, -}; -use cuprate_p2p_core::services::{CoreSyncDataRequest, CoreSyncDataResponse}; -use cuprate_p2p_core::CoreSyncData; -use cuprate_types::blockchain::BlockchainReadRequest; -use futures::future::{BoxFuture, MapErr, MapOk}; -use futures::{FutureExt, TryFutureExt}; -use std::task::{Context, Poll}; -use tower::Service; - -#[derive(Clone)] -pub struct CoreSyncService(pub BlockChainContextService); - -impl Service for CoreSyncService { - type Response = CoreSyncDataResponse; - type Error = tower::BoxError; - type Future = MapOk< - >::Future, - fn(BlockChainContextResponse) -> CoreSyncDataResponse, - >; - - fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { - self.0.poll_ready(cx) - } - - fn call(&mut self, _: CoreSyncDataRequest) -> Self::Future { - self.0 - .call(BlockChainContextRequest::GetContext) - .map_ok(|res| { - let BlockChainContextResponse::Context(ctx) = res else { - panic!("blockchain context service returned wrong response."); - }; - - let raw_ctx = ctx.unchecked_blockchain_context(); - - // TODO: the hardfork here should be the version of the top block not the current HF, - // on HF boundaries these will be different. - CoreSyncDataResponse(CoreSyncData::new( - raw_ctx.cumulative_difficulty, - // TODO: - raw_ctx.chain_height as u64, - 0, - raw_ctx.top_hash, - raw_ctx.current_hf.as_u8(), - )) - }) - } -} diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index 419c3b42..8b137891 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -1,205 +1 @@ -use bytes::Bytes; -use cuprate_p2p_core::{NetworkZone, ProtocolRequest, ProtocolResponse}; -use futures::future::BoxFuture; -use futures::FutureExt; -use monero_serai::block::Block; -use monero_serai::transaction::Transaction; -use rayon::prelude::*; -use std::task::{Context, Poll}; -use tower::{Service, ServiceExt}; -use tracing::trace; -use crate::blockchain::{handle_incoming_block, IncomingBlockError}; -use cuprate_blockchain::service::BlockchainReadHandle; -use cuprate_consensus::transactions::new_tx_verification_data; -use cuprate_fixed_bytes::ByteArray; -use cuprate_helper::asynch::rayon_spawn_async; -use cuprate_helper::cast::usize_to_u64; -use cuprate_helper::map::split_u128_into_low_high_bits; -use cuprate_p2p::constants::MAX_BLOCK_BATCH_LEN; -use cuprate_p2p_core::client::PeerInformation; -use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; -use cuprate_types::BlockCompleteEntry; -use cuprate_wire::protocol::{ - ChainRequest, ChainResponse, FluffyMissingTransactionsRequest, GetObjectsRequest, - GetObjectsResponse, NewFluffyBlock, -}; - -#[derive(Clone)] -pub struct P2pProtocolRequestHandlerMaker { - pub blockchain_read_handle: BlockchainReadHandle, -} - -impl Service> for P2pProtocolRequestHandlerMaker { - type Response = P2pProtocolRequestHandler; - type Error = tower::BoxError; - type Future = BoxFuture<'static, Result>; - - fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { - Poll::Ready(Ok(())) - } - - fn call(&mut self, peer_information: PeerInformation) -> Self::Future { - // TODO: check peer info. - - let blockchain_read_handle = self.blockchain_read_handle.clone(); - - async { - Ok(P2pProtocolRequestHandler { - peer_information, - blockchain_read_handle, - }) - } - .boxed() - } -} - -#[derive(Clone)] -pub struct P2pProtocolRequestHandler { - peer_information: PeerInformation, - blockchain_read_handle: BlockchainReadHandle, -} - -impl Service for P2pProtocolRequestHandler { - type Response = ProtocolResponse; - type Error = tower::BoxError; - type Future = BoxFuture<'static, Result>; - - fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { - Poll::Ready(Ok(())) - } - - fn call(&mut self, _: ProtocolRequest) -> Self::Future { - async { Ok(ProtocolResponse::NA) }.boxed() - } -} - -async fn get_objects( - blockchain_read_handle: BlockchainReadHandle, - req: GetObjectsRequest, -) -> Result { - if req.blocks.is_empty() { - Err("No blocks requested in a GetObjectsRequest")?; - } - - if req.blocks.len() > MAX_BLOCK_BATCH_LEN { - Err("Too many blocks requested in a GetObjectsRequest")?; - } - - let block_ids: Vec<[u8; 32]> = (&req.blocks).into(); - // de-allocate the backing [`Bytes`] - drop(req); - - Ok(ProtocolResponse::NA) - /* - - let res = blockchain_read_handle - .oneshot(BlockchainReadRequest::BlockCompleteEntries(block_ids)) - .await?; - - let BlockchainResponse::BlockCompleteEntries { - blocks, - missed_ids, - current_blockchain_height, - } = res - else { - panic!("Blockchain service returned wrong response!"); - }; - - Ok(ProtocolResponse::GetObjects(GetObjectsResponse { - blocks, - missed_ids: missed_ids.into(), - current_blockchain_height: usize_to_u64(current_blockchain_height), - })) - - */ -} - -async fn get_chain( - blockchain_read_handle: BlockchainReadHandle, - req: ChainRequest, -) -> Result { - if req.block_ids.is_empty() { - Err("No block hashes sent in a `ChainRequest`")?; - } - - Ok(ProtocolResponse::NA) - - /* - if req.block_ids.len() > MAX_BLOCKCHAIN_SUPPLEMENT_LEN { - Err("Too many block hashes in a `ChainRequest`")?; - } - - let block_ids: Vec<[u8; 32]> = (&req.block_ids).into(); - // de-allocate the backing [`Bytes`] - drop(req); - - let res = blockchain_read_handle - .oneshot(BlockchainReadRequest::NextMissingChainEntry(block_ids)) - .await?; - - let BlockchainResponse::NextMissingChainEntry { - next_entry, - first_missing_block, - start_height, - chain_height, - cumulative_difficulty, - } = res - else { - panic!("Blockchain service returned wrong response!"); - }; - - let (cumulative_difficulty_low64, cumulative_difficulty_top64) = - split_u128_into_low_high_bits(cumulative_difficulty); - - Ok(ProtocolResponse::GetChain(ChainResponse { - start_height: usize_to_u64(start_height), - total_height: usize_to_u64(chain_height), - cumulative_difficulty_low64, - cumulative_difficulty_top64, - m_block_ids: next_entry.into(), - m_block_weights: vec![], - first_block: first_missing_block.map_or(Bytes::new(), Bytes::from), - })) - - */ -} - -async fn new_fluffy_block( - mut blockchain_read_handle: BlockchainReadHandle, - incoming_block: NewFluffyBlock, -) -> Result { - let peer_blockchain_height = incoming_block.current_blockchain_height; - - let (block, txs) = rayon_spawn_async(move || { - let block = Block::read(&mut incoming_block.b.block.as_ref())?; - let txs = incoming_block - .b - .txs - .take_normal() - .expect("TODO") - .into_par_iter() - .map(|tx| { - let tx = Transaction::read(&mut tx.as_ref())?; - Ok(tx) - }) - .collect::>()?; - - Ok::<_, tower::BoxError>((block, txs)) - }) - .await?; - - let res = handle_incoming_block(block, txs, &mut blockchain_read_handle).await; - - match res { - Err(IncomingBlockError::UnknownTransactions(block_hash, tx_indexes)) => Ok( - ProtocolResponse::FluffyMissingTxs(FluffyMissingTransactionsRequest { - block_hash: ByteArray::from(block_hash), - current_blockchain_height: peer_blockchain_height, - missing_tx_indices: tx_indexes, - }), - ), - Err(IncomingBlockError::InvalidBlock(e)) => Err(e)?, - Err(IncomingBlockError::Orphan) | Ok(_) => Ok(ProtocolResponse::NA), - } -} diff --git a/binaries/cuprated/src/rpc/request_handler.rs b/binaries/cuprated/src/rpc/request_handler.rs deleted file mode 100644 index 8b137891..00000000 --- a/binaries/cuprated/src/rpc/request_handler.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/consensus/src/block.rs b/consensus/src/block.rs index 53eb1469..ada46aa4 100644 --- a/consensus/src/block.rs +++ b/consensus/src/block.rs @@ -181,6 +181,7 @@ impl PreparedBlock { }) } + /// Creates a new [`PreparedBlock`] from an [`AltBlockInformation`]. pub fn new_alt_block(block: AltBlockInformation) -> Result { Ok(Self { block_blob: block.block_blob, diff --git a/helper/src/tx_utils.rs b/helper/src/tx_utils.rs deleted file mode 100644 index aeccf32b..00000000 --- a/helper/src/tx_utils.rs +++ /dev/null @@ -1,34 +0,0 @@ -//! Utils for working with [`Transaction`] - -use monero_serai::transaction::{Input, Transaction}; - -/// Calculates the fee of the [`Transaction`]. -/// -/// # Panics -/// This will panic if the inputs overflow or the transaction outputs too much, so should only -/// be used on known to be valid txs. -pub fn tx_fee(tx: &Transaction) -> u64 { - let mut fee = 0_u64; - - match &tx { - Transaction::V1 { prefix, .. } => { - for input in &prefix.inputs { - match input { - Input::Gen(_) => return 0, - Input::ToKey { amount, .. } => { - fee = fee.checked_add(amount.unwrap_or(0)).unwrap(); - } - } - } - - for output in &prefix.outputs { - fee.checked_sub(output.amount.unwrap_or(0)).unwrap(); - } - } - Transaction::V2 { proofs, .. } => { - fee = proofs.as_ref().unwrap().base.fee; - } - }; - - fee -} diff --git a/p2p/p2p-core/src/protocol.rs b/p2p/p2p-core/src/protocol.rs index cdb0c2f3..7d8d431b 100644 --- a/p2p/p2p-core/src/protocol.rs +++ b/p2p/p2p-core/src/protocol.rs @@ -116,7 +116,6 @@ pub enum ProtocolResponse { GetChain(ChainResponse), NewFluffyBlock(NewFluffyBlock), NewTransactions(NewTransactions), - FluffyMissingTxs(FluffyMissingTransactionsRequest), NA, } @@ -140,7 +139,6 @@ impl PeerResponse { ProtocolResponse::GetChain(_) => MessageID::GetChain, ProtocolResponse::NewFluffyBlock(_) => MessageID::NewBlock, ProtocolResponse::NewTransactions(_) => MessageID::NewFluffyBlock, - ProtocolResponse::FluffyMissingTxs(_) => MessageID::FluffyMissingTxs, ProtocolResponse::NA => return None, }, diff --git a/p2p/p2p-core/src/protocol/try_from.rs b/p2p/p2p-core/src/protocol/try_from.rs index b3c1ae3d..d3a7260f 100644 --- a/p2p/p2p-core/src/protocol/try_from.rs +++ b/p2p/p2p-core/src/protocol/try_from.rs @@ -71,7 +71,6 @@ impl TryFrom for ProtocolMessage { ProtocolResponse::NewFluffyBlock(val) => Self::NewFluffyBlock(val), ProtocolResponse::GetChain(val) => Self::ChainEntryResponse(val), ProtocolResponse::GetObjects(val) => Self::GetObjectsResponse(val), - ProtocolResponse::FluffyMissingTxs(val) => Self::FluffyMissingTransactionsRequest(val), ProtocolResponse::NA => return Err(MessageConversionError), }) } diff --git a/p2p/p2p/src/client_pool.rs b/p2p/p2p/src/client_pool.rs index 99981f0c..fc97fc1b 100644 --- a/p2p/p2p/src/client_pool.rs +++ b/p2p/p2p/src/client_pool.rs @@ -154,6 +154,8 @@ impl ClientPool { self.borrow_clients(&peers).collect() } + /// Checks all clients in the pool checking if any claim a higher cumulative difficulty than the + /// amount specified. pub fn contains_client_with_more_cumulative_difficulty( &self, cumulative_difficulty: u128, diff --git a/p2p/p2p/src/constants.rs b/p2p/p2p/src/constants.rs index f79bcbf0..f70d64c9 100644 --- a/p2p/p2p/src/constants.rs +++ b/p2p/p2p/src/constants.rs @@ -16,11 +16,10 @@ pub(crate) const MAX_SEED_CONNECTIONS: usize = 3; pub(crate) const OUTBOUND_CONNECTION_ATTEMPT_TIMEOUT: Duration = Duration::from_secs(5); /// The durations of a short ban. -#[cfg_attr(not(test), expect(dead_code))] -pub(crate) const SHORT_BAN: Duration = Duration::from_secs(60 * 10); +pub const SHORT_BAN: Duration = Duration::from_secs(60 * 10); /// The durations of a medium ban. -pub(crate) const MEDIUM_BAN: Duration = Duration::from_secs(60 * 60 * 24); +pub const MEDIUM_BAN: Duration = Duration::from_secs(60 * 60 * 24); /// The durations of a long ban. pub const LONG_BAN: Duration = Duration::from_secs(60 * 60 * 24 * 7); @@ -53,7 +52,7 @@ pub(crate) const INITIAL_CHAIN_REQUESTS_TO_SEND: usize = 3; /// The enforced maximum amount of blocks to request in a batch. /// /// Requesting more than this will cause the peer to disconnect and potentially lead to bans. -pub const MAX_BLOCK_BATCH_LEN: usize = 100; +pub(crate) const MAX_BLOCK_BATCH_LEN: usize = 100; /// The timeout that the block downloader will use for requests. pub(crate) const BLOCK_DOWNLOADER_REQUEST_TIMEOUT: Duration = Duration::from_secs(30); diff --git a/p2p/p2p/src/lib.rs b/p2p/p2p/src/lib.rs index ad082fc6..b3577a77 100644 --- a/p2p/p2p/src/lib.rs +++ b/p2p/p2p/src/lib.rs @@ -172,7 +172,7 @@ impl NetworkInterface { self.address_book.clone() } - /// TODO + /// Borrows the `ClientPool`, for access to connected peers. pub const fn client_pool(&self) -> &Arc> { &self.pool } From 6e8fbf04f633f4425fc606d6dc1d3c8f88410ff8 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 4 Oct 2024 02:45:42 +0100 Subject: [PATCH 41/72] add `get_objects` handler --- Cargo.lock | 1 + binaries/cuprated/src/p2p/request_handler.rs | 106 +++++++++++++++++++ p2p/p2p/src/constants.rs | 2 +- storage/blockchain/Cargo.toml | 1 + storage/blockchain/src/ops/block.rs | 62 ++++++++++- storage/blockchain/src/service/read.rs | 38 ++++++- types/src/blockchain.rs | 10 +- 7 files changed, 214 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dd303bf6..8ba7ed84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -547,6 +547,7 @@ version = "0.0.0" dependencies = [ "bitflags 2.6.0", "bytemuck", + "bytes", "cuprate-database", "cuprate-database-service", "cuprate-helper", diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index 8b137891..818700d7 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -1 +1,107 @@ +use std::{ + future::{ready, Ready}, + task::{Context, Poll}, +}; +use futures::future::BoxFuture; +use futures::FutureExt; +use tower::{Service, ServiceExt}; + +use cuprate_blockchain::service::BlockchainReadHandle; +use cuprate_consensus::BlockChainContextService; +use cuprate_fixed_bytes::ByteArrayVec; +use cuprate_p2p::constants::MAX_BLOCK_BATCH_LEN; +use cuprate_p2p_core::{client::PeerInformation, NetworkZone, ProtocolRequest, ProtocolResponse}; +use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; +use cuprate_wire::protocol::{GetObjectsRequest, GetObjectsResponse}; + +#[derive(Clone)] +pub struct P2pProtocolRequestHandlerMaker { + pub blockchain_read_handle: BlockchainReadHandle, +} + +impl Service> for P2pProtocolRequestHandlerMaker { + type Response = P2pProtocolRequestHandler; + type Error = tower::BoxError; + type Future = Ready>; + + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { + Poll::Ready(Ok(())) + } + + fn call(&mut self, peer_information: PeerInformation) -> Self::Future { + // TODO: check sync info? + + let blockchain_read_handle = self.blockchain_read_handle.clone(); + + ready(Ok(P2pProtocolRequestHandler { + peer_information, + blockchain_read_handle, + })) + } +} + +#[derive(Clone)] +pub struct P2pProtocolRequestHandler { + peer_information: PeerInformation, + blockchain_read_handle: BlockchainReadHandle, +} + +impl Service for P2pProtocolRequestHandler { + type Response = ProtocolResponse; + type Error = anyhow::Error; + type Future = BoxFuture<'static, Result>; + + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { + Poll::Ready(Ok(())) + } + + fn call(&mut self, request: ProtocolRequest) -> Self::Future { + match request { + ProtocolRequest::GetObjects(r) => { + get_objects(r, self.blockchain_read_handle.clone()).boxed() + } + ProtocolRequest::GetChain(_) => todo!(), + ProtocolRequest::FluffyMissingTxs(_) => todo!(), + ProtocolRequest::GetTxPoolCompliment(_) => todo!(), + ProtocolRequest::NewBlock(_) => todo!(), + ProtocolRequest::NewFluffyBlock(_) => todo!(), + ProtocolRequest::NewTransactions(_) => todo!(), + } + } +} + +//---------------------------------------------------------------------------------------------------- Handler functions + +/// [`ProtocolRequest::GetObjects`] +async fn get_objects( + request: GetObjectsRequest, + mut blockchain_read_handle: BlockchainReadHandle, +) -> anyhow::Result { + if request.blocks.len() > MAX_BLOCK_BATCH_LEN { + anyhow::bail!("Peer requested more blocks than allowed.") + } + + let block_ids: Vec<[u8; 32]> = (&request.blocks).into(); + // de-allocate the backing `Bytes`. + drop(request); + + let BlockchainResponse::BlockCompleteEntries { + blocks, + missing_hashes, + blockchain_height, + } = blockchain_read_handle + .ready() + .await? + .call(BlockchainReadRequest::BlockCompleteEntries(block_ids)) + .await? + else { + panic!("blockchain returned wrong response!"); + }; + + Ok(ProtocolResponse::GetObjects(GetObjectsResponse { + blocks, + missed_ids: ByteArrayVec::from(missing_hashes), + current_blockchain_height, + })) +} diff --git a/p2p/p2p/src/constants.rs b/p2p/p2p/src/constants.rs index f70d64c9..d1060aea 100644 --- a/p2p/p2p/src/constants.rs +++ b/p2p/p2p/src/constants.rs @@ -52,7 +52,7 @@ pub(crate) const INITIAL_CHAIN_REQUESTS_TO_SEND: usize = 3; /// The enforced maximum amount of blocks to request in a batch. /// /// Requesting more than this will cause the peer to disconnect and potentially lead to bans. -pub(crate) const MAX_BLOCK_BATCH_LEN: usize = 100; +pub const MAX_BLOCK_BATCH_LEN: usize = 100; /// The timeout that the block downloader will use for requests. pub(crate) const BLOCK_DOWNLOADER_REQUEST_TIMEOUT: Duration = Duration::from_secs(30); diff --git a/storage/blockchain/Cargo.toml b/storage/blockchain/Cargo.toml index 6eecb892..073b4184 100644 --- a/storage/blockchain/Cargo.toml +++ b/storage/blockchain/Cargo.toml @@ -35,6 +35,7 @@ serde = { workspace = true, optional = true } tower = { workspace = true } thread_local = { workspace = true, optional = true } rayon = { workspace = true, optional = true } +bytes = "1.7.2" [dev-dependencies] cuprate-helper = { path = "../../helper", features = ["thread", "cast"] } diff --git a/storage/blockchain/src/ops/block.rs b/storage/blockchain/src/ops/block.rs index 6d32fd81..d038d1a1 100644 --- a/storage/blockchain/src/ops/block.rs +++ b/storage/blockchain/src/ops/block.rs @@ -1,7 +1,9 @@ //! Block functions. +use std::slice; //---------------------------------------------------------------------------------------------------- Import use bytemuck::TransparentWrapper; +use bytes::{Bytes, BytesMut}; use monero_serai::{ block::{Block, BlockHeader}, transaction::Transaction, @@ -10,15 +12,17 @@ use monero_serai::{ use cuprate_database::{ RuntimeError, StorableVec, {DatabaseRo, DatabaseRw}, }; +use cuprate_helper::cast::usize_to_u64; use cuprate_helper::{ map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}, tx::tx_fee, }; use cuprate_types::{ - AltBlockInformation, ChainId, ExtendedBlockHeader, HardFork, VerifiedBlockInformation, - VerifiedTransactionInformation, + AltBlockInformation, BlockCompleteEntry, ChainId, ExtendedBlockHeader, HardFork, + TransactionBlobs, VerifiedBlockInformation, VerifiedTransactionInformation, }; +use crate::tables::TablesIter; use crate::{ ops::{ alt_block, @@ -224,6 +228,60 @@ pub fn pop_block( Ok((block_height, block_info.block_hash, block)) } +//---------------------------------------------------------------------------------------------------- `get_block_blob_with_tx_indexes` +pub fn get_block_blob_with_tx_indexes( + block_height: &BlockHeight, + tables: &impl Tables, +) -> Result<(Vec, u64, usize), RuntimeError> { + use monero_serai::io::write_varint; + + let block_info = tables.block_infos().get(&block_height)?; + + let miner_tx_idx = block_info.mining_tx_index; + let mut block_txs = tables.block_txs_hashes().get(&block_height)?.0; + let numb_txs = block_txs.len(); + + // Get the block header + let mut block = tables.block_header_blobs().get(&block_height)?.0; + + // Add the miner tx to the blob. + let mut miner_tx_blob = tables.tx_blobs().get(&miner_tx_idx)?.0; + block.append(&mut miner_tx_blob); + + // Add the blocks tx hashes. + write_varint(&block_txs.len(), &mut block) + .expect("The number of txs per block will not exceed u64::MAX"); + for tx in block_txs { + block.extend_from_slice(&tx); + } + + Ok((block, miner_tx_idx, numb_txs)) +} + +//---------------------------------------------------------------------------------------------------- `get_block_extended_header_*` +pub fn get_block_complete_entry( + block_hash: &BlockHash, + tables: &impl TablesIter, +) -> Result { + let block_height = tables.block_heights().get(block_hash)?; + let (block_blob, miner_tx_idx, numb_non_miner_txs) = + get_block_blob_with_tx_indexes(&block_height, tables)?; + + let first_tx_idx = miner_tx_idx + 1; + + let tx_blobs = tables + .tx_blobs_iter() + .get_range(first_tx_idx..=usize_to_u64(numb_non_miner_txs))? + .map(|tx_blob| Ok(Bytes::from(tx_blob?.0))) + .collect::>()?; + + Ok(BlockCompleteEntry { + block: Bytes::from(block_blob), + txs: TransactionBlobs::Normal(tx_blobs), + pruned: false, + block_weight: 0, + }) +} //---------------------------------------------------------------------------------------------------- `get_block_extended_header_*` /// Retrieve a [`ExtendedBlockHeader`] from the database. diff --git a/storage/blockchain/src/service/read.rs b/storage/blockchain/src/service/read.rs index b0e7e044..17151351 100644 --- a/storage/blockchain/src/service/read.rs +++ b/storage/blockchain/src/service/read.rs @@ -7,7 +7,7 @@ use std::{ }; use rayon::{ - iter::{IntoParallelIterator, ParallelIterator}, + iter::{IntoParallelIterator, ParallelIterator, Either}, prelude::*, ThreadPool, }; @@ -18,9 +18,10 @@ use cuprate_database_service::{init_thread_pool, DatabaseReadService, ReaderThre use cuprate_helper::map::combine_low_high_bits_to_u128; use cuprate_types::{ blockchain::{BlockchainReadRequest, BlockchainResponse}, - Chain, ChainId, ExtendedBlockHeader, OutputOnChain, + BlockCompleteEntry, Chain, ChainId, ExtendedBlockHeader, OutputOnChain, }; +use crate::ops::block::get_block_complete_entry; use crate::{ ops::{ alt_block::{ @@ -92,6 +93,7 @@ fn map_request( /* SOMEDAY: pre-request handling, run some code for each request? */ match request { + R::BlockCompleteEntries(block_hashes) => block_complete_entries(env, block_hashes), R::BlockExtendedHeader(block) => block_extended_header(env, block), R::BlockHash(block, chain) => block_hash(env, block, chain), R::FindBlock(block_hash) => find_block(env, block_hash), @@ -182,6 +184,38 @@ macro_rules! get_tables { // TODO: The overhead of parallelism may be too much for every request, perfomace test to find optimal // amount of parallelism. +/// [`BlockchainReadRequest::BlockCompleteEntries`]. +fn block_complete_entries(env: &ConcreteEnv, block_hashes: Vec) -> ResponseResult { + // Prepare tx/tables in `ThreadLocal`. + let env_inner = env.env_inner(); + let tx_ro = thread_local(env); + let tables = thread_local(env); + + let (missing_hashes, blocks) = block_hashes + .into_par_iter() + .map(|block_hash| { + let tx_ro = tx_ro.get_or_try(|| env_inner.tx_ro())?; + let tables = get_tables!(env_inner, tx_ro, tables)?.as_ref(); + + match get_block_complete_entry(&block_hash, tables) { + Err(RuntimeError::KeyNotFound) => Ok(Either::Left(block_hash)), + res => res.map(Either::Right), + } + }) + .collect::>()?; + + let tx_ro = tx_ro.get_or_try(|| env_inner.tx_ro())?; + let tables = get_tables!(env_inner, tx_ro, tables)?.as_ref(); + + let blockchain_height = crate::ops::blockchain::chain_height(tables.block_heights())?; + + Ok(BlockchainResponse::BlockCompleteEntries { + blocks, + missing_hashes, + blockchain_height, + }) +} + /// [`BlockchainReadRequest::BlockExtendedHeader`]. #[inline] fn block_extended_header(env: &ConcreteEnv, block_height: BlockHeight) -> ResponseResult { diff --git a/types/src/blockchain.rs b/types/src/blockchain.rs index f2b96db0..11127057 100644 --- a/types/src/blockchain.rs +++ b/types/src/blockchain.rs @@ -10,7 +10,7 @@ use std::{ use crate::{ types::{Chain, ExtendedBlockHeader, OutputOnChain, VerifiedBlockInformation}, - AltBlockInformation, ChainId, + AltBlockInformation, BlockCompleteEntry, ChainId, }; //---------------------------------------------------------------------------------------------------- ReadRequest @@ -24,6 +24,8 @@ use crate::{ /// See `Response` for the expected responses per `Request`. #[derive(Debug, Clone, PartialEq, Eq)] pub enum BlockchainReadRequest { + BlockCompleteEntries(Vec<[u8; 32]>), + /// Request a block's extended header. /// /// The input is the block's height. @@ -149,6 +151,12 @@ pub enum BlockchainWriteRequest { #[derive(Debug, Clone, PartialEq, Eq)] pub enum BlockchainResponse { //------------------------------------------------------ Reads + BlockCompleteEntries { + blocks: Vec, + missing_hashes: Vec<[u8; 32]>, + blockchain_height: usize, + }, + /// Response to [`BlockchainReadRequest::BlockExtendedHeader`]. /// /// Inner value is the extended headed of the requested block. From f158f869b453b4403805a9186d88cc45a21195d9 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 4 Oct 2024 17:21:57 +0100 Subject: [PATCH 42/72] add `get_chain` handler --- binaries/cuprated/src/p2p/request_handler.rs | 59 ++++++++++- storage/blockchain/src/ops/block.rs | 16 ++- storage/blockchain/src/ops/blockchain.rs | 41 ++++++++ storage/blockchain/src/service/read.rs | 105 ++++++++++++++----- types/src/blockchain.rs | 22 ++++ 5 files changed, 205 insertions(+), 38 deletions(-) diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index 818700d7..a109ae1b 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -10,10 +10,12 @@ use tower::{Service, ServiceExt}; use cuprate_blockchain::service::BlockchainReadHandle; use cuprate_consensus::BlockChainContextService; use cuprate_fixed_bytes::ByteArrayVec; +use cuprate_helper::cast::usize_to_u64; +use cuprate_helper::map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}; use cuprate_p2p::constants::MAX_BLOCK_BATCH_LEN; use cuprate_p2p_core::{client::PeerInformation, NetworkZone, ProtocolRequest, ProtocolResponse}; use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; -use cuprate_wire::protocol::{GetObjectsRequest, GetObjectsResponse}; +use cuprate_wire::protocol::{ChainRequest, ChainResponse, GetObjectsRequest, GetObjectsResponse}; #[derive(Clone)] pub struct P2pProtocolRequestHandlerMaker { @@ -82,7 +84,7 @@ async fn get_objects( anyhow::bail!("Peer requested more blocks than allowed.") } - let block_ids: Vec<[u8; 32]> = (&request.blocks).into(); + let block_hashes: Vec<[u8; 32]> = (&request.blocks).into(); // de-allocate the backing `Bytes`. drop(request); @@ -93,7 +95,7 @@ async fn get_objects( } = blockchain_read_handle .ready() .await? - .call(BlockchainReadRequest::BlockCompleteEntries(block_ids)) + .call(BlockchainReadRequest::BlockCompleteEntries(block_hashes)) .await? else { panic!("blockchain returned wrong response!"); @@ -102,6 +104,55 @@ async fn get_objects( Ok(ProtocolResponse::GetObjects(GetObjectsResponse { blocks, missed_ids: ByteArrayVec::from(missing_hashes), - current_blockchain_height, + current_blockchain_height: usize_to_u64(blockchain_height), + })) +} + +/// [`ProtocolRequest::GetChain`] +async fn get_chain( + request: ChainRequest, + mut blockchain_read_handle: BlockchainReadHandle, +) -> anyhow::Result { + if request.block_ids.len() > 25_000 { + anyhow::bail!("Peer sent too many block hashes in chain request.") + } + + let block_hashes: Vec<[u8; 32]> = (&request.block_ids).into(); + let want_pruned_data = request.prune; + // de-allocate the backing `Bytes`. + drop(request); + + let BlockchainResponse::NextChainEntry { + start_height, + chain_height, + block_ids, + block_weights, + cumulative_difficulty, + first_block_blob, + } = blockchain_read_handle + .ready() + .await? + .call(BlockchainReadRequest::NextChainEntry(block_hashes, 10_000)) + .await? + else { + panic!("blockchain returned wrong response!"); + }; + + let (cumulative_difficulty_low64, cumulative_difficulty_top64) = + split_u128_into_low_high_bits(cumulative_difficulty); + + Ok(ProtocolResponse::GetChain(ChainResponse { + start_height: usize_to_u64(start_height), + total_height: usize_to_u64(chain_height), + cumulative_difficulty_low64, + cumulative_difficulty_top64, + m_block_ids: ByteArrayVec::from(block_ids), + first_block: Default::default(), + // only needed when + m_block_weights: if want_pruned_data { + block_weights.into_iter().map(usize_to_u64).collect() + } else { + vec![] + }, })) } diff --git a/storage/blockchain/src/ops/block.rs b/storage/blockchain/src/ops/block.rs index d038d1a1..070a413c 100644 --- a/storage/blockchain/src/ops/block.rs +++ b/storage/blockchain/src/ops/block.rs @@ -1,16 +1,15 @@ //! Block functions. -use std::slice; //---------------------------------------------------------------------------------------------------- Import use bytemuck::TransparentWrapper; -use bytes::{Bytes, BytesMut}; +use bytes::Bytes; use monero_serai::{ block::{Block, BlockHeader}, transaction::Transaction, }; use cuprate_database::{ - RuntimeError, StorableVec, {DatabaseRo, DatabaseRw}, + RuntimeError, StorableVec, {DatabaseIter, DatabaseRo, DatabaseRw}, }; use cuprate_helper::cast::usize_to_u64; use cuprate_helper::{ @@ -22,7 +21,6 @@ use cuprate_types::{ TransactionBlobs, VerifiedBlockInformation, VerifiedTransactionInformation, }; -use crate::tables::TablesIter; use crate::{ ops::{ alt_block, @@ -31,7 +29,7 @@ use crate::{ output::get_rct_num_outputs, tx::{add_tx, remove_tx}, }, - tables::{BlockHeights, BlockInfos, Tables, TablesMut}, + tables::{BlockHeights, BlockInfos, Tables, TablesIter, TablesMut}, types::{BlockHash, BlockHeight, BlockInfo}, }; @@ -235,14 +233,14 @@ pub fn get_block_blob_with_tx_indexes( ) -> Result<(Vec, u64, usize), RuntimeError> { use monero_serai::io::write_varint; - let block_info = tables.block_infos().get(&block_height)?; + let block_info = tables.block_infos().get(block_height)?; let miner_tx_idx = block_info.mining_tx_index; - let mut block_txs = tables.block_txs_hashes().get(&block_height)?.0; + let block_txs = tables.block_txs_hashes().get(block_height)?.0; let numb_txs = block_txs.len(); // Get the block header - let mut block = tables.block_header_blobs().get(&block_height)?.0; + let mut block = tables.block_header_blobs().get(block_height)?.0; // Add the miner tx to the blob. let mut miner_tx_blob = tables.tx_blobs().get(&miner_tx_idx)?.0; @@ -273,7 +271,7 @@ pub fn get_block_complete_entry( .tx_blobs_iter() .get_range(first_tx_idx..=usize_to_u64(numb_non_miner_txs))? .map(|tx_blob| Ok(Bytes::from(tx_blob?.0))) - .collect::>()?; + .collect::>()?; Ok(BlockCompleteEntry { block: Bytes::from(block_blob), diff --git a/storage/blockchain/src/ops/blockchain.rs b/storage/blockchain/src/ops/blockchain.rs index 04f8b26d..664c0d0c 100644 --- a/storage/blockchain/src/ops/blockchain.rs +++ b/storage/blockchain/src/ops/blockchain.rs @@ -3,6 +3,8 @@ //---------------------------------------------------------------------------------------------------- Import use cuprate_database::{DatabaseRo, RuntimeError}; +use crate::ops::block::block_exists; +use crate::types::BlockHash; use crate::{ ops::macros::doc_error, tables::{BlockHeights, BlockInfos}, @@ -78,6 +80,45 @@ pub fn cumulative_generated_coins( } } +/// Find the split point between our chain and a list of [`BlockHash`]s from another chain. +/// +/// This function can be used accepts chains in chronological and reverse chronological order, however +/// if the wrong order is specified the return value is meaningless. +/// +/// For chronologically ordered chains this will return the index of the first unknown, for reverse +/// chronologically ordered chains this will return the index of the fist known. +/// +/// If all blocks are known for chronologically ordered chains or unknown for reverse chronologically +/// ordered chains then the length of the chain will be returned. +#[doc = doc_error!()] +#[inline] +pub fn find_split_point( + block_ids: &[BlockHash], + chronological_order: bool, + table_block_heights: &impl DatabaseRo, +) -> Result { + let mut err = None; + + // Do a binary search to find the first unknown block in the batch. + let idx = + block_ids.partition_point( + |block_id| match block_exists(block_id, table_block_heights) { + Ok(exists) => exists & chronological_order, + Err(e) => { + err.get_or_insert(e); + // if this happens the search is scrapped, just return `false` back. + false + } + }, + ); + + if let Some(e) = err { + return Err(e); + } + + Ok(idx) +} + //---------------------------------------------------------------------------------------------------- Tests #[cfg(test)] mod test { diff --git a/storage/blockchain/src/service/read.rs b/storage/blockchain/src/service/read.rs index 17151351..10bafc29 100644 --- a/storage/blockchain/src/service/read.rs +++ b/storage/blockchain/src/service/read.rs @@ -2,26 +2,26 @@ //---------------------------------------------------------------------------------------------------- Import use std::{ + cmp::min, collections::{HashMap, HashSet}, sync::Arc, }; use rayon::{ - iter::{IntoParallelIterator, ParallelIterator, Either}, + iter::{Either, IntoParallelIterator, ParallelIterator}, prelude::*, ThreadPool, }; use thread_local::ThreadLocal; -use cuprate_database::{ConcreteEnv, DatabaseRo, Env, EnvInner, RuntimeError}; +use cuprate_database::{ConcreteEnv, DatabaseIter, DatabaseRo, Env, EnvInner, RuntimeError}; use cuprate_database_service::{init_thread_pool, DatabaseReadService, ReaderThreads}; use cuprate_helper::map::combine_low_high_bits_to_u128; use cuprate_types::{ blockchain::{BlockchainReadRequest, BlockchainResponse}, - BlockCompleteEntry, Chain, ChainId, ExtendedBlockHeader, OutputOnChain, + Chain, ChainId, ExtendedBlockHeader, OutputOnChain, }; -use crate::ops::block::get_block_complete_entry; use crate::{ ops::{ alt_block::{ @@ -29,9 +29,10 @@ use crate::{ get_alt_chain_history_ranges, }, block::{ - block_exists, get_block_extended_header_from_height, get_block_height, get_block_info, + block_exists, get_block_blob_with_tx_indexes, get_block_complete_entry, + get_block_extended_header_from_height, get_block_height, get_block_info, }, - blockchain::{cumulative_generated_coins, top_block_height}, + blockchain::{cumulative_generated_coins, find_split_point, top_block_height}, key_image::key_image_exists, output::id_to_output_on_chain, }, @@ -39,7 +40,7 @@ use crate::{ free::{compact_history_genesis_not_included, compact_history_index_to_height_offset}, types::{BlockchainReadHandle, ResponseResult}, }, - tables::{AltBlockHeights, BlockHeights, BlockInfos, OpenTables, Tables}, + tables::{AltBlockHeights, BlockHeights, BlockInfos, OpenTables, Tables, TablesIter}, types::{ AltBlockHeight, Amount, AmountIndex, BlockHash, BlockHeight, KeyImage, PreRctOutputId, }, @@ -107,6 +108,7 @@ fn map_request( R::NumberOutputsWithAmount(vec) => number_outputs_with_amount(env, vec), R::KeyImagesSpent(set) => key_images_spent(env, set), R::CompactChainHistory => compact_chain_history(env), + R::NextChainEntry(block_hashes, amount) => next_chain_entry(env, &block_hashes, amount), R::FindFirstUnknown(block_ids) => find_first_unknown(env, &block_ids), R::AltBlocksInChain(chain_id) => alt_blocks_in_chain(env, chain_id), } @@ -552,6 +554,76 @@ fn compact_chain_history(env: &ConcreteEnv) -> ResponseResult { }) } +/// [`BlockchainReadRequest::NextChainEntry`] +/// +/// # Invariant +/// `block_ids` must be sorted in reverse chronological block order, or else +/// the returned result is unspecified and meaningless, as this function +/// performs a binary search. +fn next_chain_entry( + env: &ConcreteEnv, + block_ids: &[BlockHash], + next_entry_size: usize, +) -> ResponseResult { + // Single-threaded, no `ThreadLocal` required. + let env_inner = env.env_inner(); + let tx_ro = env_inner.tx_ro()?; + + let tables = env_inner.open_tables(&tx_ro)?; + let table_block_heights = tables.block_heights(); + let table_block_infos = tables.block_infos_iter(); + + let idx = find_split_point(block_ids, false, table_block_heights)?; + + // This will happen if we have a different genesis block. + if idx == block_ids.len() { + return Ok(BlockchainResponse::NextChainEntry { + start_height: 0, + chain_height: 0, + block_ids: vec![], + block_weights: vec![], + cumulative_difficulty: 0, + first_block_blob: None, + }); + } + + // The returned chain entry must overlap with one of the blocks we were told about. + let first_known_block_hash = block_ids[idx]; + let first_known_height = table_block_heights.get(&first_known_block_hash)?; + + let chain_height = crate::ops::blockchain::chain_height(table_block_heights)?; + let last_height_in_chain_entry = min(first_known_height + next_entry_size, chain_height); + + let (block_ids, block_weights) = table_block_infos + .get_range(first_known_height..last_height_in_chain_entry)? + .map(|block_info| { + let block_info = block_info?; + + Ok((block_info.block_hash, block_info.weight)) + }) + .collect::, Vec<_>), RuntimeError>>()?; + + let top_block_info = table_block_infos.get(&(chain_height - 1))?; + + let first_block_blob = if block_ids.len() >= 2 { + Some(get_block_blob_with_tx_indexes(&(first_known_height + 1), &tables)?.0) + } else { + None + }; + + Ok(BlockchainResponse::NextChainEntry { + start_height: first_known_height, + chain_height, + block_ids, + block_weights, + cumulative_difficulty: combine_low_high_bits_to_u128( + top_block_info.cumulative_difficulty_low, + top_block_info.cumulative_difficulty_high, + ), + first_block_blob, + }) +} + /// [`BlockchainReadRequest::FindFirstUnknown`] /// /// # Invariant @@ -564,24 +636,7 @@ fn find_first_unknown(env: &ConcreteEnv, block_ids: &[BlockHash]) -> ResponseRes let table_block_heights = env_inner.open_db_ro::(&tx_ro)?; - let mut err = None; - - // Do a binary search to find the first unknown block in the batch. - let idx = - block_ids.partition_point( - |block_id| match block_exists(block_id, &table_block_heights) { - Ok(exists) => exists, - Err(e) => { - err.get_or_insert(e); - // if this happens the search is scrapped, just return `false` back. - false - } - }, - ); - - if let Some(e) = err { - return Err(e); - } + let idx = find_split_point(block_ids, true, &table_block_heights)?; Ok(if idx == block_ids.len() { BlockchainResponse::FindFirstUnknown(None) diff --git a/types/src/blockchain.rs b/types/src/blockchain.rs index 11127057..526dc431 100644 --- a/types/src/blockchain.rs +++ b/types/src/blockchain.rs @@ -95,6 +95,16 @@ pub enum BlockchainReadRequest { /// A request for the compact chain history. CompactChainHistory, + /// A request for the next chain entry. + /// + /// Input is a list of block hashes and the amount of block hashes to return in the next chain entry. + /// + /// # Invariant + /// The [`Vec`] containing the block IDs must be sorted in reverse chronological block + /// order, or else the returned response is unspecified and meaningless, + /// as this request performs a binary search + NextChainEntry(Vec<[u8; 32]>, usize), + /// A request to find the first unknown block ID in a list of block IDs. /// /// # Invariant @@ -223,6 +233,18 @@ pub enum BlockchainResponse { cumulative_difficulty: u128, }, + /// Response to [`BlockchainReadRequest::NextChainEntry`]. + /// + /// If all blocks were unknown `start_height` will be `0`, the other fields will be meaningless. + NextChainEntry { + start_height: usize, + chain_height: usize, + block_ids: Vec<[u8; 32]>, + block_weights: Vec, + cumulative_difficulty: u128, + first_block_blob: Option>, + }, + /// The response for [`BlockchainReadRequest::FindFirstUnknown`]. /// /// Contains the index of the first unknown block and its expected height. From aa274ebafee8ca59f084d79f2c2d46b33d192fb8 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 4 Oct 2024 21:45:40 +0100 Subject: [PATCH 43/72] add `fluffy_missing_txs` handler --- Cargo.lock | 1 + binaries/cuprated/src/p2p/request_handler.rs | 76 +++++++++++++++++--- net/wire/src/p2p/protocol.rs | 2 +- storage/blockchain/src/service/read.rs | 49 ++++++++++--- types/src/blockchain.rs | 16 +++++ types/src/lib.rs | 2 +- types/src/types.rs | 6 ++ 7 files changed, 132 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6dcaba3a..e55debee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -548,6 +548,7 @@ version = "0.0.0" dependencies = [ "bitflags 2.6.0", "bytemuck", + "bytes", "cuprate-constants", "cuprate-database", "cuprate-database-service", diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index a109ae1b..3b94770a 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -1,10 +1,10 @@ +use bytes::Bytes; +use futures::future::BoxFuture; +use futures::FutureExt; use std::{ future::{ready, Ready}, task::{Context, Poll}, }; - -use futures::future::BoxFuture; -use futures::FutureExt; use tower::{Service, ServiceExt}; use cuprate_blockchain::service::BlockchainReadHandle; @@ -15,7 +15,11 @@ use cuprate_helper::map::{combine_low_high_bits_to_u128, split_u128_into_low_hig use cuprate_p2p::constants::MAX_BLOCK_BATCH_LEN; use cuprate_p2p_core::{client::PeerInformation, NetworkZone, ProtocolRequest, ProtocolResponse}; use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; -use cuprate_wire::protocol::{ChainRequest, ChainResponse, GetObjectsRequest, GetObjectsResponse}; +use cuprate_types::{BlockCompleteEntry, MissingTxsInBlock, TransactionBlobs}; +use cuprate_wire::protocol::{ + ChainRequest, ChainResponse, FluffyMissingTransactionsRequest, GetObjectsRequest, + GetObjectsResponse, NewFluffyBlock, +}; #[derive(Clone)] pub struct P2pProtocolRequestHandlerMaker { @@ -63,12 +67,20 @@ impl Service for P2pProtocolRequestHandler { ProtocolRequest::GetObjects(r) => { get_objects(r, self.blockchain_read_handle.clone()).boxed() } - ProtocolRequest::GetChain(_) => todo!(), - ProtocolRequest::FluffyMissingTxs(_) => todo!(), - ProtocolRequest::GetTxPoolCompliment(_) => todo!(), - ProtocolRequest::NewBlock(_) => todo!(), + ProtocolRequest::GetChain(r) => { + get_chain(r, self.blockchain_read_handle.clone()).boxed() + } + ProtocolRequest::FluffyMissingTxs(r) => { + fluffy_missing_txs(r, self.blockchain_read_handle.clone()).boxed() + } + ProtocolRequest::NewBlock(_) => ready(Err(anyhow::anyhow!( + "Peer sent a full block when we support fluffy blocks" + ))) + .boxed(), ProtocolRequest::NewFluffyBlock(_) => todo!(), - ProtocolRequest::NewTransactions(_) => todo!(), + ProtocolRequest::GetTxPoolCompliment(_) | ProtocolRequest::NewTransactions(_) => { + ready(Ok(ProtocolResponse::NA)).boxed() + } // TODO: tx-pool } } } @@ -138,6 +150,10 @@ async fn get_chain( panic!("blockchain returned wrong response!"); }; + if start_height == 0 { + anyhow::bail!("The peers chain has a different genesis block than ours."); + } + let (cumulative_difficulty_low64, cumulative_difficulty_top64) = split_u128_into_low_high_bits(cumulative_difficulty); @@ -147,7 +163,7 @@ async fn get_chain( cumulative_difficulty_low64, cumulative_difficulty_top64, m_block_ids: ByteArrayVec::from(block_ids), - first_block: Default::default(), + first_block: first_block_blob.map_or(Bytes::new(), Bytes::from), // only needed when m_block_weights: if want_pruned_data { block_weights.into_iter().map(usize_to_u64).collect() @@ -156,3 +172,43 @@ async fn get_chain( }, })) } + +/// [`ProtocolRequest::FluffyMissingTxs`] +async fn fluffy_missing_txs( + mut request: FluffyMissingTransactionsRequest, + mut blockchain_read_handle: BlockchainReadHandle, +) -> anyhow::Result { + let tx_indexes = std::mem::take(&mut request.missing_tx_indices); + let block_hash: [u8; 32] = *request.block_hash; + let current_blockchain_height = request.current_blockchain_height; + + // de-allocate the backing `Bytes`. + drop(request); + + let BlockchainResponse::MissingTxsInBlock(res) = blockchain_read_handle + .ready() + .await? + .call(BlockchainReadRequest::MissingTxsInBlock { + block_hash, + tx_indexes, + }) + .await? + else { + panic!("blockchain returned wrong response!"); + }; + + let Some(MissingTxsInBlock { block, txs }) = res else { + anyhow::bail!("The peer requested txs out of range."); + }; + + Ok(ProtocolResponse::NewFluffyBlock(NewFluffyBlock { + b: BlockCompleteEntry { + block: Bytes::from(block), + txs: TransactionBlobs::Normal(txs.into_iter().map(Bytes::from).collect()), + pruned: false, + // only needed for pruned blocks. + block_weight: 0, + }, + current_blockchain_height, + })) +} diff --git a/net/wire/src/p2p/protocol.rs b/net/wire/src/p2p/protocol.rs index 1d1d45ab..cc4b49d3 100644 --- a/net/wire/src/p2p/protocol.rs +++ b/net/wire/src/p2p/protocol.rs @@ -159,7 +159,7 @@ epee_object!( current_blockchain_height: u64, ); -/// A request for Txs we are missing from our `TxPool` +/// A request for txs we are missing from an incoming block. #[derive(Debug, Clone, PartialEq, Eq)] pub struct FluffyMissingTransactionsRequest { /// The Block we are missing the Txs in diff --git a/storage/blockchain/src/service/read.rs b/storage/blockchain/src/service/read.rs index 10bafc29..7edf789c 100644 --- a/storage/blockchain/src/service/read.rs +++ b/storage/blockchain/src/service/read.rs @@ -14,14 +14,6 @@ use rayon::{ }; use thread_local::ThreadLocal; -use cuprate_database::{ConcreteEnv, DatabaseIter, DatabaseRo, Env, EnvInner, RuntimeError}; -use cuprate_database_service::{init_thread_pool, DatabaseReadService, ReaderThreads}; -use cuprate_helper::map::combine_low_high_bits_to_u128; -use cuprate_types::{ - blockchain::{BlockchainReadRequest, BlockchainResponse}, - Chain, ChainId, ExtendedBlockHeader, OutputOnChain, -}; - use crate::{ ops::{ alt_block::{ @@ -45,6 +37,13 @@ use crate::{ AltBlockHeight, Amount, AmountIndex, BlockHash, BlockHeight, KeyImage, PreRctOutputId, }, }; +use cuprate_database::{ConcreteEnv, DatabaseIter, DatabaseRo, Env, EnvInner, RuntimeError}; +use cuprate_database_service::{init_thread_pool, DatabaseReadService, ReaderThreads}; +use cuprate_helper::map::combine_low_high_bits_to_u128; +use cuprate_types::{ + blockchain::{BlockchainReadRequest, BlockchainResponse}, + Chain, ChainId, ExtendedBlockHeader, MissingTxsInBlock, OutputOnChain, +}; //---------------------------------------------------------------------------------------------------- init_read_service /// Initialize the [`BlockchainReadHandle`] thread-pool backed by [`rayon`]. @@ -110,6 +109,10 @@ fn map_request( R::CompactChainHistory => compact_chain_history(env), R::NextChainEntry(block_hashes, amount) => next_chain_entry(env, &block_hashes, amount), R::FindFirstUnknown(block_ids) => find_first_unknown(env, &block_ids), + R::MissingTxsInBlock { + block_hash, + tx_indexes, + } => missing_txs_in_block(env, block_hash, tx_indexes), R::AltBlocksInChain(chain_id) => alt_blocks_in_chain(env, chain_id), } @@ -649,6 +652,36 @@ fn find_first_unknown(env: &ConcreteEnv, block_ids: &[BlockHash]) -> ResponseRes }) } +/// [`BlockchainReadRequest::MissingTxsInBlock`] +fn missing_txs_in_block( + env: &ConcreteEnv, + block_hash: [u8; 32], + missing_txs: Vec, +) -> ResponseResult { + // Single-threaded, no `ThreadLocal` required. + let env_inner = env.env_inner(); + let tx_ro = env_inner.tx_ro()?; + let tables = env_inner.open_tables(&tx_ro)?; + + let block_height = tables.block_heights().get(&block_hash)?; + + let (block, miner_tx_index, numb_txs) = get_block_blob_with_tx_indexes(&block_height, &tables)?; + let first_tx_index = miner_tx_index + 1; + + if numb_txs < missing_txs.len() { + return Ok(BlockchainResponse::MissingTxsInBlock(None)); + } + + let txs = missing_txs + .into_iter() + .map(|index_offset| Ok(tables.tx_blobs().get(&(first_tx_index + index_offset))?.0)) + .collect::>()?; + + Ok(BlockchainResponse::MissingTxsInBlock(Some( + MissingTxsInBlock { block, txs }, + ))) +} + /// [`BlockchainReadRequest::AltBlocksInChain`] fn alt_blocks_in_chain(env: &ConcreteEnv, chain_id: ChainId) -> ResponseResult { // Prepare tx/tables in `ThreadLocal`. diff --git a/types/src/blockchain.rs b/types/src/blockchain.rs index 526dc431..37a04f75 100644 --- a/types/src/blockchain.rs +++ b/types/src/blockchain.rs @@ -8,6 +8,7 @@ use std::{ ops::Range, }; +use crate::types::MissingTxsInBlock; use crate::{ types::{Chain, ExtendedBlockHeader, OutputOnChain, VerifiedBlockInformation}, AltBlockInformation, BlockCompleteEntry, ChainId, @@ -113,6 +114,16 @@ pub enum BlockchainReadRequest { /// as this request performs a binary search. FindFirstUnknown(Vec<[u8; 32]>), + /// A request for transactions from a specific block. + MissingTxsInBlock { + /// The block to get transactions from. + block_hash: [u8; 32], + /// The indexes of the transactions from the block. + /// This is not the global index of the txs, instead it is the local index as they appear in + /// the block/ + tx_indexes: Vec, + }, + /// A request for all alt blocks in the chain with the given [`ChainId`]. AltBlocksInChain(ChainId), } @@ -252,6 +263,11 @@ pub enum BlockchainResponse { /// This will be [`None`] if all blocks were known. FindFirstUnknown(Option<(usize, usize)>), + /// The response for [`BlockchainReadRequest::MissingTxsInBlock`]. + /// + /// Will return [`None`] if the request contained an index out of range. + MissingTxsInBlock(Option), + /// The response for [`BlockchainReadRequest::AltBlocksInChain`]. /// /// Contains all the alt blocks in the alt-chain in chronological order. diff --git a/types/src/lib.rs b/types/src/lib.rs index 0b0dbe67..e86cf1b4 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -20,7 +20,7 @@ pub use transaction_verification_data::{ CachedVerificationState, TransactionVerificationData, TxVersion, }; pub use types::{ - AltBlockInformation, Chain, ChainId, ExtendedBlockHeader, OutputOnChain, + AltBlockInformation, Chain, ChainId, ExtendedBlockHeader, MissingTxsInBlock, OutputOnChain, VerifiedBlockInformation, VerifiedTransactionInformation, }; diff --git a/types/src/types.rs b/types/src/types.rs index a60ce6c6..f6f19c7c 100644 --- a/types/src/types.rs +++ b/types/src/types.rs @@ -155,6 +155,12 @@ pub struct OutputOnChain { pub commitment: EdwardsPoint, } +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct MissingTxsInBlock { + pub block: Vec, + pub txs: Vec>, +} + //---------------------------------------------------------------------------------------------------- Tests #[cfg(test)] mod test { From 37025bdfc059008da251a8f83c1aef641a339aa0 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sat, 5 Oct 2024 01:07:27 +0100 Subject: [PATCH 44/72] add `new_fluffy_block` handler --- binaries/cuprated/src/blockchain/interface.rs | 14 +--- binaries/cuprated/src/p2p/request_handler.rs | 78 ++++++++++++++++++- p2p/p2p-core/src/protocol.rs | 4 + p2p/p2p-core/src/protocol/try_from.rs | 3 + 4 files changed, 84 insertions(+), 15 deletions(-) diff --git a/binaries/cuprated/src/blockchain/interface.rs b/binaries/cuprated/src/blockchain/interface.rs index 189828e9..b36a31ff 100644 --- a/binaries/cuprated/src/blockchain/interface.rs +++ b/binaries/cuprated/src/blockchain/interface.rs @@ -17,7 +17,7 @@ use cuprate_consensus::transactions::new_tx_verification_data; use cuprate_helper::cast::usize_to_u64; use cuprate_types::{ blockchain::{BlockchainReadRequest, BlockchainResponse}, - Chain, + Chain, TransactionVerificationData, }; use crate::{ @@ -65,7 +65,7 @@ pub enum IncomingBlockError { /// - the block's parent is unknown pub async fn handle_incoming_block( block: Block, - given_txs: Vec, + given_txs: HashMap<[u8; 32], TransactionVerificationData>, blockchain_read_handle: &mut BlockchainReadHandle, ) -> Result { // FIXME: we should look in the tx-pool for txs when that is ready. @@ -95,14 +95,6 @@ pub async fn handle_incoming_block( } // TODO: check we actually got given the right txs. - let prepped_txs = given_txs - .into_par_iter() - .map(|tx| { - let tx = new_tx_verification_data(tx)?; - Ok((tx.tx_hash, tx)) - }) - .collect::>() - .map_err(IncomingBlockError::InvalidBlock)?; let Some(incoming_block_tx) = COMMAND_TX.get() else { // We could still be starting up the blockchain manger, so just return this as there is nothing @@ -128,7 +120,7 @@ pub async fn handle_incoming_block( incoming_block_tx .send(BlockchainManagerCommand::AddBlock { block, - prepped_txs, + prepped_txs: given_txs, response_tx, }) .await diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index 3b94770a..c868de94 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -1,6 +1,9 @@ use bytes::Bytes; use futures::future::BoxFuture; use futures::FutureExt; +use monero_serai::block::Block; +use monero_serai::transaction::Transaction; +use std::collections::HashSet; use std::{ future::{ready, Ready}, task::{Context, Poll}, @@ -8,8 +11,10 @@ use std::{ use tower::{Service, ServiceExt}; use cuprate_blockchain::service::BlockchainReadHandle; +use cuprate_consensus::transactions::new_tx_verification_data; use cuprate_consensus::BlockChainContextService; use cuprate_fixed_bytes::ByteArrayVec; +use cuprate_helper::asynch::rayon_spawn_async; use cuprate_helper::cast::usize_to_u64; use cuprate_helper::map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}; use cuprate_p2p::constants::MAX_BLOCK_BATCH_LEN; @@ -21,6 +26,9 @@ use cuprate_wire::protocol::{ GetObjectsResponse, NewFluffyBlock, }; +use crate::blockchain::interface as blockchain_interface; +use crate::blockchain::interface::IncomingBlockError; + #[derive(Clone)] pub struct P2pProtocolRequestHandlerMaker { pub blockchain_read_handle: BlockchainReadHandle, @@ -77,7 +85,9 @@ impl Service for P2pProtocolRequestHandler { "Peer sent a full block when we support fluffy blocks" ))) .boxed(), - ProtocolRequest::NewFluffyBlock(_) => todo!(), + ProtocolRequest::NewFluffyBlock(r) => { + new_fluffy_block(r, self.blockchain_read_handle.clone()).boxed() + } ProtocolRequest::GetTxPoolCompliment(_) | ProtocolRequest::NewTransactions(_) => { ready(Ok(ProtocolResponse::NA)).boxed() } // TODO: tx-pool @@ -97,7 +107,7 @@ async fn get_objects( } let block_hashes: Vec<[u8; 32]> = (&request.blocks).into(); - // de-allocate the backing `Bytes`. + // deallocate the backing `Bytes`. drop(request); let BlockchainResponse::BlockCompleteEntries { @@ -131,7 +141,7 @@ async fn get_chain( let block_hashes: Vec<[u8; 32]> = (&request.block_ids).into(); let want_pruned_data = request.prune; - // de-allocate the backing `Bytes`. + // deallocate the backing `Bytes`. drop(request); let BlockchainResponse::NextChainEntry { @@ -182,7 +192,7 @@ async fn fluffy_missing_txs( let block_hash: [u8; 32] = *request.block_hash; let current_blockchain_height = request.current_blockchain_height; - // de-allocate the backing `Bytes`. + // deallocate the backing `Bytes`. drop(request); let BlockchainResponse::MissingTxsInBlock(res) = blockchain_read_handle @@ -212,3 +222,63 @@ async fn fluffy_missing_txs( current_blockchain_height, })) } + +/// [`ProtocolRequest::NewFluffyBlock`] +async fn new_fluffy_block( + request: NewFluffyBlock, + mut blockchain_read_handle: BlockchainReadHandle, +) -> anyhow::Result { + let current_blockchain_height = request.current_blockchain_height; + + let (block, txs) = rayon_spawn_async(move || -> Result<_, anyhow::Error> { + let block = Block::read(&mut request.b.block.as_ref())?; + + let tx_blobs = request + .b + .txs + .take_normal() + .ok_or(anyhow::anyhow!("Peer sent pruned txs in fluffy block"))?; + + let mut txs_in_block = block.transactions.iter().copied().collect::>(); + + // TODO: size check these tx blobs + let txs = tx_blobs + .into_iter() + .map(|tx_blob| { + let tx = Transaction::read(&mut tx_blob.as_ref())?; + + let tx = new_tx_verification_data(tx)?; + + if !txs_in_block.remove(&tx.tx_hash) { + anyhow::bail!("Peer sent tx in fluffy block that wasn't actually in block") + } + + Ok((tx.tx_hash, tx)) + }) + .collect::>()?; + + // The backing `Bytes` will be deallocated when this closure returns. + + Ok((block, txs)) + }) + .await?; + + let res = + blockchain_interface::handle_incoming_block(block, txs, &mut blockchain_read_handle).await; + + match res { + Ok(_) => Ok(ProtocolResponse::NA), + Err(IncomingBlockError::UnknownTransactions(block_hash, missing_tx_indices)) => Ok( + ProtocolResponse::FluffyMissingTransactionsRequest(FluffyMissingTransactionsRequest { + block_hash: block_hash.into(), + current_blockchain_height, + missing_tx_indices, + }), + ), + Err(IncomingBlockError::Orphan) => { + // Block's parent was unknown, could be syncing? + Ok(ProtocolResponse::NA) + } + Err(e) => Err(e.into()), + } +} diff --git a/p2p/p2p-core/src/protocol.rs b/p2p/p2p-core/src/protocol.rs index 7d8d431b..82aac824 100644 --- a/p2p/p2p-core/src/protocol.rs +++ b/p2p/p2p-core/src/protocol.rs @@ -116,6 +116,7 @@ pub enum ProtocolResponse { GetChain(ChainResponse), NewFluffyBlock(NewFluffyBlock), NewTransactions(NewTransactions), + FluffyMissingTransactionsRequest(FluffyMissingTransactionsRequest), NA, } @@ -139,6 +140,9 @@ impl PeerResponse { ProtocolResponse::GetChain(_) => MessageID::GetChain, ProtocolResponse::NewFluffyBlock(_) => MessageID::NewBlock, ProtocolResponse::NewTransactions(_) => MessageID::NewFluffyBlock, + ProtocolResponse::FluffyMissingTransactionsRequest(_) => { + MessageID::FluffyMissingTxs + } ProtocolResponse::NA => return None, }, diff --git a/p2p/p2p-core/src/protocol/try_from.rs b/p2p/p2p-core/src/protocol/try_from.rs index d3a7260f..2dfc41db 100644 --- a/p2p/p2p-core/src/protocol/try_from.rs +++ b/p2p/p2p-core/src/protocol/try_from.rs @@ -71,6 +71,9 @@ impl TryFrom for ProtocolMessage { ProtocolResponse::NewFluffyBlock(val) => Self::NewFluffyBlock(val), ProtocolResponse::GetChain(val) => Self::ChainEntryResponse(val), ProtocolResponse::GetObjects(val) => Self::GetObjectsResponse(val), + ProtocolResponse::FluffyMissingTransactionsRequest(val) => { + Self::FluffyMissingTransactionsRequest(val) + } ProtocolResponse::NA => return Err(MessageConversionError), }) } From 783f4260b4fc195544cb4110532da5a8c16327d4 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sat, 5 Oct 2024 16:39:33 +0100 Subject: [PATCH 45/72] improve interface globals --- binaries/cuprated/src/blockchain/interface.rs | 39 ++++++++----------- binaries/cuprated/src/signals.rs | 3 ++ 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/binaries/cuprated/src/blockchain/interface.rs b/binaries/cuprated/src/blockchain/interface.rs index 189828e9..84c81e06 100644 --- a/binaries/cuprated/src/blockchain/interface.rs +++ b/binaries/cuprated/src/blockchain/interface.rs @@ -2,13 +2,13 @@ //! //! This module contains all the functions to mutate the blockchain's state in any way, through the //! blockchain manger. +use monero_serai::{block::Block, transaction::Transaction}; +use rayon::prelude::*; +use std::sync::LazyLock; use std::{ collections::{HashMap, HashSet}, sync::{Mutex, OnceLock}, }; - -use monero_serai::{block::Block, transaction::Transaction}; -use rayon::prelude::*; use tokio::sync::{mpsc, oneshot}; use tower::{Service, ServiceExt}; @@ -25,14 +25,9 @@ use crate::{ }; /// The channel used to send [`BlockchainManagerCommand`]s to the blockchain manger. -pub static COMMAND_TX: OnceLock> = OnceLock::new(); - -/// A [`HashSet`] of block hashes that the blockchain manager is currently handling. /// -/// This is used over something like a dashmap as we expect a lot of collisions in a short amount of -/// time for new blocks so we would lose the benefit of sharded locks. A dashmap is made up of `RwLocks` -/// which are also more expensive than `Mutex`s. -pub static BLOCKS_BEING_HANDLED: OnceLock>> = OnceLock::new(); +/// This channel is initialized in [`init_blockchain_manger`](super::manager::init_blockchain_manger). +pub(super) static COMMAND_TX: OnceLock> = OnceLock::new(); /// An error that can be returned from [`handle_incoming_block`]. #[derive(Debug, thiserror::Error)] @@ -68,6 +63,16 @@ pub async fn handle_incoming_block( given_txs: Vec, blockchain_read_handle: &mut BlockchainReadHandle, ) -> Result { + /// A [`HashSet`] of block hashes that the blockchain manager is currently handling. + /// + /// This lock prevents sending the same block to the blockchain manager from multiple connections + /// before one of them actually gets added to the chain, allowing peers to do other things. + /// + /// This is used over something like a dashmap as we expect a lot of collisions in a short amount of + /// time for new blocks, so we would lose the benefit of sharded locks. A dashmap is made up of `RwLocks` + /// which are also more expensive than `Mutex`s. + static BLOCKS_BEING_HANDLED: LazyLock>> = + LazyLock::new(|| Mutex::new(HashSet::new())); // FIXME: we should look in the tx-pool for txs when that is ready. if !block_exists(block.header.previous, blockchain_read_handle) @@ -111,12 +116,7 @@ pub async fn handle_incoming_block( }; // Add the blocks hash to the blocks being handled. - if !BLOCKS_BEING_HANDLED - .get_or_init(|| Mutex::new(HashSet::new())) - .lock() - .unwrap() - .insert(block_hash) - { + if !BLOCKS_BEING_HANDLED.lock().unwrap().insert(block_hash) { // If another place is already adding this block then we can stop. return Ok(false); } @@ -140,12 +140,7 @@ pub async fn handle_incoming_block( .map_err(IncomingBlockError::InvalidBlock); // Remove the block hash from the blocks being handled. - BLOCKS_BEING_HANDLED - .get() - .unwrap() - .lock() - .unwrap() - .remove(&block_hash); + BLOCKS_BEING_HANDLED.lock().unwrap().remove(&block_hash); res } diff --git a/binaries/cuprated/src/signals.rs b/binaries/cuprated/src/signals.rs index 54467559..8502679c 100644 --- a/binaries/cuprated/src/signals.rs +++ b/binaries/cuprated/src/signals.rs @@ -6,4 +6,7 @@ use tokio::sync::RwLock; /// /// A [`RwLock`] where a write lock is taken during a reorg and a read lock can be taken /// for any operation which must complete without a reorg happening. +/// +/// Currently, the only operation that needs to take a read lock is adding txs to the tx-pool, +/// this can potentially be removed in the future, see: TODO pub static REORG_LOCK: RwLock<()> = RwLock::const_new(()); From 375a1e1826f651019051e61474a7a9ea79d239ae Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sat, 5 Oct 2024 16:58:15 +0100 Subject: [PATCH 46/72] manger -> manager --- binaries/cuprated/src/blockchain/interface.rs | 20 +++++++++---------- binaries/cuprated/src/blockchain/manager.rs | 8 ++++---- .../src/blockchain/manager/handler.rs | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/binaries/cuprated/src/blockchain/interface.rs b/binaries/cuprated/src/blockchain/interface.rs index 84c81e06..bdf1bf33 100644 --- a/binaries/cuprated/src/blockchain/interface.rs +++ b/binaries/cuprated/src/blockchain/interface.rs @@ -1,16 +1,16 @@ -//! The blockchain manger interface. +//! The blockchain manager interface. //! //! This module contains all the functions to mutate the blockchain's state in any way, through the -//! blockchain manger. -use monero_serai::{block::Block, transaction::Transaction}; -use rayon::prelude::*; -use std::sync::LazyLock; +//! blockchain manager. use std::{ collections::{HashMap, HashSet}, - sync::{Mutex, OnceLock}, + sync::{Mutex, OnceLock, LazyLock}, }; + use tokio::sync::{mpsc, oneshot}; use tower::{Service, ServiceExt}; +use monero_serai::{block::Block, transaction::Transaction}; +use rayon::prelude::*; use cuprate_blockchain::service::BlockchainReadHandle; use cuprate_consensus::transactions::new_tx_verification_data; @@ -24,9 +24,9 @@ use crate::{ blockchain::manager::BlockchainManagerCommand, constants::PANIC_CRITICAL_SERVICE_ERROR, }; -/// The channel used to send [`BlockchainManagerCommand`]s to the blockchain manger. +/// The channel used to send [`BlockchainManagerCommand`]s to the blockchain manager. /// -/// This channel is initialized in [`init_blockchain_manger`](super::manager::init_blockchain_manger). +/// This channel is initialized in [`init_blockchain_manager`](super::manager::init_blockchain_manager). pub(super) static COMMAND_TX: OnceLock> = OnceLock::new(); /// An error that can be returned from [`handle_incoming_block`]. @@ -50,7 +50,7 @@ pub enum IncomingBlockError { /// This returns a [`bool`] indicating if the block was added to the main-chain ([`true`]) or an alt-chain /// ([`false`]). /// -/// If we already knew about this block or the blockchain manger is not setup yet `Ok(false)` is returned. +/// If we already knew about this block or the blockchain manager is not setup yet `Ok(false)` is returned. /// /// # Errors /// @@ -110,7 +110,7 @@ pub async fn handle_incoming_block( .map_err(IncomingBlockError::InvalidBlock)?; let Some(incoming_block_tx) = COMMAND_TX.get() else { - // We could still be starting up the blockchain manger, so just return this as there is nothing + // We could still be starting up the blockchain manager, so just return this as there is nothing // else we can do. return Ok(false); }; diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index 8725aeca..eae92520 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -37,11 +37,11 @@ mod handler; pub use commands::BlockchainManagerCommand; -/// Initialize the blockchain manger. +/// Initialize the blockchain manager. /// /// This function sets up the [`BlockchainManager`] and the [`syncer`] so that the functions in [`interface`](super::interface) /// can be called. -pub async fn init_blockchain_manger( +pub async fn init_blockchain_manager( clearnet_interface: NetworkInterface, blockchain_write_handle: BlockchainWriteHandle, blockchain_read_handle: BlockchainReadHandle, @@ -76,7 +76,7 @@ pub async fn init_blockchain_manger( panic!("Blockchain context service returned wrong response!"); }; - let manger = BlockchainManager { + let manager = BlockchainManager { blockchain_write_handle, blockchain_read_handle, blockchain_context_service, @@ -86,7 +86,7 @@ pub async fn init_blockchain_manger( broadcast_svc: clearnet_interface.broadcast_svc(), }; - tokio::spawn(manger.run(batch_rx, command_rx)); + tokio::spawn(manager.run(batch_rx, command_rx)); } /// The blockchain manager. diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs index 14073062..23e8295b 100644 --- a/binaries/cuprated/src/blockchain/manager/handler.rs +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -1,4 +1,4 @@ -//! The blockchain manger handler functions. +//! The blockchain manager handler functions. use std::{collections::HashMap, sync::Arc}; use bytes::Bytes; From f50d92145978a70c6ffa5b6bee9b8df89d2b714d Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sat, 5 Oct 2024 19:49:26 +0100 Subject: [PATCH 47/72] enums instead of bools --- binaries/cuprated/src/blockchain/interface.rs | 23 +++++---- binaries/cuprated/src/blockchain/manager.rs | 2 +- .../src/blockchain/manager/commands.rs | 14 +++++- .../src/blockchain/manager/handler.rs | 50 +++++++++++-------- 4 files changed, 54 insertions(+), 35 deletions(-) diff --git a/binaries/cuprated/src/blockchain/interface.rs b/binaries/cuprated/src/blockchain/interface.rs index bdf1bf33..879103e0 100644 --- a/binaries/cuprated/src/blockchain/interface.rs +++ b/binaries/cuprated/src/blockchain/interface.rs @@ -4,13 +4,13 @@ //! blockchain manager. use std::{ collections::{HashMap, HashSet}, - sync::{Mutex, OnceLock, LazyLock}, + sync::{LazyLock, Mutex, OnceLock}, }; -use tokio::sync::{mpsc, oneshot}; -use tower::{Service, ServiceExt}; use monero_serai::{block::Block, transaction::Transaction}; use rayon::prelude::*; +use tokio::sync::{mpsc, oneshot}; +use tower::{Service, ServiceExt}; use cuprate_blockchain::service::BlockchainReadHandle; use cuprate_consensus::transactions::new_tx_verification_data; @@ -21,12 +21,14 @@ use cuprate_types::{ }; use crate::{ - blockchain::manager::BlockchainManagerCommand, constants::PANIC_CRITICAL_SERVICE_ERROR, + blockchain::manager::{BlockchainManagerCommand, IncomingBlockOk}, + constants::PANIC_CRITICAL_SERVICE_ERROR, }; /// The channel used to send [`BlockchainManagerCommand`]s to the blockchain manager. /// -/// This channel is initialized in [`init_blockchain_manager`](super::manager::init_blockchain_manager). +/// This channel is initialized in [`init_blockchain_manager`](super::manager::init_blockchain_manager), the functions +/// in this file document what happens if this is not initialized when they are called. pub(super) static COMMAND_TX: OnceLock> = OnceLock::new(); /// An error that can be returned from [`handle_incoming_block`]. @@ -62,7 +64,7 @@ pub async fn handle_incoming_block( block: Block, given_txs: Vec, blockchain_read_handle: &mut BlockchainReadHandle, -) -> Result { +) -> Result { /// A [`HashSet`] of block hashes that the blockchain manager is currently handling. /// /// This lock prevents sending the same block to the blockchain manager from multiple connections @@ -88,7 +90,7 @@ pub async fn handle_incoming_block( .await .expect(PANIC_CRITICAL_SERVICE_ERROR) { - return Ok(false); + return Ok(IncomingBlockOk::AlreadyHave); } // TODO: remove this when we have a working tx-pool. @@ -110,15 +112,14 @@ pub async fn handle_incoming_block( .map_err(IncomingBlockError::InvalidBlock)?; let Some(incoming_block_tx) = COMMAND_TX.get() else { - // We could still be starting up the blockchain manager, so just return this as there is nothing - // else we can do. - return Ok(false); + // We could still be starting up the blockchain manager. + return Ok(IncomingBlockOk::NotReady); }; // Add the blocks hash to the blocks being handled. if !BLOCKS_BEING_HANDLED.lock().unwrap().insert(block_hash) { // If another place is already adding this block then we can stop. - return Ok(false); + return Ok(IncomingBlockOk::AlreadyHave); } // From this point on we MUST not early return without removing the block hash from `BLOCKS_BEING_HANDLED`. diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index eae92520..6019592f 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -35,7 +35,7 @@ use crate::{ mod commands; mod handler; -pub use commands::BlockchainManagerCommand; +pub use commands::{BlockchainManagerCommand, IncomingBlockOk}; /// Initialize the blockchain manager. /// diff --git a/binaries/cuprated/src/blockchain/manager/commands.rs b/binaries/cuprated/src/blockchain/manager/commands.rs index a8d84733..f5890a83 100644 --- a/binaries/cuprated/src/blockchain/manager/commands.rs +++ b/binaries/cuprated/src/blockchain/manager/commands.rs @@ -15,6 +15,18 @@ pub enum BlockchainManagerCommand { /// All the transactions defined in [`Block::transactions`]. prepped_txs: HashMap<[u8; 32], TransactionVerificationData>, /// The channel to send the response down. - response_tx: oneshot::Sender>, + response_tx: oneshot::Sender>, }, } + +/// The [`Ok`] response for an incoming block. +pub enum IncomingBlockOk { + /// The block was added to the main-chain. + AddedToMainChain, + /// The blockchain manager is not ready yet. + NotReady, + /// The block was added to an alt-chain. + AddedToAltChain, + /// We already have the block. + AlreadyHave, +} diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs index 23e8295b..d37811bc 100644 --- a/binaries/cuprated/src/blockchain/manager/handler.rs +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -1,10 +1,10 @@ //! The blockchain manager handler functions. -use std::{collections::HashMap, sync::Arc}; - use bytes::Bytes; use futures::{TryFutureExt, TryStreamExt}; use monero_serai::{block::Block, transaction::Transaction}; use rayon::prelude::*; +use std::ops::ControlFlow; +use std::{collections::HashMap, sync::Arc}; use tower::{Service, ServiceExt}; use tracing::info; @@ -22,6 +22,7 @@ use cuprate_types::{ AltBlockInformation, HardFork, TransactionVerificationData, VerifiedBlockInformation, }; +use crate::blockchain::manager::commands::IncomingBlockOk; use crate::{ blockchain::{ manager::commands::BlockchainManagerCommand, types::ConsensusBlockchainReadHandle, @@ -73,11 +74,10 @@ impl super::BlockchainManager { &mut self, block: Block, prepared_txs: HashMap<[u8; 32], TransactionVerificationData>, - ) -> Result { + ) -> Result { if block.header.previous != self.cached_blockchain_context.top_hash { self.handle_incoming_alt_block(block, prepared_txs).await?; - - return Ok(false); + return Ok(IncomingBlockOk::AddedToAltChain); } let VerifyBlockResponse::MainChain(verified_block) = self @@ -91,7 +91,7 @@ impl super::BlockchainManager { }) .await? else { - panic!("Incorrect response!"); + unreachable!(); }; let block_blob = Bytes::copy_from_slice(&verified_block.block_blob); @@ -100,7 +100,7 @@ impl super::BlockchainManager { self.broadcast_block(block_blob, self.cached_blockchain_context.chain_height) .await; - Ok(true) + Ok(IncomingBlockOk::AddedToMainChain) } /// Handle an incoming [`BlockBatch`]. @@ -160,7 +160,7 @@ impl super::BlockchainManager { self.stop_current_block_downloader.notify_one(); return; } - _ => panic!("Incorrect response!"), + _ => unreachable!(), }; for (block, txs) in prepped_blocks { @@ -179,7 +179,7 @@ impl super::BlockchainManager { self.stop_current_block_downloader.notify_one(); return; } - _ => panic!("Incorrect response!"), + _ => unreachable!(), }; self.add_valid_block_to_main_chain(verified_block).await; @@ -226,16 +226,14 @@ impl super::BlockchainManager { self.stop_current_block_downloader.notify_one(); return; } - // the chain was reorged - Ok(true) => { + Ok(AddAltBlock::Reorged) => { // Collect the remaining blocks and add them to the main chain instead. batch.blocks = blocks.collect(); self.handle_incoming_block_batch_main_chain(batch).await; - return; } // continue adding alt blocks. - Ok(false) => (), + Ok(AddAltBlock::Cached) => (), } } } @@ -258,11 +256,11 @@ impl super::BlockchainManager { /// /// This function will panic if any internal service returns an unexpected error that we cannot /// recover from. - pub async fn handle_incoming_alt_block( + async fn handle_incoming_alt_block( &mut self, block: Block, prepared_txs: HashMap<[u8; 32], TransactionVerificationData>, - ) -> Result { + ) -> Result { let VerifyBlockResponse::AltChain(alt_block_info) = self .block_verifier_service .ready() @@ -274,7 +272,7 @@ impl super::BlockchainManager { }) .await? else { - panic!("Incorrect response!"); + unreachable!(); }; // TODO: check in consensus crate if alt block with this hash already exists. @@ -284,7 +282,7 @@ impl super::BlockchainManager { > self.cached_blockchain_context.cumulative_difficulty { self.try_do_reorg(alt_block_info).await?; - return Ok(true); + return Ok(AddAltBlock::Reorged); } self.blockchain_write_handle @@ -294,7 +292,7 @@ impl super::BlockchainManager { .call(BlockchainWriteRequest::WriteAltBlock(alt_block_info)) .await?; - Ok(false) + Ok(AddAltBlock::Cached) } /// Attempt a re-org with the given top block of the alt-chain. @@ -328,7 +326,7 @@ impl super::BlockchainManager { )) .await? else { - panic!("Incorrect response!"); + unreachable!(); }; alt_blocks.push(top_alt_block); @@ -347,7 +345,7 @@ impl super::BlockchainManager { .await .expect(PANIC_CRITICAL_SERVICE_ERROR) else { - panic!("Incorrect response!"); + unreachable!(); }; self.blockchain_context_service @@ -409,7 +407,7 @@ impl super::BlockchainManager { }) .await? else { - panic!("Incorrect response!"); + unreachable!(); }; self.add_valid_block_to_main_chain(verified_block).await; @@ -465,9 +463,17 @@ impl super::BlockchainManager { .await .expect(PANIC_CRITICAL_SERVICE_ERROR) else { - panic!("Incorrect response!"); + unreachable!(); }; self.cached_blockchain_context = blockchain_context.unchecked_blockchain_context().clone(); } } + +/// The result from successfully adding an alt-block. +enum AddAltBlock { + /// The alt-block was cached. + Cached, + /// The chain was reorged. + Reorged, +} From 27a8acdb04064fa70f476ed3fae83b46ac2eb418 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sat, 5 Oct 2024 19:57:30 +0100 Subject: [PATCH 48/72] move chain service to separate file --- binaries/cuprated/src/blockchain.rs | 1 + .../cuprated/src/blockchain/chain_service.rs | 72 +++++++++++++++++++ binaries/cuprated/src/blockchain/manager.rs | 2 +- binaries/cuprated/src/blockchain/types.rs | 64 ----------------- 4 files changed, 74 insertions(+), 65 deletions(-) create mode 100644 binaries/cuprated/src/blockchain/chain_service.rs diff --git a/binaries/cuprated/src/blockchain.rs b/binaries/cuprated/src/blockchain.rs index 1a9c0b7c..a06f3fa7 100644 --- a/binaries/cuprated/src/blockchain.rs +++ b/binaries/cuprated/src/blockchain.rs @@ -19,6 +19,7 @@ use cuprate_types::{ use crate::constants::PANIC_CRITICAL_SERVICE_ERROR; +mod chain_service; pub mod interface; mod manager; mod syncer; diff --git a/binaries/cuprated/src/blockchain/chain_service.rs b/binaries/cuprated/src/blockchain/chain_service.rs new file mode 100644 index 00000000..eeaf4a06 --- /dev/null +++ b/binaries/cuprated/src/blockchain/chain_service.rs @@ -0,0 +1,72 @@ +use std::task::{Context, Poll}; + +use futures::{future::BoxFuture, FutureExt, TryFutureExt}; +use tower::Service; + +use cuprate_blockchain::service::BlockchainReadHandle; +use cuprate_p2p::block_downloader::{ChainSvcRequest, ChainSvcResponse}; +use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; + +/// That service that allows retrieving the chain state to give to the P2P crates, so we can figure out +/// what blocks we need. +/// +/// This has a more minimal interface than [`BlockchainReadRequest`] to make using the p2p crates easier. +#[derive(Clone)] +pub struct ChainService(pub BlockchainReadHandle); + +impl Service for ChainService { + type Response = ChainSvcResponse; + type Error = tower::BoxError; + type Future = BoxFuture<'static, Result>; + + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + self.0.poll_ready(cx).map_err(Into::into) + } + + fn call(&mut self, req: ChainSvcRequest) -> Self::Future { + let map_res = |res: BlockchainResponse| match res { + BlockchainResponse::CompactChainHistory { + block_ids, + cumulative_difficulty, + } => ChainSvcResponse::CompactHistory { + block_ids, + cumulative_difficulty, + }, + BlockchainResponse::FindFirstUnknown(res) => ChainSvcResponse::FindFirstUnknown(res), + _ => panic!("Blockchain returned wrong response"), + }; + + match req { + ChainSvcRequest::CompactHistory => self + .0 + .call(BlockchainReadRequest::CompactChainHistory) + .map_ok(map_res) + .map_err(Into::into) + .boxed(), + ChainSvcRequest::FindFirstUnknown(req) => self + .0 + .call(BlockchainReadRequest::FindFirstUnknown(req)) + .map_ok(map_res) + .map_err(Into::into) + .boxed(), + ChainSvcRequest::CumulativeDifficulty => self + .0 + .call(BlockchainReadRequest::CompactChainHistory) + .map_ok(|res| { + // TODO create a custom request instead of hijacking this one. + // TODO: use the context cache. + let BlockchainResponse::CompactChainHistory { + cumulative_difficulty, + .. + } = res + else { + panic!("Blockchain returned wrong response"); + }; + + ChainSvcResponse::CumulativeDifficulty(cumulative_difficulty) + }) + .map_err(Into::into) + .boxed(), + } + } +} diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index 6019592f..f6c11fc0 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -24,9 +24,9 @@ use cuprate_types::{ use crate::{ blockchain::{ + chain_service::ChainService, interface::COMMAND_TX, syncer, - types::ChainService, types::{ConcreteBlockVerifierService, ConsensusBlockchainReadHandle}, }, constants::PANIC_CRITICAL_SERVICE_ERROR, diff --git a/binaries/cuprated/src/blockchain/types.rs b/binaries/cuprated/src/blockchain/types.rs index 1bf921ec..e3ee62b3 100644 --- a/binaries/cuprated/src/blockchain/types.rs +++ b/binaries/cuprated/src/blockchain/types.rs @@ -22,67 +22,3 @@ pub type ConcreteTxVerifierService = TxVerifierService tower::BoxError>; - -/// That service that allows retrieving the chain state to give to the P2P crates, so we can figure out -/// what blocks we need. -/// -/// This has a more minimal interface than [`BlockchainReadRequest`] to make using the p2p crates easier. -#[derive(Clone)] -pub struct ChainService(pub BlockchainReadHandle); - -impl Service for ChainService { - type Response = ChainSvcResponse; - type Error = tower::BoxError; - type Future = BoxFuture<'static, Result>; - - fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { - self.0.poll_ready(cx).map_err(Into::into) - } - - fn call(&mut self, req: ChainSvcRequest) -> Self::Future { - let map_res = |res: BlockchainResponse| match res { - BlockchainResponse::CompactChainHistory { - block_ids, - cumulative_difficulty, - } => ChainSvcResponse::CompactHistory { - block_ids, - cumulative_difficulty, - }, - BlockchainResponse::FindFirstUnknown(res) => ChainSvcResponse::FindFirstUnknown(res), - _ => panic!("Blockchain returned wrong response"), - }; - - match req { - ChainSvcRequest::CompactHistory => self - .0 - .call(BlockchainReadRequest::CompactChainHistory) - .map_ok(map_res) - .map_err(Into::into) - .boxed(), - ChainSvcRequest::FindFirstUnknown(req) => self - .0 - .call(BlockchainReadRequest::FindFirstUnknown(req)) - .map_ok(map_res) - .map_err(Into::into) - .boxed(), - ChainSvcRequest::CumulativeDifficulty => self - .0 - .call(BlockchainReadRequest::CompactChainHistory) - .map_ok(|res| { - // TODO create a custom request instead of hijacking this one. - // TODO: use the context cache. - let BlockchainResponse::CompactChainHistory { - cumulative_difficulty, - .. - } = res - else { - panic!("Blockchain returned wrong response"); - }; - - ChainSvcResponse::CumulativeDifficulty(cumulative_difficulty) - }) - .map_err(Into::into) - .boxed(), - } - } -} From a21e489fdc9b2fd755c32479e4deb05c12fb76d5 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sat, 5 Oct 2024 21:16:51 +0100 Subject: [PATCH 49/72] more review fixes --- binaries/cuprated/src/blockchain/chain_service.rs | 4 ++-- binaries/cuprated/src/blockchain/interface.rs | 7 ++----- binaries/cuprated/src/blockchain/manager.rs | 2 +- .../cuprated/src/blockchain/manager/commands.rs | 2 +- binaries/cuprated/src/blockchain/manager/handler.rs | 13 +++++++++---- binaries/cuprated/src/blockchain/syncer.rs | 4 ++-- binaries/cuprated/src/constants.rs | 1 + 7 files changed, 18 insertions(+), 15 deletions(-) diff --git a/binaries/cuprated/src/blockchain/chain_service.rs b/binaries/cuprated/src/blockchain/chain_service.rs index eeaf4a06..af862d1d 100644 --- a/binaries/cuprated/src/blockchain/chain_service.rs +++ b/binaries/cuprated/src/blockchain/chain_service.rs @@ -33,7 +33,7 @@ impl Service for ChainService { cumulative_difficulty, }, BlockchainResponse::FindFirstUnknown(res) => ChainSvcResponse::FindFirstUnknown(res), - _ => panic!("Blockchain returned wrong response"), + _ => unreachable!(), }; match req { @@ -60,7 +60,7 @@ impl Service for ChainService { .. } = res else { - panic!("Blockchain returned wrong response"); + unreachable!() }; ChainSvcResponse::CumulativeDifficulty(cumulative_difficulty) diff --git a/binaries/cuprated/src/blockchain/interface.rs b/binaries/cuprated/src/blockchain/interface.rs index 879103e0..985e60d8 100644 --- a/binaries/cuprated/src/blockchain/interface.rs +++ b/binaries/cuprated/src/blockchain/interface.rs @@ -49,10 +49,7 @@ pub enum IncomingBlockError { /// Try to add a new block to the blockchain. /// -/// This returns a [`bool`] indicating if the block was added to the main-chain ([`true`]) or an alt-chain -/// ([`false`]). -/// -/// If we already knew about this block or the blockchain manager is not setup yet `Ok(false)` is returned. +/// On success returns [`IncomingBlockOk`]. /// /// # Errors /// @@ -157,7 +154,7 @@ async fn block_exists( .call(BlockchainReadRequest::FindBlock(block_hash)) .await? else { - panic!("Invalid blockchain response!"); + unreachable!(); }; Ok(chain.is_some()) diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index f6c11fc0..568ed572 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -73,7 +73,7 @@ pub async fn init_blockchain_manager( .await .expect(PANIC_CRITICAL_SERVICE_ERROR) else { - panic!("Blockchain context service returned wrong response!"); + unreachable!() }; let manager = BlockchainManager { diff --git a/binaries/cuprated/src/blockchain/manager/commands.rs b/binaries/cuprated/src/blockchain/manager/commands.rs index f5890a83..643ed88c 100644 --- a/binaries/cuprated/src/blockchain/manager/commands.rs +++ b/binaries/cuprated/src/blockchain/manager/commands.rs @@ -1,4 +1,4 @@ -//! This module contains the commands for th blockchain manager. +//! This module contains the commands for the blockchain manager. use std::collections::HashMap; use monero_serai::block::Block; diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs index d37811bc..e9e6c3c3 100644 --- a/binaries/cuprated/src/blockchain/manager/handler.rs +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -33,6 +33,11 @@ use crate::{ impl super::BlockchainManager { /// Handle an incoming command from another part of Cuprate. + /// + /// # Panics + /// + /// This function will panic if any internal service returns an unexpected error that we cannot + /// recover from. pub async fn handle_command(&mut self, command: BlockchainManagerCommand) { match command { BlockchainManagerCommand::AddBlock { @@ -68,8 +73,10 @@ impl super::BlockchainManager { /// /// Otherwise, this function will validate and add the block to the main chain. /// - /// On success returns a [`bool`] indicating if the block was added to the main chain ([`true`]) - /// or an alt-chain ([`false`]). + /// # Panics + /// + /// This function will panic if any internal service returns an unexpected error that we cannot + /// recover from. pub async fn handle_incoming_block( &mut self, block: Block, @@ -244,8 +251,6 @@ impl super::BlockchainManager { /// of the alt chain is higher than the main chain it will attempt a reorg otherwise it will add /// the alt block to the alt block cache. /// - /// This function returns a [`bool`] indicating if the chain was reorganised ([`true`]) or not ([`false`]). - /// /// # Errors /// /// This will return an [`Err`] if: diff --git a/binaries/cuprated/src/blockchain/syncer.rs b/binaries/cuprated/src/blockchain/syncer.rs index 8c58c54e..7e72c36c 100644 --- a/binaries/cuprated/src/blockchain/syncer.rs +++ b/binaries/cuprated/src/blockchain/syncer.rs @@ -65,7 +65,7 @@ where .call(BlockChainContextRequest::GetContext) .await? else { - panic!("Blockchain context service returned wrong response!"); + unreachable!(); }; let client_pool = clearnet_interface.client_pool(); @@ -130,7 +130,7 @@ where .oneshot(BlockChainContextRequest::GetContext) .await? else { - panic!("Blockchain context service returned wrong response!"); + unreachable!(); }; *old_context = ctx; diff --git a/binaries/cuprated/src/constants.rs b/binaries/cuprated/src/constants.rs index d4dfc1ad..2f3c7bb6 100644 --- a/binaries/cuprated/src/constants.rs +++ b/binaries/cuprated/src/constants.rs @@ -14,6 +14,7 @@ pub const VERSION_BUILD: &str = if cfg!(debug_assertions) { formatcp!("{VERSION}-release") }; +/// The panic message used when cuprated encounters a critical service error. pub const PANIC_CRITICAL_SERVICE_ERROR: &str = "A service critical to Cuprate's function returned an unexpected error."; From 4af0145baa1a466559a116207ff59456f1e6a459 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sat, 5 Oct 2024 22:23:25 +0100 Subject: [PATCH 50/72] sort imports + docs --- binaries/cuprated/src/p2p/request_handler.rs | 36 ++++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index c868de94..0bf6ee23 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -1,36 +1,39 @@ -use bytes::Bytes; -use futures::future::BoxFuture; -use futures::FutureExt; -use monero_serai::block::Block; -use monero_serai::transaction::Transaction; -use std::collections::HashSet; use std::{ + collections::HashSet, future::{ready, Ready}, task::{Context, Poll}, }; + +use bytes::Bytes; +use futures::{future::BoxFuture, FutureExt}; +use monero_serai::{block::Block, transaction::Transaction}; use tower::{Service, ServiceExt}; use cuprate_blockchain::service::BlockchainReadHandle; -use cuprate_consensus::transactions::new_tx_verification_data; -use cuprate_consensus::BlockChainContextService; +use cuprate_consensus::{transactions::new_tx_verification_data, BlockChainContextService}; use cuprate_fixed_bytes::ByteArrayVec; -use cuprate_helper::asynch::rayon_spawn_async; -use cuprate_helper::cast::usize_to_u64; -use cuprate_helper::map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}; +use cuprate_helper::{ + asynch::rayon_spawn_async, + cast::usize_to_u64, + map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}, +}; use cuprate_p2p::constants::MAX_BLOCK_BATCH_LEN; use cuprate_p2p_core::{client::PeerInformation, NetworkZone, ProtocolRequest, ProtocolResponse}; -use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse}; -use cuprate_types::{BlockCompleteEntry, MissingTxsInBlock, TransactionBlobs}; +use cuprate_types::{ + blockchain::{BlockchainReadRequest, BlockchainResponse}, + BlockCompleteEntry, MissingTxsInBlock, TransactionBlobs, +}; use cuprate_wire::protocol::{ ChainRequest, ChainResponse, FluffyMissingTransactionsRequest, GetObjectsRequest, GetObjectsResponse, NewFluffyBlock, }; -use crate::blockchain::interface as blockchain_interface; -use crate::blockchain::interface::IncomingBlockError; +use crate::blockchain::interface::{self as blockchain_interface, IncomingBlockError}; +/// The P2P protocol request handler [`MakeService`](tower::MakeService). #[derive(Clone)] pub struct P2pProtocolRequestHandlerMaker { + /// The [`BlockchainReadHandle`] pub blockchain_read_handle: BlockchainReadHandle, } @@ -55,9 +58,12 @@ impl Service> for P2pProtocolRequestHandlerMa } } +/// The P2P protocol request handler. #[derive(Clone)] pub struct P2pProtocolRequestHandler { + /// The [`PeerInformation`] for this peer. peer_information: PeerInformation, + /// The [`BlockchainReadHandle`] blockchain_read_handle: BlockchainReadHandle, } From adf592e5309eba8740356541ac8dd43bd59849da Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 10 Oct 2024 20:12:18 +0100 Subject: [PATCH 51/72] init dandelion integration --- Cargo.lock | 1 + Cargo.toml | 1 + binaries/cuprated/Cargo.toml | 1 + binaries/cuprated/src/blockchain.rs | 2 +- binaries/cuprated/src/txpool.rs | 5 + binaries/cuprated/src/txpool/dandelion.rs | 38 +++ .../src/txpool/dandelion/diffuse_service.rs | 32 +++ .../src/txpool/dandelion/stem_service.rs | 54 ++++ .../cuprated/src/txpool/dandelion/tx_store.rs | 47 ++++ binaries/cuprated/src/txpool/incoming_tx.rs | 249 ++++++++++++++++++ binaries/cuprated/src/txpool/manager.rs | 1 + .../cuprated/src/txpool/txs_being_handled.rs | 48 ++++ p2p/dandelion-tower/src/router.rs | 6 + p2p/p2p/src/client_pool.rs | 12 +- storage/service/src/service/write.rs | 2 +- storage/txpool/src/service/interface.rs | 8 + 16 files changed, 504 insertions(+), 3 deletions(-) create mode 100644 binaries/cuprated/src/txpool/dandelion.rs create mode 100644 binaries/cuprated/src/txpool/dandelion/diffuse_service.rs create mode 100644 binaries/cuprated/src/txpool/dandelion/stem_service.rs create mode 100644 binaries/cuprated/src/txpool/dandelion/tx_store.rs create mode 100644 binaries/cuprated/src/txpool/incoming_tx.rs create mode 100644 binaries/cuprated/src/txpool/manager.rs create mode 100644 binaries/cuprated/src/txpool/txs_being_handled.rs diff --git a/Cargo.lock b/Cargo.lock index 5fea18d0..5e597f86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1008,6 +1008,7 @@ dependencies = [ "serde", "serde_bytes", "serde_json", + "sha3", "thiserror", "thread_local", "tokio", diff --git a/Cargo.toml b/Cargo.toml index fa348ccd..1de62ec7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -78,6 +78,7 @@ rayon = { version = "1.10.0", default-features = false } serde_bytes = { version = "0.11.15", default-features = false } serde_json = { version = "1.0.128", default-features = false } serde = { version = "1.0.210", default-features = false } +sha3 = { version = "0.10.8", default-features = false } thiserror = { version = "1.0.63", default-features = false } thread_local = { version = "1.1.8", default-features = false } tokio-util = { version = "0.7.12", default-features = false } diff --git a/binaries/cuprated/Cargo.toml b/binaries/cuprated/Cargo.toml index 325406bf..62a10322 100644 --- a/binaries/cuprated/Cargo.toml +++ b/binaries/cuprated/Cargo.toml @@ -64,6 +64,7 @@ rayon = { workspace = true } serde_bytes = { workspace = true } serde_json = { workspace = true } serde = { workspace = true } +sha3 = { workspace = true, features = ["std"] } thiserror = { workspace = true } thread_local = { workspace = true } tokio-util = { workspace = true } diff --git a/binaries/cuprated/src/blockchain.rs b/binaries/cuprated/src/blockchain.rs index a06f3fa7..c4b75e4e 100644 --- a/binaries/cuprated/src/blockchain.rs +++ b/binaries/cuprated/src/blockchain.rs @@ -25,7 +25,7 @@ mod manager; mod syncer; mod types; -use types::{ +pub use types::{ ConcreteBlockVerifierService, ConcreteTxVerifierService, ConsensusBlockchainReadHandle, }; diff --git a/binaries/cuprated/src/txpool.rs b/binaries/cuprated/src/txpool.rs index a6f05e75..af5a4205 100644 --- a/binaries/cuprated/src/txpool.rs +++ b/binaries/cuprated/src/txpool.rs @@ -1,3 +1,8 @@ //! Transaction Pool //! //! Will handle initiating the tx-pool, providing the preprocessor required for the dandelion pool. + +mod dandelion; +mod incoming_tx; +mod manager; +mod txs_being_handled; diff --git a/binaries/cuprated/src/txpool/dandelion.rs b/binaries/cuprated/src/txpool/dandelion.rs new file mode 100644 index 00000000..47d1ca38 --- /dev/null +++ b/binaries/cuprated/src/txpool/dandelion.rs @@ -0,0 +1,38 @@ +use bytes::Bytes; +use cuprate_dandelion_tower::{DandelionConfig, DandelionRouter}; +use cuprate_p2p::NetworkInterface; +use cuprate_p2p_core::ClearNet; +use cuprate_wire::NetworkAddress; + +mod diffuse_service; +mod stem_service; +mod tx_store; + +struct DandelionTx(Bytes); + +type TxId = [u8; 32]; + +pub fn start_dandelion_router( + clear_net: NetworkInterface, +) -> DandelionRouter< + stem_service::OutboundPeerStream, + diffuse_service::DiffuseService, + NetworkAddress, + stem_service::StemPeerService, + DandelionTx, +> { + DandelionRouter::new( + diffuse_service::DiffuseService { + clear_net_broadcast_service: clear_net.broadcast_svc(), + }, + stem_service::OutboundPeerStream { + clear_net: clear_net.clone(), + }, + DandelionConfig { + time_between_hop: Default::default(), + epoch_duration: Default::default(), + fluff_probability: 0.0, + graph: Default::default(), + }, + ) +} diff --git a/binaries/cuprated/src/txpool/dandelion/diffuse_service.rs b/binaries/cuprated/src/txpool/dandelion/diffuse_service.rs new file mode 100644 index 00000000..57b7d292 --- /dev/null +++ b/binaries/cuprated/src/txpool/dandelion/diffuse_service.rs @@ -0,0 +1,32 @@ +use std::task::{Context, Poll}; +use tower::Service; + +use crate::txpool::dandelion::DandelionTx; +use cuprate_dandelion_tower::traits::DiffuseRequest; +use cuprate_p2p::{BroadcastRequest, BroadcastSvc, NetworkInterface}; +use cuprate_p2p_core::ClearNet; + +pub struct DiffuseService { + pub clear_net_broadcast_service: BroadcastSvc, +} + +impl Service> for DiffuseService { + type Response = BroadcastSvc::Response; + type Error = tower::BoxError; + type Future = BroadcastSvc::Future; + + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + self.clear_net_broadcast_service + .poll_ready(cx) + .map_err(Into::into) + } + + fn call(&mut self, req: DiffuseRequest) -> Self::Future { + self.clear_net_broadcast_service + .call(BroadcastRequest::Transaction { + tx_bytes: req.0 .0, + direction: None, + received_from: None, + }) + } +} diff --git a/binaries/cuprated/src/txpool/dandelion/stem_service.rs b/binaries/cuprated/src/txpool/dandelion/stem_service.rs new file mode 100644 index 00000000..6970ebfc --- /dev/null +++ b/binaries/cuprated/src/txpool/dandelion/stem_service.rs @@ -0,0 +1,54 @@ +use super::DandelionTx; +use bytes::Bytes; +use cuprate_dandelion_tower::traits::StemRequest; +use cuprate_dandelion_tower::OutboundPeer; +use cuprate_p2p::NetworkInterface; +use cuprate_p2p_core::client::Client; +use cuprate_p2p_core::{ClearNet, NetworkZone, PeerRequest, ProtocolRequest}; +use cuprate_wire::protocol::NewTransactions; +use cuprate_wire::NetworkAddress; +use futures::Stream; +use std::pin::Pin; +use std::task::{Context, Poll}; +use tower::Service; + +pub struct OutboundPeerStream { + pub clear_net: NetworkInterface, +} + +impl Stream for OutboundPeerStream { + type Item = Result>, tower::BoxError>; + + fn poll_next(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll> { + Poll::Ready(Some(Ok(self + .clear_net + .client_pool() + .outbound_client() + .map_or(OutboundPeer::Exhausted, |client| { + OutboundPeer::Peer(client.info.id.into(), StemPeerService(client)) + })))) + } +} + +pub struct StemPeerService(Client); + +impl Service> for StemPeerService { + type Response = (); + type Error = tower::BoxError; + type Future = Client::Future; + + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + self.0.poll_ready(cx) + } + + fn call(&mut self, req: StemRequest) -> Self::Future { + self.0 + .call(PeerRequest::Protocol(ProtocolRequest::NewTransactions( + NewTransactions { + txs: vec![req.0 .0], + dandelionpp_fluff: false, + padding: Bytes::new(), + }, + ))) + } +} diff --git a/binaries/cuprated/src/txpool/dandelion/tx_store.rs b/binaries/cuprated/src/txpool/dandelion/tx_store.rs new file mode 100644 index 00000000..98de764b --- /dev/null +++ b/binaries/cuprated/src/txpool/dandelion/tx_store.rs @@ -0,0 +1,47 @@ +use crate::txpool::dandelion::{DandelionTx, TxId}; +use bytes::Bytes; +use cuprate_dandelion_tower::traits::{TxStoreRequest, TxStoreResponse}; +use cuprate_database::RuntimeError; +use cuprate_txpool::service::interface::{TxpoolReadRequest, TxpoolReadResponse}; +use cuprate_txpool::service::{TxpoolReadHandle, TxpoolWriteHandle}; +use futures::future::BoxFuture; +use futures::{FutureExt, StreamExt, TryFutureExt}; +use std::task::{Context, Poll}; +use tower::util::Oneshot; +use tower::{Service, ServiceExt}; + +pub struct TxStoreService { + txpool_read_handle: TxpoolReadHandle, + txpool_write_handle: TxpoolWriteHandle, +} + +impl Service> for TxStoreService { + type Response = TxStoreResponse; + type Error = tower::BoxError; + type Future = BoxFuture<'static, Result>; + + fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { + Poll::Ready(Ok(())) + } + + fn call(&mut self, req: TxStoreRequest) -> Self::Future { + match req { + TxStoreRequest::Get(tx_id) => self + .txpool_read_handle + .clone() + .oneshot(TxpoolReadRequest::TxBlob(tx_id)) + .map(|res| match res { + Ok(TxpoolReadResponse::TxBlob(blob)) => Ok(TxStoreResponse::Transaction(Some( + (DandelionTx(Bytes::from(blob)), todo!()), + ))), + Err(RuntimeError::KeyNotFound) => Ok(TxStoreResponse::Transaction(None)), + Err(e) => Err(e.into()), + Ok(_) => unreachable!(), + }) + .boxed(), + TxStoreRequest::Promote(tx_id) => { + todo!() + } + } + } +} diff --git a/binaries/cuprated/src/txpool/incoming_tx.rs b/binaries/cuprated/src/txpool/incoming_tx.rs new file mode 100644 index 00000000..37202b06 --- /dev/null +++ b/binaries/cuprated/src/txpool/incoming_tx.rs @@ -0,0 +1,249 @@ +use std::collections::HashSet; +use std::future::ready; +use std::sync::Arc; +use std::task::{Context, Poll}; + +use crate::blockchain::ConcreteTxVerifierService; +use crate::txpool::txs_being_handled::{tx_blob_hash, TxBeingHandledLocally, TxsBeingHandled}; +use bytes::Bytes; +use cuprate_consensus::transactions::new_tx_verification_data; +use cuprate_consensus::{ + BlockChainContextRequest, BlockChainContextResponse, BlockChainContextService, + ExtendedConsensusError, TxVerifierService, VerifyTxRequest, VerifyTxResponse, +}; +use cuprate_dandelion_tower::pool::{DandelionPoolService, IncomingTx, IncomingTxBuilder}; +use cuprate_dandelion_tower::TxState; +use cuprate_helper::asynch::rayon_spawn_async; +use cuprate_txpool::service::interface::{ + TxpoolReadRequest, TxpoolWriteRequest, TxpoolWriteResponse, +}; +use cuprate_txpool::service::{TxpoolReadHandle, TxpoolWriteHandle}; +use cuprate_wire::NetworkAddress; +use dashmap::DashSet; +use futures::future::BoxFuture; +use futures::FutureExt; +use monero_serai::transaction::Transaction; +use sha3::{Digest, Sha3_256}; +use tower::{Service, ServiceExt}; + +pub enum IncomingTxError { + Parse(std::io::Error), + Consensus(ExtendedConsensusError), + DuplicateTransaction, +} + +pub enum IncomingTxs { + Bytes { + txs: Vec, + state: TxState, + }, +} + +struct DandelionTx(Bytes); + +type TxId = [u8; 32]; + +pub struct IncomingTxHandler { + txs_being_added: Arc, + + blockchain_context_cache: BlockChainContextService, + + dandelion_pool_manager: DandelionPoolService, + tx_verifier_service: ConcreteTxVerifierService, + + txpool_write_handle: TxpoolWriteHandle, + + txpool_read_handle: TxpoolReadHandle, +} + +impl Service for IncomingTxHandler { + type Response = (); + type Error = IncomingTxError; + type Future = BoxFuture<'static, Result>; + + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + Poll::Ready(Ok(())) + } + + fn call(&mut self, req: IncomingTxs) -> Self::Future { + let IncomingTxs::Bytes { mut txs, state } = req; + + let mut local_tracker = self.txs_being_added.local_tracker(); + + txs.retain(|bytes| local_tracker.try_add_tx(bytes.as_ref())); + + if txs.is_empty() { + return ready(Ok(())).boxed(); + } + + let mut blockchain_context_cache = self.blockchain_context_cache.clone(); + let mut tx_verifier_service = self.tx_verifier_service.clone(); + let mut txpool_write_handle = self.txpool_write_handle.clone(); + + async move { + let txs = rayon_spawn_async(move || { + txs.into_iter() + .map(|bytes| { + let tx = Transaction::read(&mut bytes.as_ref()) + .map_err(IncomingTxError::Parse)?; + + let tx = new_tx_verification_data(tx) + .map_err(|e| IncomingTxError::Consensus(e.into()))?; + + Ok(Arc::new(tx)) + }) + .collect::, IncomingTxError>>() + }) + .await?; + + let BlockChainContextResponse::Context(context) = blockchain_context_cache + .ready() + .await? + .call(BlockChainContextRequest::GetContext) + .await? + else { + unreachable!() + }; + + let context = context.unchecked_blockchain_context(); + + tx_verifier_service + .ready() + .await? + .call(VerifyTxRequest::Prepped { + txs: txs.clone(), + current_chain_height: context.chain_height, + top_hash: context.top_hash, + time_for_time_lock: context.current_adjusted_timestamp_for_time_lock(), + hf: context.current_hf, + }) + .await?; + + txpool_write_handle + .ready() + .await? + .call(TxpoolWriteRequest::AddTransaction { + tx, + state_stem: state.state_stem(), + }) + .await; + + todo!() + } + .boxed() + } +} + +async fn handle_incoming_txs( + txs: Vec, + state: TxState, + tx_being_handled_locally: TxBeingHandledLocally, + mut blockchain_context_cache: BlockChainContextService, + mut tx_verifier_service: ConcreteTxVerifierService, + mut txpool_write_handle: TxpoolWriteHandle, + mut txpool_read_handle: TxpoolReadHandle, + mut dandelion_pool_manager: DandelionPoolService, +) -> Result<(), IncomingTxError> { + let mut tx_blob_hashes = HashSet::new(); + + let txs = txs + .into_iter() + .map(|tx_blob| { + let tx_blob_hash = tx_blob_hash(tx_blob.as_ref()); + if !tx_blob_hashes.insert(tx_blob_hash) { + return Err(IncomingTxError::DuplicateTransaction); + } + + Ok((tx_blob_hash, tx_blob)) + }) + .collect::, _>>()?; + + let TxpoolReadRequest::FilterKnownTxBlobHashes(tx_blob_hashes) = txpool_read_handle + .ready() + .await? + .call(TxpoolReadRequest::FilterKnownTxBlobHashes(tx_blob_hashes)) + .await? + else { + unreachable!() + }; + + let txs = rayon_spawn_async(move || { + txs.into_iter() + .filter_map(|(tx_blob_hash, tx_blob)| { + if tx_blob_hashes.contains(&tx_blob_hash) { + Some(tx_blob) + } else { + None + } + }) + .map(|bytes| { + let tx = Transaction::read(&mut bytes.as_ref()).map_err(IncomingTxError::Parse)?; + + let tx = new_tx_verification_data(tx) + .map_err(|e| IncomingTxError::Consensus(e.into()))?; + + Ok(Arc::new(tx)) + }) + .collect::, IncomingTxError>>() + }) + .await?; + + let BlockChainContextResponse::Context(context) = blockchain_context_cache + .ready() + .await? + .call(BlockChainContextRequest::GetContext) + .await? + else { + unreachable!() + }; + + let context = context.unchecked_blockchain_context(); + + tx_verifier_service + .ready() + .await? + .call(VerifyTxRequest::Prepped { + txs: txs.clone(), + current_chain_height: context.chain_height, + top_hash: context.top_hash, + time_for_time_lock: context.current_adjusted_timestamp_for_time_lock(), + hf: context.current_hf, + }) + .await?; + + for tx in txs { + let incoming_tx = IncomingTxBuilder::new(Bytes::copy_from_slice(&tx.tx_blob), tx.tx_hash); + + let TxpoolWriteResponse::AddTransaction(double_spend) = txpool_write_handle + .ready() + .await? + .call(TxpoolWriteRequest::AddTransaction { + tx, + state_stem: state.state_stem(), + }) + .await? + else { + unreachable!() + }; + + // TODO: track double spends to quickly ignore them from their blob hash. + if let Some(tx_hash) = double_spend { + continue; + }; + + // TODO: check blockchain for double spends to prevent a race condition. + + // TODO: fill this in properly. + let incoming_tx = incoming_tx + .with_routing_state(state.clone()) + .with_state_in_db(None) + .build() + .unwrap(); + + dandelion_pool_manager + .ready() + .await? + .call(incoming_tx) + .await?; + } +} diff --git a/binaries/cuprated/src/txpool/manager.rs b/binaries/cuprated/src/txpool/manager.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/binaries/cuprated/src/txpool/manager.rs @@ -0,0 +1 @@ + diff --git a/binaries/cuprated/src/txpool/txs_being_handled.rs b/binaries/cuprated/src/txpool/txs_being_handled.rs new file mode 100644 index 00000000..3973e7a0 --- /dev/null +++ b/binaries/cuprated/src/txpool/txs_being_handled.rs @@ -0,0 +1,48 @@ +use dashmap::DashSet; +use sha3::{Digest, Sha3_256}; +use std::sync::Arc; + +pub fn tx_blob_hash(tx_bytes: &[u8]) -> [u8; 32] { + let mut hasher = Sha3_256::new(); + hasher.update(tx_bytes); + hasher.finalize().into() +} +#[derive(Clone)] +pub struct TxsBeingHandled(Arc>); + +impl TxsBeingHandled { + pub fn local_tracker(&self) -> TxBeingHandledLocally { + TxBeingHandledLocally { + txs_being_handled: self.clone(), + txs: vec![], + } + } +} + +pub struct TxBeingHandledLocally { + txs_being_handled: TxsBeingHandled, + txs: Vec<[u8; 32]>, +} + +impl TxBeingHandledLocally { + pub fn try_add_tx(&mut self, tx_bytes: &[u8]) -> bool { + let mut hasher = Sha3_256::new(); + hasher.update(tx_bytes); + let tx_blob_hash = hasher.finalize().into(); + + if !self.txs_being_handled.0.insert(tx_blob_hash) { + return false; + } + + self.txs.push(tx_blob_hash); + true + } +} + +impl Drop for TxBeingHandledLocally { + fn drop(&mut self) { + for hash in &self.txs { + self.txs_being_handled.0.remove(hash); + } + } +} diff --git a/p2p/dandelion-tower/src/router.rs b/p2p/dandelion-tower/src/router.rs index 88702be0..c04dcaea 100644 --- a/p2p/dandelion-tower/src/router.rs +++ b/p2p/dandelion-tower/src/router.rs @@ -73,6 +73,12 @@ pub enum TxState { Local, } +impl TxState { + pub const fn state_stem(&self) -> bool { + matches!(self, Self::Local | Self::Stem { .. }) + } +} + /// A request to route a transaction. pub struct DandelionRouteReq { /// The transaction. diff --git a/p2p/p2p/src/client_pool.rs b/p2p/p2p/src/client_pool.rs index fc97fc1b..25dd2420 100644 --- a/p2p/p2p/src/client_pool.rs +++ b/p2p/p2p/src/client_pool.rs @@ -18,7 +18,7 @@ use tracing::{Instrument, Span}; use cuprate_p2p_core::{ client::{Client, InternalPeerID}, handles::ConnectionHandle, - NetworkZone, + ConnectionDirection, NetworkZone, }; pub(crate) mod disconnect_monitor; @@ -165,6 +165,16 @@ impl ClientPool { sync_data.cumulative_difficulty() > cumulative_difficulty }) } + + pub fn outbound_client(&self) -> Option> { + let client = self + .clients + .iter() + .find(|element| element.value().info.direction == ConnectionDirection::Outbound)?; + let id = *client.key(); + + Some(self.clients.remove(&id).unwrap().1) + } } mod sealed { diff --git a/storage/service/src/service/write.rs b/storage/service/src/service/write.rs index f75d6151..3914f229 100644 --- a/storage/service/src/service/write.rs +++ b/storage/service/src/service/write.rs @@ -21,7 +21,7 @@ const WRITER_THREAD_NAME: &str = concat!(module_path!(), "::DatabaseWriter"); /// Calling [`tower::Service::call`] with a [`DatabaseWriteHandle`] /// will return an `async`hronous channel that can be `.await`ed upon /// to receive the corresponding response. -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct DatabaseWriteHandle { /// Sender channel to the database write thread-pool. /// diff --git a/storage/txpool/src/service/interface.rs b/storage/txpool/src/service/interface.rs index 450b28d6..22a09cba 100644 --- a/storage/txpool/src/service/interface.rs +++ b/storage/txpool/src/service/interface.rs @@ -1,6 +1,8 @@ //! Tx-pool [`service`](super) interface. //! //! This module contains `cuprate_txpool`'s [`tower::Service`] request and response enums. + +use std::collections::HashSet; use std::sync::Arc; use cuprate_types::TransactionVerificationData; @@ -9,11 +11,14 @@ use crate::types::TransactionHash; //---------------------------------------------------------------------------------------------------- TxpoolReadRequest /// The transaction pool [`tower::Service`] read request type. +#[derive(Clone)] pub enum TxpoolReadRequest { /// A request for the blob (raw bytes) of a transaction with the given hash. TxBlob(TransactionHash), /// A request for the [`TransactionVerificationData`] of a transaction in the tx pool. TxVerificationData(TransactionHash), + + FilterKnownTxBlobHashes(HashSet), } //---------------------------------------------------------------------------------------------------- TxpoolReadResponse @@ -25,10 +30,13 @@ pub enum TxpoolReadResponse { TxBlob(Vec), /// A response of [`TransactionVerificationData`]. TxVerificationData(TransactionVerificationData), + + FilterKnownTxBlobHashes(HashSet), } //---------------------------------------------------------------------------------------------------- TxpoolWriteRequest /// The transaction pool [`tower::Service`] write request type. +#[derive(Clone)] pub enum TxpoolWriteRequest { /// Add a transaction to the pool. /// From d2c7e49e8014e34c4971d69d1ad29c59f1818cb1 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 10 Oct 2024 21:14:22 +0100 Subject: [PATCH 52/72] add dandelion start function --- binaries/cuprated/src/txpool/dandelion.rs | 32 ++++++++++++++++--- .../cuprated/src/txpool/dandelion/tx_store.rs | 4 +-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/binaries/cuprated/src/txpool/dandelion.rs b/binaries/cuprated/src/txpool/dandelion.rs index 47d1ca38..27f1f79d 100644 --- a/binaries/cuprated/src/txpool/dandelion.rs +++ b/binaries/cuprated/src/txpool/dandelion.rs @@ -1,26 +1,50 @@ use bytes::Bytes; +use cuprate_dandelion_tower::pool::DandelionPoolService; use cuprate_dandelion_tower::{DandelionConfig, DandelionRouter}; use cuprate_p2p::NetworkInterface; use cuprate_p2p_core::ClearNet; +use cuprate_txpool::service::{TxpoolReadHandle, TxpoolWriteHandle}; use cuprate_wire::NetworkAddress; mod diffuse_service; mod stem_service; mod tx_store; +#[derive(Clone)] struct DandelionTx(Bytes); type TxId = [u8; 32]; -pub fn start_dandelion_router( - clear_net: NetworkInterface, -) -> DandelionRouter< +type ConcreteDandelionRouter = DandelionRouter< stem_service::OutboundPeerStream, diffuse_service::DiffuseService, NetworkAddress, stem_service::StemPeerService, DandelionTx, -> { +>; + +pub fn start_dandelion_pool_manager( + router: ConcreteDandelionRouter, + txpool_read_handle: TxpoolReadHandle, + txpool_write_handle: TxpoolWriteHandle, +) -> DandelionPoolService { + cuprate_dandelion_tower::pool::start_dandelion_pool_manager( + 12, + router, + tx_store::TxStoreService { + txpool_read_handle, + txpool_write_handle, + }, + DandelionConfig { + time_between_hop: Default::default(), + epoch_duration: Default::default(), + fluff_probability: 0.0, + graph: Default::default(), + }, + ) +} + +pub fn dandelion_router(clear_net: NetworkInterface) -> ConcreteDandelionRouter { DandelionRouter::new( diffuse_service::DiffuseService { clear_net_broadcast_service: clear_net.broadcast_svc(), diff --git a/binaries/cuprated/src/txpool/dandelion/tx_store.rs b/binaries/cuprated/src/txpool/dandelion/tx_store.rs index 98de764b..29f719e5 100644 --- a/binaries/cuprated/src/txpool/dandelion/tx_store.rs +++ b/binaries/cuprated/src/txpool/dandelion/tx_store.rs @@ -11,8 +11,8 @@ use tower::util::Oneshot; use tower::{Service, ServiceExt}; pub struct TxStoreService { - txpool_read_handle: TxpoolReadHandle, - txpool_write_handle: TxpoolWriteHandle, + pub txpool_read_handle: TxpoolReadHandle, + pub txpool_write_handle: TxpoolWriteHandle, } impl Service> for TxStoreService { From b6d94cf78017109d55f670ddc198f925947da75d Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sun, 13 Oct 2024 01:22:20 +0100 Subject: [PATCH 53/72] finish incoming tx handler --- binaries/cuprated/Cargo.toml | 2 +- binaries/cuprated/src/txpool.rs | 1 - binaries/cuprated/src/txpool/dandelion.rs | 31 +- .../src/txpool/dandelion/diffuse_service.rs | 21 +- .../src/txpool/dandelion/stem_service.rs | 41 +- .../cuprated/src/txpool/dandelion/tx_store.rs | 63 +++- binaries/cuprated/src/txpool/incoming_tx.rs | 357 ++++++++++-------- binaries/cuprated/src/txpool/manager.rs | 1 - .../cuprated/src/txpool/txs_being_handled.rs | 7 +- p2p/dandelion-tower/src/router.rs | 2 +- storage/service/src/service/write.rs | 10 +- storage/txpool/src/service/interface.rs | 27 +- storage/txpool/src/service/read.rs | 1 + storage/txpool/src/types.rs | 3 + 14 files changed, 328 insertions(+), 239 deletions(-) delete mode 100644 binaries/cuprated/src/txpool/manager.rs diff --git a/binaries/cuprated/Cargo.toml b/binaries/cuprated/Cargo.toml index 62a10322..c8a4247f 100644 --- a/binaries/cuprated/Cargo.toml +++ b/binaries/cuprated/Cargo.toml @@ -20,7 +20,7 @@ cuprate-levin = { path = "../../net/levin" } cuprate-wire = { path = "../../net/wire" } cuprate-p2p = { path = "../../p2p/p2p" } cuprate-p2p-core = { path = "../../p2p/p2p-core" } -cuprate-dandelion-tower = { path = "../../p2p/dandelion-tower" } +cuprate-dandelion-tower = { path = "../../p2p/dandelion-tower", features = ["txpool"] } cuprate-async-buffer = { path = "../../p2p/async-buffer" } cuprate-address-book = { path = "../../p2p/address-book" } cuprate-blockchain = { path = "../../storage/blockchain", features = ["service"] } diff --git a/binaries/cuprated/src/txpool.rs b/binaries/cuprated/src/txpool.rs index af5a4205..79731023 100644 --- a/binaries/cuprated/src/txpool.rs +++ b/binaries/cuprated/src/txpool.rs @@ -4,5 +4,4 @@ mod dandelion; mod incoming_tx; -mod manager; mod txs_being_handled; diff --git a/binaries/cuprated/src/txpool/dandelion.rs b/binaries/cuprated/src/txpool/dandelion.rs index 27f1f79d..07fd4792 100644 --- a/binaries/cuprated/src/txpool/dandelion.rs +++ b/binaries/cuprated/src/txpool/dandelion.rs @@ -1,6 +1,8 @@ +use std::time::Duration; + use bytes::Bytes; use cuprate_dandelion_tower::pool::DandelionPoolService; -use cuprate_dandelion_tower::{DandelionConfig, DandelionRouter}; +use cuprate_dandelion_tower::{DandelionConfig, DandelionRouter, Graph}; use cuprate_p2p::NetworkInterface; use cuprate_p2p_core::ClearNet; use cuprate_txpool::service::{TxpoolReadHandle, TxpoolWriteHandle}; @@ -11,10 +13,17 @@ mod stem_service; mod tx_store; #[derive(Clone)] -struct DandelionTx(Bytes); +pub struct DandelionTx(Bytes); type TxId = [u8; 32]; +const DANDELION_CONFIG: DandelionConfig = DandelionConfig { + time_between_hop: Duration::from_millis(175), + epoch_duration: Duration::from_secs(10 * 60), + fluff_probability: 0.12, + graph: Graph::FourRegular, +}; + type ConcreteDandelionRouter = DandelionRouter< stem_service::OutboundPeerStream, diffuse_service::DiffuseService, @@ -35,12 +44,7 @@ pub fn start_dandelion_pool_manager( txpool_read_handle, txpool_write_handle, }, - DandelionConfig { - time_between_hop: Default::default(), - epoch_duration: Default::default(), - fluff_probability: 0.0, - graph: Default::default(), - }, + DANDELION_CONFIG, ) } @@ -49,14 +53,7 @@ pub fn dandelion_router(clear_net: NetworkInterface) -> ConcreteDandel diffuse_service::DiffuseService { clear_net_broadcast_service: clear_net.broadcast_svc(), }, - stem_service::OutboundPeerStream { - clear_net: clear_net.clone(), - }, - DandelionConfig { - time_between_hop: Default::default(), - epoch_duration: Default::default(), - fluff_probability: 0.0, - graph: Default::default(), - }, + stem_service::OutboundPeerStream { clear_net }, + DANDELION_CONFIG, ) } diff --git a/binaries/cuprated/src/txpool/dandelion/diffuse_service.rs b/binaries/cuprated/src/txpool/dandelion/diffuse_service.rs index 57b7d292..115799d0 100644 --- a/binaries/cuprated/src/txpool/dandelion/diffuse_service.rs +++ b/binaries/cuprated/src/txpool/dandelion/diffuse_service.rs @@ -1,19 +1,26 @@ -use std::task::{Context, Poll}; +use std::{ + future::{ready, Ready}, + task::{Context, Poll}, +}; + +use futures::FutureExt; use tower::Service; -use crate::txpool::dandelion::DandelionTx; use cuprate_dandelion_tower::traits::DiffuseRequest; use cuprate_p2p::{BroadcastRequest, BroadcastSvc, NetworkInterface}; use cuprate_p2p_core::ClearNet; +use super::DandelionTx; + +/// The dandelion diffusion service. pub struct DiffuseService { pub clear_net_broadcast_service: BroadcastSvc, } impl Service> for DiffuseService { - type Response = BroadcastSvc::Response; + type Response = (); type Error = tower::BoxError; - type Future = BroadcastSvc::Future; + type Future = Ready>; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { self.clear_net_broadcast_service @@ -22,11 +29,17 @@ impl Service> for DiffuseService { } fn call(&mut self, req: DiffuseRequest) -> Self::Future { + // TODO: Call `into_inner` when 1.82.0 stabilizes self.clear_net_broadcast_service .call(BroadcastRequest::Transaction { tx_bytes: req.0 .0, direction: None, received_from: None, }) + .now_or_never() + .unwrap() + .expect("Broadcast service is Infallible"); + + ready(Ok(())) } } diff --git a/binaries/cuprated/src/txpool/dandelion/stem_service.rs b/binaries/cuprated/src/txpool/dandelion/stem_service.rs index 6970ebfc..330c8843 100644 --- a/binaries/cuprated/src/txpool/dandelion/stem_service.rs +++ b/binaries/cuprated/src/txpool/dandelion/stem_service.rs @@ -1,17 +1,23 @@ -use super::DandelionTx; -use bytes::Bytes; -use cuprate_dandelion_tower::traits::StemRequest; -use cuprate_dandelion_tower::OutboundPeer; +use std::{ + pin::Pin, + task::{Context, Poll}, +}; + +use cuprate_dandelion_tower::{traits::StemRequest, OutboundPeer}; use cuprate_p2p::NetworkInterface; -use cuprate_p2p_core::client::Client; -use cuprate_p2p_core::{ClearNet, NetworkZone, PeerRequest, ProtocolRequest}; -use cuprate_wire::protocol::NewTransactions; -use cuprate_wire::NetworkAddress; +use cuprate_p2p_core::{ + client::{Client, InternalPeerID}, + ClearNet, NetworkZone, PeerRequest, ProtocolRequest, +}; +use cuprate_wire::{protocol::NewTransactions, NetworkAddress}; + +use bytes::Bytes; use futures::Stream; -use std::pin::Pin; -use std::task::{Context, Poll}; use tower::Service; +use super::DandelionTx; + +/// The dandelion outbound peer stream. pub struct OutboundPeerStream { pub clear_net: NetworkInterface, } @@ -20,22 +26,29 @@ impl Stream for OutboundPeerStream { type Item = Result>, tower::BoxError>; fn poll_next(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll> { + // TODO: make the outbound peer choice random. Poll::Ready(Some(Ok(self .clear_net .client_pool() .outbound_client() .map_or(OutboundPeer::Exhausted, |client| { - OutboundPeer::Peer(client.info.id.into(), StemPeerService(client)) + let addr = match client.info.id { + InternalPeerID::KnownAddr(addr) => addr, + InternalPeerID::Unknown(_) => panic!("Outbound peer had an unknown address"), + }; + + OutboundPeer::Peer(addr.into(), StemPeerService(client)) })))) } } -pub struct StemPeerService(Client); +/// The stem service, used to send stem txs. +pub struct StemPeerService(Client); impl Service> for StemPeerService { - type Response = (); + type Response = as Service>::Response; type Error = tower::BoxError; - type Future = Client::Future; + type Future = as Service>::Future; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { self.0.poll_ready(cx) diff --git a/binaries/cuprated/src/txpool/dandelion/tx_store.rs b/binaries/cuprated/src/txpool/dandelion/tx_store.rs index 29f719e5..f13a6460 100644 --- a/binaries/cuprated/src/txpool/dandelion/tx_store.rs +++ b/binaries/cuprated/src/txpool/dandelion/tx_store.rs @@ -1,15 +1,27 @@ -use crate::txpool::dandelion::{DandelionTx, TxId}; -use bytes::Bytes; -use cuprate_dandelion_tower::traits::{TxStoreRequest, TxStoreResponse}; -use cuprate_database::RuntimeError; -use cuprate_txpool::service::interface::{TxpoolReadRequest, TxpoolReadResponse}; -use cuprate_txpool::service::{TxpoolReadHandle, TxpoolWriteHandle}; -use futures::future::BoxFuture; -use futures::{FutureExt, StreamExt, TryFutureExt}; -use std::task::{Context, Poll}; -use tower::util::Oneshot; -use tower::{Service, ServiceExt}; +use std::{ + f32::consts::E, + task::{Context, Poll}, +}; +use bytes::Bytes; +use futures::{future::BoxFuture, FutureExt, StreamExt, TryFutureExt}; +use tower::{util::Oneshot, Service, ServiceExt}; + +use cuprate_dandelion_tower::{ + traits::{TxStoreRequest, TxStoreResponse}, + State, +}; +use cuprate_database::RuntimeError; +use cuprate_txpool::service::{ + interface::{TxpoolReadRequest, TxpoolReadResponse, TxpoolWriteRequest, TxpoolWriteResponse}, + TxpoolReadHandle, TxpoolWriteHandle, +}; + +use super::{DandelionTx, TxId}; + +/// The dandelion tx-store service. +/// +/// This is just mapping the interface [`cuprate_dandelion_tower`] wants to what [`cuprate_txpool`] provides. pub struct TxStoreService { pub txpool_read_handle: TxpoolReadHandle, pub txpool_write_handle: TxpoolWriteHandle, @@ -31,17 +43,34 @@ impl Service> for TxStoreService { .clone() .oneshot(TxpoolReadRequest::TxBlob(tx_id)) .map(|res| match res { - Ok(TxpoolReadResponse::TxBlob(blob)) => Ok(TxStoreResponse::Transaction(Some( - (DandelionTx(Bytes::from(blob)), todo!()), - ))), + Ok(TxpoolReadResponse::TxBlob { + tx_blob, + state_stem, + }) => { + let state = if state_stem { + State::Stem + } else { + State::Fluff + }; + + Ok(TxStoreResponse::Transaction(Some(( + DandelionTx(Bytes::from(tx_blob)), + state, + )))) + } Err(RuntimeError::KeyNotFound) => Ok(TxStoreResponse::Transaction(None)), Err(e) => Err(e.into()), Ok(_) => unreachable!(), }) .boxed(), - TxStoreRequest::Promote(tx_id) => { - todo!() - } + TxStoreRequest::Promote(tx_id) => self + .txpool_write_handle + .oneshot(TxpoolWriteRequest::Promote(tx_id)) + .map(|res| match res { + Ok(_) | Err(RuntimeError::KeyNotFound) => TxStoreResponse::Ok, + Err(e) => Err(e.into()), + }) + .boxed(), } } } diff --git a/binaries/cuprated/src/txpool/incoming_tx.rs b/binaries/cuprated/src/txpool/incoming_tx.rs index 37202b06..abac69dd 100644 --- a/binaries/cuprated/src/txpool/incoming_tx.rs +++ b/binaries/cuprated/src/txpool/incoming_tx.rs @@ -1,58 +1,76 @@ -use std::collections::HashSet; -use std::future::ready; -use std::sync::Arc; -use std::task::{Context, Poll}; +use std::{ + collections::HashSet, + future::ready, + sync::Arc, + task::{Context, Poll}, +}; -use crate::blockchain::ConcreteTxVerifierService; -use crate::txpool::txs_being_handled::{tx_blob_hash, TxBeingHandledLocally, TxsBeingHandled}; use bytes::Bytes; -use cuprate_consensus::transactions::new_tx_verification_data; -use cuprate_consensus::{ - BlockChainContextRequest, BlockChainContextResponse, BlockChainContextService, - ExtendedConsensusError, TxVerifierService, VerifyTxRequest, VerifyTxResponse, -}; -use cuprate_dandelion_tower::pool::{DandelionPoolService, IncomingTx, IncomingTxBuilder}; -use cuprate_dandelion_tower::TxState; -use cuprate_helper::asynch::rayon_spawn_async; -use cuprate_txpool::service::interface::{ - TxpoolReadRequest, TxpoolWriteRequest, TxpoolWriteResponse, -}; -use cuprate_txpool::service::{TxpoolReadHandle, TxpoolWriteHandle}; -use cuprate_wire::NetworkAddress; use dashmap::DashSet; -use futures::future::BoxFuture; -use futures::FutureExt; +use futures::{future::BoxFuture, FutureExt}; use monero_serai::transaction::Transaction; use sha3::{Digest, Sha3_256}; use tower::{Service, ServiceExt}; +use cuprate_consensus::{ + transactions::new_tx_verification_data, BlockChainContextRequest, BlockChainContextResponse, + BlockChainContextService, ExtendedConsensusError, TxVerifierService, VerifyTxRequest, + VerifyTxResponse, +}; +use cuprate_dandelion_tower::{ + pool::{DandelionPoolService, IncomingTx, IncomingTxBuilder}, + TxState, +}; +use cuprate_helper::asynch::rayon_spawn_async; +use cuprate_txpool::service::{ + interface::{TxpoolReadRequest, TxpoolReadResponse, TxpoolWriteRequest, TxpoolWriteResponse}, + TxpoolReadHandle, TxpoolWriteHandle, +}; +use cuprate_types::TransactionVerificationData; +use cuprate_wire::NetworkAddress; + +use crate::{ + blockchain::ConcreteTxVerifierService, + constants::PANIC_CRITICAL_SERVICE_ERROR, + signals::REORG_LOCK, + txpool::txs_being_handled::{tx_blob_hash, TxBeingHandledLocally, TxsBeingHandled}, +}; + +/// An error that can happen handling an incoming tx. pub enum IncomingTxError { Parse(std::io::Error), Consensus(ExtendedConsensusError), DuplicateTransaction, } -pub enum IncomingTxs { - Bytes { - txs: Vec, - state: TxState, - }, +/// Incoming transactions. +pub struct IncomingTxs { + pub txs: Vec, + pub state: TxState, } +/// The transaction type used for dandelion++. +#[derive(Clone)] struct DandelionTx(Bytes); +/// A transaction ID/hash. type TxId = [u8; 32]; +/// The service than handles incoming transaction pool transactions. +/// +/// This service handles everything including verifying the tx, adding it to the pool and routing it to other nodes. pub struct IncomingTxHandler { - txs_being_added: Arc, - + /// A store of txs currently being handled in incoming tx requests. + txs_being_handled: TxsBeingHandled, + /// The blockchain context cache. blockchain_context_cache: BlockChainContextService, - + /// The dandelion txpool manager. dandelion_pool_manager: DandelionPoolService, + /// The transaction verifier service. tx_verifier_service: ConcreteTxVerifierService, - + /// The txpool write handle. txpool_write_handle: TxpoolWriteHandle, - + /// The txpool read handle. txpool_read_handle: TxpoolReadHandle, } @@ -66,70 +84,18 @@ impl Service for IncomingTxHandler { } fn call(&mut self, req: IncomingTxs) -> Self::Future { - let IncomingTxs::Bytes { mut txs, state } = req; + let IncomingTxs::Bytes { txs, state } = req; - let mut local_tracker = self.txs_being_added.local_tracker(); - - txs.retain(|bytes| local_tracker.try_add_tx(bytes.as_ref())); - - if txs.is_empty() { - return ready(Ok(())).boxed(); - } - - let mut blockchain_context_cache = self.blockchain_context_cache.clone(); - let mut tx_verifier_service = self.tx_verifier_service.clone(); - let mut txpool_write_handle = self.txpool_write_handle.clone(); - - async move { - let txs = rayon_spawn_async(move || { - txs.into_iter() - .map(|bytes| { - let tx = Transaction::read(&mut bytes.as_ref()) - .map_err(IncomingTxError::Parse)?; - - let tx = new_tx_verification_data(tx) - .map_err(|e| IncomingTxError::Consensus(e.into()))?; - - Ok(Arc::new(tx)) - }) - .collect::, IncomingTxError>>() - }) - .await?; - - let BlockChainContextResponse::Context(context) = blockchain_context_cache - .ready() - .await? - .call(BlockChainContextRequest::GetContext) - .await? - else { - unreachable!() - }; - - let context = context.unchecked_blockchain_context(); - - tx_verifier_service - .ready() - .await? - .call(VerifyTxRequest::Prepped { - txs: txs.clone(), - current_chain_height: context.chain_height, - top_hash: context.top_hash, - time_for_time_lock: context.current_adjusted_timestamp_for_time_lock(), - hf: context.current_hf, - }) - .await?; - - txpool_write_handle - .ready() - .await? - .call(TxpoolWriteRequest::AddTransaction { - tx, - state_stem: state.state_stem(), - }) - .await; - - todo!() - } + handle_incoming_txs( + txs, + state, + self.txs_being_handled.clone(), + self.blockchain_context_cache.clone(), + self.tx_verifier_service.clone(), + self.txpool_write_handle.clone(), + self.txpool_read_handle.clone(), + self.dandelion_pool_manager.clone(), + ) .boxed() } } @@ -137,38 +103,106 @@ impl Service for IncomingTxHandler { async fn handle_incoming_txs( txs: Vec, state: TxState, - tx_being_handled_locally: TxBeingHandledLocally, + txs_being_handled: TxsBeingHandled, mut blockchain_context_cache: BlockChainContextService, mut tx_verifier_service: ConcreteTxVerifierService, mut txpool_write_handle: TxpoolWriteHandle, mut txpool_read_handle: TxpoolReadHandle, mut dandelion_pool_manager: DandelionPoolService, ) -> Result<(), IncomingTxError> { - let mut tx_blob_hashes = HashSet::new(); + let reorg_guard = REORG_LOCK.read().await; - let txs = txs - .into_iter() - .map(|tx_blob| { - let tx_blob_hash = tx_blob_hash(tx_blob.as_ref()); - if !tx_blob_hashes.insert(tx_blob_hash) { - return Err(IncomingTxError::DuplicateTransaction); - } + let (txs, txs_being_handled_guard) = + prepare_incoming_txs(txs, txs_being_handled, &mut txpool_read_handle).await?; - Ok((tx_blob_hash, tx_blob)) - }) - .collect::, _>>()?; - - let TxpoolReadRequest::FilterKnownTxBlobHashes(tx_blob_hashes) = txpool_read_handle + let BlockChainContextResponse::Context(context) = blockchain_context_cache .ready() - .await? - .call(TxpoolReadRequest::FilterKnownTxBlobHashes(tx_blob_hashes)) - .await? + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR) + .call(BlockChainContextRequest::GetContext) + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR) else { unreachable!() }; - let txs = rayon_spawn_async(move || { - txs.into_iter() + let context = context.unchecked_blockchain_context(); + + tx_verifier_service + .ready() + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR) + .call(VerifyTxRequest::Prepped { + txs: txs.clone(), + current_chain_height: context.chain_height, + top_hash: context.top_hash, + time_for_time_lock: context.current_adjusted_timestamp_for_time_lock(), + hf: context.current_hf, + }) + .await + .map_err(IncomingTxError::Consensus)?; + + for tx in txs { + handle_valid_tx( + tx, + state.clone(), + &mut txpool_write_handle, + &mut dandelion_pool_manager, + ) + .await + } + + Ok(()) +} + +/// Prepares the incoming transactions for verification. +/// +/// This will filter out all transactions already in the pool or txs already being handled in another request. +async fn prepare_incoming_txs( + tx_blobs: Vec, + txs_being_handled: TxsBeingHandled, + txpool_read_handle: &mut TxpoolReadHandle, +) -> Result<(Vec>, TxBeingHandledLocally), IncomingTxError> { + let mut tx_blob_hashes = HashSet::new(); + let mut txs_being_handled_loacally = txs_being_handled.local_tracker(); + + // Compute the blob hash for each tx and filter out the txs currently being handled by another incoming tx batch. + let txs = tx_blobs + .into_iter() + .filter_map(|tx_blob| { + let tx_blob_hash = tx_blob_hash(tx_blob.as_ref()); + + // If a duplicate is in here the incoming tx batch contained the same tx twice. + if !tx_blob_hashes.insert(tx_blob_hash) { + return Some(Err(IncomingTxError::DuplicateTransaction)); + } + + // If a duplicate is here it is being handled in another batch. + if !txs_being_handled_loacally.try_add_tx(tx_blob_hash) { + return None; + } + + Some(Ok((tx_blob_hash, tx_blob))) + }) + .collect::, _>>()?; + + // Filter the txs already in the txpool out. + // This will leave the txs already in the pool in [`TxBeingHandledLocally`] but that shouldn't be an issue. + let TxpoolReadResponse::FilterKnownTxBlobHashes(tx_blob_hashes) = txpool_read_handle + .ready() + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR) + .call(TxpoolReadRequest::FilterKnownTxBlobHashes(tx_blob_hashes)) + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR) + else { + unreachable!() + }; + + // Now prepare the txs for verification. + rayon_spawn_async(move || { + let txs = txs + .into_iter() .filter_map(|(tx_blob_hash, tx_blob)| { if tx_blob_hashes.contains(&tx_blob_hash) { Some(tx_blob) @@ -184,66 +218,55 @@ async fn handle_incoming_txs( Ok(Arc::new(tx)) }) - .collect::, IncomingTxError>>() - }) - .await?; + .collect::, IncomingTxError>>()?; - let BlockChainContextResponse::Context(context) = blockchain_context_cache + Ok((txs, txs_being_handled_loacally)) + }) + .await +} + +async fn handle_valid_tx( + tx: Arc, + state: TxState, + txpool_write_handle: &mut TxpoolWriteHandle, + dandelion_pool_manager: &mut DandelionPoolService, +) { + let incoming_tx = + IncomingTxBuilder::new(DandelionTx(Bytes::copy_from_slice(&tx.tx_blob)), tx.tx_hash); + + let TxpoolWriteResponse::AddTransaction(double_spend) = txpool_write_handle .ready() - .await? - .call(BlockChainContextRequest::GetContext) - .await? + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR) + .call(TxpoolWriteRequest::AddTransaction { + tx, + state_stem: state.state_stem(), + }) + .await + .expect("TODO") else { unreachable!() }; - let context = context.unchecked_blockchain_context(); + // TODO: track double spends to quickly ignore them from their blob hash. + if let Some(tx_hash) = double_spend { + return; + }; - tx_verifier_service + // TODO: check blockchain for double spends to prevent a race condition. + + // TODO: fill this in properly. + let incoming_tx = incoming_tx + .with_routing_state(state) + .with_state_in_db(None) + .build() + .unwrap(); + + dandelion_pool_manager .ready() - .await? - .call(VerifyTxRequest::Prepped { - txs: txs.clone(), - current_chain_height: context.chain_height, - top_hash: context.top_hash, - time_for_time_lock: context.current_adjusted_timestamp_for_time_lock(), - hf: context.current_hf, - }) - .await?; - - for tx in txs { - let incoming_tx = IncomingTxBuilder::new(Bytes::copy_from_slice(&tx.tx_blob), tx.tx_hash); - - let TxpoolWriteResponse::AddTransaction(double_spend) = txpool_write_handle - .ready() - .await? - .call(TxpoolWriteRequest::AddTransaction { - tx, - state_stem: state.state_stem(), - }) - .await? - else { - unreachable!() - }; - - // TODO: track double spends to quickly ignore them from their blob hash. - if let Some(tx_hash) = double_spend { - continue; - }; - - // TODO: check blockchain for double spends to prevent a race condition. - - // TODO: fill this in properly. - let incoming_tx = incoming_tx - .with_routing_state(state.clone()) - .with_state_in_db(None) - .build() - .unwrap(); - - dandelion_pool_manager - .ready() - .await? - .call(incoming_tx) - .await?; - } + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR) + .call(incoming_tx) + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR); } diff --git a/binaries/cuprated/src/txpool/manager.rs b/binaries/cuprated/src/txpool/manager.rs deleted file mode 100644 index 8b137891..00000000 --- a/binaries/cuprated/src/txpool/manager.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/binaries/cuprated/src/txpool/txs_being_handled.rs b/binaries/cuprated/src/txpool/txs_being_handled.rs index 3973e7a0..8b30821d 100644 --- a/binaries/cuprated/src/txpool/txs_being_handled.rs +++ b/binaries/cuprated/src/txpool/txs_being_handled.rs @@ -7,6 +7,7 @@ pub fn tx_blob_hash(tx_bytes: &[u8]) -> [u8; 32] { hasher.update(tx_bytes); hasher.finalize().into() } + #[derive(Clone)] pub struct TxsBeingHandled(Arc>); @@ -25,11 +26,7 @@ pub struct TxBeingHandledLocally { } impl TxBeingHandledLocally { - pub fn try_add_tx(&mut self, tx_bytes: &[u8]) -> bool { - let mut hasher = Sha3_256::new(); - hasher.update(tx_bytes); - let tx_blob_hash = hasher.finalize().into(); - + pub fn try_add_tx(&mut self, tx_blob_hash: [u8; 32]) -> bool { if !self.txs_being_handled.0.insert(tx_blob_hash) { return false; } diff --git a/p2p/dandelion-tower/src/router.rs b/p2p/dandelion-tower/src/router.rs index c04dcaea..899b1235 100644 --- a/p2p/dandelion-tower/src/router.rs +++ b/p2p/dandelion-tower/src/router.rs @@ -74,7 +74,7 @@ pub enum TxState { } impl TxState { - pub const fn state_stem(&self) -> bool { + pub fn state_stem(&self) -> bool { matches!(self, Self::Local | Self::Stem { .. }) } } diff --git a/storage/service/src/service/write.rs b/storage/service/src/service/write.rs index 3914f229..607c4aa6 100644 --- a/storage/service/src/service/write.rs +++ b/storage/service/src/service/write.rs @@ -21,7 +21,7 @@ const WRITER_THREAD_NAME: &str = concat!(module_path!(), "::DatabaseWriter"); /// Calling [`tower::Service::call`] with a [`DatabaseWriteHandle`] /// will return an `async`hronous channel that can be `.await`ed upon /// to receive the corresponding response. -#[derive(Debug, Clone)] +#[derive(Debug)] pub struct DatabaseWriteHandle { /// Sender channel to the database write thread-pool. /// @@ -30,6 +30,14 @@ pub struct DatabaseWriteHandle { crossbeam::channel::Sender<(Req, oneshot::Sender>)>, } +impl Clone for DatabaseWriteHandle { + fn clone(&self) -> Self { + Self { + sender: self.sender.clone(), + } + } +} + impl DatabaseWriteHandle where Req: Send + 'static, diff --git a/storage/txpool/src/service/interface.rs b/storage/txpool/src/service/interface.rs index 22a09cba..cfcd8da8 100644 --- a/storage/txpool/src/service/interface.rs +++ b/storage/txpool/src/service/interface.rs @@ -1,13 +1,11 @@ //! Tx-pool [`service`](super) interface. //! //! This module contains `cuprate_txpool`'s [`tower::Service`] request and response enums. - -use std::collections::HashSet; -use std::sync::Arc; +use std::{collections::HashSet, sync::Arc}; use cuprate_types::TransactionVerificationData; -use crate::types::TransactionHash; +use crate::types::{TransactionBlobHash, TransactionHash}; //---------------------------------------------------------------------------------------------------- TxpoolReadRequest /// The transaction pool [`tower::Service`] read request type. @@ -17,8 +15,10 @@ pub enum TxpoolReadRequest { TxBlob(TransactionHash), /// A request for the [`TransactionVerificationData`] of a transaction in the tx pool. TxVerificationData(TransactionHash), - - FilterKnownTxBlobHashes(HashSet), + /// A request to filter (remove) all **known** transactions from the set. + /// + /// The hash is **not** the transaction hash, it is the hash of the serialized tx-blob. + FilterKnownTxBlobHashes(HashSet), } //---------------------------------------------------------------------------------------------------- TxpoolReadResponse @@ -26,12 +26,14 @@ pub enum TxpoolReadRequest { #[expect(clippy::large_enum_variant)] pub enum TxpoolReadResponse { /// A response containing the raw bytes of a transaction. - // TODO: use bytes::Bytes. - TxBlob(Vec), + TxBlob { + tx_blob: Vec, + state_stem: bool, + }, /// A response of [`TransactionVerificationData`]. TxVerificationData(TransactionVerificationData), - - FilterKnownTxBlobHashes(HashSet), + /// The response for [`TxpoolReadRequest::FilterKnownTxBlobHashes`]. + FilterKnownTxBlobHashes(HashSet), } //---------------------------------------------------------------------------------------------------- TxpoolWriteRequest @@ -53,6 +55,11 @@ pub enum TxpoolWriteRequest { /// /// Returns [`TxpoolWriteResponse::Ok`]. RemoveTransaction(TransactionHash), + /// Promote a transaction from the stem pool to the fluff pool. + /// If the tx is already in the fluff pool this does nothing. + /// + /// Returns [`TxpoolWriteResponse::Ok`]. + Promote(TransactionHash), } //---------------------------------------------------------------------------------------------------- TxpoolWriteResponse diff --git a/storage/txpool/src/service/read.rs b/storage/txpool/src/service/read.rs index f0068130..20a4bcdc 100644 --- a/storage/txpool/src/service/read.rs +++ b/storage/txpool/src/service/read.rs @@ -58,6 +58,7 @@ fn map_request( match request { TxpoolReadRequest::TxBlob(tx_hash) => tx_blob(env, &tx_hash), TxpoolReadRequest::TxVerificationData(tx_hash) => tx_verification_data(env, &tx_hash), + _ => todo!(), } } diff --git a/storage/txpool/src/types.rs b/storage/txpool/src/types.rs index 4da2d0fe..83d9e01a 100644 --- a/storage/txpool/src/types.rs +++ b/storage/txpool/src/types.rs @@ -17,6 +17,9 @@ pub type KeyImage = [u8; 32]; /// A transaction hash. pub type TransactionHash = [u8; 32]; +/// A transaction blob hash. +pub type TransactionBlobHash = [u8; 32]; + bitflags::bitflags! { /// Flags representing the state of the transaction in the pool. #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] From 4ba94f4bb7f58e30cb64d51baa9581b4985ce639 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sun, 13 Oct 2024 01:50:48 +0100 Subject: [PATCH 54/72] Add tx blob hash table --- Cargo.lock | 1 + storage/txpool/Cargo.toml | 1 + storage/txpool/src/free.rs | 16 +++++++++++++++- storage/txpool/src/ops/tx_write.rs | 9 +++++++++ storage/txpool/src/service/interface.rs | 7 ++----- storage/txpool/src/tables.rs | 10 ++++++++-- 6 files changed, 36 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e597f86..6742abec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -910,6 +910,7 @@ dependencies = [ "monero-serai", "rayon", "serde", + "sha3", "tempfile", "thiserror", "tokio", diff --git a/storage/txpool/Cargo.toml b/storage/txpool/Cargo.toml index 70211d9e..923060ee 100644 --- a/storage/txpool/Cargo.toml +++ b/storage/txpool/Cargo.toml @@ -29,6 +29,7 @@ bytemuck = { workspace = true, features = ["must_cast", "derive" bitflags = { workspace = true, features = ["std", "serde", "bytemuck"] } thiserror = { workspace = true } hex = { workspace = true } +sha3 = { workspace = true, features = ["std"] } tower = { workspace = true, optional = true } rayon = { workspace = true, optional = true } diff --git a/storage/txpool/src/free.rs b/storage/txpool/src/free.rs index d394002b..e04e3508 100644 --- a/storage/txpool/src/free.rs +++ b/storage/txpool/src/free.rs @@ -1,9 +1,11 @@ //! General free functions (related to the tx-pool database). //---------------------------------------------------------------------------------------------------- Import +use sha3::{Digest, Sha3_256}; + use cuprate_database::{ConcreteEnv, Env, EnvInner, InitError, RuntimeError, TxRw}; -use crate::{config::Config, tables::OpenTables}; +use crate::{config::Config, tables::OpenTables, types::TransactionBlobHash}; //---------------------------------------------------------------------------------------------------- Free functions /// Open the txpool database using the passed [`Config`]. @@ -60,3 +62,15 @@ pub fn open(config: Config) -> Result { Ok(env) } + +/// Calculate the transaction blob hash. +/// +/// This value is supposed to be quick to compute just based of the tx-blob without needing to parse the tx. +/// +/// The exact way the hash is calculated is not stable and is subject to change, as such it should not be exposed +/// as a way to interact with Cuprate externally. +pub fn transaction_blob_hash(tx_blob: &[u8]) -> TransactionBlobHash { + let mut hasher = Sha3_256::new(); + hasher.update(tx_blob); + hasher.finalize().into() +} diff --git a/storage/txpool/src/ops/tx_write.rs b/storage/txpool/src/ops/tx_write.rs index 9885b9c5..7b3b9a63 100644 --- a/storage/txpool/src/ops/tx_write.rs +++ b/storage/txpool/src/ops/tx_write.rs @@ -8,6 +8,7 @@ use cuprate_database::{DatabaseRw, RuntimeError, StorableVec}; use cuprate_types::TransactionVerificationData; use crate::{ + free::transaction_blob_hash, ops::{ key_images::{add_tx_key_images, remove_tx_key_images}, TxPoolWriteError, @@ -56,6 +57,10 @@ pub fn add_transaction( let kis_table = tables.spent_key_images_mut(); add_tx_key_images(&tx.tx.prefix().inputs, &tx.tx_hash, kis_table)?; + // Add the blob hash to table 4. + let blob_hash = transaction_blob_hash(&tx.tx_blob); + tables.known_blob_hashes_mut().put(&blob_hash, &())?; + Ok(()) } @@ -79,5 +84,9 @@ pub fn remove_transaction( let kis_table = tables.spent_key_images_mut(); remove_tx_key_images(&tx.prefix().inputs, kis_table)?; + // Remove the blob hash from table 4. + let blob_hash = transaction_blob_hash(&tx_blob); + tables.known_blob_hashes_mut().delete(&blob_hash)?; + Ok(()) } diff --git a/storage/txpool/src/service/interface.rs b/storage/txpool/src/service/interface.rs index cfcd8da8..a5d6634e 100644 --- a/storage/txpool/src/service/interface.rs +++ b/storage/txpool/src/service/interface.rs @@ -16,7 +16,7 @@ pub enum TxpoolReadRequest { /// A request for the [`TransactionVerificationData`] of a transaction in the tx pool. TxVerificationData(TransactionHash), /// A request to filter (remove) all **known** transactions from the set. - /// + /// /// The hash is **not** the transaction hash, it is the hash of the serialized tx-blob. FilterKnownTxBlobHashes(HashSet), } @@ -26,10 +26,7 @@ pub enum TxpoolReadRequest { #[expect(clippy::large_enum_variant)] pub enum TxpoolReadResponse { /// A response containing the raw bytes of a transaction. - TxBlob { - tx_blob: Vec, - state_stem: bool, - }, + TxBlob { tx_blob: Vec, state_stem: bool }, /// A response of [`TransactionVerificationData`]. TxVerificationData(TransactionVerificationData), /// The response for [`TxpoolReadRequest::FilterKnownTxBlobHashes`]. diff --git a/storage/txpool/src/tables.rs b/storage/txpool/src/tables.rs index dbb686ae..2ab32629 100644 --- a/storage/txpool/src/tables.rs +++ b/storage/txpool/src/tables.rs @@ -16,7 +16,9 @@ //! accessing _all_ tables defined here at once. use cuprate_database::{define_tables, StorableVec}; -use crate::types::{KeyImage, RawCachedVerificationState, TransactionHash, TransactionInfo}; +use crate::types::{ + KeyImage, RawCachedVerificationState, TransactionBlobHash, TransactionHash, TransactionInfo, +}; define_tables! { /// Serialized transaction blobs. @@ -41,5 +43,9 @@ define_tables! { /// /// This table contains the spent key images from all transactions in the pool. 3 => SpentKeyImages, - KeyImage => TransactionHash + KeyImage => TransactionHash, + + /// Transaction blob hashes that are in the pool. + 4 => KnownBlobHashes, + TransactionBlobHash => (), } From 2d5567e47bd532fda832c163cfb9438f11f3e9db Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sun, 13 Oct 2024 02:20:45 +0100 Subject: [PATCH 55/72] Add missing txpool requests --- .../cuprated/src/txpool/dandelion/tx_store.rs | 3 +- binaries/cuprated/src/txpool/incoming_tx.rs | 6 +-- storage/txpool/src/lib.rs | 2 +- storage/txpool/src/service/read.rs | 47 ++++++++++++++++--- storage/txpool/src/service/write.rs | 25 ++++++++-- 5 files changed, 67 insertions(+), 16 deletions(-) diff --git a/binaries/cuprated/src/txpool/dandelion/tx_store.rs b/binaries/cuprated/src/txpool/dandelion/tx_store.rs index f13a6460..c8fda16a 100644 --- a/binaries/cuprated/src/txpool/dandelion/tx_store.rs +++ b/binaries/cuprated/src/txpool/dandelion/tx_store.rs @@ -65,9 +65,10 @@ impl Service> for TxStoreService { .boxed(), TxStoreRequest::Promote(tx_id) => self .txpool_write_handle + .clone() .oneshot(TxpoolWriteRequest::Promote(tx_id)) .map(|res| match res { - Ok(_) | Err(RuntimeError::KeyNotFound) => TxStoreResponse::Ok, + Ok(_) | Err(RuntimeError::KeyNotFound) => Ok(TxStoreResponse::Ok), Err(e) => Err(e.into()), }) .boxed(), diff --git a/binaries/cuprated/src/txpool/incoming_tx.rs b/binaries/cuprated/src/txpool/incoming_tx.rs index abac69dd..addcad5f 100644 --- a/binaries/cuprated/src/txpool/incoming_tx.rs +++ b/binaries/cuprated/src/txpool/incoming_tx.rs @@ -84,11 +84,9 @@ impl Service for IncomingTxHandler { } fn call(&mut self, req: IncomingTxs) -> Self::Future { - let IncomingTxs::Bytes { txs, state } = req; - handle_incoming_txs( - txs, - state, + req.txs, + req.state, self.txs_being_handled.clone(), self.blockchain_context_cache.clone(), self.tx_verifier_service.clone(), diff --git a/storage/txpool/src/lib.rs b/storage/txpool/src/lib.rs index 243dc4d9..04d7bb91 100644 --- a/storage/txpool/src/lib.rs +++ b/storage/txpool/src/lib.rs @@ -13,7 +13,7 @@ pub mod tables; pub mod types; pub use config::Config; -pub use free::open; +pub use free::{open, transaction_blob_hash}; //re-exports pub use cuprate_database; diff --git a/storage/txpool/src/service/read.rs b/storage/txpool/src/service/read.rs index 20a4bcdc..4bcb32a1 100644 --- a/storage/txpool/src/service/read.rs +++ b/storage/txpool/src/service/read.rs @@ -1,4 +1,4 @@ -use std::sync::Arc; +use std::{collections::HashSet, sync::Arc}; use rayon::ThreadPool; @@ -11,8 +11,8 @@ use crate::{ interface::{TxpoolReadRequest, TxpoolReadResponse}, types::{ReadResponseResult, TxpoolReadHandle}, }, - tables::{OpenTables, TransactionBlobs}, - types::TransactionHash, + tables::{KnownBlobHashes, OpenTables, TransactionBlobs, TransactionInfos}, + types::{TransactionBlobHash, TransactionHash, TxStateFlags}, }; // TODO: update the docs here @@ -58,7 +58,9 @@ fn map_request( match request { TxpoolReadRequest::TxBlob(tx_hash) => tx_blob(env, &tx_hash), TxpoolReadRequest::TxVerificationData(tx_hash) => tx_verification_data(env, &tx_hash), - _ => todo!(), + TxpoolReadRequest::FilterKnownTxBlobHashes(blob_hashes) => { + filter_known_tx_blob_hashes(env, blob_hashes) + } } } @@ -86,10 +88,15 @@ fn tx_blob(env: &ConcreteEnv, tx_hash: &TransactionHash) -> ReadResponseResult { let tx_ro = inner_env.tx_ro()?; let tx_blobs_table = inner_env.open_db_ro::(&tx_ro)?; + let tx_infos_table = inner_env.open_db_ro::(&tx_ro)?; - tx_blobs_table - .get(tx_hash) - .map(|blob| TxpoolReadResponse::TxBlob(blob.0)) + let tx_blob = tx_blobs_table.get(tx_hash)?.0; + let tx_info = tx_infos_table.get(tx_hash)?; + + Ok(TxpoolReadResponse::TxBlob { + tx_blob, + state_stem: tx_info.flags.contains(TxStateFlags::STATE_STEM), + }) } /// [`TxpoolReadRequest::TxVerificationData`]. @@ -102,3 +109,29 @@ fn tx_verification_data(env: &ConcreteEnv, tx_hash: &TransactionHash) -> ReadRes get_transaction_verification_data(tx_hash, &tables).map(TxpoolReadResponse::TxVerificationData) } + +/// [`TxpoolReadRequest::FilterKnownTxBlobHashes`]. +fn filter_known_tx_blob_hashes( + env: &ConcreteEnv, + mut blob_hashes: HashSet, +) -> ReadResponseResult { + let inner_env = env.env_inner(); + let tx_ro = inner_env.tx_ro()?; + + let tx_blob_hashes = inner_env.open_db_ro::(&tx_ro)?; + + let mut err = None; + blob_hashes.retain(|blob_hash| match tx_blob_hashes.contains(blob_hash) { + Ok(exists) => !exists, + Err(e) => { + err.get_or_insert(e); + false + } + }); + + if let Some(e) = err { + return Err(e); + } + + Ok(TxpoolReadResponse::FilterKnownTxBlobHashes(blob_hashes)) +} diff --git a/storage/txpool/src/service/write.rs b/storage/txpool/src/service/write.rs index 8a3b1bf7..84916c85 100644 --- a/storage/txpool/src/service/write.rs +++ b/storage/txpool/src/service/write.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use cuprate_database::{ConcreteEnv, Env, EnvInner, RuntimeError, TxRw}; +use cuprate_database::{ConcreteEnv, DatabaseRw, Env, EnvInner, RuntimeError, TxRw}; use cuprate_database_service::DatabaseWriteHandle; use cuprate_types::TransactionVerificationData; @@ -10,8 +10,8 @@ use crate::{ interface::{TxpoolWriteRequest, TxpoolWriteResponse}, types::TxpoolWriteHandle, }, - tables::OpenTables, - types::TransactionHash, + tables::{OpenTables, TransactionInfos}, + types::{TransactionHash, TxStateFlags}, }; //---------------------------------------------------------------------------------------------------- init_write_service @@ -31,6 +31,7 @@ fn handle_txpool_request( add_transaction(env, tx, *state_stem) } TxpoolWriteRequest::RemoveTransaction(tx_hash) => remove_transaction(env, tx_hash), + TxpoolWriteRequest::Promote(tx_hash) => promote(env, tx_hash), } } @@ -101,3 +102,21 @@ fn remove_transaction( TxRw::commit(tx_rw)?; Ok(TxpoolWriteResponse::Ok) } + +/// [`TxpoolWriteRequest::Promote`] +fn promote( + env: &ConcreteEnv, + tx_hash: &TransactionHash, +) -> Result { + let env_inner = env.env_inner(); + let tx_rw = env_inner.tx_rw()?; + + let mut tx_infos = env_inner.open_db_rw::(&tx_rw)?; + + tx_infos.update(tx_hash, |mut info| { + info.flags.remove(TxStateFlags::STATE_STEM); + Some(info) + })?; + + Ok(TxpoolWriteResponse::Ok) +} From 93fb3c657c256e7bd67d28afffd70b955bd46f8d Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sun, 13 Oct 2024 18:35:58 +0100 Subject: [PATCH 56/72] handle duplicate stem txs --- binaries/cuprated/src/txpool/incoming_tx.rs | 68 +++++++++++++++++++-- storage/txpool/src/ops.rs | 2 +- storage/txpool/src/ops/tx_read.rs | 12 ++++ storage/txpool/src/ops/tx_write.rs | 4 +- storage/txpool/src/service/interface.rs | 7 ++- storage/txpool/src/service/read.rs | 32 ++++++++-- storage/txpool/src/tables.rs | 2 +- 7 files changed, 112 insertions(+), 15 deletions(-) diff --git a/binaries/cuprated/src/txpool/incoming_tx.rs b/binaries/cuprated/src/txpool/incoming_tx.rs index addcad5f..f0404b6b 100644 --- a/binaries/cuprated/src/txpool/incoming_tx.rs +++ b/binaries/cuprated/src/txpool/incoming_tx.rs @@ -19,7 +19,7 @@ use cuprate_consensus::{ }; use cuprate_dandelion_tower::{ pool::{DandelionPoolService, IncomingTx, IncomingTxBuilder}, - TxState, + State, TxState, }; use cuprate_helper::asynch::rayon_spawn_async; use cuprate_txpool::service::{ @@ -110,7 +110,7 @@ async fn handle_incoming_txs( ) -> Result<(), IncomingTxError> { let reorg_guard = REORG_LOCK.read().await; - let (txs, txs_being_handled_guard) = + let (txs, stem_pool_txs, txs_being_handled_guard) = prepare_incoming_txs(txs, txs_being_handled, &mut txpool_read_handle).await?; let BlockChainContextResponse::Context(context) = blockchain_context_cache @@ -150,6 +150,16 @@ async fn handle_incoming_txs( .await } + for stem_tx in stem_pool_txs { + rerelay_stem_tx( + &stem_tx, + state.clone(), + &mut txpool_read_handle, + &mut dandelion_pool_manager, + ) + .await; + } + Ok(()) } @@ -160,7 +170,14 @@ async fn prepare_incoming_txs( tx_blobs: Vec, txs_being_handled: TxsBeingHandled, txpool_read_handle: &mut TxpoolReadHandle, -) -> Result<(Vec>, TxBeingHandledLocally), IncomingTxError> { +) -> Result< + ( + Vec>, + Vec, + TxBeingHandledLocally, + ), + IncomingTxError, +> { let mut tx_blob_hashes = HashSet::new(); let mut txs_being_handled_loacally = txs_being_handled.local_tracker(); @@ -186,7 +203,10 @@ async fn prepare_incoming_txs( // Filter the txs already in the txpool out. // This will leave the txs already in the pool in [`TxBeingHandledLocally`] but that shouldn't be an issue. - let TxpoolReadResponse::FilterKnownTxBlobHashes(tx_blob_hashes) = txpool_read_handle + let TxpoolReadResponse::FilterKnownTxBlobHashes { + unknown_blob_hashes, + stem_pool_hashes, + } = txpool_read_handle .ready() .await .expect(PANIC_CRITICAL_SERVICE_ERROR) @@ -202,7 +222,7 @@ async fn prepare_incoming_txs( let txs = txs .into_iter() .filter_map(|(tx_blob_hash, tx_blob)| { - if tx_blob_hashes.contains(&tx_blob_hash) { + if unknown_blob_hashes.contains(&tx_blob_hash) { Some(tx_blob) } else { None @@ -218,7 +238,7 @@ async fn prepare_incoming_txs( }) .collect::, IncomingTxError>>()?; - Ok((txs, txs_being_handled_loacally)) + Ok((txs, stem_pool_hashes, txs_being_handled_loacally)) }) .await } @@ -268,3 +288,39 @@ async fn handle_valid_tx( .await .expect(PANIC_CRITICAL_SERVICE_ERROR); } + +async fn rerelay_stem_tx( + tx_hash: &TxId, + state: TxState, + txpool_read_handle: &mut TxpoolReadHandle, + dandelion_pool_manager: &mut DandelionPoolService, +) { + let TxpoolReadResponse::TxBlob { tx_blob, .. } = txpool_read_handle + .ready() + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR) + .call(TxpoolReadRequest::TxBlob(*tx_hash)) + .await + .expect("TODO") + else { + unreachable!() + }; + + let incoming_tx = + IncomingTxBuilder::new(DandelionTx(Bytes::copy_from_slice(&tx_blob)), *tx_hash); + + // TODO: fill this in properly. + let incoming_tx = incoming_tx + .with_routing_state(state) + .with_state_in_db(Some(State::Stem)) + .build() + .unwrap(); + + dandelion_pool_manager + .ready() + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR) + .call(incoming_tx) + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR); +} diff --git a/storage/txpool/src/ops.rs b/storage/txpool/src/ops.rs index 50d9ea4a..289a8bbf 100644 --- a/storage/txpool/src/ops.rs +++ b/storage/txpool/src/ops.rs @@ -85,7 +85,7 @@ mod key_images; mod tx_read; mod tx_write; -pub use tx_read::get_transaction_verification_data; +pub use tx_read::{get_transaction_verification_data, in_stem_pool}; pub use tx_write::{add_transaction, remove_transaction}; /// An error that can occur on some tx-write ops. diff --git a/storage/txpool/src/ops/tx_read.rs b/storage/txpool/src/ops/tx_read.rs index db894151..6b79cba8 100644 --- a/storage/txpool/src/ops/tx_read.rs +++ b/storage/txpool/src/ops/tx_read.rs @@ -8,6 +8,8 @@ use monero_serai::transaction::Transaction; use cuprate_database::{DatabaseRo, RuntimeError}; use cuprate_types::{TransactionVerificationData, TxVersion}; +use crate::tables::TransactionInfos; +use crate::types::TxStateFlags; use crate::{tables::Tables, types::TransactionHash}; /// Gets the [`TransactionVerificationData`] of a transaction in the tx-pool, leaving the tx in the pool. @@ -34,3 +36,13 @@ pub fn get_transaction_verification_data( cached_verification_state: Mutex::new(cached_verification_state), }) } + +pub fn in_stem_pool( + tx_hash: &TransactionHash, + tx_infos: &impl DatabaseRo, +) -> Result { + Ok(tx_infos + .get(tx_hash)? + .flags + .contains(TxStateFlags::STATE_STEM)) +} diff --git a/storage/txpool/src/ops/tx_write.rs b/storage/txpool/src/ops/tx_write.rs index 7b3b9a63..dc5ab463 100644 --- a/storage/txpool/src/ops/tx_write.rs +++ b/storage/txpool/src/ops/tx_write.rs @@ -59,7 +59,9 @@ pub fn add_transaction( // Add the blob hash to table 4. let blob_hash = transaction_blob_hash(&tx.tx_blob); - tables.known_blob_hashes_mut().put(&blob_hash, &())?; + tables + .known_blob_hashes_mut() + .put(&blob_hash, &tx.tx_hash)?; Ok(()) } diff --git a/storage/txpool/src/service/interface.rs b/storage/txpool/src/service/interface.rs index a5d6634e..0e570399 100644 --- a/storage/txpool/src/service/interface.rs +++ b/storage/txpool/src/service/interface.rs @@ -30,7 +30,12 @@ pub enum TxpoolReadResponse { /// A response of [`TransactionVerificationData`]. TxVerificationData(TransactionVerificationData), /// The response for [`TxpoolReadRequest::FilterKnownTxBlobHashes`]. - FilterKnownTxBlobHashes(HashSet), + FilterKnownTxBlobHashes { + /// The blob hashes that are unknown. + unknown_blob_hashes: HashSet, + /// The tx hashes of the blob hashes that were known but were in the stem pool. + stem_pool_hashes: Vec, + }, } //---------------------------------------------------------------------------------------------------- TxpoolWriteRequest diff --git a/storage/txpool/src/service/read.rs b/storage/txpool/src/service/read.rs index 4bcb32a1..9e92a0d4 100644 --- a/storage/txpool/src/service/read.rs +++ b/storage/txpool/src/service/read.rs @@ -2,9 +2,10 @@ use std::{collections::HashSet, sync::Arc}; use rayon::ThreadPool; -use cuprate_database::{ConcreteEnv, DatabaseRo, Env, EnvInner}; +use cuprate_database::{ConcreteEnv, DatabaseRo, Env, EnvInner, RuntimeError}; use cuprate_database_service::{init_thread_pool, DatabaseReadService, ReaderThreads}; +use crate::ops::in_stem_pool; use crate::{ ops::get_transaction_verification_data, service::{ @@ -119,12 +120,30 @@ fn filter_known_tx_blob_hashes( let tx_ro = inner_env.tx_ro()?; let tx_blob_hashes = inner_env.open_db_ro::(&tx_ro)?; + let tx_infos = inner_env.open_db_ro::(&tx_ro)?; + + let mut stem_pool_hashes = Vec::new(); + + // A closure that returns if a tx with a certain blob hash is unknown. + // This also fills in `stem_tx_hashes`. + let mut tx_unknown = |blob_hash| -> Result { + match tx_blob_hashes.get(&blob_hash) { + Ok(tx_hash) => { + if in_stem_pool(&tx_hash, &tx_infos)? { + stem_pool_hashes.push(tx_hash); + } + Ok(false) + } + Err(RuntimeError::KeyNotFound) => Ok(true), + Err(e) => Err(e), + } + }; let mut err = None; - blob_hashes.retain(|blob_hash| match tx_blob_hashes.contains(blob_hash) { - Ok(exists) => !exists, + blob_hashes.retain(|blob_hash| match tx_unknown(*blob_hash) { + Ok(res) => res, Err(e) => { - err.get_or_insert(e); + err = Some(e); false } }); @@ -133,5 +152,8 @@ fn filter_known_tx_blob_hashes( return Err(e); } - Ok(TxpoolReadResponse::FilterKnownTxBlobHashes(blob_hashes)) + Ok(TxpoolReadResponse::FilterKnownTxBlobHashes { + unknown_blob_hashes: blob_hashes, + stem_pool_hashes, + }) } diff --git a/storage/txpool/src/tables.rs b/storage/txpool/src/tables.rs index 2ab32629..1f2d4490 100644 --- a/storage/txpool/src/tables.rs +++ b/storage/txpool/src/tables.rs @@ -47,5 +47,5 @@ define_tables! { /// Transaction blob hashes that are in the pool. 4 => KnownBlobHashes, - TransactionBlobHash => (), + TransactionBlobHash => TransactionHash, } From 5ab5b062fdd3cbdcfa5c065d6b45d31998d4bd23 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sun, 13 Oct 2024 22:43:53 +0100 Subject: [PATCH 57/72] check txpool on incoming block --- binaries/cuprated/src/blockchain/interface.rs | 57 ++++++++++++------- storage/txpool/src/service/interface.rs | 10 +++- storage/txpool/src/service/read.rs | 36 ++++++++++-- storage/txpool/src/types.rs | 1 - 4 files changed, 77 insertions(+), 27 deletions(-) diff --git a/binaries/cuprated/src/blockchain/interface.rs b/binaries/cuprated/src/blockchain/interface.rs index 985e60d8..7f7dfd3a 100644 --- a/binaries/cuprated/src/blockchain/interface.rs +++ b/binaries/cuprated/src/blockchain/interface.rs @@ -15,6 +15,8 @@ use tower::{Service, ServiceExt}; use cuprate_blockchain::service::BlockchainReadHandle; use cuprate_consensus::transactions::new_tx_verification_data; use cuprate_helper::cast::usize_to_u64; +use cuprate_txpool::service::interface::{TxpoolReadRequest, TxpoolReadResponse}; +use cuprate_txpool::service::TxpoolReadHandle; use cuprate_types::{ blockchain::{BlockchainReadRequest, BlockchainResponse}, Chain, @@ -38,7 +40,7 @@ pub enum IncomingBlockError { /// /// The inner values are the block hash and the indexes of the missing txs in the block. #[error("Unknown transactions in block.")] - UnknownTransactions([u8; 32], Vec), + UnknownTransactions([u8; 32], Vec), /// We are missing the block's parent. #[error("The block has an unknown parent.")] Orphan, @@ -59,8 +61,9 @@ pub enum IncomingBlockError { /// - the block's parent is unknown pub async fn handle_incoming_block( block: Block, - given_txs: Vec, + mut given_txs: HashMap<[u8; 32], Transaction>, blockchain_read_handle: &mut BlockchainReadHandle, + txpool_read_handle: &mut TxpoolReadHandle, ) -> Result { /// A [`HashSet`] of block hashes that the blockchain manager is currently handling. /// @@ -72,7 +75,12 @@ pub async fn handle_incoming_block( /// which are also more expensive than `Mutex`s. static BLOCKS_BEING_HANDLED: LazyLock>> = LazyLock::new(|| Mutex::new(HashSet::new())); - // FIXME: we should look in the tx-pool for txs when that is ready. + + if given_txs.len() > block.transactions.len() { + return Err(IncomingBlockError::InvalidBlock(anyhow::anyhow!( + "Too many transactions given for block" + ))); + } if !block_exists(block.header.previous, blockchain_read_handle) .await @@ -90,23 +98,32 @@ pub async fn handle_incoming_block( return Ok(IncomingBlockOk::AlreadyHave); } - // TODO: remove this when we have a working tx-pool. - if given_txs.len() != block.transactions.len() { - return Err(IncomingBlockError::UnknownTransactions( - block_hash, - (0..usize_to_u64(block.transactions.len())).collect(), - )); - } + let TxpoolReadResponse::TxsForBlock { mut txs, missing } = txpool_read_handle + .ready() + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR) + .call(TxpoolReadRequest::TxsForBlock(block.transactions.clone())) + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR) + else { + unreachable!() + }; - // TODO: check we actually got given the right txs. - let prepped_txs = given_txs - .into_par_iter() - .map(|tx| { - let tx = new_tx_verification_data(tx)?; - Ok((tx.tx_hash, tx)) - }) - .collect::>() - .map_err(IncomingBlockError::InvalidBlock)?; + if !missing.is_empty() { + let needed_hashes = missing.iter().map(|index| block.transactions[*index]); + + for needed_hash in needed_hashes { + let Some(tx) = given_txs.remove(&needed_hash) else { + return Err(IncomingBlockError::UnknownTransactions(block_hash, missing)); + }; + + txs.insert( + needed_hash, + new_tx_verification_data(tx) + .map_err(|e| IncomingBlockError::InvalidBlock(e.into()))?, + ); + } + } let Some(incoming_block_tx) = COMMAND_TX.get() else { // We could still be starting up the blockchain manager. @@ -126,7 +143,7 @@ pub async fn handle_incoming_block( incoming_block_tx .send(BlockchainManagerCommand::AddBlock { block, - prepped_txs, + prepped_txs: txs, response_tx, }) .await diff --git a/storage/txpool/src/service/interface.rs b/storage/txpool/src/service/interface.rs index 0e570399..8e88065a 100644 --- a/storage/txpool/src/service/interface.rs +++ b/storage/txpool/src/service/interface.rs @@ -1,9 +1,9 @@ //! Tx-pool [`service`](super) interface. //! //! This module contains `cuprate_txpool`'s [`tower::Service`] request and response enums. -use std::{collections::HashSet, sync::Arc}; - use cuprate_types::TransactionVerificationData; +use std::collections::HashMap; +use std::{collections::HashSet, sync::Arc}; use crate::types::{TransactionBlobHash, TransactionHash}; @@ -19,6 +19,8 @@ pub enum TxpoolReadRequest { /// /// The hash is **not** the transaction hash, it is the hash of the serialized tx-blob. FilterKnownTxBlobHashes(HashSet), + /// A request to pull some transactions for an incoming block. + TxsForBlock(Vec), } //---------------------------------------------------------------------------------------------------- TxpoolReadResponse @@ -36,6 +38,10 @@ pub enum TxpoolReadResponse { /// The tx hashes of the blob hashes that were known but were in the stem pool. stem_pool_hashes: Vec, }, + TxsForBlock { + txs: HashMap<[u8; 32], TransactionVerificationData>, + missing: Vec, + }, } //---------------------------------------------------------------------------------------------------- TxpoolWriteRequest diff --git a/storage/txpool/src/service/read.rs b/storage/txpool/src/service/read.rs index 9e92a0d4..47c1d657 100644 --- a/storage/txpool/src/service/read.rs +++ b/storage/txpool/src/service/read.rs @@ -1,13 +1,15 @@ -use std::{collections::HashSet, sync::Arc}; +use std::{ + collections::{HashMap, HashSet}, + sync::Arc, +}; use rayon::ThreadPool; use cuprate_database::{ConcreteEnv, DatabaseRo, Env, EnvInner, RuntimeError}; use cuprate_database_service::{init_thread_pool, DatabaseReadService, ReaderThreads}; -use crate::ops::in_stem_pool; use crate::{ - ops::get_transaction_verification_data, + ops::{get_transaction_verification_data, in_stem_pool}, service::{ interface::{TxpoolReadRequest, TxpoolReadResponse}, types::{ReadResponseResult, TxpoolReadHandle}, @@ -51,7 +53,6 @@ fn init_read_service_with_pool(env: Arc, pool: Arc) -> /// 1. `Request` is mapped to a handler function /// 2. Handler function is called /// 3. [`TxpoolReadResponse`] is returned -#[expect(clippy::needless_pass_by_value)] fn map_request( env: &ConcreteEnv, // Access to the database request: TxpoolReadRequest, // The request we must fulfill @@ -62,6 +63,7 @@ fn map_request( TxpoolReadRequest::FilterKnownTxBlobHashes(blob_hashes) => { filter_known_tx_blob_hashes(env, blob_hashes) } + TxpoolReadRequest::TxsForBlock(txs_needed) => txs_for_block(env, txs_needed), } } @@ -157,3 +159,29 @@ fn filter_known_tx_blob_hashes( stem_pool_hashes, }) } + +/// [`TxpoolReadRequest::TxsForBlock`]. +fn txs_for_block(env: &ConcreteEnv, txs: Vec) -> ReadResponseResult { + let inner_env = env.env_inner(); + let tx_ro = inner_env.tx_ro()?; + + let tables = inner_env.open_tables(&tx_ro)?; + + let mut missing_tx_indexes = Vec::with_capacity(txs.len()); + let mut txs_verification_data = HashMap::with_capacity(txs.len()); + + for (i, tx_hash) in txs.into_iter().enumerate() { + match get_transaction_verification_data(&tx_hash, &tables) { + Ok(tx) => { + txs_verification_data.insert(tx_hash, tx); + } + Err(RuntimeError::KeyNotFound) => missing_tx_indexes.push(i), + Err(e) => return Err(e), + } + } + + Ok(TxpoolReadResponse::TxsForBlock { + txs: txs_verification_data, + missing: missing_tx_indexes, + }) +} diff --git a/storage/txpool/src/types.rs b/storage/txpool/src/types.rs index 83d9e01a..2acb819e 100644 --- a/storage/txpool/src/types.rs +++ b/storage/txpool/src/types.rs @@ -6,7 +6,6 @@ //! //! use bytemuck::{Pod, Zeroable}; - use monero_serai::transaction::Timelock; use cuprate_types::{CachedVerificationState, HardFork}; From 74a07cb8baf565defcaf1c62679a711b65a3e9ba Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Mon, 14 Oct 2024 01:00:02 +0100 Subject: [PATCH 58/72] add request to remove tx in new blocks from the pool --- storage/txpool/src/service/interface.rs | 7 ++- storage/txpool/src/service/write.rs | 65 +++++++++++++++++++++++-- storage/txpool/src/tables.rs | 6 ++- storage/txpool/src/types.rs | 6 +++ 4 files changed, 79 insertions(+), 5 deletions(-) diff --git a/storage/txpool/src/service/interface.rs b/storage/txpool/src/service/interface.rs index 8e88065a..7dc52f56 100644 --- a/storage/txpool/src/service/interface.rs +++ b/storage/txpool/src/service/interface.rs @@ -5,7 +5,7 @@ use cuprate_types::TransactionVerificationData; use std::collections::HashMap; use std::{collections::HashSet, sync::Arc}; -use crate::types::{TransactionBlobHash, TransactionHash}; +use crate::types::{KeyImage, TransactionBlobHash, TransactionHash}; //---------------------------------------------------------------------------------------------------- TxpoolReadRequest /// The transaction pool [`tower::Service`] read request type. @@ -68,6 +68,11 @@ pub enum TxpoolWriteRequest { /// /// Returns [`TxpoolWriteResponse::Ok`]. Promote(TransactionHash), + + NewBlock { + blockchain_height: usize, + spent_key_images: Vec, + }, } //---------------------------------------------------------------------------------------------------- TxpoolWriteResponse diff --git a/storage/txpool/src/service/write.rs b/storage/txpool/src/service/write.rs index 84916c85..2a4a5bba 100644 --- a/storage/txpool/src/service/write.rs +++ b/storage/txpool/src/service/write.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use cuprate_database::{ConcreteEnv, DatabaseRw, Env, EnvInner, RuntimeError, TxRw}; +use cuprate_database::{ConcreteEnv, DatabaseRo, DatabaseRw, Env, EnvInner, RuntimeError, TxRw}; use cuprate_database_service::DatabaseWriteHandle; use cuprate_types::TransactionVerificationData; @@ -10,8 +10,8 @@ use crate::{ interface::{TxpoolWriteRequest, TxpoolWriteResponse}, types::TxpoolWriteHandle, }, - tables::{OpenTables, TransactionInfos}, - types::{TransactionHash, TxStateFlags}, + tables::{OpenTables, Tables, TablesMut, TransactionInfos}, + types::{KeyImage, PoolInfo, TransactionHash, TxStateFlags}, }; //---------------------------------------------------------------------------------------------------- init_write_service @@ -32,6 +32,10 @@ fn handle_txpool_request( } TxpoolWriteRequest::RemoveTransaction(tx_hash) => remove_transaction(env, tx_hash), TxpoolWriteRequest::Promote(tx_hash) => promote(env, tx_hash), + TxpoolWriteRequest::NewBlock { + blockchain_height, + spent_key_images, + } => new_block(env, *blockchain_height, spent_key_images), } } @@ -118,5 +122,60 @@ fn promote( Some(info) })?; + drop(tx_infos); + + TxRw::commit(tx_rw)?; + Ok(TxpoolWriteResponse::Ok) +} + +fn new_block( + env: &ConcreteEnv, + blockchain_height: usize, + spent_key_images: &[KeyImage], +) -> Result { + let env_inner = env.env_inner(); + let tx_rw = env_inner.tx_rw()?; + + // FIXME: use try blocks once stable. + let result = || { + let mut tables_mut = env_inner.open_tables_mut(&tx_rw)?; + + for key_image in spent_key_images { + match tables_mut + .spent_key_images() + .get(key_image) + .and_then(|tx_hash| ops::remove_transaction(&tx_hash, &mut tables_mut)) + { + Ok(()) | Err(RuntimeError::KeyNotFound) => (), + Err(e) => return Err(e), + } + } + + let res = tables_mut.pool_stats_mut().update(&(), |mut info| { + info.last_known_blockchain_height = blockchain_height; + + Some(info) + }); + + match res { + Ok(()) => (), + Err(RuntimeError::KeyNotFound) => tables_mut.pool_stats_mut().put( + &(), + &PoolInfo { + last_known_blockchain_height: blockchain_height, + }, + )?, + Err(e) => return Err(e), + } + + Ok(()) + }; + + if let Err(e) = result() { + TxRw::abort(tx_rw)?; + return Err(e); + } + + TxRw::commit(tx_rw)?; Ok(TxpoolWriteResponse::Ok) } diff --git a/storage/txpool/src/tables.rs b/storage/txpool/src/tables.rs index 1f2d4490..d1d44686 100644 --- a/storage/txpool/src/tables.rs +++ b/storage/txpool/src/tables.rs @@ -17,7 +17,8 @@ use cuprate_database::{define_tables, StorableVec}; use crate::types::{ - KeyImage, RawCachedVerificationState, TransactionBlobHash, TransactionHash, TransactionInfo, + KeyImage, PoolInfo, RawCachedVerificationState, TransactionBlobHash, TransactionHash, + TransactionInfo, }; define_tables! { @@ -48,4 +49,7 @@ define_tables! { /// Transaction blob hashes that are in the pool. 4 => KnownBlobHashes, TransactionBlobHash => TransactionHash, + + 5 => PoolStats, + () => PoolInfo, } diff --git a/storage/txpool/src/types.rs b/storage/txpool/src/types.rs index 2acb819e..f1c1d0f7 100644 --- a/storage/txpool/src/types.rs +++ b/storage/txpool/src/types.rs @@ -19,6 +19,12 @@ pub type TransactionHash = [u8; 32]; /// A transaction blob hash. pub type TransactionBlobHash = [u8; 32]; +#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] +#[repr(C)] +pub struct PoolInfo { + pub last_known_blockchain_height: usize, +} + bitflags::bitflags! { /// Flags representing the state of the transaction in the pool. #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] From fb29f3237560c54430e2927e55bc9b8ef75305b7 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Mon, 14 Oct 2024 18:15:43 +0100 Subject: [PATCH 59/72] tell the txpool about incoming blocks --- binaries/cuprated/src/blockchain/manager.rs | 5 ++++ .../src/blockchain/manager/handler.rs | 26 +++++++++++++++++++ binaries/cuprated/src/txpool/incoming_tx.rs | 3 +-- storage/txpool/src/service/interface.rs | 14 +++++++--- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index 568ed572..13f78717 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -36,6 +36,7 @@ mod commands; mod handler; pub use commands::{BlockchainManagerCommand, IncomingBlockOk}; +use cuprate_txpool::service::TxpoolWriteHandle; /// Initialize the blockchain manager. /// @@ -45,6 +46,7 @@ pub async fn init_blockchain_manager( clearnet_interface: NetworkInterface, blockchain_write_handle: BlockchainWriteHandle, blockchain_read_handle: BlockchainReadHandle, + txpool_write_handle: TxpoolWriteHandle, mut blockchain_context_service: BlockChainContextService, block_verifier_service: ConcreteBlockVerifierService, block_downloader_config: BlockDownloaderConfig, @@ -79,6 +81,7 @@ pub async fn init_blockchain_manager( let manager = BlockchainManager { blockchain_write_handle, blockchain_read_handle, + txpool_write_handle, blockchain_context_service, cached_blockchain_context: blockchain_context.unchecked_blockchain_context().clone(), block_verifier_service, @@ -101,6 +104,8 @@ pub struct BlockchainManager { blockchain_write_handle: BlockchainWriteHandle, /// A [`BlockchainReadHandle`]. blockchain_read_handle: BlockchainReadHandle, + /// A [`TxpoolWriteHandle`]. + txpool_write_handle: TxpoolWriteHandle, // TODO: Improve the API of the cache service. // TODO: rename the cache service -> `BlockchainContextService`. /// The blockchain context cache, this caches the current state of the blockchain to quickly calculate/retrieve diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs index 303e2e49..b341ca6d 100644 --- a/binaries/cuprated/src/blockchain/manager/handler.rs +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -1,6 +1,7 @@ //! The blockchain manager handler functions. use bytes::Bytes; use futures::{TryFutureExt, TryStreamExt}; +use monero_serai::transaction::Input; use monero_serai::{block::Block, transaction::Transaction}; use rayon::prelude::*; use std::ops::ControlFlow; @@ -17,6 +18,7 @@ use cuprate_consensus::{ }; use cuprate_helper::cast::usize_to_u64; use cuprate_p2p::{block_downloader::BlockBatch, constants::LONG_BAN, BroadcastRequest}; +use cuprate_txpool::service::interface::TxpoolWriteRequest; use cuprate_types::{ blockchain::{BlockchainReadRequest, BlockchainResponse, BlockchainWriteRequest}, AltBlockInformation, HardFork, TransactionVerificationData, VerifiedBlockInformation, @@ -434,6 +436,19 @@ impl super::BlockchainManager { &mut self, verified_block: VerifiedBlockInformation, ) { + // FIXME: this is pretty inefficient, we should probably return the KI map created in the consensus crate. + let spent_key_images = verified_block + .txs + .iter() + .flat_map(|tx| { + tx.tx.prefix().inputs.iter().map(|input| match input { + Input::ToKey { key_image, .. } => key_image.compress().0, + Input::Gen(_) => unreachable!(), + }) + }) + .collect::>(); + let blockchain_height = verified_block.height + 1; + self.blockchain_context_service .ready() .await @@ -472,6 +487,17 @@ impl super::BlockchainManager { }; self.cached_blockchain_context = blockchain_context.unchecked_blockchain_context().clone(); + + self.txpool_write_handle + .ready() + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR) + .call(TxpoolWriteRequest::NewBlock { + spent_key_images, + blockchain_height, + }) + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR); } } diff --git a/binaries/cuprated/src/txpool/incoming_tx.rs b/binaries/cuprated/src/txpool/incoming_tx.rs index f0404b6b..14e98e05 100644 --- a/binaries/cuprated/src/txpool/incoming_tx.rs +++ b/binaries/cuprated/src/txpool/incoming_tx.rs @@ -271,9 +271,8 @@ async fn handle_valid_tx( return; }; - // TODO: check blockchain for double spends to prevent a race condition. + // TODO: There is a race condition possible if a tx and block come in at the same time . - // TODO: fill this in properly. let incoming_tx = incoming_tx .with_routing_state(state) .with_state_in_db(None) diff --git a/storage/txpool/src/service/interface.rs b/storage/txpool/src/service/interface.rs index 7dc52f56..8a527ab5 100644 --- a/storage/txpool/src/service/interface.rs +++ b/storage/txpool/src/service/interface.rs @@ -1,9 +1,12 @@ //! Tx-pool [`service`](super) interface. //! //! This module contains `cuprate_txpool`'s [`tower::Service`] request and response enums. +use std::{ + collections::{HashMap, HashSet}, + sync::Arc, +}; + use cuprate_types::TransactionVerificationData; -use std::collections::HashMap; -use std::{collections::HashSet, sync::Arc}; use crate::types::{KeyImage, TransactionBlobHash, TransactionHash}; @@ -38,8 +41,11 @@ pub enum TxpoolReadResponse { /// The tx hashes of the blob hashes that were known but were in the stem pool. stem_pool_hashes: Vec, }, + /// The response for [`TxpoolReadRequest::TxsForBlock`]. TxsForBlock { + /// The txs we had in the txpool. txs: HashMap<[u8; 32], TransactionVerificationData>, + /// The indexes of the missing txs. missing: Vec, }, } @@ -68,9 +74,11 @@ pub enum TxpoolWriteRequest { /// /// Returns [`TxpoolWriteResponse::Ok`]. Promote(TransactionHash), - + /// Tell the tx-pool about a new block. NewBlock { + /// The new blockchain height. blockchain_height: usize, + /// The spent key images in the new block. spent_key_images: Vec, }, } From b8e96cffcb0b852fccf676f3752154ee0e8f95e7 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Mon, 14 Oct 2024 19:25:00 +0100 Subject: [PATCH 60/72] fix merge --- binaries/cuprated/src/txpool/incoming_tx.rs | 5 +++-- p2p/dandelion-tower/src/router.rs | 2 +- storage/txpool/src/service/interface.rs | 5 ++++- storage/txpool/src/service/read.rs | 1 - storage/txpool/src/types.rs | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/binaries/cuprated/src/txpool/incoming_tx.rs b/binaries/cuprated/src/txpool/incoming_tx.rs index 14e98e05..a486738b 100644 --- a/binaries/cuprated/src/txpool/incoming_tx.rs +++ b/binaries/cuprated/src/txpool/incoming_tx.rs @@ -98,6 +98,7 @@ impl Service for IncomingTxHandler { } } +#[expect(clippy::too_many_arguments)] async fn handle_incoming_txs( txs: Vec, state: TxState, @@ -117,7 +118,7 @@ async fn handle_incoming_txs( .ready() .await .expect(PANIC_CRITICAL_SERVICE_ERROR) - .call(BlockChainContextRequest::GetContext) + .call(BlockChainContextRequest::Context) .await .expect(PANIC_CRITICAL_SERVICE_ERROR) else { @@ -147,7 +148,7 @@ async fn handle_incoming_txs( &mut txpool_write_handle, &mut dandelion_pool_manager, ) - .await + .await; } for stem_tx in stem_pool_txs { diff --git a/p2p/dandelion-tower/src/router.rs b/p2p/dandelion-tower/src/router.rs index 899b1235..c04dcaea 100644 --- a/p2p/dandelion-tower/src/router.rs +++ b/p2p/dandelion-tower/src/router.rs @@ -74,7 +74,7 @@ pub enum TxState { } impl TxState { - pub fn state_stem(&self) -> bool { + pub const fn state_stem(&self) -> bool { matches!(self, Self::Local | Self::Stem { .. }) } } diff --git a/storage/txpool/src/service/interface.rs b/storage/txpool/src/service/interface.rs index e1eb050c..0aa90491 100644 --- a/storage/txpool/src/service/interface.rs +++ b/storage/txpool/src/service/interface.rs @@ -8,7 +8,10 @@ use std::{ use cuprate_types::TransactionVerificationData; -use crate::{tx::TxEntry, types::{KeyImage, TransactionBlobHash, TransactionHash}}; +use crate::{ + tx::TxEntry, + types::{KeyImage, TransactionBlobHash, TransactionHash}, +}; //---------------------------------------------------------------------------------------------------- TxpoolReadRequest /// The transaction pool [`tower::Service`] read request type. diff --git a/storage/txpool/src/service/read.rs b/storage/txpool/src/service/read.rs index 41ee0198..bdeeb74b 100644 --- a/storage/txpool/src/service/read.rs +++ b/storage/txpool/src/service/read.rs @@ -4,7 +4,6 @@ clippy::unnecessary_wraps, reason = "TODO: finish implementing the signatures from " )] - use std::{ collections::{HashMap, HashSet}, sync::Arc, diff --git a/storage/txpool/src/types.rs b/storage/txpool/src/types.rs index f1c1d0f7..f507bbaa 100644 --- a/storage/txpool/src/types.rs +++ b/storage/txpool/src/types.rs @@ -19,6 +19,7 @@ pub type TransactionHash = [u8; 32]; /// A transaction blob hash. pub type TransactionBlobHash = [u8; 32]; +/// Information on the tx-pool. #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] #[repr(C)] pub struct PoolInfo { From bfb4cbf831205dde14b87e5da3b72353dbb0a371 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Mon, 14 Oct 2024 19:31:17 +0100 Subject: [PATCH 61/72] typos --- binaries/cuprated/src/txpool/incoming_tx.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/binaries/cuprated/src/txpool/incoming_tx.rs b/binaries/cuprated/src/txpool/incoming_tx.rs index a486738b..1ade33d6 100644 --- a/binaries/cuprated/src/txpool/incoming_tx.rs +++ b/binaries/cuprated/src/txpool/incoming_tx.rs @@ -180,7 +180,7 @@ async fn prepare_incoming_txs( IncomingTxError, > { let mut tx_blob_hashes = HashSet::new(); - let mut txs_being_handled_loacally = txs_being_handled.local_tracker(); + let mut txs_being_handled_locally = txs_being_handled.local_tracker(); // Compute the blob hash for each tx and filter out the txs currently being handled by another incoming tx batch. let txs = tx_blobs @@ -194,7 +194,7 @@ async fn prepare_incoming_txs( } // If a duplicate is here it is being handled in another batch. - if !txs_being_handled_loacally.try_add_tx(tx_blob_hash) { + if !txs_being_handled_locally.try_add_tx(tx_blob_hash) { return None; } @@ -239,7 +239,7 @@ async fn prepare_incoming_txs( }) .collect::, IncomingTxError>>()?; - Ok((txs, stem_pool_hashes, txs_being_handled_loacally)) + Ok((txs, stem_pool_hashes, txs_being_handled_locally)) }) .await } From 6c1f871d81f848e9694444755f45902929aee227 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Mon, 14 Oct 2024 20:24:12 +0100 Subject: [PATCH 62/72] remove blockchain height from txpool --- .../src/blockchain/manager/handler.rs | 6 +---- storage/txpool/src/service/interface.rs | 2 -- storage/txpool/src/service/write.rs | 27 +++---------------- storage/txpool/src/tables.rs | 6 +---- storage/txpool/src/types.rs | 7 ----- 5 files changed, 5 insertions(+), 43 deletions(-) diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs index ef537fc3..c3d256b3 100644 --- a/binaries/cuprated/src/blockchain/manager/handler.rs +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -447,7 +447,6 @@ impl super::BlockchainManager { }) }) .collect::>(); - let blockchain_height = verified_block.height + 1; self.blockchain_context_service .ready() @@ -492,10 +491,7 @@ impl super::BlockchainManager { .ready() .await .expect(PANIC_CRITICAL_SERVICE_ERROR) - .call(TxpoolWriteRequest::NewBlock { - spent_key_images, - blockchain_height, - }) + .call(TxpoolWriteRequest::NewBlock { spent_key_images }) .await .expect(PANIC_CRITICAL_SERVICE_ERROR); } diff --git a/storage/txpool/src/service/interface.rs b/storage/txpool/src/service/interface.rs index 0aa90491..a400a217 100644 --- a/storage/txpool/src/service/interface.rs +++ b/storage/txpool/src/service/interface.rs @@ -106,8 +106,6 @@ pub enum TxpoolWriteRequest { /// Tell the tx-pool about a new block. NewBlock { - /// The new blockchain height. - blockchain_height: usize, /// The spent key images in the new block. spent_key_images: Vec, }, diff --git a/storage/txpool/src/service/write.rs b/storage/txpool/src/service/write.rs index 2a4a5bba..9d1a5980 100644 --- a/storage/txpool/src/service/write.rs +++ b/storage/txpool/src/service/write.rs @@ -10,8 +10,8 @@ use crate::{ interface::{TxpoolWriteRequest, TxpoolWriteResponse}, types::TxpoolWriteHandle, }, - tables::{OpenTables, Tables, TablesMut, TransactionInfos}, - types::{KeyImage, PoolInfo, TransactionHash, TxStateFlags}, + tables::{OpenTables, Tables, TransactionInfos}, + types::{KeyImage, TransactionHash, TxStateFlags}, }; //---------------------------------------------------------------------------------------------------- init_write_service @@ -32,10 +32,7 @@ fn handle_txpool_request( } TxpoolWriteRequest::RemoveTransaction(tx_hash) => remove_transaction(env, tx_hash), TxpoolWriteRequest::Promote(tx_hash) => promote(env, tx_hash), - TxpoolWriteRequest::NewBlock { - blockchain_height, - spent_key_images, - } => new_block(env, *blockchain_height, spent_key_images), + TxpoolWriteRequest::NewBlock { spent_key_images } => new_block(env, spent_key_images), } } @@ -130,7 +127,6 @@ fn promote( fn new_block( env: &ConcreteEnv, - blockchain_height: usize, spent_key_images: &[KeyImage], ) -> Result { let env_inner = env.env_inner(); @@ -151,23 +147,6 @@ fn new_block( } } - let res = tables_mut.pool_stats_mut().update(&(), |mut info| { - info.last_known_blockchain_height = blockchain_height; - - Some(info) - }); - - match res { - Ok(()) => (), - Err(RuntimeError::KeyNotFound) => tables_mut.pool_stats_mut().put( - &(), - &PoolInfo { - last_known_blockchain_height: blockchain_height, - }, - )?, - Err(e) => return Err(e), - } - Ok(()) }; diff --git a/storage/txpool/src/tables.rs b/storage/txpool/src/tables.rs index d1d44686..1f2d4490 100644 --- a/storage/txpool/src/tables.rs +++ b/storage/txpool/src/tables.rs @@ -17,8 +17,7 @@ use cuprate_database::{define_tables, StorableVec}; use crate::types::{ - KeyImage, PoolInfo, RawCachedVerificationState, TransactionBlobHash, TransactionHash, - TransactionInfo, + KeyImage, RawCachedVerificationState, TransactionBlobHash, TransactionHash, TransactionInfo, }; define_tables! { @@ -49,7 +48,4 @@ define_tables! { /// Transaction blob hashes that are in the pool. 4 => KnownBlobHashes, TransactionBlobHash => TransactionHash, - - 5 => PoolStats, - () => PoolInfo, } diff --git a/storage/txpool/src/types.rs b/storage/txpool/src/types.rs index f507bbaa..2acb819e 100644 --- a/storage/txpool/src/types.rs +++ b/storage/txpool/src/types.rs @@ -19,13 +19,6 @@ pub type TransactionHash = [u8; 32]; /// A transaction blob hash. pub type TransactionBlobHash = [u8; 32]; -/// Information on the tx-pool. -#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] -#[repr(C)] -pub struct PoolInfo { - pub last_known_blockchain_height: usize, -} - bitflags::bitflags! { /// Flags representing the state of the transaction in the pool. #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)] From dc482558db44466920cafe5cd6609813fba1d398 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Mon, 14 Oct 2024 21:02:47 +0100 Subject: [PATCH 63/72] fix merge --- binaries/cuprated/src/p2p/request_handler.rs | 10 +--------- storage/blockchain/src/service/read.rs | 4 ++-- types/src/blockchain.rs | 17 ++++++++++++----- types/src/lib.rs | 5 +++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index 0bf6ee23..f2f39017 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -245,21 +245,13 @@ async fn new_fluffy_block( .take_normal() .ok_or(anyhow::anyhow!("Peer sent pruned txs in fluffy block"))?; - let mut txs_in_block = block.transactions.iter().copied().collect::>(); - // TODO: size check these tx blobs let txs = tx_blobs .into_iter() .map(|tx_blob| { let tx = Transaction::read(&mut tx_blob.as_ref())?; - let tx = new_tx_verification_data(tx)?; - - if !txs_in_block.remove(&tx.tx_hash) { - anyhow::bail!("Peer sent tx in fluffy block that wasn't actually in block") - } - - Ok((tx.tx_hash, tx)) + Ok(tx) }) .collect::>()?; diff --git a/storage/blockchain/src/service/read.rs b/storage/blockchain/src/service/read.rs index f7515ef2..f8642db2 100644 --- a/storage/blockchain/src/service/read.rs +++ b/storage/blockchain/src/service/read.rs @@ -22,12 +22,12 @@ use rayon::{ }; use thread_local::ThreadLocal; -use cuprate_database::{ConcreteEnv, DatabaseRo, Env, EnvInner, RuntimeError}; +use cuprate_database::{ConcreteEnv, DatabaseIter, DatabaseRo, Env, EnvInner, RuntimeError}; use cuprate_database_service::{init_thread_pool, DatabaseReadService, ReaderThreads}; use cuprate_helper::map::combine_low_high_bits_to_u128; use cuprate_types::{ blockchain::{BlockchainReadRequest, BlockchainResponse}, - Chain, ChainId, ExtendedBlockHeader, OutputHistogramInput, OutputOnChain, + Chain, ChainId, ExtendedBlockHeader, MissingTxsInBlock, OutputHistogramInput, OutputOnChain, }; use crate::{ diff --git a/types/src/blockchain.rs b/types/src/blockchain.rs index 68cbca24..f908d894 100644 --- a/types/src/blockchain.rs +++ b/types/src/blockchain.rs @@ -11,9 +11,11 @@ use std::{ use monero_serai::block::Block; use crate::{ - types::{MissingTxsInBlock, Chain, ExtendedBlockHeader, OutputOnChain, VerifiedBlockInformation}, - BlockCompleteEntry, - AltBlockInformation, ChainId, CoinbaseTxSum, OutputHistogramEntry, OutputHistogramInput, + types::{ + Chain, ExtendedBlockHeader, MissingTxsInBlock, OutputOnChain, VerifiedBlockInformation, + }, + AltBlockInformation, BlockCompleteEntry, ChainId, CoinbaseTxSum, OutputHistogramEntry, + OutputHistogramInput, }; //---------------------------------------------------------------------------------------------------- ReadRequest @@ -130,7 +132,9 @@ pub enum BlockchainReadRequest { AltBlocksInChain(ChainId), /// Get a [`Block`] by its height. - Block { height: usize }, + Block { + height: usize, + }, /// Get a [`Block`] by its hash. BlockByHash([u8; 32]), @@ -150,7 +154,10 @@ pub enum BlockchainReadRequest { /// `N` last blocks starting at particular height. /// /// TODO: document fields after impl. - CoinbaseTxSum { height: usize, count: u64 }, + CoinbaseTxSum { + height: usize, + count: u64, + }, } //---------------------------------------------------------------------------------------------------- WriteRequest diff --git a/types/src/lib.rs b/types/src/lib.rs index 0fd1ec7b..b86bb20f 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -21,8 +21,9 @@ pub use transaction_verification_data::{ }; pub use types::{ AltBlockInformation, Chain, ChainId, ChainInfo, CoinbaseTxSum, ExtendedBlockHeader, - FeeEstimate, HardForkInfo, MinerData, MinerDataTxBacklogEntry, OutputHistogramEntry, - OutputHistogramInput, OutputOnChain, VerifiedBlockInformation, VerifiedTransactionInformation, + FeeEstimate, HardForkInfo, MinerData, MinerDataTxBacklogEntry, MissingTxsInBlock, + OutputHistogramEntry, OutputHistogramInput, OutputOnChain, VerifiedBlockInformation, + VerifiedTransactionInformation, }; //---------------------------------------------------------------------------------------------------- Feature-gated From 511639d1b4601b30e3a8b05e94ca76175c0d828f Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Mon, 14 Oct 2024 21:10:09 +0100 Subject: [PATCH 64/72] fix merge --- binaries/cuprated/src/p2p/request_handler.rs | 41 ++++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index f2f39017..f6e0be39 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -1,17 +1,18 @@ +use bytes::Bytes; +use futures::{future::BoxFuture, FutureExt}; +use monero_serai::{block::Block, transaction::Transaction}; +use std::hash::Hash; use std::{ collections::HashSet, future::{ready, Ready}, task::{Context, Poll}, }; - -use bytes::Bytes; -use futures::{future::BoxFuture, FutureExt}; -use monero_serai::{block::Block, transaction::Transaction}; use tower::{Service, ServiceExt}; use cuprate_blockchain::service::BlockchainReadHandle; use cuprate_consensus::{transactions::new_tx_verification_data, BlockChainContextService}; use cuprate_fixed_bytes::ByteArrayVec; +use cuprate_helper::cast::u64_to_usize; use cuprate_helper::{ asynch::rayon_spawn_async, cast::usize_to_u64, @@ -19,6 +20,7 @@ use cuprate_helper::{ }; use cuprate_p2p::constants::MAX_BLOCK_BATCH_LEN; use cuprate_p2p_core::{client::PeerInformation, NetworkZone, ProtocolRequest, ProtocolResponse}; +use cuprate_txpool::service::TxpoolReadHandle; use cuprate_types::{ blockchain::{BlockchainReadRequest, BlockchainResponse}, BlockCompleteEntry, MissingTxsInBlock, TransactionBlobs, @@ -35,6 +37,8 @@ use crate::blockchain::interface::{self as blockchain_interface, IncomingBlockEr pub struct P2pProtocolRequestHandlerMaker { /// The [`BlockchainReadHandle`] pub blockchain_read_handle: BlockchainReadHandle, + /// The [`TxpoolReadHandle`]. + pub txpool_read_handle: TxpoolReadHandle, } impl Service> for P2pProtocolRequestHandlerMaker { @@ -50,10 +54,12 @@ impl Service> for P2pProtocolRequestHandlerMa // TODO: check sync info? let blockchain_read_handle = self.blockchain_read_handle.clone(); + let txpool_read_handle = self.txpool_read_handle.clone(); ready(Ok(P2pProtocolRequestHandler { peer_information, blockchain_read_handle, + txpool_read_handle, })) } } @@ -63,8 +69,10 @@ impl Service> for P2pProtocolRequestHandlerMa pub struct P2pProtocolRequestHandler { /// The [`PeerInformation`] for this peer. peer_information: PeerInformation, - /// The [`BlockchainReadHandle`] + /// The [`BlockchainReadHandle`]. blockchain_read_handle: BlockchainReadHandle, + /// The [`TxpoolReadHandle`]. + txpool_read_handle: TxpoolReadHandle, } impl Service for P2pProtocolRequestHandler { @@ -91,9 +99,12 @@ impl Service for P2pProtocolRequestHandler { "Peer sent a full block when we support fluffy blocks" ))) .boxed(), - ProtocolRequest::NewFluffyBlock(r) => { - new_fluffy_block(r, self.blockchain_read_handle.clone()).boxed() - } + ProtocolRequest::NewFluffyBlock(r) => new_fluffy_block( + r, + self.blockchain_read_handle.clone(), + self.txpool_read_handle.clone(), + ) + .boxed(), ProtocolRequest::GetTxPoolCompliment(_) | ProtocolRequest::NewTransactions(_) => { ready(Ok(ProtocolResponse::NA)).boxed() } // TODO: tx-pool @@ -233,6 +244,7 @@ async fn fluffy_missing_txs( async fn new_fluffy_block( request: NewFluffyBlock, mut blockchain_read_handle: BlockchainReadHandle, + mut txpool_read_handle: TxpoolReadHandle, ) -> anyhow::Result { let current_blockchain_height = request.current_blockchain_height; @@ -251,7 +263,7 @@ async fn new_fluffy_block( .map(|tx_blob| { let tx = Transaction::read(&mut tx_blob.as_ref())?; - Ok(tx) + Ok((tx.hash(), tx)) }) .collect::>()?; @@ -261,8 +273,13 @@ async fn new_fluffy_block( }) .await?; - let res = - blockchain_interface::handle_incoming_block(block, txs, &mut blockchain_read_handle).await; + let res = blockchain_interface::handle_incoming_block( + block, + txs, + &mut blockchain_read_handle, + &mut txpool_read_handle, + ) + .await; match res { Ok(_) => Ok(ProtocolResponse::NA), @@ -270,7 +287,7 @@ async fn new_fluffy_block( ProtocolResponse::FluffyMissingTransactionsRequest(FluffyMissingTransactionsRequest { block_hash: block_hash.into(), current_blockchain_height, - missing_tx_indices, + missing_tx_indices: missing_tx_indices.into_iter().map(usize_to_u64).collect(), }), ), Err(IncomingBlockError::Orphan) => { From 54957c10331fb4aef277367dfb415422a08752d7 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Mon, 14 Oct 2024 23:37:16 +0100 Subject: [PATCH 65/72] handle incoming txs in p2p request handler --- binaries/cuprated/src/p2p/request_handler.rs | 99 ++++++++++++++++++-- binaries/cuprated/src/txpool.rs | 2 + binaries/cuprated/src/txpool/incoming_tx.rs | 19 ++-- 3 files changed, 104 insertions(+), 16 deletions(-) diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index f6e0be39..b21e066d 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -10,7 +10,11 @@ use std::{ use tower::{Service, ServiceExt}; use cuprate_blockchain::service::BlockchainReadHandle; -use cuprate_consensus::{transactions::new_tx_verification_data, BlockChainContextService}; +use cuprate_consensus::{ + transactions::new_tx_verification_data, BlockChainContextRequest, BlockChainContextResponse, + BlockChainContextService, +}; +use cuprate_dandelion_tower::TxState; use cuprate_fixed_bytes::ByteArrayVec; use cuprate_helper::cast::u64_to_usize; use cuprate_helper::{ @@ -19,7 +23,10 @@ use cuprate_helper::{ map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}, }; use cuprate_p2p::constants::MAX_BLOCK_BATCH_LEN; -use cuprate_p2p_core::{client::PeerInformation, NetworkZone, ProtocolRequest, ProtocolResponse}; +use cuprate_p2p_core::client::InternalPeerID; +use cuprate_p2p_core::{ + client::PeerInformation, NetZoneAddress, NetworkZone, ProtocolRequest, ProtocolResponse, +}; use cuprate_txpool::service::TxpoolReadHandle; use cuprate_types::{ blockchain::{BlockchainReadRequest, BlockchainResponse}, @@ -27,21 +34,28 @@ use cuprate_types::{ }; use cuprate_wire::protocol::{ ChainRequest, ChainResponse, FluffyMissingTransactionsRequest, GetObjectsRequest, - GetObjectsResponse, NewFluffyBlock, + GetObjectsResponse, NewFluffyBlock, NewTransactions, }; use crate::blockchain::interface::{self as blockchain_interface, IncomingBlockError}; +use crate::constants::PANIC_CRITICAL_SERVICE_ERROR; +use crate::txpool::{IncomingTxHandler, IncomingTxs}; /// The P2P protocol request handler [`MakeService`](tower::MakeService). #[derive(Clone)] pub struct P2pProtocolRequestHandlerMaker { /// The [`BlockchainReadHandle`] pub blockchain_read_handle: BlockchainReadHandle, + + pub blockchain_context_service: BlockChainContextService, + /// The [`TxpoolReadHandle`]. pub txpool_read_handle: TxpoolReadHandle, + + pub incoming_tx_handler: IncomingTxHandler, } -impl Service> for P2pProtocolRequestHandlerMaker { +impl Service> for P2pProtocolRequestHandlerMaker { type Response = P2pProtocolRequestHandler; type Error = tower::BoxError; type Future = Ready>; @@ -59,23 +73,29 @@ impl Service> for P2pProtocolRequestHandlerMa ready(Ok(P2pProtocolRequestHandler { peer_information, blockchain_read_handle, + blockchain_context_service: self.blockchain_context_service.clone(), txpool_read_handle, + incoming_tx_handler: self.incoming_tx_handler.clone(), })) } } /// The P2P protocol request handler. #[derive(Clone)] -pub struct P2pProtocolRequestHandler { +pub struct P2pProtocolRequestHandler { /// The [`PeerInformation`] for this peer. peer_information: PeerInformation, /// The [`BlockchainReadHandle`]. blockchain_read_handle: BlockchainReadHandle, + + blockchain_context_service: BlockChainContextService, /// The [`TxpoolReadHandle`]. txpool_read_handle: TxpoolReadHandle, + + incoming_tx_handler: IncomingTxHandler, } -impl Service for P2pProtocolRequestHandler { +impl Service for P2pProtocolRequestHandler { type Response = ProtocolResponse; type Error = anyhow::Error; type Future = BoxFuture<'static, Result>; @@ -105,9 +125,14 @@ impl Service for P2pProtocolRequestHandler { self.txpool_read_handle.clone(), ) .boxed(), - ProtocolRequest::GetTxPoolCompliment(_) | ProtocolRequest::NewTransactions(_) => { - ready(Ok(ProtocolResponse::NA)).boxed() - } // TODO: tx-pool + ProtocolRequest::NewTransactions(r) => new_transactions( + self.peer_information.clone(), + r, + self.blockchain_context_service.clone(), + self.incoming_tx_handler.clone(), + ) + .boxed(), + ProtocolRequest::GetTxPoolCompliment(_) => ready(Ok(ProtocolResponse::NA)).boxed(), // TODO: tx-pool } } } @@ -297,3 +322,59 @@ async fn new_fluffy_block( Err(e) => Err(e.into()), } } + +async fn new_transactions( + peer_information: PeerInformation, + request: NewTransactions, + mut blockchain_context_service: BlockChainContextService, + mut incoming_tx_handler: IncomingTxHandler, +) -> anyhow::Result { + let BlockChainContextResponse::Context(context) = blockchain_context_service + .ready() + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR) + .call(BlockChainContextRequest::Context) + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR) + else { + unreachable!() + }; + + let context = context.unchecked_blockchain_context(); + + if usize_to_u64(context.chain_height + 2) + < peer_information + .core_sync_data + .lock() + .unwrap() + .current_height + { + return Ok(ProtocolResponse::NA); + } + + let state = if request.dandelionpp_fluff { + TxState::Fluff + } else { + let InternalPeerID::KnownAddr(addr) = peer_information.id else { + todo!("Anonymity networks") + }; + + TxState::Stem { from: addr.into() } + }; + + drop(request.padding); + let res = incoming_tx_handler + .ready() + .await + .expect(PANIC_CRITICAL_SERVICE_ERROR) + .call(IncomingTxs { + txs: request.txs, + state, + }) + .await; + + match res { + Ok(()) => Ok(ProtocolResponse::NA), + Err(e) => Err(e.into()), + } +} diff --git a/binaries/cuprated/src/txpool.rs b/binaries/cuprated/src/txpool.rs index 79731023..a44c765a 100644 --- a/binaries/cuprated/src/txpool.rs +++ b/binaries/cuprated/src/txpool.rs @@ -5,3 +5,5 @@ mod dandelion; mod incoming_tx; mod txs_being_handled; + +pub use incoming_tx::{IncomingTxError, IncomingTxHandler, IncomingTxs}; diff --git a/binaries/cuprated/src/txpool/incoming_tx.rs b/binaries/cuprated/src/txpool/incoming_tx.rs index 1ade33d6..9ffa8b9d 100644 --- a/binaries/cuprated/src/txpool/incoming_tx.rs +++ b/binaries/cuprated/src/txpool/incoming_tx.rs @@ -37,9 +37,13 @@ use crate::{ }; /// An error that can happen handling an incoming tx. +#[derive(Debug, thiserror::Error)] pub enum IncomingTxError { + #[error("parse error: {0}")] Parse(std::io::Error), + #[error("consensus error: {0}")] Consensus(ExtendedConsensusError), + #[error("Duplicate tx sent in message")] DuplicateTransaction, } @@ -51,7 +55,7 @@ pub struct IncomingTxs { /// The transaction type used for dandelion++. #[derive(Clone)] -struct DandelionTx(Bytes); +pub struct DandelionTx(Bytes); /// A transaction ID/hash. type TxId = [u8; 32]; @@ -59,19 +63,20 @@ type TxId = [u8; 32]; /// The service than handles incoming transaction pool transactions. /// /// This service handles everything including verifying the tx, adding it to the pool and routing it to other nodes. +#[derive(Clone)] pub struct IncomingTxHandler { /// A store of txs currently being handled in incoming tx requests. - txs_being_handled: TxsBeingHandled, + pub txs_being_handled: TxsBeingHandled, /// The blockchain context cache. - blockchain_context_cache: BlockChainContextService, + pub blockchain_context_cache: BlockChainContextService, /// The dandelion txpool manager. - dandelion_pool_manager: DandelionPoolService, + pub dandelion_pool_manager: DandelionPoolService, /// The transaction verifier service. - tx_verifier_service: ConcreteTxVerifierService, + pub tx_verifier_service: ConcreteTxVerifierService, /// The txpool write handle. - txpool_write_handle: TxpoolWriteHandle, + pub txpool_write_handle: TxpoolWriteHandle, /// The txpool read handle. - txpool_read_handle: TxpoolReadHandle, + pub txpool_read_handle: TxpoolReadHandle, } impl Service for IncomingTxHandler { From 82a2133a8b7513b227cf47d9eca80014dcb852d1 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sun, 27 Oct 2024 20:00:49 +0000 Subject: [PATCH 66/72] Allow `IncomingTxHandler` to be given later --- binaries/cuprated/src/p2p/request_handler.rs | 46 +++++++++++++++++--- binaries/cuprated/src/txpool/incoming_tx.rs | 7 +++ consensus/rules/src/miner_tx.rs | 2 +- consensus/src/context/difficulty.rs | 2 +- p2p/p2p/src/constants.rs | 2 +- 5 files changed, 49 insertions(+), 10 deletions(-) diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index b21e066d..be88a049 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -1,4 +1,5 @@ use bytes::Bytes; +use futures::future::Shared; use futures::{future::BoxFuture, FutureExt}; use monero_serai::{block::Block, transaction::Transaction}; use std::hash::Hash; @@ -7,6 +8,8 @@ use std::{ future::{ready, Ready}, task::{Context, Poll}, }; +use tokio::sync::{broadcast, oneshot, watch}; +use tokio_stream::wrappers::WatchStream; use tower::{Service, ServiceExt}; use cuprate_blockchain::service::BlockchainReadHandle; @@ -22,7 +25,7 @@ use cuprate_helper::{ cast::usize_to_u64, map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}, }; -use cuprate_p2p::constants::MAX_BLOCK_BATCH_LEN; +use cuprate_p2p::constants::{MAX_BLOCK_BATCH_LEN, MAX_TRANSACTION_BLOB_SIZE, MEDIUM_BAN}; use cuprate_p2p_core::client::InternalPeerID; use cuprate_p2p_core::{ client::PeerInformation, NetZoneAddress, NetworkZone, ProtocolRequest, ProtocolResponse, @@ -52,7 +55,9 @@ pub struct P2pProtocolRequestHandlerMaker { /// The [`TxpoolReadHandle`]. pub txpool_read_handle: TxpoolReadHandle, - pub incoming_tx_handler: IncomingTxHandler, + pub incoming_tx_handler: Option, + + pub incoming_tx_handler_fut: Shared>, } impl Service> for P2pProtocolRequestHandlerMaker { @@ -60,11 +65,25 @@ impl Service> for P2pProtocolRequestHandle type Error = tower::BoxError; type Future = Ready>; - fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + if self.incoming_tx_handler.is_none() { + return self + .incoming_tx_handler_fut + .poll_unpin(cx) + .map(|incoming_tx_handler| { + self.incoming_tx_handler = Some(incoming_tx_handler?); + Ok(()) + }); + } + Poll::Ready(Ok(())) } fn call(&mut self, peer_information: PeerInformation) -> Self::Future { + let Some(incoming_tx_handler) = self.incoming_tx_handler.clone() else { + panic!("poll_ready was not called or did not return `Poll::Ready`") + }; + // TODO: check sync info? let blockchain_read_handle = self.blockchain_read_handle.clone(); @@ -75,7 +94,7 @@ impl Service> for P2pProtocolRequestHandle blockchain_read_handle, blockchain_context_service: self.blockchain_context_service.clone(), txpool_read_handle, - incoming_tx_handler: self.incoming_tx_handler.clone(), + incoming_tx_handler, })) } } @@ -120,6 +139,7 @@ impl Service for P2pProtocolRequestHandler new_fluffy_block( + self.peer_information.clone(), r, self.blockchain_read_handle.clone(), self.txpool_read_handle.clone(), @@ -216,7 +236,7 @@ async fn get_chain( cumulative_difficulty_top64, m_block_ids: ByteArrayVec::from(block_ids), first_block: first_block_blob.map_or(Bytes::new(), Bytes::from), - // only needed when + // only needed when pruned m_block_weights: if want_pruned_data { block_weights.into_iter().map(usize_to_u64).collect() } else { @@ -266,13 +286,20 @@ async fn fluffy_missing_txs( } /// [`ProtocolRequest::NewFluffyBlock`] -async fn new_fluffy_block( +async fn new_fluffy_block( + peer_information: PeerInformation, request: NewFluffyBlock, mut blockchain_read_handle: BlockchainReadHandle, mut txpool_read_handle: TxpoolReadHandle, ) -> anyhow::Result { let current_blockchain_height = request.current_blockchain_height; + peer_information + .core_sync_data + .lock() + .unwrap() + .current_height = current_blockchain_height; + let (block, txs) = rayon_spawn_async(move || -> Result<_, anyhow::Error> { let block = Block::read(&mut request.b.block.as_ref())?; @@ -282,10 +309,14 @@ async fn new_fluffy_block( .take_normal() .ok_or(anyhow::anyhow!("Peer sent pruned txs in fluffy block"))?; - // TODO: size check these tx blobs let txs = tx_blobs .into_iter() .map(|tx_blob| { + if tx_blob.len() > MAX_TRANSACTION_BLOB_SIZE { + peer_information.handle.ban_peer(MEDIUM_BAN); + anyhow::bail!("Peer sent a transaction over the size limit."); + } + let tx = Transaction::read(&mut tx_blob.as_ref())?; Ok((tx.hash(), tx)) @@ -323,6 +354,7 @@ async fn new_fluffy_block( } } +/// [`ProtocolRequest::NewTransactions`] async fn new_transactions( peer_information: PeerInformation, request: NewTransactions, diff --git a/binaries/cuprated/src/txpool/incoming_tx.rs b/binaries/cuprated/src/txpool/incoming_tx.rs index 9ffa8b9d..b352bfe4 100644 --- a/binaries/cuprated/src/txpool/incoming_tx.rs +++ b/binaries/cuprated/src/txpool/incoming_tx.rs @@ -22,6 +22,7 @@ use cuprate_dandelion_tower::{ State, TxState, }; use cuprate_helper::asynch::rayon_spawn_async; +use cuprate_p2p::constants::MAX_TRANSACTION_BLOB_SIZE; use cuprate_txpool::service::{ interface::{TxpoolReadRequest, TxpoolReadResponse, TxpoolWriteRequest, TxpoolWriteResponse}, TxpoolReadHandle, TxpoolWriteHandle, @@ -39,6 +40,8 @@ use crate::{ /// An error that can happen handling an incoming tx. #[derive(Debug, thiserror::Error)] pub enum IncomingTxError { + #[error("Peer sent a transaction which is too big")] + TooLarge, #[error("parse error: {0}")] Parse(std::io::Error), #[error("consensus error: {0}")] @@ -191,6 +194,10 @@ async fn prepare_incoming_txs( let txs = tx_blobs .into_iter() .filter_map(|tx_blob| { + if tx_blob.len() > MAX_TRANSACTION_BLOB_SIZE { + return Some(Err(IncomingTxError::TooLarge)); + } + let tx_blob_hash = tx_blob_hash(tx_blob.as_ref()); // If a duplicate is in here the incoming tx batch contained the same tx twice. diff --git a/consensus/rules/src/miner_tx.rs b/consensus/rules/src/miner_tx.rs index 5221ee55..bb3b004a 100644 --- a/consensus/rules/src/miner_tx.rs +++ b/consensus/rules/src/miner_tx.rs @@ -68,7 +68,7 @@ pub fn calculate_block_reward( .unwrap(); let effective_median_bw: u128 = median_bw.try_into().unwrap(); - (((base_reward as u128 * multiplicand) / effective_median_bw) / effective_median_bw) + (((u128::from(base_reward) * multiplicand) / effective_median_bw) / effective_median_bw) .try_into() .unwrap() } diff --git a/consensus/src/context/difficulty.rs b/consensus/src/context/difficulty.rs index 9316dc5e..4c92b72e 100644 --- a/consensus/src/context/difficulty.rs +++ b/consensus/src/context/difficulty.rs @@ -330,7 +330,7 @@ fn next_difficulty( } // TODO: do checked operations here and unwrap so we don't silently overflow? - (windowed_work * hf.block_time().as_secs() as u128 + time_span - 1) / time_span + (windowed_work * u128::from(hf.block_time().as_secs()) + time_span - 1) / time_span } /// Get the start and end of the window to calculate difficulty. diff --git a/p2p/p2p/src/constants.rs b/p2p/p2p/src/constants.rs index d1060aea..59c2e1a3 100644 --- a/p2p/p2p/src/constants.rs +++ b/p2p/p2p/src/constants.rs @@ -61,7 +61,7 @@ pub(crate) const BLOCK_DOWNLOADER_REQUEST_TIMEOUT: Duration = Duration::from_sec /// be less than. /// /// ref: -pub(crate) const MAX_TRANSACTION_BLOB_SIZE: usize = 1_000_000; +pub const MAX_TRANSACTION_BLOB_SIZE: usize = 1_000_000; /// The maximum amount of block IDs allowed in a chain entry response. /// From f865ede656749b702be711d32d3b25ab4357f16a Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Mon, 28 Oct 2024 00:43:42 +0000 Subject: [PATCH 67/72] add p2p clearnet init --- binaries/cuprated/src/p2p.rs | 44 +++++++++++++++++ .../cuprated/src/p2p/core_sync_service.rs | 48 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 binaries/cuprated/src/p2p/core_sync_service.rs diff --git a/binaries/cuprated/src/p2p.rs b/binaries/cuprated/src/p2p.rs index f55d41db..7f13c3ff 100644 --- a/binaries/cuprated/src/p2p.rs +++ b/binaries/cuprated/src/p2p.rs @@ -2,4 +2,48 @@ //! //! Will handle initiating the P2P and contains a protocol request handler. +use crate::txpool::IncomingTxHandler; +use cuprate_blockchain::service::BlockchainReadHandle; +use cuprate_consensus::BlockChainContextService; +use cuprate_p2p::{NetworkInterface, P2PConfig}; +use cuprate_p2p_core::ClearNet; +use cuprate_txpool::service::TxpoolReadHandle; +use futures::{FutureExt, TryFutureExt}; +use tokio::sync::oneshot; +use tower::ServiceExt; + +mod core_sync_service; pub mod request_handler; + +pub async fn start_clearnet_p2p( + blockchain_read_handle: BlockchainReadHandle, + blockchain_context_service: BlockChainContextService, + txpool_read_handle: TxpoolReadHandle, + config: P2PConfig, +) -> Result< + ( + NetworkInterface, + oneshot::Sender, + ), + tower::BoxError, +> { + let (incoming_tx_handler_tx, incoming_tx_handler_rx) = oneshot::channel(); + + let request_handler_maker = request_handler::P2pProtocolRequestHandlerMaker { + blockchain_read_handle, + blockchain_context_service: blockchain_context_service.clone(), + txpool_read_handle, + incoming_tx_handler: None, + incoming_tx_handler_fut: incoming_tx_handler_rx.shared(), + }; + + Ok(( + cuprate_p2p::initialize_network( + request_handler_maker.map_response(|s| s.map_err(Into::into)), + core_sync_service::CoreSyncService(blockchain_context_service), + config, + ) + .await?, + incoming_tx_handler_tx, + )) +} diff --git a/binaries/cuprated/src/p2p/core_sync_service.rs b/binaries/cuprated/src/p2p/core_sync_service.rs new file mode 100644 index 00000000..04f20045 --- /dev/null +++ b/binaries/cuprated/src/p2p/core_sync_service.rs @@ -0,0 +1,48 @@ +use cuprate_consensus::{ + BlockChainContextRequest, BlockChainContextResponse, BlockChainContextService, +}; +use cuprate_helper::cast::usize_to_u64; +use cuprate_helper::map::split_u128_into_low_high_bits; +use cuprate_p2p_core::services::{CoreSyncDataRequest, CoreSyncDataResponse}; +use cuprate_wire::CoreSyncData; +use futures::future::BoxFuture; +use futures::{FutureExt, TryFutureExt}; +use std::task::{Context, Poll}; +use tower::Service; + +#[derive(Clone)] +pub struct CoreSyncService(pub BlockChainContextService); + +impl Service for CoreSyncService { + type Response = CoreSyncDataResponse; + type Error = tower::BoxError; + type Future = BoxFuture<'static, Result>; + + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + self.0.poll_ready(cx) + } + + fn call(&mut self, _: CoreSyncDataRequest) -> Self::Future { + self.0 + .call(BlockChainContextRequest::Context) + .map_ok(|res| { + let BlockChainContextResponse::Context(context) = res else { + unreachable!() + }; + + let context = context.unchecked_blockchain_context(); + let (cumulative_difficulty, cumulative_difficulty_top64) = + split_u128_into_low_high_bits(context.cumulative_difficulty); + + CoreSyncDataResponse(CoreSyncData { + cumulative_difficulty, + cumulative_difficulty_top64, + current_height: usize_to_u64(context.chain_height), + pruning_seed: 0, + top_id: context.top_hash, + top_version: context.current_hf.as_u8(), + }) + }) + .boxed() + } +} From d0055f16bdc73dc7cd2b465e55007899da9098ca Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 31 Oct 2024 23:32:32 +0000 Subject: [PATCH 68/72] fix build --- Cargo.lock | 2 - binaries/cuprated/src/blockchain/manager.rs | 1 - binaries/cuprated/src/p2p.rs | 43 ++++++++++++++++++++ binaries/cuprated/src/p2p/request_handler.rs | 33 ++++++++++----- binaries/cuprated/src/txpool.rs | 2 +- binaries/cuprated/src/txpool/incoming_tx.rs | 5 +++ 6 files changed, 71 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a2be6d61..3d4aa692 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -963,7 +963,6 @@ dependencies = [ "monero-serai", "rayon", "serde", - "sha3", "tempfile", "thiserror", "tokio", @@ -1064,7 +1063,6 @@ dependencies = [ "serde", "serde_bytes", "serde_json", - "sha3", "thiserror", "thread_local", "tokio", diff --git a/binaries/cuprated/src/blockchain/manager.rs b/binaries/cuprated/src/blockchain/manager.rs index 1dba6407..2166795e 100644 --- a/binaries/cuprated/src/blockchain/manager.rs +++ b/binaries/cuprated/src/blockchain/manager.rs @@ -38,7 +38,6 @@ mod commands; mod handler; pub use commands::{BlockchainManagerCommand, IncomingBlockOk}; -use cuprate_txpool::service::TxpoolWriteHandle; /// Initialize the blockchain manager. /// diff --git a/binaries/cuprated/src/p2p.rs b/binaries/cuprated/src/p2p.rs index cdf1cef7..9e24b607 100644 --- a/binaries/cuprated/src/p2p.rs +++ b/binaries/cuprated/src/p2p.rs @@ -1,8 +1,51 @@ //! P2P //! //! Will handle initiating the P2P and contains a protocol request handler. +use crate::txpool::IncomingTxHandler; +use cuprate_blockchain::service::BlockchainReadHandle; +use cuprate_consensus::BlockChainContextService; +use cuprate_p2p::{NetworkInterface, P2PConfig}; +use cuprate_p2p_core::ClearNet; +use cuprate_txpool::service::TxpoolReadHandle; +use futures::{FutureExt, TryFutureExt}; +use tokio::sync::oneshot; +use tower::ServiceExt; +mod core_sync_service; mod network_address; pub mod request_handler; pub use network_address::CrossNetworkInternalPeerId; + +pub async fn start_clearnet_p2p( + blockchain_read_handle: BlockchainReadHandle, + blockchain_context_service: BlockChainContextService, + txpool_read_handle: TxpoolReadHandle, + config: P2PConfig, +) -> Result< + ( + NetworkInterface, + oneshot::Sender, + ), + tower::BoxError, +> { + let (incoming_tx_handler_tx, incoming_tx_handler_rx) = oneshot::channel(); + + let request_handler_maker = request_handler::P2pProtocolRequestHandlerMaker { + blockchain_read_handle, + blockchain_context_service: blockchain_context_service.clone(), + txpool_read_handle, + incoming_tx_handler: None, + incoming_tx_handler_fut: incoming_tx_handler_rx.shared(), + }; + + Ok(( + cuprate_p2p::initialize_network( + request_handler_maker.map_response(|s| s.map_err(Into::into)), + core_sync_service::CoreSyncService(blockchain_context_service), + config, + ) + .await?, + incoming_tx_handler_tx, + )) +} diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index be88a049..0f39ecec 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -42,6 +42,7 @@ use cuprate_wire::protocol::{ use crate::blockchain::interface::{self as blockchain_interface, IncomingBlockError}; use crate::constants::PANIC_CRITICAL_SERVICE_ERROR; +use crate::p2p::CrossNetworkInternalPeerId; use crate::txpool::{IncomingTxHandler, IncomingTxs}; /// The P2P protocol request handler [`MakeService`](tower::MakeService). @@ -60,8 +61,12 @@ pub struct P2pProtocolRequestHandlerMaker { pub incoming_tx_handler_fut: Shared>, } -impl Service> for P2pProtocolRequestHandlerMaker { - type Response = P2pProtocolRequestHandler; +impl Service> for P2pProtocolRequestHandlerMaker +where + A: NetZoneAddress, + InternalPeerID: Into, +{ + type Response = P2pProtocolRequestHandler; type Error = tower::BoxError; type Future = Ready>; @@ -79,7 +84,7 @@ impl Service> for P2pProtocolRequestHandle Poll::Ready(Ok(())) } - fn call(&mut self, peer_information: PeerInformation) -> Self::Future { + fn call(&mut self, peer_information: PeerInformation) -> Self::Future { let Some(incoming_tx_handler) = self.incoming_tx_handler.clone() else { panic!("poll_ready was not called or did not return `Poll::Ready`") }; @@ -114,7 +119,11 @@ pub struct P2pProtocolRequestHandler { incoming_tx_handler: IncomingTxHandler, } -impl Service for P2pProtocolRequestHandler { +impl Service for P2pProtocolRequestHandler +where + A: NetZoneAddress, + InternalPeerID: Into, +{ type Response = ProtocolResponse; type Error = anyhow::Error; type Future = BoxFuture<'static, Result>; @@ -355,12 +364,16 @@ async fn new_fluffy_block( } /// [`ProtocolRequest::NewTransactions`] -async fn new_transactions( +async fn new_transactions( peer_information: PeerInformation, request: NewTransactions, mut blockchain_context_service: BlockChainContextService, mut incoming_tx_handler: IncomingTxHandler, -) -> anyhow::Result { +) -> anyhow::Result +where + A: NetZoneAddress, + InternalPeerID: Into, +{ let BlockChainContextResponse::Context(context) = blockchain_context_service .ready() .await @@ -387,11 +400,9 @@ async fn new_transactions( let state = if request.dandelionpp_fluff { TxState::Fluff } else { - let InternalPeerID::KnownAddr(addr) = peer_information.id else { - todo!("Anonymity networks") - }; - - TxState::Stem { from: addr.into() } + TxState::Stem { + from: peer_information.id.into(), + } }; drop(request.padding); diff --git a/binaries/cuprated/src/txpool.rs b/binaries/cuprated/src/txpool.rs index 9592c2bf..20769567 100644 --- a/binaries/cuprated/src/txpool.rs +++ b/binaries/cuprated/src/txpool.rs @@ -12,4 +12,4 @@ mod dandelion; mod incoming_tx; mod txs_being_handled; -pub use incoming_tx::IncomingTxHandler; +pub use incoming_tx::{IncomingTxError, IncomingTxHandler, IncomingTxs}; diff --git a/binaries/cuprated/src/txpool/incoming_tx.rs b/binaries/cuprated/src/txpool/incoming_tx.rs index e2041598..bf7684e4 100644 --- a/binaries/cuprated/src/txpool/incoming_tx.rs +++ b/binaries/cuprated/src/txpool/incoming_tx.rs @@ -43,9 +43,13 @@ use crate::{ }; /// An error that can happen handling an incoming tx. +#[derive(Debug, thiserror::Error)] pub enum IncomingTxError { + #[error("Error parsing tx: {0}")] Parse(std::io::Error), + #[error(transparent)] Consensus(ExtendedConsensusError), + #[error("Duplicate tx in message")] DuplicateTransaction, } @@ -67,6 +71,7 @@ pub(super) type TxId = [u8; 32]; /// The service than handles incoming transaction pool transactions. /// /// This service handles everything including verifying the tx, adding it to the pool and routing it to other nodes. +#[derive(Clone)] pub struct IncomingTxHandler { /// A store of txs currently being handled in incoming tx requests. pub(super) txs_being_handled: TxsBeingHandled, From a14f1225686e1067613738798f9cde657bf85501 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 1 Nov 2024 15:13:34 +0000 Subject: [PATCH 69/72] misc changes --- binaries/cuprated/src/p2p/request_handler.rs | 20 +++++++++++++------- p2p/p2p/src/constants.rs | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index 0f39ecec..c93f0580 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -25,7 +25,9 @@ use cuprate_helper::{ cast::usize_to_u64, map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits}, }; -use cuprate_p2p::constants::{MAX_BLOCK_BATCH_LEN, MAX_TRANSACTION_BLOB_SIZE, MEDIUM_BAN}; +use cuprate_p2p::constants::{ + MAX_BLOCKS_IDS_IN_CHAIN_ENTRY, MAX_BLOCK_BATCH_LEN, MAX_TRANSACTION_BLOB_SIZE, MEDIUM_BAN, +}; use cuprate_p2p_core::client::InternalPeerID; use cuprate_p2p_core::{ client::PeerInformation, NetZoneAddress, NetworkZone, ProtocolRequest, ProtocolResponse, @@ -206,7 +208,7 @@ async fn get_chain( request: ChainRequest, mut blockchain_read_handle: BlockchainReadHandle, ) -> anyhow::Result { - if request.block_ids.len() > 25_000 { + if request.block_ids.len() > MAX_BLOCKS_IDS_IN_CHAIN_ENTRY { anyhow::bail!("Peer sent too many block hashes in chain request.") } @@ -387,6 +389,7 @@ where let context = context.unchecked_blockchain_context(); + // If we are more than 2 blocks behind the peer then ignore the txs - we are probably still syncing. if usize_to_u64(context.chain_height + 2) < peer_information .core_sync_data @@ -405,15 +408,18 @@ where } }; - drop(request.padding); + // Drop all the data except the stuff we still need. + let NewTransactions { + txs, + dandelionpp_fluff: _, + padding: _, + } = request; + let res = incoming_tx_handler .ready() .await .expect(PANIC_CRITICAL_SERVICE_ERROR) - .call(IncomingTxs { - txs: request.txs, - state, - }) + .call(IncomingTxs { txs, state }) .await; match res { diff --git a/p2p/p2p/src/constants.rs b/p2p/p2p/src/constants.rs index 59c2e1a3..a81557c2 100644 --- a/p2p/p2p/src/constants.rs +++ b/p2p/p2p/src/constants.rs @@ -67,7 +67,7 @@ pub const MAX_TRANSACTION_BLOB_SIZE: usize = 1_000_000; /// /// ref: // TODO: link to the protocol book when this section is added. -pub(crate) const MAX_BLOCKS_IDS_IN_CHAIN_ENTRY: usize = 25_000; +pub const MAX_BLOCKS_IDS_IN_CHAIN_ENTRY: usize = 25_000; /// The amount of failures downloading a specific batch before we stop attempting to download it. pub(crate) const MAX_DOWNLOAD_FAILURES: usize = 5; From 49db43180f0e3a7da190ab45f6a9b990e9d45456 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Mon, 18 Nov 2024 16:04:00 +0000 Subject: [PATCH 70/72] doc updates --- binaries/cuprated/src/p2p.rs | 14 +++++-- binaries/cuprated/src/p2p/request_handler.rs | 43 +++++++++++--------- types/src/blockchain.rs | 15 ++++--- types/src/lib.rs | 4 +- 4 files changed, 45 insertions(+), 31 deletions(-) diff --git a/binaries/cuprated/src/p2p.rs b/binaries/cuprated/src/p2p.rs index 9e24b607..aeb98b60 100644 --- a/binaries/cuprated/src/p2p.rs +++ b/binaries/cuprated/src/p2p.rs @@ -1,15 +1,17 @@ //! P2P //! //! Will handle initiating the P2P and contains a protocol request handler. -use crate::txpool::IncomingTxHandler; +use futures::{FutureExt, TryFutureExt}; +use tokio::sync::oneshot; +use tower::ServiceExt; + use cuprate_blockchain::service::BlockchainReadHandle; use cuprate_consensus::BlockChainContextService; use cuprate_p2p::{NetworkInterface, P2PConfig}; use cuprate_p2p_core::ClearNet; use cuprate_txpool::service::TxpoolReadHandle; -use futures::{FutureExt, TryFutureExt}; -use tokio::sync::oneshot; -use tower::ServiceExt; + +use crate::txpool::IncomingTxHandler; mod core_sync_service; mod network_address; @@ -17,6 +19,10 @@ pub mod request_handler; pub use network_address::CrossNetworkInternalPeerId; +/// Starts the P2P clearnet network, returning a [`NetworkInterface`] to interact with it. +/// +/// A [`oneshot::Sender`] is also returned to provide the [`IncomingTxHandler`], until this is provided network +/// handshakes can not be completed. pub async fn start_clearnet_p2p( blockchain_read_handle: BlockchainReadHandle, blockchain_context_service: BlockChainContextService, diff --git a/binaries/cuprated/src/p2p/request_handler.rs b/binaries/cuprated/src/p2p/request_handler.rs index c93f0580..cb0757c6 100644 --- a/binaries/cuprated/src/p2p/request_handler.rs +++ b/binaries/cuprated/src/p2p/request_handler.rs @@ -1,13 +1,16 @@ -use bytes::Bytes; -use futures::future::Shared; -use futures::{future::BoxFuture, FutureExt}; -use monero_serai::{block::Block, transaction::Transaction}; -use std::hash::Hash; use std::{ collections::HashSet, future::{ready, Ready}, + hash::Hash, task::{Context, Poll}, }; + +use bytes::Bytes; +use futures::{ + future::{BoxFuture, Shared}, + FutureExt, +}; +use monero_serai::{block::Block, transaction::Transaction}; use tokio::sync::{broadcast, oneshot, watch}; use tokio_stream::wrappers::WatchStream; use tower::{Service, ServiceExt}; @@ -28,9 +31,9 @@ use cuprate_helper::{ use cuprate_p2p::constants::{ MAX_BLOCKS_IDS_IN_CHAIN_ENTRY, MAX_BLOCK_BATCH_LEN, MAX_TRANSACTION_BLOB_SIZE, MEDIUM_BAN, }; -use cuprate_p2p_core::client::InternalPeerID; use cuprate_p2p_core::{ - client::PeerInformation, NetZoneAddress, NetworkZone, ProtocolRequest, ProtocolResponse, + client::{InternalPeerID, PeerInformation}, + NetZoneAddress, NetworkZone, ProtocolRequest, ProtocolResponse, }; use cuprate_txpool::service::TxpoolReadHandle; use cuprate_types::{ @@ -42,30 +45,32 @@ use cuprate_wire::protocol::{ GetObjectsResponse, NewFluffyBlock, NewTransactions, }; -use crate::blockchain::interface::{self as blockchain_interface, IncomingBlockError}; -use crate::constants::PANIC_CRITICAL_SERVICE_ERROR; -use crate::p2p::CrossNetworkInternalPeerId; -use crate::txpool::{IncomingTxHandler, IncomingTxs}; +use crate::{ + blockchain::interface::{self as blockchain_interface, IncomingBlockError}, + constants::PANIC_CRITICAL_SERVICE_ERROR, + p2p::CrossNetworkInternalPeerId, + txpool::{IncomingTxError, IncomingTxHandler, IncomingTxs}, +}; /// The P2P protocol request handler [`MakeService`](tower::MakeService). #[derive(Clone)] pub struct P2pProtocolRequestHandlerMaker { - /// The [`BlockchainReadHandle`] pub blockchain_read_handle: BlockchainReadHandle, pub blockchain_context_service: BlockChainContextService, - /// The [`TxpoolReadHandle`]. pub txpool_read_handle: TxpoolReadHandle, + /// The [`IncomingTxHandler`], wrapped in an [`Option`] as there is a cyclic reference between [`P2pProtocolRequestHandlerMaker`] + /// and the [`IncomingTxHandler`]. pub incoming_tx_handler: Option, + /// A [`Future`](std::future::Future) that produces the [`IncomingTxHandler`]. pub incoming_tx_handler_fut: Shared>, } impl Service> for P2pProtocolRequestHandlerMaker where - A: NetZoneAddress, InternalPeerID: Into, { type Response = P2pProtocolRequestHandler; @@ -109,13 +114,12 @@ where /// The P2P protocol request handler. #[derive(Clone)] pub struct P2pProtocolRequestHandler { - /// The [`PeerInformation`] for this peer. peer_information: PeerInformation, - /// The [`BlockchainReadHandle`]. + blockchain_read_handle: BlockchainReadHandle, blockchain_context_service: BlockChainContextService, - /// The [`TxpoolReadHandle`]. + txpool_read_handle: TxpoolReadHandle, incoming_tx_handler: IncomingTxHandler, @@ -123,7 +127,6 @@ pub struct P2pProtocolRequestHandler { impl Service for P2pProtocolRequestHandler where - A: NetZoneAddress, InternalPeerID: Into, { type Response = ProtocolResponse; @@ -163,7 +166,7 @@ where self.incoming_tx_handler.clone(), ) .boxed(), - ProtocolRequest::GetTxPoolCompliment(_) => ready(Ok(ProtocolResponse::NA)).boxed(), // TODO: tx-pool + ProtocolRequest::GetTxPoolCompliment(_) => ready(Ok(ProtocolResponse::NA)).boxed(), // TODO: should we support this? } } } @@ -303,6 +306,7 @@ async fn new_fluffy_block( mut blockchain_read_handle: BlockchainReadHandle, mut txpool_read_handle: TxpoolReadHandle, ) -> anyhow::Result { + // TODO: check context service here and ignore the block? let current_blockchain_height = request.current_blockchain_height; peer_information @@ -324,7 +328,6 @@ async fn new_fluffy_block( .into_iter() .map(|tx_blob| { if tx_blob.len() > MAX_TRANSACTION_BLOB_SIZE { - peer_information.handle.ban_peer(MEDIUM_BAN); anyhow::bail!("Peer sent a transaction over the size limit."); } diff --git a/types/src/blockchain.rs b/types/src/blockchain.rs index b5da7cb7..13458bd0 100644 --- a/types/src/blockchain.rs +++ b/types/src/blockchain.rs @@ -13,9 +13,9 @@ use monero_serai::block::Block; use crate::{ types::{ Chain, ExtendedBlockHeader, MissingTxsInBlock, OutputOnChain, VerifiedBlockInformation, - }, ChainInfo, - AltBlockInformation, BlockCompleteEntry, ChainId, CoinbaseTxSum, OutputHistogramEntry, - OutputHistogramInput, + }, + AltBlockInformation, BlockCompleteEntry, ChainId, ChainInfo, CoinbaseTxSum, + OutputHistogramEntry, OutputHistogramInput, }; //---------------------------------------------------------------------------------------------------- ReadRequest @@ -132,7 +132,9 @@ pub enum BlockchainReadRequest { AltBlocksInChain(ChainId), /// Get a [`Block`] by its height. - Block { height: usize }, + Block { + height: usize, + }, /// Get a [`Block`] by its hash. BlockByHash([u8; 32]), @@ -152,7 +154,10 @@ pub enum BlockchainReadRequest { /// `N` last blocks starting at particular height. /// /// TODO: document fields after impl. - CoinbaseTxSum { height: usize, count: u64 }, + CoinbaseTxSum { + height: usize, + count: u64, + }, /// Get information on all alternative chains. AltChains, diff --git a/types/src/lib.rs b/types/src/lib.rs index a5a04f9d..51d37d6c 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -26,8 +26,8 @@ pub use transaction_verification_data::{ pub use types::{ AddAuxPow, AltBlockInformation, AuxPow, Chain, ChainId, ChainInfo, CoinbaseTxSum, ExtendedBlockHeader, FeeEstimate, HardForkInfo, MinerData, MinerDataTxBacklogEntry, - OutputHistogramEntry, OutputHistogramInput, OutputOnChain, VerifiedBlockInformation, - VerifiedTransactionInformation, + MissingTxsInBlock, OutputHistogramEntry, OutputHistogramInput, OutputOnChain, + VerifiedBlockInformation, VerifiedTransactionInformation, }; //---------------------------------------------------------------------------------------------------- Feature-gated From 1fc7c0a577fc17d42d6b71dc9f8579a91759ea50 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Mon, 18 Nov 2024 16:23:33 +0000 Subject: [PATCH 71/72] more doc updates --- storage/blockchain/src/ops/block.rs | 12 +++++++++--- storage/blockchain/src/ops/blockchain.rs | 10 ++++------ types/src/blockchain.rs | 24 ++++++++++++++++-------- types/src/types.rs | 1 + 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/storage/blockchain/src/ops/block.rs b/storage/blockchain/src/ops/block.rs index 070a413c..94c1fc64 100644 --- a/storage/blockchain/src/ops/block.rs +++ b/storage/blockchain/src/ops/block.rs @@ -227,6 +227,9 @@ pub fn pop_block( Ok((block_height, block_info.block_hash, block)) } //---------------------------------------------------------------------------------------------------- `get_block_blob_with_tx_indexes` +/// Retrieve a block's raw bytes, the index of the miner transaction and the number of non miner-txs in the block. +/// +#[doc = doc_error!()] pub fn get_block_blob_with_tx_indexes( block_height: &BlockHeight, tables: &impl Tables, @@ -249,14 +252,17 @@ pub fn get_block_blob_with_tx_indexes( // Add the blocks tx hashes. write_varint(&block_txs.len(), &mut block) .expect("The number of txs per block will not exceed u64::MAX"); - for tx in block_txs { - block.extend_from_slice(&tx); - } + + let block_txs_bytes = bytemuck::cast_slice(&block_txs); + block.extend_from_slice(block_txs_bytes); Ok((block, miner_tx_idx, numb_txs)) } //---------------------------------------------------------------------------------------------------- `get_block_extended_header_*` +/// Retrieve a [`BlockCompleteEntry`] from the database. +/// +#[doc = doc_error!()] pub fn get_block_complete_entry( block_hash: &BlockHash, tables: &impl TablesIter, diff --git a/storage/blockchain/src/ops/blockchain.rs b/storage/blockchain/src/ops/blockchain.rs index 664c0d0c..c6cd4040 100644 --- a/storage/blockchain/src/ops/blockchain.rs +++ b/storage/blockchain/src/ops/blockchain.rs @@ -3,12 +3,10 @@ //---------------------------------------------------------------------------------------------------- Import use cuprate_database::{DatabaseRo, RuntimeError}; -use crate::ops::block::block_exists; -use crate::types::BlockHash; use crate::{ - ops::macros::doc_error, + ops::{block::block_exists, macros::doc_error}, tables::{BlockHeights, BlockInfos}, - types::BlockHeight, + types::{BlockHash, BlockHeight}, }; //---------------------------------------------------------------------------------------------------- Free Functions @@ -82,7 +80,7 @@ pub fn cumulative_generated_coins( /// Find the split point between our chain and a list of [`BlockHash`]s from another chain. /// -/// This function can be used accepts chains in chronological and reverse chronological order, however +/// This function accepts chains in chronological and reverse chronological order, however /// if the wrong order is specified the return value is meaningless. /// /// For chronologically ordered chains this will return the index of the first unknown, for reverse @@ -99,7 +97,7 @@ pub fn find_split_point( ) -> Result { let mut err = None; - // Do a binary search to find the first unknown block in the batch. + // Do a binary search to find the first unknown/known block in the batch. let idx = block_ids.partition_point( |block_id| match block_exists(block_id, table_block_heights) { diff --git a/types/src/blockchain.rs b/types/src/blockchain.rs index 13458bd0..258d526f 100644 --- a/types/src/blockchain.rs +++ b/types/src/blockchain.rs @@ -29,6 +29,9 @@ use crate::{ /// See `Response` for the expected responses per `Request`. #[derive(Debug, Clone, PartialEq, Eq)] pub enum BlockchainReadRequest { + /// Request [`BlockCompleteEntry`]s. + /// + /// The input is the block hashes. BlockCompleteEntries(Vec<[u8; 32]>), /// Request a block's extended header. @@ -124,7 +127,7 @@ pub enum BlockchainReadRequest { block_hash: [u8; 32], /// The indexes of the transactions from the block. /// This is not the global index of the txs, instead it is the local index as they appear in - /// the block/ + /// the block. tx_indexes: Vec, }, @@ -132,9 +135,7 @@ pub enum BlockchainReadRequest { AltBlocksInChain(ChainId), /// Get a [`Block`] by its height. - Block { - height: usize, - }, + Block { height: usize }, /// Get a [`Block`] by its hash. BlockByHash([u8; 32]), @@ -154,10 +155,7 @@ pub enum BlockchainReadRequest { /// `N` last blocks starting at particular height. /// /// TODO: document fields after impl. - CoinbaseTxSum { - height: usize, - count: u64, - }, + CoinbaseTxSum { height: usize, count: u64 }, /// Get information on all alternative chains. AltChains, @@ -211,9 +209,13 @@ pub enum BlockchainWriteRequest { #[expect(clippy::large_enum_variant)] pub enum BlockchainResponse { //------------------------------------------------------ Reads + /// Response to [`BlockchainReadRequest::BlockCompleteEntries`]. BlockCompleteEntries { + /// The [`BlockCompleteEntry`]s that we had. blocks: Vec, + /// The hashes of blocks that were requested, but we don't have. missing_hashes: Vec<[u8; 32]>, + /// Our blockchain height. blockchain_height: usize, }, @@ -287,11 +289,17 @@ pub enum BlockchainResponse { /// /// If all blocks were unknown `start_height` will be `0`, the other fields will be meaningless. NextChainEntry { + /// The start height of this entry, `0` if we could not find the split point. start_height: usize, + /// The current chain height. chain_height: usize, + /// The next block hashes in the entry. block_ids: Vec<[u8; 32]>, + /// The block weights of the next blocks. block_weights: Vec, + /// The current cumulative difficulty of our chain. cumulative_difficulty: u128, + /// The block blob of the 2nd block in `block_ids`, if there is one. first_block_blob: Option>, }, diff --git a/types/src/types.rs b/types/src/types.rs index 6386e917..ebb02c56 100644 --- a/types/src/types.rs +++ b/types/src/types.rs @@ -259,6 +259,7 @@ pub struct AddAuxPow { pub aux_pow: Vec, } +/// The inner response for a request for missing txs. #[derive(Clone, Debug, PartialEq, Eq)] pub struct MissingTxsInBlock { pub block: Vec, From e11568357a74d83f62f0b2b233841de2c4aa4d7f Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Mon, 18 Nov 2024 16:39:29 +0000 Subject: [PATCH 72/72] sort imports --- binaries/cuprated/src/p2p/core_sync_service.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/binaries/cuprated/src/p2p/core_sync_service.rs b/binaries/cuprated/src/p2p/core_sync_service.rs index 04f20045..d3c3ca1e 100644 --- a/binaries/cuprated/src/p2p/core_sync_service.rs +++ b/binaries/cuprated/src/p2p/core_sync_service.rs @@ -1,15 +1,16 @@ +use std::task::{Context, Poll}; + +use futures::{future::BoxFuture, FutureExt, TryFutureExt}; +use tower::Service; + use cuprate_consensus::{ BlockChainContextRequest, BlockChainContextResponse, BlockChainContextService, }; -use cuprate_helper::cast::usize_to_u64; -use cuprate_helper::map::split_u128_into_low_high_bits; +use cuprate_helper::{cast::usize_to_u64, map::split_u128_into_low_high_bits}; use cuprate_p2p_core::services::{CoreSyncDataRequest, CoreSyncDataResponse}; use cuprate_wire::CoreSyncData; -use futures::future::BoxFuture; -use futures::{FutureExt, TryFutureExt}; -use std::task::{Context, Poll}; -use tower::Service; +/// The core sync service. #[derive(Clone)] pub struct CoreSyncService(pub BlockChainContextService);