mirror of
https://github.com/Cuprate/cuprate.git
synced 2025-04-10 00:07:34 +00:00
update rust to 2024
This commit is contained in:
parent
435c6b717f
commit
f15a754c50
186 changed files with 1846 additions and 851 deletions
binaries/cuprated
Cargo.toml
src
consensus
Cargo.toml
context
fast-sync
rules
Cargo.toml
src
src
tests
constants
cryptonight
helper
net
epee-encoding
fixed-bytes
levin
wire
p2p
address-book
async-buffer
bucket
dandelion-tower
p2p-core
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "cuprated"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
description = "The Cuprate Rust Monero node."
|
||||
license = "AGPL-3.0-only"
|
||||
authors = ["Boog900", "hinto-janai", "SyntheticBird45"]
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use futures::FutureExt;
|
||||
use tokio::sync::{mpsc, Notify};
|
||||
use tokio::sync::{Notify, mpsc};
|
||||
use tower::{BoxError, Service, ServiceExt};
|
||||
|
||||
use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle};
|
||||
use cuprate_consensus::{generate_genesis_block, BlockchainContextService, ContextConfig};
|
||||
use cuprate_consensus::{BlockchainContextService, ContextConfig, generate_genesis_block};
|
||||
use cuprate_cryptonight::cryptonight_hash_v0;
|
||||
use cuprate_p2p::{block_downloader::BlockDownloaderConfig, NetworkInterface};
|
||||
use cuprate_p2p::{NetworkInterface, block_downloader::BlockDownloaderConfig};
|
||||
use cuprate_p2p_core::{ClearNet, Network};
|
||||
use cuprate_types::{
|
||||
blockchain::{BlockchainReadRequest, BlockchainWriteRequest},
|
||||
VerifiedBlockInformation,
|
||||
blockchain::{BlockchainReadRequest, BlockchainWriteRequest},
|
||||
};
|
||||
|
||||
use crate::constants::PANIC_CRITICAL_SERVICE_ERROR;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::task::{Context, Poll};
|
||||
|
||||
use futures::{future::BoxFuture, FutureExt, TryFutureExt};
|
||||
use futures::{FutureExt, TryFutureExt, future::BoxFuture};
|
||||
use tower::Service;
|
||||
|
||||
use cuprate_blockchain::service::BlockchainReadHandle;
|
||||
|
|
|
@ -14,8 +14,8 @@ use tower::{Service, ServiceExt};
|
|||
use cuprate_blockchain::service::BlockchainReadHandle;
|
||||
use cuprate_consensus::transactions::new_tx_verification_data;
|
||||
use cuprate_txpool::service::{
|
||||
interface::{TxpoolReadRequest, TxpoolReadResponse},
|
||||
TxpoolReadHandle,
|
||||
interface::{TxpoolReadRequest, TxpoolReadResponse},
|
||||
};
|
||||
use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse};
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::{collections::HashMap, sync::Arc};
|
|||
|
||||
use futures::StreamExt;
|
||||
use monero_serai::block::Block;
|
||||
use tokio::sync::{mpsc, oneshot, Notify, OwnedSemaphorePermit};
|
||||
use tokio::sync::{Notify, OwnedSemaphorePermit, mpsc, oneshot};
|
||||
use tower::{BoxError, Service, ServiceExt};
|
||||
use tracing::error;
|
||||
|
||||
|
@ -12,14 +12,14 @@ use cuprate_consensus::{
|
|||
ExtendedConsensusError,
|
||||
};
|
||||
use cuprate_p2p::{
|
||||
block_downloader::{BlockBatch, BlockDownloaderConfig},
|
||||
BroadcastSvc, NetworkInterface,
|
||||
block_downloader::{BlockBatch, BlockDownloaderConfig},
|
||||
};
|
||||
use cuprate_p2p_core::ClearNet;
|
||||
use cuprate_txpool::service::TxpoolWriteHandle;
|
||||
use cuprate_types::{
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
Chain, TransactionVerificationData,
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
|
|
|
@ -9,25 +9,25 @@ use monero_serai::{
|
|||
};
|
||||
use rayon::prelude::*;
|
||||
use tower::{Service, ServiceExt};
|
||||
use tracing::{info, instrument, Span};
|
||||
use tracing::{Span, info, instrument};
|
||||
|
||||
use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle};
|
||||
use cuprate_consensus::{
|
||||
BlockChainContextRequest, BlockChainContextResponse, ExtendedConsensusError,
|
||||
block::{
|
||||
batch_prepare_main_chain_blocks, sanity_check_alt_block, verify_main_chain_block,
|
||||
verify_prepped_main_chain_block, PreparedBlock,
|
||||
PreparedBlock, batch_prepare_main_chain_blocks, sanity_check_alt_block,
|
||||
verify_main_chain_block, verify_prepped_main_chain_block,
|
||||
},
|
||||
transactions::new_tx_verification_data,
|
||||
BlockChainContextRequest, BlockChainContextResponse, ExtendedConsensusError,
|
||||
};
|
||||
use cuprate_consensus_context::NewBlockData;
|
||||
use cuprate_fast_sync::{block_to_verified_block_information, fast_sync_top_height};
|
||||
use cuprate_helper::cast::usize_to_u64;
|
||||
use cuprate_p2p::{block_downloader::BlockBatch, constants::LONG_BAN, BroadcastRequest};
|
||||
use cuprate_p2p::{BroadcastRequest, block_downloader::BlockBatch, constants::LONG_BAN};
|
||||
use cuprate_txpool::service::interface::TxpoolWriteRequest;
|
||||
use cuprate_types::{
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse, BlockchainWriteRequest},
|
||||
AltBlockInformation, Chain, HardFork, TransactionVerificationData, VerifiedBlockInformation,
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse, BlockchainWriteRequest},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::{sync::Arc, time::Duration};
|
|||
|
||||
use futures::StreamExt;
|
||||
use tokio::{
|
||||
sync::{mpsc, Notify, OwnedSemaphorePermit, Semaphore},
|
||||
sync::{Notify, OwnedSemaphorePermit, Semaphore, mpsc},
|
||||
time::interval,
|
||||
};
|
||||
use tower::{Service, ServiceExt};
|
||||
|
@ -12,8 +12,8 @@ use tracing::instrument;
|
|||
use cuprate_consensus::{BlockChainContextRequest, BlockChainContextResponse, BlockchainContext};
|
||||
use cuprate_consensus_context::BlockchainContextService;
|
||||
use cuprate_p2p::{
|
||||
block_downloader::{BlockBatch, BlockDownloaderConfig, ChainSvcRequest, ChainSvcResponse},
|
||||
NetworkInterface, PeerSetRequest, PeerSetResponse,
|
||||
block_downloader::{BlockBatch, BlockDownloaderConfig, ChainSvcRequest, ChainSvcResponse},
|
||||
};
|
||||
use cuprate_p2p_core::{ClearNet, NetworkZone};
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//! `cuprated` [`Command`] definition and handling.
|
||||
use std::{io, thread::sleep, time::Duration};
|
||||
|
||||
use clap::{builder::TypedValueParser, Parser, ValueEnum};
|
||||
use clap::{Parser, ValueEnum, builder::TypedValueParser};
|
||||
use tokio::sync::mpsc;
|
||||
use tower::{Service, ServiceExt};
|
||||
use tracing::level_filters::LevelFilter;
|
||||
|
@ -124,7 +124,9 @@ pub async fn io_loop(
|
|||
let height = context.chain_height;
|
||||
let top_hash = hex::encode(context.top_hash);
|
||||
|
||||
println!("STATUS:\n uptime: {h}h {m}m {s}s,\n height: {height},\n top_hash: {top_hash}");
|
||||
println!(
|
||||
"STATUS:\n uptime: {h}h {m}m {s}s,\n height: {height},\n top_hash: {top_hash}"
|
||||
);
|
||||
}
|
||||
Command::FastSyncTopHeight => {
|
||||
let top_height = cuprate_fast_sync::fast_sync_top_height();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! cuprated config
|
||||
use std::{
|
||||
fs::{read_to_string, File},
|
||||
fs::{File, read_to_string},
|
||||
io,
|
||||
path::Path,
|
||||
time::Duration,
|
||||
|
|
|
@ -46,7 +46,9 @@ fn killswitch() {
|
|||
|
||||
// Prints a generic killswitch message.
|
||||
let print_killswitch_msg = |msg| {
|
||||
eprintln!("killswitch: {msg}. (current_ts: {current_ts}, killswitch_activation_timestamp: {KILLSWITCH_ACTIVATION_TIMESTAMP}). `cuprated` will now exit. For more details on why this exists, see: <https://github.com/Cuprate/cuprate/pull/365>.");
|
||||
eprintln!(
|
||||
"killswitch: {msg}. (current_ts: {current_ts}, killswitch_activation_timestamp: {KILLSWITCH_ACTIVATION_TIMESTAMP}). `cuprated` will now exit. For more details on why this exists, see: <https://github.com/Cuprate/cuprate/pull/365>."
|
||||
);
|
||||
};
|
||||
|
||||
if current_ts < SYSTEM_CLOCK_SANITY_TIMESTAMP {
|
||||
|
|
|
@ -8,20 +8,19 @@ use std::{
|
|||
sync::OnceLock,
|
||||
};
|
||||
use tracing::{
|
||||
instrument::WithSubscriber, level_filters::LevelFilter, subscriber::Interest, Metadata,
|
||||
Metadata, instrument::WithSubscriber, level_filters::LevelFilter, subscriber::Interest,
|
||||
};
|
||||
use tracing_appender::{non_blocking::NonBlocking, rolling::Rotation};
|
||||
use tracing_subscriber::{
|
||||
Layer, Registry,
|
||||
filter::Filtered,
|
||||
fmt::{
|
||||
self,
|
||||
self, Layer as FmtLayer,
|
||||
format::{DefaultFields, Format},
|
||||
Layer as FmtLayer,
|
||||
},
|
||||
layer::{Context, Filter, Layered, SubscriberExt},
|
||||
reload::{Handle, Layer as ReloadLayer},
|
||||
util::SubscriberInitExt,
|
||||
Layer, Registry,
|
||||
};
|
||||
|
||||
use cuprate_helper::fs::logs_path;
|
||||
|
|
|
@ -21,7 +21,7 @@ use std::{mem, sync::Arc};
|
|||
use tokio::sync::mpsc;
|
||||
use tower::{Service, ServiceExt};
|
||||
use tracing::level_filters::LevelFilter;
|
||||
use tracing_subscriber::{layer::SubscriberExt, reload::Handle, util::SubscriberInitExt, Registry};
|
||||
use tracing_subscriber::{Registry, layer::SubscriberExt, reload::Handle, util::SubscriberInitExt};
|
||||
|
||||
use cuprate_consensus_context::{
|
||||
BlockChainContextRequest, BlockChainContextResponse, BlockchainContextService,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use std::{
|
||||
future::{ready, Ready},
|
||||
future::{Ready, ready},
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
use futures::{future::BoxFuture, FutureExt, TryFutureExt};
|
||||
use futures::{FutureExt, TryFutureExt, future::BoxFuture};
|
||||
use tower::Service;
|
||||
|
||||
use cuprate_consensus::{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::net::SocketAddr;
|
||||
|
||||
use cuprate_p2p_core::{client::InternalPeerID, ClearNet, NetworkZone};
|
||||
use cuprate_p2p_core::{ClearNet, NetworkZone, client::InternalPeerID};
|
||||
|
||||
/// An identifier for a P2P peer on any network.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use std::{
|
||||
collections::HashSet,
|
||||
future::{ready, Ready},
|
||||
future::{Ready, ready},
|
||||
hash::Hash,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures::{
|
||||
future::{BoxFuture, Shared},
|
||||
FutureExt,
|
||||
future::{BoxFuture, Shared},
|
||||
};
|
||||
use monero_serai::{block::Block, transaction::Transaction};
|
||||
use tokio::sync::{broadcast, oneshot, watch};
|
||||
|
@ -17,8 +17,8 @@ use tower::{Service, ServiceExt};
|
|||
|
||||
use cuprate_blockchain::service::BlockchainReadHandle;
|
||||
use cuprate_consensus::{
|
||||
transactions::new_tx_verification_data, BlockChainContextRequest, BlockChainContextResponse,
|
||||
BlockchainContextService,
|
||||
BlockChainContextRequest, BlockChainContextResponse, BlockchainContextService,
|
||||
transactions::new_tx_verification_data,
|
||||
};
|
||||
use cuprate_dandelion_tower::TxState;
|
||||
use cuprate_fixed_bytes::ByteArrayVec;
|
||||
|
@ -29,16 +29,16 @@ use cuprate_helper::{
|
|||
map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits},
|
||||
};
|
||||
use cuprate_p2p::constants::{
|
||||
MAX_BLOCKS_IDS_IN_CHAIN_ENTRY, MAX_BLOCK_BATCH_LEN, MAX_TRANSACTION_BLOB_SIZE, MEDIUM_BAN,
|
||||
MAX_BLOCK_BATCH_LEN, MAX_BLOCKS_IDS_IN_CHAIN_ENTRY, MAX_TRANSACTION_BLOB_SIZE, MEDIUM_BAN,
|
||||
};
|
||||
use cuprate_p2p_core::{
|
||||
client::{InternalPeerID, PeerInformation},
|
||||
NetZoneAddress, NetworkZone, ProtocolRequest, ProtocolResponse,
|
||||
client::{InternalPeerID, PeerInformation},
|
||||
};
|
||||
use cuprate_txpool::service::TxpoolReadHandle;
|
||||
use cuprate_types::{
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
BlockCompleteEntry, TransactionBlobs, TxsInBlock,
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
};
|
||||
use cuprate_wire::protocol::{
|
||||
ChainRequest, ChainResponse, FluffyMissingTransactionsRequest, GetObjectsRequest,
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
use std::convert::Infallible;
|
||||
|
||||
use anyhow::{anyhow, Error};
|
||||
use anyhow::{Error, anyhow};
|
||||
use tower::ServiceExt;
|
||||
|
||||
use cuprate_helper::cast::usize_to_u64;
|
||||
use cuprate_p2p_core::{
|
||||
AddressBook, NetworkZone,
|
||||
services::{AddressBookRequest, AddressBookResponse},
|
||||
types::{BanState, ConnectionId},
|
||||
AddressBook, NetworkZone,
|
||||
};
|
||||
use cuprate_pruning::PruningSeed;
|
||||
use cuprate_rpc_types::misc::{ConnectionInfo, Span};
|
||||
|
|
|
@ -13,10 +13,10 @@ use tower::{Service, ServiceExt};
|
|||
use cuprate_blockchain::{service::BlockchainReadHandle, types::AltChainInfo};
|
||||
use cuprate_helper::cast::{u64_to_usize, usize_to_u64};
|
||||
use cuprate_types::{
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
output_cache::OutputCache,
|
||||
Chain, ChainInfo, CoinbaseTxSum, ExtendedBlockHeader, HardFork, MinerData,
|
||||
OutputHistogramEntry, OutputHistogramInput, OutputOnChain,
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
output_cache::OutputCache,
|
||||
};
|
||||
|
||||
/// [`BlockchainReadRequest::Block`].
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use std::convert::Infallible;
|
||||
|
||||
use anyhow::{anyhow, Error};
|
||||
use anyhow::{Error, anyhow};
|
||||
use monero_serai::block::Block;
|
||||
use tower::{Service, ServiceExt};
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use monero_serai::block::Block;
|
|||
use tower::{Service, ServiceExt};
|
||||
|
||||
use cuprate_helper::cast::{u64_to_usize, usize_to_u64};
|
||||
use cuprate_p2p_core::{types::ConnectionId, NetworkZone};
|
||||
use cuprate_p2p_core::{NetworkZone, types::ConnectionId};
|
||||
use cuprate_pruning::PruningSeed;
|
||||
use cuprate_rpc_types::misc::Span;
|
||||
use cuprate_types::{AddAuxPow, AuxPow, HardFork};
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
use std::convert::Infallible;
|
||||
|
||||
use anyhow::{anyhow, Error};
|
||||
use anyhow::{Error, anyhow};
|
||||
use tower::{Service, ServiceExt};
|
||||
|
||||
use cuprate_helper::cast::usize_to_u64;
|
||||
use cuprate_txpool::{
|
||||
service::{
|
||||
interface::{TxpoolReadRequest, TxpoolReadResponse},
|
||||
TxpoolReadHandle,
|
||||
},
|
||||
TxEntry,
|
||||
service::{
|
||||
TxpoolReadHandle,
|
||||
interface::{TxpoolReadRequest, TxpoolReadResponse},
|
||||
},
|
||||
};
|
||||
|
||||
// FIXME: use `anyhow::Error` over `tower::BoxError` in txpool.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use cuprate_dandelion_tower::{
|
||||
pool::DandelionPoolService, DandelionConfig, DandelionRouter, Graph,
|
||||
DandelionConfig, DandelionRouter, Graph, pool::DandelionPoolService,
|
||||
};
|
||||
use cuprate_p2p::NetworkInterface;
|
||||
use cuprate_p2p_core::ClearNet;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use std::{
|
||||
future::{ready, Ready},
|
||||
future::{Ready, ready},
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
|
@ -33,7 +33,7 @@ impl Service<DiffuseRequest<DandelionTx>> for DiffuseService {
|
|||
let Ok(()) = self
|
||||
.clear_net_broadcast_service
|
||||
.call(BroadcastRequest::Transaction {
|
||||
tx_bytes: req.0 .0,
|
||||
tx_bytes: req.0.0,
|
||||
direction: None,
|
||||
received_from: None,
|
||||
})
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
use std::{
|
||||
future::Future,
|
||||
pin::Pin,
|
||||
task::{ready, Context, Poll},
|
||||
task::{Context, Poll, ready},
|
||||
};
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures::{future::BoxFuture, FutureExt, Stream};
|
||||
use futures::{FutureExt, Stream, future::BoxFuture};
|
||||
use tower::Service;
|
||||
|
||||
use cuprate_dandelion_tower::{traits::StemRequest, OutboundPeer};
|
||||
use cuprate_dandelion_tower::{OutboundPeer, traits::StemRequest};
|
||||
use cuprate_p2p::{ClientDropGuard, NetworkInterface, PeerSetRequest, PeerSetResponse};
|
||||
use cuprate_p2p_core::{
|
||||
client::{Client, InternalPeerID},
|
||||
BroadcastMessage, ClearNet, NetworkZone, PeerRequest, ProtocolRequest,
|
||||
client::{Client, InternalPeerID},
|
||||
};
|
||||
use cuprate_wire::protocol::NewTransactions;
|
||||
|
||||
|
@ -98,7 +98,7 @@ impl<N: NetworkZone> Service<StemRequest<DandelionTx>> for StemPeerService<N> {
|
|||
self.0
|
||||
.broadcast_client()
|
||||
.call(BroadcastMessage::NewTransactions(NewTransactions {
|
||||
txs: vec![req.0 .0],
|
||||
txs: vec![req.0.0],
|
||||
dandelionpp_fluff: false,
|
||||
padding: Bytes::new(),
|
||||
}))
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
use std::task::{Context, Poll};
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures::{future::BoxFuture, FutureExt};
|
||||
use futures::{FutureExt, future::BoxFuture};
|
||||
use tower::{Service, ServiceExt};
|
||||
|
||||
use cuprate_dandelion_tower::{
|
||||
traits::{TxStoreRequest, TxStoreResponse},
|
||||
State,
|
||||
traits::{TxStoreRequest, TxStoreResponse},
|
||||
};
|
||||
use cuprate_database::RuntimeError;
|
||||
use cuprate_txpool::service::{
|
||||
interface::{TxpoolReadRequest, TxpoolReadResponse, TxpoolWriteRequest},
|
||||
TxpoolReadHandle, TxpoolWriteHandle,
|
||||
interface::{TxpoolReadRequest, TxpoolReadResponse, TxpoolWriteRequest},
|
||||
};
|
||||
|
||||
use super::{DandelionTx, TxId};
|
||||
|
|
|
@ -5,29 +5,29 @@ use std::{
|
|||
};
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures::{future::BoxFuture, FutureExt};
|
||||
use futures::{FutureExt, future::BoxFuture};
|
||||
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::transactions::{PrepTransactions, start_tx_verification};
|
||||
use cuprate_consensus::{
|
||||
transactions::new_tx_verification_data, BlockChainContextRequest, BlockChainContextResponse,
|
||||
BlockchainContextService, ExtendedConsensusError,
|
||||
BlockChainContextRequest, BlockChainContextResponse, BlockchainContextService,
|
||||
ExtendedConsensusError, transactions::new_tx_verification_data,
|
||||
};
|
||||
use cuprate_dandelion_tower::{
|
||||
pool::{DandelionPoolService, IncomingTxBuilder},
|
||||
State, TxState,
|
||||
pool::{DandelionPoolService, IncomingTxBuilder},
|
||||
};
|
||||
use cuprate_helper::asynch::rayon_spawn_async;
|
||||
use cuprate_p2p::NetworkInterface;
|
||||
use cuprate_p2p_core::ClearNet;
|
||||
use cuprate_txpool::{
|
||||
service::{
|
||||
TxpoolReadHandle, TxpoolWriteHandle,
|
||||
interface::{
|
||||
TxpoolReadRequest, TxpoolReadResponse, TxpoolWriteRequest, TxpoolWriteResponse,
|
||||
},
|
||||
TxpoolReadHandle, TxpoolWriteHandle,
|
||||
},
|
||||
transaction_blob_hash,
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "cuprate-consensus"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
description = "A crate implementing all Moneros consensus rules."
|
||||
license = "MIT"
|
||||
authors = ["Boog900"]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "cuprate-consensus-context"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
authors = ["SyntheticBird","Boog900"]
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@ use std::{collections::HashMap, sync::Arc};
|
|||
|
||||
use tower::ServiceExt;
|
||||
|
||||
use cuprate_consensus_rules::{blocks::BlockError, ConsensusError};
|
||||
use cuprate_consensus_rules::{ConsensusError, blocks::BlockError};
|
||||
use cuprate_types::{
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
Chain, ChainId,
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
ContextCacheError, __private::Database, difficulty::DifficultyCache, rx_vms::RandomXVm,
|
||||
__private::Database, ContextCacheError, difficulty::DifficultyCache, rx_vms::RandomXVm,
|
||||
weight::BlockWeightsCache,
|
||||
};
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ use tracing::instrument;
|
|||
|
||||
use cuprate_helper::num::median;
|
||||
use cuprate_types::{
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
Chain,
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
};
|
||||
|
||||
use crate::{ContextCacheError, Database, HardFork};
|
||||
|
|
|
@ -5,8 +5,8 @@ use tracing::instrument;
|
|||
|
||||
use cuprate_consensus_rules::{HFVotes, HFsInfo, HardFork};
|
||||
use cuprate_types::{
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
Chain,
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
};
|
||||
|
||||
use crate::{ContextCacheError, Database};
|
||||
|
|
|
@ -18,14 +18,14 @@ use std::{
|
|||
};
|
||||
|
||||
use arc_swap::Cache;
|
||||
use futures::{channel::oneshot, FutureExt};
|
||||
use futures::{FutureExt, channel::oneshot};
|
||||
use monero_serai::block::Block;
|
||||
use tokio::sync::mpsc;
|
||||
use tokio_util::sync::PollSender;
|
||||
use tower::Service;
|
||||
|
||||
use cuprate_consensus_rules::{
|
||||
blocks::ContextToVerifyBlock, current_unix_timestamp, ConsensusError, HardFork,
|
||||
ConsensusError, HardFork, blocks::ContextToVerifyBlock, current_unix_timestamp,
|
||||
};
|
||||
|
||||
pub mod difficulty;
|
||||
|
@ -41,7 +41,7 @@ use difficulty::DifficultyCache;
|
|||
use rx_vms::RandomXVm;
|
||||
use weight::BlockWeightsCache;
|
||||
|
||||
pub use alt_chains::{sealed::AltChainRequestToken, AltChainContextCache};
|
||||
pub use alt_chains::{AltChainContextCache, sealed::AltChainRequestToken};
|
||||
pub use difficulty::DifficultyCacheConfig;
|
||||
pub use hardforks::HardForkConfig;
|
||||
pub use weight::BlockWeightsCacheConfig;
|
||||
|
@ -432,22 +432,22 @@ pub mod __private {
|
|||
/// ```
|
||||
pub trait Database:
|
||||
tower::Service<
|
||||
BlockchainReadRequest,
|
||||
Response = BlockchainResponse,
|
||||
Error = tower::BoxError,
|
||||
Future = Self::Future2,
|
||||
>
|
||||
BlockchainReadRequest,
|
||||
Response = BlockchainResponse,
|
||||
Error = tower::BoxError,
|
||||
Future = Self::Future2,
|
||||
>
|
||||
{
|
||||
type Future2: Future<Output = Result<Self::Response, Self::Error>> + Send + 'static;
|
||||
}
|
||||
|
||||
impl<
|
||||
T: tower::Service<
|
||||
T: tower::Service<
|
||||
BlockchainReadRequest,
|
||||
Response = BlockchainResponse,
|
||||
Error = tower::BoxError,
|
||||
>,
|
||||
> Database for T
|
||||
> Database for T
|
||||
where
|
||||
T::Future: Future<Output = Result<Self::Response, Self::Error>> + Send + 'static,
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
|
||||
use futures::{stream::FuturesOrdered, StreamExt};
|
||||
use futures::{StreamExt, stream::FuturesOrdered};
|
||||
use randomx_rs::{RandomXCache, RandomXError, RandomXFlag, RandomXVM as VmInner};
|
||||
use rayon::prelude::*;
|
||||
use thread_local::ThreadLocal;
|
||||
|
@ -17,13 +17,13 @@ use tracing::instrument;
|
|||
|
||||
use cuprate_consensus_rules::blocks::randomx_seed_height;
|
||||
use cuprate_consensus_rules::{
|
||||
blocks::{is_randomx_seed_height, RandomX, RX_SEEDHASH_EPOCH_BLOCKS},
|
||||
HardFork,
|
||||
blocks::{RX_SEEDHASH_EPOCH_BLOCKS, RandomX, is_randomx_seed_height},
|
||||
};
|
||||
use cuprate_helper::asynch::rayon_spawn_async;
|
||||
use cuprate_types::{
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
Chain,
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
};
|
||||
|
||||
use crate::{ContextCacheError, Database};
|
||||
|
|
|
@ -14,18 +14,18 @@ use tracing::Instrument;
|
|||
use cuprate_consensus_rules::blocks::ContextToVerifyBlock;
|
||||
use cuprate_helper::cast::u64_to_usize;
|
||||
use cuprate_types::{
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
Chain, HardFork,
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
alt_chains::{get_alt_chain_difficulty_cache, get_alt_chain_weight_cache, AltChainMap},
|
||||
BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW, BlockChainContextRequest, BlockChainContextResponse,
|
||||
BlockchainContext, ContextCacheError, ContextConfig, Database,
|
||||
alt_chains::{AltChainMap, get_alt_chain_difficulty_cache, get_alt_chain_weight_cache},
|
||||
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.
|
||||
|
|
|
@ -14,11 +14,11 @@ use std::{
|
|||
use tower::ServiceExt;
|
||||
use tracing::instrument;
|
||||
|
||||
use cuprate_consensus_rules::blocks::{penalty_free_zone, PENALTY_FREE_ZONE_5};
|
||||
use cuprate_consensus_rules::blocks::{PENALTY_FREE_ZONE_5, penalty_free_zone};
|
||||
use cuprate_helper::{asynch::rayon_spawn_async, num::RollingMedian};
|
||||
use cuprate_types::{
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
Chain,
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
};
|
||||
|
||||
use crate::{ContextCacheError, Database, HardFork};
|
||||
|
@ -97,7 +97,12 @@ impl BlockWeightsCache {
|
|||
)
|
||||
.await?;
|
||||
|
||||
tracing::info!("Initialized block weight cache, chain-height: {:?}, long term weights length: {:?}, short term weights length: {:?}", chain_height, long_term_weights.len(), short_term_block_weights.len());
|
||||
tracing::info!(
|
||||
"Initialized block weight cache, chain-height: {:?}, long term weights length: {:?}, short term weights length: {:?}",
|
||||
chain_height,
|
||||
long_term_weights.len(),
|
||||
short_term_block_weights.len()
|
||||
);
|
||||
|
||||
Ok(Self {
|
||||
short_term_block_weights: rayon_spawn_async(move || {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "cuprate-fast-sync"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
|
||||
[[bin]]
|
||||
|
|
|
@ -12,8 +12,8 @@ use cuprate_blockchain::{
|
|||
config::ConfigBuilder, cuprate_database::DbResult, service::BlockchainReadHandle,
|
||||
};
|
||||
use cuprate_types::{
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
Chain,
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
};
|
||||
|
||||
const BATCH_SIZE: usize = 512;
|
||||
|
|
|
@ -17,8 +17,8 @@ use cuprate_consensus_context::BlockchainContext;
|
|||
use cuprate_p2p::block_downloader::ChainEntry;
|
||||
use cuprate_p2p_core::NetworkZone;
|
||||
use cuprate_types::{
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
Chain, VerifiedBlockInformation, VerifiedTransactionInformation,
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
};
|
||||
|
||||
/// A [`OnceLock`] representing the fast sync hashes.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "cuprate-consensus-rules"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
authors = ["Boog900"]
|
||||
|
||||
|
|
|
@ -6,10 +6,9 @@ use monero_serai::block::Block;
|
|||
use cuprate_cryptonight::*;
|
||||
|
||||
use crate::{
|
||||
check_block_version_vote, current_unix_timestamp,
|
||||
HardFork, check_block_version_vote, current_unix_timestamp,
|
||||
hard_forks::HardForkError,
|
||||
miner_tx::{check_miner_tx, MinerTxError},
|
||||
HardFork,
|
||||
miner_tx::{MinerTxError, check_miner_tx},
|
||||
};
|
||||
|
||||
const BLOCK_SIZE_SANITY_LEEWAY: usize = 100;
|
||||
|
|
|
@ -18,7 +18,7 @@ pub mod miner_tx;
|
|||
pub mod transactions;
|
||||
|
||||
pub use decomposed_amount::is_decomposed_amount;
|
||||
pub use hard_forks::{check_block_version_vote, HFVotes, HFsInfo, HardFork};
|
||||
pub use hard_forks::{HFVotes, HFsInfo, HardFork, check_block_version_vote};
|
||||
pub use transactions::TxVersion;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
|
||||
|
|
|
@ -3,7 +3,7 @@ use monero_serai::transaction::{Input, Output, Timelock, Transaction};
|
|||
use cuprate_constants::block::MAX_BLOCK_HEIGHT_USIZE;
|
||||
use cuprate_types::TxVersion;
|
||||
|
||||
use crate::{is_decomposed_amount, transactions::check_output_types, HardFork};
|
||||
use crate::{HardFork, is_decomposed_amount, transactions::check_output_types};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
|
||||
pub enum MinerTxError {
|
||||
|
|
|
@ -8,8 +8,8 @@ use monero_serai::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
batch_verifier::BatchVerifier, blocks::penalty_free_zone, check_point_canonically_encoded,
|
||||
is_decomposed_amount, HardFork,
|
||||
HardFork, batch_verifier::BatchVerifier, blocks::penalty_free_zone,
|
||||
check_point_canonically_encoded, is_decomposed_amount,
|
||||
};
|
||||
|
||||
// re-export.
|
||||
|
|
|
@ -4,7 +4,7 @@ use curve25519_dalek::edwards::CompressedEdwardsY;
|
|||
use indexmap::{IndexMap, IndexSet};
|
||||
use monero_serai::transaction::{Input, Timelock};
|
||||
|
||||
use crate::{transactions::TransactionError, HardFork};
|
||||
use crate::{HardFork, transactions::TransactionError};
|
||||
|
||||
/// Gets the absolute offsets from the relative offsets.
|
||||
///
|
||||
|
|
|
@ -4,9 +4,9 @@ use monero_serai::{
|
|||
generators::H,
|
||||
io::decompress_point,
|
||||
ringct::{
|
||||
RctProofs, RctPrunable, RctType,
|
||||
clsag::ClsagError,
|
||||
mlsag::{AggregateRingMatrixBuilder, MlsagError, RingMatrix},
|
||||
RctProofs, RctPrunable, RctType,
|
||||
},
|
||||
transaction::Input,
|
||||
};
|
||||
|
@ -14,7 +14,7 @@ use rand::thread_rng;
|
|||
#[cfg(feature = "rayon")]
|
||||
use rayon::prelude::*;
|
||||
|
||||
use crate::{batch_verifier::BatchVerifier, transactions::Rings, try_par_iter, HardFork};
|
||||
use crate::{HardFork, batch_verifier::BatchVerifier, transactions::Rings, try_par_iter};
|
||||
|
||||
/// This constant contains the IDs of 2 transactions that should be allowed after the fork the ringCT
|
||||
/// type they used should be banned.
|
||||
|
@ -234,24 +234,30 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn grandfathered_bulletproofs2() {
|
||||
assert!(check_rct_type(
|
||||
RctType::MlsagBulletproofsCompactAmount,
|
||||
HardFork::V14,
|
||||
&[0; 32]
|
||||
)
|
||||
.is_err());
|
||||
assert!(
|
||||
check_rct_type(
|
||||
RctType::MlsagBulletproofsCompactAmount,
|
||||
HardFork::V14,
|
||||
&[0; 32]
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
|
||||
assert!(check_rct_type(
|
||||
RctType::MlsagBulletproofsCompactAmount,
|
||||
HardFork::V14,
|
||||
&GRANDFATHERED_TRANSACTIONS[0]
|
||||
)
|
||||
.is_ok());
|
||||
assert!(check_rct_type(
|
||||
RctType::MlsagBulletproofsCompactAmount,
|
||||
HardFork::V14,
|
||||
&GRANDFATHERED_TRANSACTIONS[1]
|
||||
)
|
||||
.is_ok());
|
||||
assert!(
|
||||
check_rct_type(
|
||||
RctType::MlsagBulletproofsCompactAmount,
|
||||
HardFork::V14,
|
||||
&GRANDFATHERED_TRANSACTIONS[0]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
assert!(
|
||||
check_rct_type(
|
||||
RctType::MlsagBulletproofsCompactAmount,
|
||||
HardFork::V14,
|
||||
&GRANDFATHERED_TRANSACTIONS[1]
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use std::ops::Range;
|
||||
|
||||
use curve25519_dalek::{
|
||||
EdwardsPoint,
|
||||
constants::{ED25519_BASEPOINT_COMPRESSED, EIGHT_TORSION},
|
||||
edwards::CompressedEdwardsY,
|
||||
EdwardsPoint,
|
||||
};
|
||||
use proptest::{collection::vec, prelude::*};
|
||||
|
||||
|
@ -91,12 +91,14 @@ fn test_decoy_info() {
|
|||
#[test]
|
||||
fn test_torsion_ki() {
|
||||
for &key_image in &EIGHT_TORSION[1..] {
|
||||
assert!(check_key_images(&Input::ToKey {
|
||||
key_image: key_image.compress(),
|
||||
amount: None,
|
||||
key_offsets: vec![],
|
||||
})
|
||||
.is_err());
|
||||
assert!(
|
||||
check_key_images(&Input::ToKey {
|
||||
key_image: key_image.compress(),
|
||||
amount: None,
|
||||
key_offsets: vec![],
|
||||
})
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,22 +21,22 @@ use cuprate_types::{
|
|||
};
|
||||
|
||||
use cuprate_consensus_rules::{
|
||||
ConsensusError, HardFork,
|
||||
blocks::{
|
||||
calculate_pow_hash, check_block, check_block_pow, randomx_seed_height, BlockError, RandomX,
|
||||
BlockError, RandomX, calculate_pow_hash, check_block, check_block_pow, randomx_seed_height,
|
||||
},
|
||||
hard_forks::HardForkError,
|
||||
miner_tx::MinerTxError,
|
||||
ConsensusError, HardFork,
|
||||
};
|
||||
|
||||
use crate::{transactions::start_tx_verification, Database, ExtendedConsensusError};
|
||||
use crate::{Database, ExtendedConsensusError, transactions::start_tx_verification};
|
||||
|
||||
mod alt_block;
|
||||
mod batch_prepare;
|
||||
mod free;
|
||||
|
||||
pub use alt_block::sanity_check_alt_block;
|
||||
pub use batch_prepare::{batch_prepare_main_chain_blocks, BatchPrepareCache};
|
||||
pub use batch_prepare::{BatchPrepareCache, batch_prepare_main_chain_blocks};
|
||||
use free::pull_ordered_transactions;
|
||||
|
||||
/// A pre-prepared block with all data needed to verify it, except the block's proof of work.
|
||||
|
|
|
@ -8,17 +8,17 @@ use monero_serai::{block::Block, transaction::Input};
|
|||
use tower::{Service, ServiceExt};
|
||||
|
||||
use cuprate_consensus_context::{
|
||||
AltChainContextCache, AltChainRequestToken, BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW,
|
||||
difficulty::DifficultyCache,
|
||||
rx_vms::RandomXVm,
|
||||
weight::{self, BlockWeightsCache},
|
||||
AltChainContextCache, AltChainRequestToken, BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW,
|
||||
};
|
||||
use cuprate_consensus_rules::{
|
||||
ConsensusError,
|
||||
blocks::{
|
||||
check_block_pow, check_block_weight, check_timestamp, randomx_seed_height, BlockError,
|
||||
BlockError, check_block_pow, check_block_weight, check_timestamp, randomx_seed_height,
|
||||
},
|
||||
miner_tx::MinerTxError,
|
||||
ConsensusError,
|
||||
};
|
||||
use cuprate_helper::{asynch::rayon_spawn_async, cast::u64_to_usize};
|
||||
use cuprate_types::{
|
||||
|
@ -27,8 +27,8 @@ use cuprate_types::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
block::{free::pull_ordered_transactions, PreparedBlock},
|
||||
BlockChainContextRequest, BlockChainContextResponse, ExtendedConsensusError,
|
||||
block::{PreparedBlock, free::pull_ordered_transactions},
|
||||
};
|
||||
|
||||
/// This function sanity checks an alt-block.
|
||||
|
|
|
@ -5,22 +5,22 @@ use rayon::prelude::*;
|
|||
use tower::{Service, ServiceExt};
|
||||
use tracing::instrument;
|
||||
|
||||
use cuprate_consensus_context::{rx_vms::RandomXVm, BlockchainContextService};
|
||||
use cuprate_consensus_context::{BlockchainContextService, rx_vms::RandomXVm};
|
||||
use cuprate_consensus_rules::{
|
||||
blocks::{check_block_pow, is_randomx_seed_height, randomx_seed_height, BlockError},
|
||||
ConsensusError, HardFork,
|
||||
blocks::{BlockError, check_block_pow, is_randomx_seed_height, randomx_seed_height},
|
||||
hard_forks::HardForkError,
|
||||
miner_tx::MinerTxError,
|
||||
ConsensusError, HardFork,
|
||||
};
|
||||
use cuprate_helper::asynch::rayon_spawn_async;
|
||||
use cuprate_types::{output_cache::OutputCache, TransactionVerificationData};
|
||||
use cuprate_types::{TransactionVerificationData, output_cache::OutputCache};
|
||||
|
||||
use crate::{
|
||||
batch_verifier::MultiThreadedBatchVerifier,
|
||||
block::{free::order_transactions, PreparedBlock, PreparedBlockExPow},
|
||||
transactions::{check_kis_unique, contextual_data::get_output_cache, start_tx_verification},
|
||||
BlockChainContextRequest, BlockChainContextResponse, ExtendedConsensusError,
|
||||
__private::Database,
|
||||
BlockChainContextRequest, BlockChainContextResponse, ExtendedConsensusError,
|
||||
batch_verifier::MultiThreadedBatchVerifier,
|
||||
block::{PreparedBlock, PreparedBlockExPow, free::order_transactions},
|
||||
transactions::{check_kis_unique, contextual_data::get_output_cache, start_tx_verification},
|
||||
};
|
||||
|
||||
/// Cached state created when batch preparing a group of blocks.
|
||||
|
|
|
@ -28,11 +28,13 @@ pub(crate) fn order_transactions(
|
|||
}
|
||||
}
|
||||
|
||||
debug_assert!(block
|
||||
.transactions
|
||||
.iter()
|
||||
.zip(txs.iter())
|
||||
.all(|(tx_hash, tx)| tx_hash == &tx.tx_hash));
|
||||
debug_assert!(
|
||||
block
|
||||
.transactions
|
||||
.iter()
|
||||
.zip(txs.iter())
|
||||
.all(|(tx_hash, tx)| tx_hash == &tx.tx_hash)
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -26,15 +26,15 @@ mod tests;
|
|||
pub mod transactions;
|
||||
|
||||
pub use cuprate_consensus_context::{
|
||||
initialize_blockchain_context, BlockChainContextRequest, BlockChainContextResponse,
|
||||
BlockchainContext, BlockchainContextService, ContextConfig,
|
||||
BlockChainContextRequest, BlockChainContextResponse, BlockchainContext,
|
||||
BlockchainContextService, ContextConfig, initialize_blockchain_context,
|
||||
};
|
||||
|
||||
// re-export.
|
||||
pub use cuprate_consensus_rules::genesis::generate_genesis_block;
|
||||
pub use cuprate_types::{
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
HardFork,
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
};
|
||||
|
||||
/// An Error returned from one of the consensus services.
|
||||
|
@ -72,22 +72,22 @@ pub mod __private {
|
|||
/// ```
|
||||
pub trait Database:
|
||||
tower::Service<
|
||||
BlockchainReadRequest,
|
||||
Response = BlockchainResponse,
|
||||
Error = tower::BoxError,
|
||||
Future: Send + 'static,
|
||||
>
|
||||
BlockchainReadRequest,
|
||||
Response = BlockchainResponse,
|
||||
Error = tower::BoxError,
|
||||
Future: Send + 'static,
|
||||
>
|
||||
{
|
||||
}
|
||||
|
||||
impl<
|
||||
T: tower::Service<
|
||||
T: tower::Service<
|
||||
BlockchainReadRequest,
|
||||
Response = BlockchainResponse,
|
||||
Error = tower::BoxError,
|
||||
Future: Send + 'static,
|
||||
>,
|
||||
> Database for T
|
||||
> Database for T
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,10 @@ use proptest::{strategy::Strategy, test_runner::TestRunner};
|
|||
use tower::ServiceExt;
|
||||
|
||||
use cuprate_consensus_context::{
|
||||
initialize_blockchain_context, BlockChainContextRequest, ContextConfig, NewBlockData,
|
||||
BlockChainContextRequest, ContextConfig, NewBlockData, initialize_blockchain_context,
|
||||
};
|
||||
|
||||
use crate::{tests::mock_db::*, HardFork};
|
||||
use crate::{HardFork, tests::mock_db::*};
|
||||
|
||||
pub(crate) mod data;
|
||||
mod difficulty;
|
||||
|
|
|
@ -4,8 +4,8 @@ use proptest::collection::{size_range, vec};
|
|||
use proptest::{prelude::*, prop_assert_eq, prop_compose, proptest};
|
||||
|
||||
use crate::{
|
||||
tests::{context::data::DIF_3000000_3002000, mock_db::*},
|
||||
HardFork,
|
||||
tests::{context::data::DIF_3000000_3002000, mock_db::*},
|
||||
};
|
||||
use cuprate_consensus_context::difficulty::*;
|
||||
use cuprate_helper::num::median;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use proptest::{collection::vec, prelude::*};
|
||||
|
||||
use cuprate_consensus_context::{hardforks::HardForkState, HardForkConfig};
|
||||
use cuprate_consensus_context::{HardForkConfig, hardforks::HardForkState};
|
||||
use cuprate_consensus_rules::hard_forks::{HFInfo, HFsInfo, HardFork, NUMB_OF_HARD_FORKS};
|
||||
|
||||
use crate::tests::{
|
||||
|
|
|
@ -3,10 +3,10 @@ use std::collections::VecDeque;
|
|||
use proptest::prelude::*;
|
||||
use tokio::runtime::Builder;
|
||||
|
||||
use cuprate_consensus_context::rx_vms::{get_last_rx_seed_heights, RandomXVmCache};
|
||||
use cuprate_consensus_context::rx_vms::{RandomXVmCache, get_last_rx_seed_heights};
|
||||
use cuprate_consensus_rules::{
|
||||
blocks::{is_randomx_seed_height, randomx_seed_height},
|
||||
HardFork,
|
||||
blocks::{is_randomx_seed_height, randomx_seed_height},
|
||||
};
|
||||
|
||||
use crate::tests::mock_db::*;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::{
|
||||
tests::{context::data::BW_2850000_3050000, mock_db::*},
|
||||
HardFork,
|
||||
tests::{context::data::BW_2850000_3050000, mock_db::*},
|
||||
};
|
||||
use cuprate_consensus_context::{
|
||||
weight::{calculate_block_long_term_weight, BlockWeightsCache},
|
||||
BlockWeightsCacheConfig,
|
||||
weight::{BlockWeightsCache, calculate_block_long_term_weight},
|
||||
};
|
||||
use cuprate_types::Chain;
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ use proptest_derive::Arbitrary;
|
|||
use tower::{BoxError, Service};
|
||||
|
||||
use cuprate_types::{
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
ExtendedBlockHeader,
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
};
|
||||
|
||||
use crate::HardFork;
|
||||
|
|
|
@ -32,24 +32,24 @@ use rayon::prelude::*;
|
|||
use tower::ServiceExt;
|
||||
|
||||
use cuprate_consensus_rules::{
|
||||
transactions::{
|
||||
check_decoy_info, check_transaction_contextual, check_transaction_semantic,
|
||||
output_unlocked, TransactionError,
|
||||
},
|
||||
ConsensusError, HardFork,
|
||||
transactions::{
|
||||
TransactionError, check_decoy_info, check_transaction_contextual,
|
||||
check_transaction_semantic, output_unlocked,
|
||||
},
|
||||
};
|
||||
use cuprate_helper::asynch::rayon_spawn_async;
|
||||
use cuprate_types::{
|
||||
CachedVerificationState, TransactionVerificationData, TxVersion,
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
output_cache::OutputCache,
|
||||
CachedVerificationState, TransactionVerificationData, TxVersion,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
Database, ExtendedConsensusError,
|
||||
batch_verifier::MultiThreadedBatchVerifier,
|
||||
block::BatchPrepareCache,
|
||||
transactions::contextual_data::{batch_get_decoy_info, batch_get_ring_member_info},
|
||||
Database, ExtendedConsensusError,
|
||||
};
|
||||
|
||||
pub mod contextual_data;
|
||||
|
|
|
@ -19,20 +19,20 @@ use tower::ServiceExt;
|
|||
use tracing::instrument;
|
||||
|
||||
use cuprate_consensus_rules::{
|
||||
transactions::{
|
||||
get_absolute_offsets, insert_ring_member_ids, DecoyInfo, Rings, TransactionError,
|
||||
TxRingMembersInfo,
|
||||
},
|
||||
ConsensusError, HardFork, TxVersion,
|
||||
transactions::{
|
||||
DecoyInfo, Rings, TransactionError, TxRingMembersInfo, get_absolute_offsets,
|
||||
insert_ring_member_ids,
|
||||
},
|
||||
};
|
||||
|
||||
use cuprate_types::{
|
||||
OutputOnChain,
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
output_cache::OutputCache,
|
||||
OutputOnChain,
|
||||
};
|
||||
|
||||
use crate::{transactions::TransactionVerificationData, Database, ExtendedConsensusError};
|
||||
use crate::{Database, ExtendedConsensusError, transactions::TransactionVerificationData};
|
||||
|
||||
/// Get the ring members for the inputs from the outputs on the chain.
|
||||
///
|
||||
|
@ -214,15 +214,12 @@ pub async fn batch_get_ring_member_info<D: Database>(
|
|||
/// This functions panics if `hf == HardFork::V1` as decoy info
|
||||
/// should not be needed for V1.
|
||||
#[instrument(level = "debug", skip_all)]
|
||||
pub async fn batch_get_decoy_info<'a, 'b, D: Database>(
|
||||
txs_verification_data: impl Iterator<Item = &'a TransactionVerificationData> + Clone,
|
||||
pub async fn batch_get_decoy_info<D: Database>(
|
||||
txs_verification_data: impl Iterator<Item = &TransactionVerificationData> + Clone,
|
||||
hf: HardFork,
|
||||
mut database: D,
|
||||
cache: Option<&'b OutputCache>,
|
||||
) -> Result<
|
||||
impl Iterator<Item = Result<DecoyInfo, ConsensusError>> + sealed::Captures<(&'a (), &'b ())>,
|
||||
ExtendedConsensusError,
|
||||
> {
|
||||
cache: Option<&OutputCache>,
|
||||
) -> Result<impl Iterator<Item = Result<DecoyInfo, ConsensusError>>, ExtendedConsensusError> {
|
||||
// decoy info is not needed for V1.
|
||||
assert_ne!(hf, HardFork::V1);
|
||||
|
||||
|
@ -271,11 +268,3 @@ pub async fn batch_get_decoy_info<'a, 'b, D: Database>(
|
|||
.map_err(ConsensusError::Transaction)
|
||||
}))
|
||||
}
|
||||
|
||||
mod sealed {
|
||||
/// TODO: Remove me when 2024 Rust
|
||||
///
|
||||
/// <https://rust-lang.github.io/rfcs/3498-lifetime-capture-rules-2024.html#the-captures-trick>
|
||||
pub trait Captures<U> {}
|
||||
impl<T: ?Sized, U> Captures<U> for T {}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use monero_serai::{
|
||||
ringct::{bulletproofs::Bulletproof, RctType},
|
||||
ringct::{RctType, bulletproofs::Bulletproof},
|
||||
transaction::{Input, Transaction},
|
||||
};
|
||||
|
||||
use cuprate_consensus_rules::{transactions::TransactionError, ConsensusError};
|
||||
use cuprate_consensus_rules::{ConsensusError, transactions::TransactionError};
|
||||
use cuprate_types::{CachedVerificationState, TransactionVerificationData, TxVersion};
|
||||
|
||||
/// Creates a new [`TransactionVerificationData`] from a [`Transaction`].
|
||||
|
|
|
@ -14,9 +14,9 @@ use tower::service_fn;
|
|||
|
||||
use cuprate_consensus::{__private::Database, transactions::start_tx_verification};
|
||||
use cuprate_types::{
|
||||
OutputOnChain,
|
||||
blockchain::{BlockchainReadRequest, BlockchainResponse},
|
||||
output_cache::OutputCache,
|
||||
OutputOnChain,
|
||||
};
|
||||
|
||||
use cuprate_consensus_rules::HardFork;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "cuprate-constants"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
description = "Constant/static data used throughout Cuprate"
|
||||
license = "MIT"
|
||||
authors = ["hinto-janai"]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "cuprate-cryptonight"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
description = "A wrapper around Monero's CryptoNight hash function."
|
||||
license = "MIT"
|
||||
authors = ["dimalinux", "Boog900", "The Monero Project"]
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,4 @@
|
|||
use crate::slow_hash::{Variant, MEMORY_BLOCKS};
|
||||
use crate::slow_hash::{MEMORY_BLOCKS, Variant};
|
||||
|
||||
const U64_MASK: u128 = u64::MAX as u128;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::cmp::max;
|
||||
|
||||
use seq_macro::seq;
|
||||
use InstructionList::{Add, Mul, Ret, Rol, Ror, Sub, Xor};
|
||||
use seq_macro::seq;
|
||||
|
||||
use crate::{
|
||||
blake256::{Blake256, Digest},
|
||||
|
|
|
@ -4,7 +4,7 @@ use cnaes::{AES_BLOCK_SIZE, CN_AES_KEY_SIZE};
|
|||
use digest::Digest as _;
|
||||
use groestl::Groestl256;
|
||||
use jh::Jh256;
|
||||
use skein::{consts::U32, Skein512};
|
||||
use skein::{Skein512, consts::U32};
|
||||
|
||||
use crate::{
|
||||
blake256::{Blake256, Digest as _},
|
||||
|
@ -358,7 +358,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_keccak1600() {
|
||||
let input: [u8; 44] = hex_to_array(
|
||||
"5468697320697320612074657374205468697320697320612074657374205468697320697320612074657374"
|
||||
"5468697320697320612074657374205468697320697320612074657374205468697320697320612074657374",
|
||||
);
|
||||
let mut output = [0_u8; KECCAK1600_BYTE_SIZE];
|
||||
keccak1600(&input, &mut output);
|
||||
|
@ -399,7 +399,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_hash_permutations() {
|
||||
let mut state_bytes: [u8; KECCAK1600_BYTE_SIZE] = hex_to_array(
|
||||
"af6fe96f8cb409bdd2a61fb837e346f1a28007b0f078a8d68bc1224b6fcfcc3c39f1244db8c0af06e94173db4a54038a2f7a6a9c729928b5ec79668a30cbf5f2622fea9d7982e587e6612c4e6a1d28fdbaba4af1aea99e63322a632d514f35b4fc5cf231e9a6328efb5eb22ad2cfabe571ee8b6ef7dbc64f63185d54a771bdccd207b75e10547b4928f5dcb309192d88bf313d8bc53c8fe71da7ea93355d266c5cc8d39a1273e44b074d143849a3b302edad73c2e61f936c502f6bbabb972b616062b66d56cd8136"
|
||||
"af6fe96f8cb409bdd2a61fb837e346f1a28007b0f078a8d68bc1224b6fcfcc3c39f1244db8c0af06e94173db4a54038a2f7a6a9c729928b5ec79668a30cbf5f2622fea9d7982e587e6612c4e6a1d28fdbaba4af1aea99e63322a632d514f35b4fc5cf231e9a6328efb5eb22ad2cfabe571ee8b6ef7dbc64f63185d54a771bdccd207b75e10547b4928f5dcb309192d88bf313d8bc53c8fe71da7ea93355d266c5cc8d39a1273e44b074d143849a3b302edad73c2e61f936c502f6bbabb972b616062b66d56cd8136",
|
||||
);
|
||||
const EXPECTED: &str = "31e2fb6eb8e2e376d42a53bc88166378f2a23cf9be54645ff69e8ade3aa4b7ad35040d0e3ad0ee0d8562d53a51acdf14f44de5c097c48a29f63676346194b3af13c3c45af214335a14329491081068a32ea29b3a6856e0efa737dff49d3b5dbf3f7847f058bb41d36347c19d5cd5bdb354ac64a86156c8194e19b0f62d109a8112024a7734730a2bb221c137d3034204e1e57d9cec9689bc199de684f38aeed4624b84c39675a4755ce9b69fde9d36cabd12f1aef4a5b2bb6c6126900799f2109e9b6b55d7bb3ff5";
|
||||
hash_permutation(&mut state_bytes);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "cuprate-helper"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
description = "Helper functions used around Cuprate."
|
||||
license = "MIT"
|
||||
authors = ["hinto-janai <hinto.janai@protonmail.com>", "Boog900"]
|
||||
|
|
|
@ -9,7 +9,7 @@ use core::{
|
|||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
use futures::{channel::oneshot, FutureExt};
|
||||
use futures::{FutureExt, channel::oneshot};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- InfallibleOneshotReceiver
|
||||
/// A oneshot receiver channel that doesn't return an Error.
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
use std::sync::LazyLock;
|
||||
|
||||
use curve25519_dalek::{
|
||||
Scalar,
|
||||
constants::{ED25519_BASEPOINT_COMPRESSED, ED25519_BASEPOINT_POINT},
|
||||
edwards::CompressedEdwardsY,
|
||||
edwards::VartimeEdwardsPrecomputation,
|
||||
traits::VartimePrecomputedMultiscalarMul,
|
||||
Scalar,
|
||||
};
|
||||
use monero_serai::generators::H;
|
||||
|
||||
|
@ -110,9 +110,9 @@ pub fn compute_zero_commitment(amount: u64) -> CompressedEdwardsY {
|
|||
//---------------------------------------------------------------------------------------------------- Tests
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use curve25519_dalek::{traits::VartimePrecomputedMultiscalarMul, Scalar};
|
||||
use curve25519_dalek::{Scalar, traits::VartimePrecomputedMultiscalarMul};
|
||||
|
||||
use crate::crypto::{compute_zero_commitment, H_PRECOMP, ZERO_COMMITMENT_DECOMPOSED_AMOUNT};
|
||||
use crate::crypto::{H_PRECOMP, ZERO_COMMITMENT_DECOMPOSED_AMOUNT, compute_zero_commitment};
|
||||
|
||||
#[test]
|
||||
/// Compare the output of `compute_zero_commitment` for all
|
||||
|
|
|
@ -35,7 +35,9 @@ macro_rules! impl_number {
|
|||
)*
|
||||
};
|
||||
}
|
||||
impl_number!(u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize);
|
||||
impl_number!(
|
||||
u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize
|
||||
);
|
||||
|
||||
/// Floating point numbers
|
||||
///
|
||||
|
@ -106,14 +108,16 @@ where
|
|||
let len = array.len();
|
||||
|
||||
// TODO: use `is_sorted` when stable.
|
||||
debug_assert!(array
|
||||
.windows(2)
|
||||
.try_for_each(|window| if window[0] <= window[1] {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(())
|
||||
})
|
||||
.is_ok());
|
||||
debug_assert!(
|
||||
array
|
||||
.windows(2)
|
||||
.try_for_each(|window| if window[0] <= window[1] {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(())
|
||||
})
|
||||
.is_ok()
|
||||
);
|
||||
|
||||
let mid = len / 2;
|
||||
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
[package]
|
||||
name = "cuprate-epee-encoding"
|
||||
version = "0.5.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
authors = ["Boog900"]
|
||||
readme = "README.md"
|
||||
keywords = ["monero", "epee", "no-std"]
|
||||
description = "Epee binary format library."
|
||||
repository = "https://github.com/Boog900/epee-encoding"
|
||||
rust-version = "1.60"
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
|
|
|
@ -3,7 +3,7 @@ use alloc::{string::ToString, vec, vec::Vec};
|
|||
use bytes::{Buf, BufMut, Bytes, BytesMut};
|
||||
use ref_cast::RefCast;
|
||||
|
||||
use crate::{error::*, EpeeValue, InnerMarker, Marker};
|
||||
use crate::{EpeeValue, InnerMarker, Marker, error::*};
|
||||
|
||||
#[derive(RefCast)]
|
||||
#[repr(transparent)]
|
||||
|
|
|
@ -9,10 +9,10 @@ use bytes::{Buf, BufMut, Bytes, BytesMut};
|
|||
use cuprate_fixed_bytes::{ByteArray, ByteArrayVec};
|
||||
|
||||
use crate::{
|
||||
EpeeObject, Error, InnerMarker, MAX_STRING_LEN_POSSIBLE, Marker, Result,
|
||||
io::{checked_read_primitive, checked_write_primitive},
|
||||
varint::{read_varint, write_varint},
|
||||
write_bytes, write_iterator, EpeeObject, Error, InnerMarker, Marker, Result,
|
||||
MAX_STRING_LEN_POSSIBLE,
|
||||
write_bytes, write_iterator,
|
||||
};
|
||||
|
||||
/// A trait for epee values.
|
||||
|
|
|
@ -13,7 +13,7 @@ epee_object!(
|
|||
);
|
||||
|
||||
#[test]
|
||||
#[allow(clippy::useless_asref)]
|
||||
#[expect(clippy::useless_asref)]
|
||||
fn optional_val_not_in_data() {
|
||||
let bytes: &[u8] = b"\x01\x11\x01\x01\x01\x01\x02\x01\x01\x00";
|
||||
let t: T = from_bytes(&mut bytes.as_ref()).unwrap();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "cuprate-fixed-bytes"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
authors = ["Boog900"]
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "cuprate-levin"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
description = "A crate for working with the Levin protocol in Rust."
|
||||
license = "MIT"
|
||||
authors = ["Boog900"]
|
||||
|
|
|
@ -23,9 +23,9 @@ use tokio_util::codec::{Decoder, Encoder};
|
|||
use cuprate_helper::cast::u64_to_usize;
|
||||
|
||||
use crate::{
|
||||
header::{Flags, HEADER_SIZE},
|
||||
message::{make_dummy_message, LevinMessage},
|
||||
Bucket, BucketBuilder, BucketError, BucketHead, LevinBody, LevinCommand, MessageType, Protocol,
|
||||
header::{Flags, HEADER_SIZE},
|
||||
message::{LevinMessage, make_dummy_message},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
|
@ -159,7 +159,7 @@ impl MessageType {
|
|||
_ => {
|
||||
return Err(BucketError::InvalidHeaderFlags(
|
||||
"Unable to assign a message type to this bucket",
|
||||
))
|
||||
));
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ use bytes::{Bytes, BytesMut};
|
|||
use cuprate_helper::cast::usize_to_u64;
|
||||
|
||||
use crate::{
|
||||
header::{Flags, HEADER_SIZE},
|
||||
Bucket, BucketBuilder, BucketError, BucketHead, LevinBody, LevinCommand, Protocol,
|
||||
header::{Flags, HEADER_SIZE},
|
||||
};
|
||||
|
||||
/// A levin message that can be sent to a peer.
|
||||
|
|
|
@ -10,15 +10,15 @@ use proptest::{prelude::any_with, prop_assert_eq, proptest, sample::size_range};
|
|||
use rand::Fill;
|
||||
use tokio::{
|
||||
io::duplex,
|
||||
time::{timeout, Duration},
|
||||
time::{Duration, timeout},
|
||||
};
|
||||
use tokio_util::codec::{FramedRead, FramedWrite};
|
||||
|
||||
use cuprate_helper::cast::u64_to_usize;
|
||||
|
||||
use cuprate_levin::{
|
||||
message::make_fragmented_messages, BucketBuilder, BucketError, LevinBody, LevinCommand,
|
||||
LevinMessageCodec, MessageType, Protocol,
|
||||
BucketBuilder, BucketError, LevinBody, LevinCommand, LevinMessageCodec, MessageType, Protocol,
|
||||
message::make_fragmented_messages,
|
||||
};
|
||||
|
||||
/// A timeout put on streams so tests don't stall.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "cuprate-wire"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
authors = ["Boog900"]
|
||||
repository = "https://github.com/SyntheticBird45/cuprate/tree/main/net/monero-wire"
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
|
|||
use bytes::Buf;
|
||||
use thiserror::Error;
|
||||
|
||||
use cuprate_epee_encoding::{epee_object, EpeeObjectBuilder};
|
||||
use cuprate_epee_encoding::{EpeeObjectBuilder, epee_object};
|
||||
|
||||
use crate::NetworkAddress;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "cuprate-address-book"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
authors = ["Boog900"]
|
||||
|
||||
|
|
|
@ -9,27 +9,27 @@ use std::{
|
|||
};
|
||||
|
||||
use futures::{
|
||||
future::{ready, Ready},
|
||||
FutureExt,
|
||||
future::{Ready, ready},
|
||||
};
|
||||
use tokio::{
|
||||
task::JoinHandle,
|
||||
time::{interval, Instant, Interval, MissedTickBehavior},
|
||||
time::{Instant, Interval, MissedTickBehavior, interval},
|
||||
};
|
||||
use tokio_util::time::DelayQueue;
|
||||
use tower::Service;
|
||||
|
||||
use cuprate_p2p_core::{
|
||||
NetZoneAddress, NetworkZone,
|
||||
client::InternalPeerID,
|
||||
handles::ConnectionHandle,
|
||||
services::{AddressBookRequest, AddressBookResponse, ZoneSpecificPeerListEntryBase},
|
||||
NetZoneAddress, NetworkZone,
|
||||
};
|
||||
use cuprate_pruning::PruningSeed;
|
||||
|
||||
use crate::{
|
||||
peer_list::PeerList, store::save_peers_to_disk, AddressBookConfig, AddressBookError,
|
||||
BorshNetworkZone,
|
||||
AddressBookConfig, AddressBookError, BorshNetworkZone, peer_list::PeerList,
|
||||
store::save_peers_to_disk,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -7,7 +7,7 @@ use cuprate_p2p_core::handles::HandleBuilder;
|
|||
use cuprate_pruning::PruningSeed;
|
||||
|
||||
use super::{AddressBook, ConnectionPeerEntry, InternalPeerID};
|
||||
use crate::{peer_list::tests::make_fake_peer_list, AddressBookConfig, AddressBookError};
|
||||
use crate::{AddressBookConfig, AddressBookError, peer_list::tests::make_fake_peer_list};
|
||||
|
||||
use cuprate_test_utils::test_netzone::{TestNetZone, TestNetZoneAddr};
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ use indexmap::IndexMap;
|
|||
use rand::prelude::*;
|
||||
|
||||
use cuprate_constants::block::MAX_BLOCK_HEIGHT_USIZE;
|
||||
use cuprate_p2p_core::{services::ZoneSpecificPeerListEntryBase, NetZoneAddress, NetworkZone};
|
||||
use cuprate_p2p_core::{NetZoneAddress, NetworkZone, services::ZoneSpecificPeerListEntryBase};
|
||||
use cuprate_pruning::PruningSeed;
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::collections::HashSet;
|
|||
|
||||
use rand::Rng;
|
||||
|
||||
use cuprate_p2p_core::{services::ZoneSpecificPeerListEntryBase, NetZoneAddress};
|
||||
use cuprate_p2p_core::{NetZoneAddress, services::ZoneSpecificPeerListEntryBase};
|
||||
use cuprate_pruning::PruningSeed;
|
||||
use cuprate_test_utils::test_netzone::{TestNetZone, TestNetZoneAddr};
|
||||
|
||||
|
@ -155,10 +155,11 @@ fn peer_list_get_peer_with_block() {
|
|||
.take_random_peer(&mut r, Some(1), &HashSet::new())
|
||||
.expect("We just added a peer with the correct seed");
|
||||
|
||||
assert!(peer
|
||||
.pruning_seed
|
||||
.get_next_unpruned_block(1, 1_000_000)
|
||||
.is_ok());
|
||||
assert!(
|
||||
peer.pruning_seed
|
||||
.get_next_unpruned_block(1, 1_000_000)
|
||||
.is_ok()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
|
||||
use std::fs;
|
||||
|
||||
use borsh::{from_slice, to_vec, BorshDeserialize, BorshSerialize};
|
||||
use tokio::task::{spawn_blocking, JoinHandle};
|
||||
use borsh::{BorshDeserialize, BorshSerialize, from_slice, to_vec};
|
||||
use tokio::task::{JoinHandle, spawn_blocking};
|
||||
|
||||
use cuprate_p2p_core::{services::ZoneSpecificPeerListEntryBase, NetZoneAddress};
|
||||
use cuprate_p2p_core::{NetZoneAddress, services::ZoneSpecificPeerListEntryBase};
|
||||
|
||||
use crate::{peer_list::PeerList, AddressBookConfig, BorshNetworkZone};
|
||||
use crate::{AddressBookConfig, BorshNetworkZone, peer_list::PeerList};
|
||||
|
||||
// TODO: store anchor and ban list.
|
||||
|
||||
|
@ -70,7 +70,7 @@ pub(crate) async fn read_peers_from_disk<Z: BorshNetworkZone>(
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::peer_list::{tests::make_fake_peer_list, PeerList};
|
||||
use crate::peer_list::{PeerList, tests::make_fake_peer_list};
|
||||
|
||||
use cuprate_test_utils::test_netzone::{TestNetZone, TestNetZoneAddr};
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "cuprate-async-buffer"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
authors = ["Boog900"]
|
||||
|
||||
|
|
|
@ -9,17 +9,17 @@ use std::{
|
|||
future::Future,
|
||||
pin::Pin,
|
||||
sync::{
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
Arc,
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
},
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
use futures::{
|
||||
channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender},
|
||||
Stream, StreamExt,
|
||||
channel::mpsc::{UnboundedReceiver, UnboundedSender, unbounded},
|
||||
ready,
|
||||
task::AtomicWaker,
|
||||
Stream, StreamExt,
|
||||
};
|
||||
|
||||
#[derive(thiserror::Error, Debug, Copy, Clone, Eq, PartialEq)]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "cuprate-p2p-bucket"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
authors = ["SyntheticBird"]
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "cuprate-dandelion-tower"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
authors = ["Boog900"]
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@ use tokio_util::time::DelayQueue;
|
|||
use tower::{Service, ServiceExt};
|
||||
|
||||
use crate::{
|
||||
DandelionConfig, DandelionRouteReq, DandelionRouterError, State, TxState,
|
||||
pool::IncomingTx,
|
||||
traits::{TxStoreRequest, TxStoreResponse},
|
||||
DandelionConfig, DandelionRouteReq, DandelionRouterError, State, TxState,
|
||||
};
|
||||
|
||||
#[derive(Copy, Clone, Debug, thiserror::Error)]
|
||||
|
|
|
@ -26,7 +26,7 @@ use std::{
|
|||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
use futures::{future::BoxFuture, FutureExt};
|
||||
use futures::{FutureExt, future::BoxFuture};
|
||||
use rand_distr::Exp;
|
||||
use tokio::{
|
||||
sync::{mpsc, oneshot},
|
||||
|
@ -37,9 +37,9 @@ use tower::Service;
|
|||
use tracing::Instrument;
|
||||
|
||||
use crate::{
|
||||
DandelionConfig, DandelionRouteReq, DandelionRouterError, State,
|
||||
pool::manager::DandelionPoolShutDown,
|
||||
traits::{TxStoreRequest, TxStoreResponse},
|
||||
DandelionConfig, DandelionRouteReq, DandelionRouterError, State,
|
||||
};
|
||||
|
||||
mod incoming_tx;
|
||||
|
|
|
@ -12,17 +12,17 @@ use std::{
|
|||
hash::Hash,
|
||||
marker::PhantomData,
|
||||
pin::Pin,
|
||||
task::{ready, Context, Poll},
|
||||
task::{Context, Poll, ready},
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
use futures::{future::BoxFuture, FutureExt, TryFutureExt, TryStream};
|
||||
use futures::{FutureExt, TryFutureExt, TryStream, future::BoxFuture};
|
||||
use rand::{distributions::Bernoulli, prelude::*, thread_rng};
|
||||
use tower::Service;
|
||||
|
||||
use crate::{
|
||||
traits::{DiffuseRequest, StemRequest},
|
||||
DandelionConfig,
|
||||
traits::{DiffuseRequest, StemRequest},
|
||||
};
|
||||
|
||||
/// An error returned from the [`DandelionRouter`]
|
||||
|
@ -176,18 +176,21 @@ where
|
|||
};
|
||||
|
||||
while self.stem_peers.len() < peers_needed {
|
||||
match ready!(self
|
||||
.outbound_peer_discover
|
||||
.as_mut()
|
||||
.try_poll_next(cx)
|
||||
.map_err(DandelionRouterError::OutboundPeerStreamError))
|
||||
match ready!(
|
||||
self.outbound_peer_discover
|
||||
.as_mut()
|
||||
.try_poll_next(cx)
|
||||
.map_err(DandelionRouterError::OutboundPeerStreamError)
|
||||
)
|
||||
.ok_or(DandelionRouterError::OutboundPeerDiscoverExited)??
|
||||
{
|
||||
OutboundPeer::Peer(key, svc) => {
|
||||
self.stem_peers.insert(key, svc);
|
||||
}
|
||||
OutboundPeer::Exhausted => {
|
||||
tracing::warn!("Failed to retrieve enough outbound peers for optimal dandelion++, privacy may be degraded.");
|
||||
tracing::warn!(
|
||||
"Failed to retrieve enough outbound peers for optimal dandelion++, privacy may be degraded."
|
||||
);
|
||||
return Poll::Ready(Ok(()));
|
||||
}
|
||||
}
|
||||
|
@ -239,7 +242,9 @@ where
|
|||
|
||||
fn stem_local_tx(&mut self, tx: Tx) -> BoxFuture<'static, Result<State, DandelionRouterError>> {
|
||||
if self.stem_peers.is_empty() {
|
||||
tracing::warn!("Stem peers are empty, no outbound connections to stem local tx to, fluffing instead, privacy will be degraded.");
|
||||
tracing::warn!(
|
||||
"Stem peers are empty, no outbound connections to stem local tx to, fluffing instead, privacy will be degraded."
|
||||
);
|
||||
return self.fluff_tx(tx);
|
||||
}
|
||||
|
||||
|
@ -328,10 +333,11 @@ where
|
|||
// now we have removed the failed peers check if we still have enough for the graph chosen.
|
||||
ready!(self.poll_prepare_graph(cx)?);
|
||||
|
||||
ready!(self
|
||||
.broadcast_svc
|
||||
.poll_ready(cx)
|
||||
.map_err(DandelionRouterError::BroadcastError)?);
|
||||
ready!(
|
||||
self.broadcast_svc
|
||||
.poll_ready(cx)
|
||||
.map_err(DandelionRouterError::BroadcastError)?
|
||||
);
|
||||
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@ use std::{collections::HashMap, future::Future, hash::Hash, sync::Arc};
|
|||
|
||||
use futures::{Stream, StreamExt, TryStreamExt};
|
||||
use tokio::sync::mpsc::{self, UnboundedReceiver};
|
||||
use tower::{util::service_fn, Service, ServiceExt};
|
||||
use tower::{Service, ServiceExt, util::service_fn};
|
||||
|
||||
use crate::{
|
||||
traits::{TxStoreRequest, TxStoreResponse},
|
||||
OutboundPeer, State,
|
||||
traits::{TxStoreRequest, TxStoreResponse},
|
||||
};
|
||||
|
||||
#[expect(clippy::type_complexity)]
|
||||
|
@ -19,11 +19,11 @@ pub(crate) fn mock_discover_svc<Req: Send + 'static>() -> (
|
|||
OutboundPeer<
|
||||
usize,
|
||||
impl Service<
|
||||
Req,
|
||||
Future = impl Future<Output = Result<(), tower::BoxError>> + Send + 'static,
|
||||
Error = tower::BoxError,
|
||||
> + Send
|
||||
+ 'static,
|
||||
Req,
|
||||
Future = impl Future<Output = Result<(), tower::BoxError>> + Send + 'static,
|
||||
Error = tower::BoxError,
|
||||
> + Send
|
||||
+ 'static,
|
||||
>,
|
||||
tower::BoxError,
|
||||
>,
|
||||
|
@ -52,11 +52,11 @@ pub(crate) fn mock_discover_svc<Req: Send + 'static>() -> (
|
|||
|
||||
pub(crate) fn mock_broadcast_svc<Req: Send + 'static>() -> (
|
||||
impl Service<
|
||||
Req,
|
||||
Future = impl Future<Output = Result<(), tower::BoxError>> + Send + 'static,
|
||||
Error = tower::BoxError,
|
||||
> + Send
|
||||
+ 'static,
|
||||
Req,
|
||||
Future = impl Future<Output = Result<(), tower::BoxError>> + Send + 'static,
|
||||
Error = tower::BoxError,
|
||||
> + Send
|
||||
+ 'static,
|
||||
UnboundedReceiver<Req>,
|
||||
) {
|
||||
let (tx, rx) = mpsc::unbounded_channel();
|
||||
|
@ -77,12 +77,12 @@ pub(crate) fn mock_in_memory_backing_pool<
|
|||
TxID: Clone + Hash + Eq + Send + 'static,
|
||||
>() -> (
|
||||
impl Service<
|
||||
TxStoreRequest<TxID>,
|
||||
Response = TxStoreResponse<Tx>,
|
||||
Future = impl Future<Output = Result<TxStoreResponse<Tx>, tower::BoxError>> + Send + 'static,
|
||||
Error = tower::BoxError,
|
||||
> + Send
|
||||
+ 'static,
|
||||
TxStoreRequest<TxID>,
|
||||
Response = TxStoreResponse<Tx>,
|
||||
Future = impl Future<Output = Result<TxStoreResponse<Tx>, tower::BoxError>> + Send + 'static,
|
||||
Error = tower::BoxError,
|
||||
> + Send
|
||||
+ 'static,
|
||||
Arc<std::sync::Mutex<HashMap<TxID, (Tx, State)>>>,
|
||||
) {
|
||||
let txs = Arc::new(std::sync::Mutex::new(HashMap::new()));
|
||||
|
|
|
@ -2,8 +2,8 @@ use std::time::Duration;
|
|||
|
||||
use super::*;
|
||||
use crate::{
|
||||
pool::{start_dandelion_pool_manager, IncomingTx},
|
||||
DandelionConfig, DandelionRouter, Graph, TxState,
|
||||
pool::{IncomingTx, start_dandelion_pool_manager},
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "cuprate-p2p-core"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
authors = ["Boog900"]
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use std::{
|
||||
fmt::{Debug, Display, Formatter},
|
||||
sync::{Arc, Mutex},
|
||||
task::{ready, Context, Poll},
|
||||
task::{Context, Poll, ready},
|
||||
};
|
||||
|
||||
use futures::channel::oneshot;
|
||||
use tokio::{
|
||||
sync::{mpsc, OwnedSemaphorePermit, Semaphore},
|
||||
sync::{OwnedSemaphorePermit, Semaphore, mpsc},
|
||||
task::JoinHandle,
|
||||
};
|
||||
use tokio_util::sync::{PollSemaphore, PollSender};
|
||||
|
@ -18,8 +18,8 @@ use cuprate_pruning::PruningSeed;
|
|||
use cuprate_wire::CoreSyncData;
|
||||
|
||||
use crate::{
|
||||
handles::{ConnectionGuard, ConnectionHandle},
|
||||
ConnectionDirection, NetworkZone, PeerError, PeerRequest, PeerResponse, SharedError,
|
||||
handles::{ConnectionGuard, ConnectionHandle},
|
||||
};
|
||||
|
||||
mod connection;
|
||||
|
|
|
@ -5,24 +5,24 @@
|
|||
use std::pin::Pin;
|
||||
|
||||
use futures::{
|
||||
SinkExt, Stream, StreamExt,
|
||||
channel::oneshot,
|
||||
stream::{Fuse, FusedStream},
|
||||
SinkExt, Stream, StreamExt,
|
||||
};
|
||||
use tokio::{
|
||||
sync::{mpsc, OwnedSemaphorePermit},
|
||||
time::{sleep, timeout, Sleep},
|
||||
sync::{OwnedSemaphorePermit, mpsc},
|
||||
time::{Sleep, sleep, timeout},
|
||||
};
|
||||
use tokio_stream::wrappers::ReceiverStream;
|
||||
|
||||
use cuprate_wire::{LevinCommand, Message, ProtocolMessage};
|
||||
|
||||
use crate::{
|
||||
AddressBook, BroadcastMessage, CoreSyncSvc, MessageID, NetworkZone, PeerError, PeerRequest,
|
||||
PeerResponse, ProtocolRequestHandler, ProtocolResponse, SharedError,
|
||||
client::request_handler::PeerRequestHandler,
|
||||
constants::{REQUEST_HANDLER_TIMEOUT, REQUEST_TIMEOUT, SENDING_TIMEOUT},
|
||||
handles::ConnectionGuard,
|
||||
AddressBook, BroadcastMessage, CoreSyncSvc, MessageID, NetworkZone, PeerError, PeerRequest,
|
||||
PeerResponse, ProtocolRequestHandler, ProtocolResponse, SharedError,
|
||||
};
|
||||
|
||||
/// A request to the connection task from a [`Client`](crate::client::Client).
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue