diff --git a/binaries/cuprated/src/blockchain/manager/handler.rs b/binaries/cuprated/src/blockchain/manager/handler.rs index 91fb26c78..e98872e5b 100644 --- a/binaries/cuprated/src/blockchain/manager/handler.rs +++ b/binaries/cuprated/src/blockchain/manager/handler.rs @@ -324,7 +324,7 @@ impl super::BlockchainManager { top_alt_block.chain_id, )) .await - .expect("TODO") + .map_err(|e| anyhow::anyhow!(e))? else { unreachable!(); }; diff --git a/binaries/cuprated/src/p2p/core_sync_service.rs b/binaries/cuprated/src/p2p/core_sync_service.rs index 96b2ee6dc..55975d525 100644 --- a/binaries/cuprated/src/p2p/core_sync_service.rs +++ b/binaries/cuprated/src/p2p/core_sync_service.rs @@ -1,5 +1,7 @@ -use std::future::{ready, Ready}; -use std::task::{Context, Poll}; +use std::{ + future::{ready, Ready}, + task::{Context, Poll}, +}; use futures::{future::BoxFuture, FutureExt, TryFutureExt}; use tower::Service; diff --git a/binaries/cuprated/src/txpool/incoming_tx.rs b/binaries/cuprated/src/txpool/incoming_tx.rs index b64a6c62d..93d47f195 100644 --- a/binaries/cuprated/src/txpool/incoming_tx.rs +++ b/binaries/cuprated/src/txpool/incoming_tx.rs @@ -5,6 +5,10 @@ use std::{ }; use bytes::Bytes; +use futures::{future::BoxFuture, FutureExt}; +use monero_serai::transaction::Transaction; +use tower::{BoxError, Service, ServiceExt}; + use cuprate_blockchain::service::BlockchainReadHandle; use cuprate_consensus::transactions::{start_tx_verification, PrepTransactions}; use cuprate_consensus::{ @@ -28,12 +32,9 @@ use cuprate_txpool::{ transaction_blob_hash, }; use cuprate_types::TransactionVerificationData; -use futures::{future::BoxFuture, FutureExt}; -use monero_serai::transaction::Transaction; -use tower::{BoxError, Service, ServiceExt}; -use crate::blockchain::ConsensusBlockchainReadHandle; use crate::{ + blockchain::ConsensusBlockchainReadHandle, constants::PANIC_CRITICAL_SERVICE_ERROR, p2p::CrossNetworkInternalPeerId, signals::REORG_LOCK, @@ -85,6 +86,7 @@ pub struct IncomingTxHandler { pub(super) txpool_write_handle: TxpoolWriteHandle, /// The txpool read handle. pub(super) txpool_read_handle: TxpoolReadHandle, + /// The blockchain read handle. pub(super) blockchain_read_handle: ConsensusBlockchainReadHandle, } @@ -305,7 +307,7 @@ async fn handle_valid_tx( .await .expect(PANIC_CRITICAL_SERVICE_ERROR) .call(TxpoolWriteRequest::AddTransaction { - tx, + tx: Box::new(tx), state_stem: state.is_stem_stage(), }) .await diff --git a/consensus/context/src/lib.rs b/consensus/context/src/lib.rs index c1be3a302..075612cb6 100644 --- a/consensus/context/src/lib.rs +++ b/consensus/context/src/lib.rs @@ -8,9 +8,6 @@ // FIXME: should we pull in a dependency just to link docs? use monero_serai as _; -use arc_swap::Cache; -use futures::{channel::oneshot, FutureExt}; -use monero_serai::block::Block; use std::{ cmp::min, collections::HashMap, @@ -19,6 +16,10 @@ use std::{ sync::Arc, task::{Context, Poll}, }; + +use arc_swap::Cache; +use futures::{channel::oneshot, FutureExt}; +use monero_serai::block::Block; use tokio::sync::mpsc; use tokio_util::sync::PollSender; use tower::Service; diff --git a/consensus/context/src/task.rs b/consensus/context/src/task.rs index 8941907b2..327a3e067 100644 --- a/consensus/context/src/task.rs +++ b/consensus/context/src/task.rs @@ -3,10 +3,10 @@ //! This module contains the async task that handles keeping track of blockchain context. //! It holds all the context caches and handles [`tower::Service`] requests. //! +use std::sync::Arc; use arc_swap::ArcSwap; use futures::channel::oneshot; -use std::sync::Arc; use tokio::sync::mpsc; use tower::ServiceExt; use tracing::Instrument; @@ -18,13 +18,14 @@ use cuprate_types::{ Chain, HardFork, }; -use crate::difficulty::DifficultyCache; -use crate::hardforks::HardForkState; -use crate::weight::BlockWeightsCache; use crate::{ alt_chains::{get_alt_chain_difficulty_cache, get_alt_chain_weight_cache, AltChainMap}, - rx_vms, BlockChainContextRequest, BlockChainContextResponse, BlockchainContext, - ContextCacheError, ContextConfig, Database, BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW, + difficulty::DifficultyCache, + hardforks::HardForkState, + rx_vms, + weight::BlockWeightsCache, + BlockChainContextRequest, BlockChainContextResponse, BlockchainContext, ContextCacheError, + ContextConfig, Database, BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW, }; /// A request from the context service to the context task. diff --git a/consensus/src/block/batch_prepare.rs b/consensus/src/block/batch_prepare.rs index e05a1fd50..61fcba338 100644 --- a/consensus/src/block/batch_prepare.rs +++ b/consensus/src/block/batch_prepare.rs @@ -1,13 +1,11 @@ use std::{collections::HashMap, sync::Arc}; -use crate::batch_verifier::MultiThreadedBatchVerifier; -use crate::transactions::start_tx_verification; -use crate::{ - block::{free::order_transactions, PreparedBlock, PreparedBlockExPow}, - BlockChainContextRequest, BlockChainContextResponse, ExtendedConsensusError, -}; -use cuprate_consensus_context::rx_vms::RandomXVm; -use cuprate_consensus_context::BlockchainContextService; +use monero_serai::{block::Block, transaction::Transaction}; +use rayon::prelude::*; +use tower::{Service, ServiceExt}; +use tracing::instrument; + +use cuprate_consensus_context::{rx_vms::RandomXVm, BlockchainContextService}; use cuprate_consensus_rules::{ blocks::{check_block_pow, is_randomx_seed_height, randomx_seed_height, BlockError}, hard_forks::HardForkError, @@ -16,10 +14,13 @@ use cuprate_consensus_rules::{ }; use cuprate_helper::asynch::rayon_spawn_async; use cuprate_types::TransactionVerificationData; -use monero_serai::{block::Block, transaction::Transaction}; -use rayon::prelude::*; -use tower::{Service, ServiceExt}; -use tracing::instrument; + +use crate::{ + batch_verifier::MultiThreadedBatchVerifier, + block::{free::order_transactions, PreparedBlock, PreparedBlockExPow}, + transactions::start_tx_verification, + BlockChainContextRequest, BlockChainContextResponse, ExtendedConsensusError, +}; /// Batch prepares a list of blocks for verification. #[instrument(level = "debug", name = "batch_prep_blocks", skip_all, fields(amt = blocks.len()))] diff --git a/storage/txpool/src/service/interface.rs b/storage/txpool/src/service/interface.rs index 52475924e..e83fd4297 100644 --- a/storage/txpool/src/service/interface.rs +++ b/storage/txpool/src/service/interface.rs @@ -81,14 +81,13 @@ pub enum TxpoolReadResponse { //---------------------------------------------------------------------------------------------------- TxpoolWriteRequest /// The transaction pool [`tower::Service`] write request type. #[derive(Clone)] -#[expect(clippy::large_enum_variant)] pub enum TxpoolWriteRequest { /// Add a transaction to the pool. /// /// Returns [`TxpoolWriteResponse::AddTransaction`]. AddTransaction { /// The tx to add. - tx: TransactionVerificationData, + tx: Box<TransactionVerificationData>, /// A [`bool`] denoting the routing state of this tx. /// /// [`true`] if this tx is in the stem state. diff --git a/types/src/transaction_verification_data.rs b/types/src/transaction_verification_data.rs index 51ebe90b5..120c9061e 100644 --- a/types/src/transaction_verification_data.rs +++ b/types/src/transaction_verification_data.rs @@ -35,6 +35,7 @@ impl TxVersion { pub enum CachedVerificationState { /// The transaction has not been validated. NotVerified, + /// The transaction was only validated semantically. JustSemantic(HardFork), /// The transaction is valid* if the block represented by this hash is in the blockchain and the [`HardFork`] /// is the same.