From ed598e374e868efe82c3809b589fb141ad44858d Mon Sep 17 00:00:00 2001
From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
Date: Mon, 22 Jan 2024 01:56:34 +0000
Subject: [PATCH] remove empty cuprate bin and `common`
---
Cargo.lock | 67 +++---
Cargo.toml | 8 +-
common/Cargo.toml | 19 --
common/LICENSE | 14 --
common/src/hardforks.rs | 250 --------------------
common/src/lib.rs | 37 ---
common/src/tower_utils.rs | 28 ---
consensus/Cargo.toml | 2 +-
consensus/rules/Cargo.toml | 2 +-
consensus/rules/src/genesis.rs | 6 +-
consensus/src/bin/scan_chain.rs | 2 +-
consensus/src/bin/tx_pool.rs | 2 +-
consensus/src/context/difficulty.rs | 6 +-
consensus/src/context/hardforks.rs | 4 +-
consensus/src/context/weight.rs | 6 +-
consensus/src/helper.rs | 44 ----
consensus/src/lib.rs | 4 +-
consensus/src/rpc.rs | 4 +-
consensus/src/rpc/connection.rs | 41 +---
consensus/src/tests/context.rs | 11 +-
consensus/src/tests/context/difficulty.rs | 4 +-
consensus/src/tests/context/weight.rs | 2 +-
consensus/src/tests/mock_db.rs | 4 +-
consensus/src/transactions.rs | 5 +-
cuprate/Cargo.toml | 21 --
cuprate/README.md | 9 -
cuprate/src/application.rs | 88 -------
cuprate/src/bin/cuprate/main.rs | 11 -
cuprate/src/commands.rs | 87 -------
cuprate/src/commands/start.rs | 42 ----
cuprate/src/config.rs | 45 ----
cuprate/src/error.rs | 70 ------
cuprate/src/lib.rs | 22 --
cuprate/src/prelude.rs | 9 -
cuprate/tests/acceptance.rs | 91 -------
helper/Cargo.toml | 7 +-
helper/src/lib.rs | 1 +
{common => helper}/src/network.rs | 13 +
helper/src/num.rs | 10 +-
net/monero-wire/Cargo.toml | 10 +-
p2p/address-book/Cargo.toml | 6 +-
p2p/address-book/src/book.rs | 2 +-
p2p/address-book/src/book/tests.rs | 2 +-
p2p/address-book/src/peer_list.rs | 2 +-
p2p/address-book/src/peer_list/tests.rs | 2 +-
p2p/monero-p2p/Cargo.toml | 7 +-
p2p/monero-p2p/src/client.rs | 2 +-
p2p/monero-p2p/src/services.rs | 2 +-
p2p/monero-p2p/tests/handshake.rs | 2 +-
pruning/Cargo.toml | 13 +
common/src/pruning.rs => pruning/src/lib.rs | 21 +-
51 files changed, 142 insertions(+), 1027 deletions(-)
delete mode 100644 common/Cargo.toml
delete mode 100644 common/LICENSE
delete mode 100644 common/src/hardforks.rs
delete mode 100644 common/src/lib.rs
delete mode 100644 common/src/tower_utils.rs
delete mode 100644 consensus/src/helper.rs
delete mode 100644 cuprate/Cargo.toml
delete mode 100644 cuprate/README.md
delete mode 100644 cuprate/src/application.rs
delete mode 100644 cuprate/src/bin/cuprate/main.rs
delete mode 100644 cuprate/src/commands.rs
delete mode 100644 cuprate/src/commands/start.rs
delete mode 100644 cuprate/src/config.rs
delete mode 100644 cuprate/src/error.rs
delete mode 100644 cuprate/src/lib.rs
delete mode 100644 cuprate/src/prelude.rs
delete mode 100644 cuprate/tests/acceptance.rs
rename {common => helper}/src/network.rs (63%)
create mode 100644 pruning/Cargo.toml
rename common/src/pruning.rs => pruning/src/lib.rs (96%)
diff --git a/Cargo.lock b/Cargo.lock
index b73592f9..d79b9eb1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -428,31 +428,20 @@ dependencies = [
"thiserror",
]
-[[package]]
-name = "cuprate-common"
-version = "0.1.0"
-dependencies = [
- "borsh",
- "chrono",
- "futures",
- "hex",
- "thiserror",
-]
-
[[package]]
name = "cuprate-consensus"
version = "0.1.0"
dependencies = [
"borsh",
"clap",
- "cuprate-common",
+ "cuprate-helper",
"curve25519-dalek",
"dalek-ff-group",
"dirs",
"futures",
"hex",
"monero-consensus",
- "monero-epee-bin-serde 1.0.1 (git+https://github.com/monero-rs/monero-epee-bin-serde.git?rev=e4a585a)",
+ "monero-epee-bin-serde",
"monero-serai",
"monero-wire",
"multiexp",
@@ -472,6 +461,18 @@ dependencies = [
"tracing-subscriber",
]
+[[package]]
+name = "cuprate-helper"
+version = "0.1.0"
+dependencies = [
+ "chrono",
+ "futures",
+ "libc",
+ "rayon",
+ "tokio",
+ "windows",
+]
+
[[package]]
name = "cuprate-test-utils"
version = "0.1.0"
@@ -816,18 +817,6 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
-[[package]]
-name = "helper"
-version = "0.1.0"
-dependencies = [
- "chrono",
- "futures",
- "libc",
- "rayon",
- "tokio",
- "windows",
-]
-
[[package]]
name = "hermit-abi"
version = "0.3.4"
@@ -1098,10 +1087,10 @@ version = "0.1.0"
dependencies = [
"async-trait",
"borsh",
- "cuprate-common",
"cuprate-test-utils",
"futures",
"monero-p2p",
+ "monero-pruning",
"monero-wire",
"pin-project",
"rand",
@@ -1117,7 +1106,7 @@ version = "0.1.0"
dependencies = [
"crypto-bigint",
"cryptonight-cuprate",
- "cuprate-common",
+ "cuprate-helper",
"curve25519-dalek",
"dalek-ff-group",
"hex",
@@ -1136,22 +1125,13 @@ dependencies = [
[[package]]
name = "monero-epee-bin-serde"
version = "1.0.1"
-source = "git+https://github.com/monero-rs/monero-epee-bin-serde.git?rev=aafe4ba#aafe4ba1b9912b03cf616db7403628fc2bd82eb1"
+source = "git+https://github.com/monero-rs/monero-epee-bin-serde.git?rev=fae7a23#fae7a23f8e57f19553c341c0878b4f0fa5a6994d"
dependencies = [
"byteorder",
"serde",
"serde_bytes",
]
-[[package]]
-name = "monero-epee-bin-serde"
-version = "1.0.1"
-source = "git+https://github.com/monero-rs/monero-epee-bin-serde.git?rev=e4a585a#e4a585a9deda5f888ebca766d5e61a2bb987147c"
-dependencies = [
- "byteorder",
- "serde",
-]
-
[[package]]
name = "monero-generators"
version = "0.4.0"
@@ -1171,10 +1151,11 @@ version = "0.1.0"
dependencies = [
"async-trait",
"borsh",
- "cuprate-common",
+ "cuprate-helper",
"cuprate-test-utils",
"futures",
"hex",
+ "monero-pruning",
"monero-wire",
"thiserror",
"tokio",
@@ -1185,6 +1166,14 @@ dependencies = [
"tracing-subscriber",
]
+[[package]]
+name = "monero-pruning"
+version = "0.1.0"
+dependencies = [
+ "borsh",
+ "thiserror",
+]
+
[[package]]
name = "monero-serai"
version = "0.1.4-alpha"
@@ -1225,7 +1214,7 @@ version = "0.1.0"
dependencies = [
"hex",
"levin-cuprate",
- "monero-epee-bin-serde 1.0.1 (git+https://github.com/monero-rs/monero-epee-bin-serde.git?rev=aafe4ba)",
+ "monero-epee-bin-serde",
"serde",
"serde_bytes",
"thiserror",
diff --git a/Cargo.toml b/Cargo.toml
index 84492c9d..b56473ad 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,18 +2,16 @@
resolver = "2"
members = [
- "common",
"consensus",
"consensus/rules",
"cryptonight",
- # "cuprate",
- # "database",
"helper",
"net/levin",
"net/monero-wire",
"p2p/monero-p2p",
"p2p/address-book",
- "test-utils"
+ "pruning",
+ "test-utils",
]
[profile.release]
@@ -47,7 +45,7 @@ dirs = { version = "5.0.1", default-features = false }
futures = { version = "0.3.29", default-features = false }
hex = { version = "0.4.3", default-features = false }
hex-literal = { version = "0.4", default-features = false }
-monero-epee-bin-serde = { git = "https://github.com/monero-rs/monero-epee-bin-serde.git", rev = "e4a585a", default-features = false }
+monero-epee-bin-serde = { git = "https://github.com/monero-rs/monero-epee-bin-serde.git", rev = "fae7a23", default-features = false }
monero-serai = { git = "https://github.com/Cuprate/serai.git", rev = "a59966b", default-features = false }
multiexp = { git = "https://github.com/Cuprate/serai.git", rev = "a59966b", default-features = false }
pin-project = { version = "1.1.3", default-features = false }
diff --git a/common/Cargo.toml b/common/Cargo.toml
deleted file mode 100644
index d20d73a7..00000000
--- a/common/Cargo.toml
+++ /dev/null
@@ -1,19 +0,0 @@
-[package]
-name = "cuprate-common"
-version = "0.1.0"
-edition = "2021"
-license = "AGPL-3.0-only"
-authors = ["Boog900"]
-
-[features]
-default = []
-borsh = ["dep:borsh"]
-
-[dependencies]
-chrono = { workspace = true }
-thiserror = { workspace = true }
-hex = { workspace = true, features = ["std"] }
-
-futures = { workspace = true, features = ["std"] }
-
-borsh = { workspace = true, features = ["derive", "std"], optional = true }
\ No newline at end of file
diff --git a/common/LICENSE b/common/LICENSE
deleted file mode 100644
index e19903e6..00000000
--- a/common/LICENSE
+++ /dev/null
@@ -1,14 +0,0 @@
- Copyright (C) 2023 Cuprate Contributors
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
\ No newline at end of file
diff --git a/common/src/hardforks.rs b/common/src/hardforks.rs
deleted file mode 100644
index ca014cb8..00000000
--- a/common/src/hardforks.rs
+++ /dev/null
@@ -1,250 +0,0 @@
-use chrono::NaiveDateTime;
-
-use crate::network::Network;
-
-// this function blindly unwraps
-// SAFETY: only call when you know the timestamp is good
-fn time_from_timestamp(stamp: i64) -> NaiveDateTime {
- NaiveDateTime::from_timestamp_opt(stamp, 0).unwrap()
-}
-
-fn get_hard_forks(network: Network) -> [(u8, u64, NaiveDateTime); 16] {
- match network {
- Network::MainNet => {
- [
- // | version | Height | TimeStamp | *timestamp is when fork height was decided
- (1, 1, time_from_timestamp(1341378000)),
- (2, 1009827, time_from_timestamp(1442763710)),
- (3, 1141317, time_from_timestamp(1458558528)),
- (4, 1220516, time_from_timestamp(1483574400)),
- (5, 1288616, time_from_timestamp(1489520158)),
- (6, 1400000, time_from_timestamp(1503046577)),
- (7, 1546000, time_from_timestamp(1521303150)),
- (8, 1685555, time_from_timestamp(1535889547)),
- (9, 1686275, time_from_timestamp(1535889548)),
- (10, 1788000, time_from_timestamp(1549792439)),
- (11, 1788720, time_from_timestamp(1550225678)),
- (12, 1978433, time_from_timestamp(1571419280)),
- (13, 2210000, time_from_timestamp(1598180817)),
- (14, 2210720, time_from_timestamp(1598180818)),
- (15, 2688888, time_from_timestamp(1656629117)),
- (16, 2689608, time_from_timestamp(1656629118)),
- ]
- }
- Network::TestNet => [
- (1, 1, time_from_timestamp(1341378000)),
- (2, 624634, time_from_timestamp(1445355000)),
- (3, 800500, time_from_timestamp(1472415034)),
- (4, 801219, time_from_timestamp(1472415035)),
- (5, 802660, time_from_timestamp(1472415036 + 86400 * 180)),
- (6, 971400, time_from_timestamp(1501709789)),
- (7, 1057027, time_from_timestamp(1512211236)),
- (8, 1057058, time_from_timestamp(1533211200)),
- (9, 1057778, time_from_timestamp(1533297600)),
- (10, 1154318, time_from_timestamp(1550153694)),
- (11, 1155038, time_from_timestamp(1550225678)),
- (12, 1308737, time_from_timestamp(1569582000)),
- (13, 1543939, time_from_timestamp(1599069376)),
- (14, 1544659, time_from_timestamp(1599069377)),
- (15, 1982800, time_from_timestamp(1652727000)),
- (16, 1983520, time_from_timestamp(1652813400)),
- ],
- Network::StageNet => [
- (1, 1, time_from_timestamp(1341378000)),
- (2, 32000, time_from_timestamp(1521000000)),
- (3, 33000, time_from_timestamp(1521120000)),
- (4, 34000, time_from_timestamp(1521240000)),
- (5, 35000, time_from_timestamp(1521360000)),
- (6, 36000, time_from_timestamp(1521480000)),
- (7, 37000, time_from_timestamp(1521600000)),
- (8, 176456, time_from_timestamp(1537821770)),
- (9, 177176, time_from_timestamp(1537821771)),
- (10, 269000, time_from_timestamp(1550153694)),
- (11, 269720, time_from_timestamp(1550225678)),
- (12, 454721, time_from_timestamp(1571419280)),
- (13, 675405, time_from_timestamp(1598180817)),
- (14, 676125, time_from_timestamp(1598180818)),
- (15, 1151000, time_from_timestamp(1656629117)),
- (16, 1151720, time_from_timestamp(1656629118)),
- ],
- }
-}
-
-pub struct HardForks {
- hard_forks: [(u8, u64, NaiveDateTime); 16],
-}
-
-impl HardForks {
- pub fn new(network: Network) -> Self {
- HardForks {
- hard_forks: get_hard_forks(network),
- }
- }
-
- pub fn get_ideal_version_from_height(&self, height: u64) -> u8 {
- for hf in self.hard_forks.iter().rev() {
- if height >= hf.1 {
- return hf.0;
- }
- }
- 0
- }
-
- pub fn get_earliest_ideal_height_for_version(&self, version: u8) -> Option {
- if self.hard_forks.len() < version as usize {
- None
- } else if version == 0 {
- Some(0)
- } else {
- Some(self.hard_forks[(version - 1) as usize].1)
- }
- }
-
- pub fn get_ideal_version(&self) -> u8 {
- self.hard_forks.last().expect("This is not empty").0
- }
-}
-
-#[cfg(test)]
-mod tests {
- use crate::network::Network;
-
- use super::HardForks;
-
- const MAIN_NET_FORKS: [u64; 16] = [
- 1, 1009827, 1141317, 1220516, 1288616, 1400000, 1546000, 1685555, 1686275, 1788000,
- 1788720, 1978433, 2210000, 2210720, 2688888, 2689608,
- ];
- const TEST_NET_FORKS: [u64; 16] = [
- 1, 624634, 800500, 801219, 802660, 971400, 1057027, 1057058, 1057778, 1154318, 1155038,
- 1308737, 1543939, 1544659, 1982800, 1983520,
- ];
- const STAGE_NET_FORKS: [u64; 16] = [
- 1, 32000, 33000, 34000, 35000, 36000, 37000, 176456, 177176, 269000, 269720, 454721,
- 675405, 676125, 1151000, 1151720,
- ];
-
- #[test]
- fn get_ideal_version() {
- let hardforks = HardForks::new(Network::MainNet);
-
- let version = hardforks.get_ideal_version();
- assert_eq!(version as usize, MAIN_NET_FORKS.len());
- assert_eq!(version as usize, TEST_NET_FORKS.len());
- assert_eq!(version as usize, STAGE_NET_FORKS.len());
-
- let height = hardforks
- .get_earliest_ideal_height_for_version(version)
- .unwrap();
- let got_version = hardforks.get_ideal_version_from_height(height);
- assert_eq!(version, got_version);
- }
-
- #[test]
- fn get_earliest_ideal_height_for_version_mainnet() {
- let hardforks = HardForks::new(Network::MainNet);
-
- for (height, version) in MAIN_NET_FORKS.iter().zip(1..MAIN_NET_FORKS.len() as u8) {
- assert_eq!(
- hardforks
- .get_earliest_ideal_height_for_version(version)
- .unwrap(),
- *height
- );
- assert_eq!(
- hardforks
- .get_earliest_ideal_height_for_version(version)
- .unwrap(),
- *height
- );
- }
- assert!(hardforks
- .get_earliest_ideal_height_for_version(MAIN_NET_FORKS.len() as u8 + 1)
- .is_none())
- }
-
- #[test]
- fn get_earliest_ideal_height_for_version_testnet() {
- let hardforks = HardForks::new(Network::TestNet);
-
- for (height, version) in TEST_NET_FORKS.iter().zip(1..TEST_NET_FORKS.len() as u8) {
- assert_eq!(
- hardforks
- .get_earliest_ideal_height_for_version(version)
- .unwrap(),
- *height
- );
- assert_eq!(
- hardforks
- .get_earliest_ideal_height_for_version(version)
- .unwrap(),
- *height
- );
- }
- assert!(hardforks
- .get_earliest_ideal_height_for_version(TEST_NET_FORKS.len() as u8 + 1)
- .is_none())
- }
-
- #[test]
- fn get_earliest_ideal_height_for_version_stagenet() {
- let hardforks = HardForks::new(Network::StageNet);
-
- for (height, version) in STAGE_NET_FORKS.iter().zip(1..STAGE_NET_FORKS.len() as u8) {
- assert_eq!(
- hardforks
- .get_earliest_ideal_height_for_version(version)
- .unwrap(),
- *height
- );
- assert_eq!(
- hardforks
- .get_earliest_ideal_height_for_version(version)
- .unwrap(),
- *height
- );
- }
- assert!(hardforks
- .get_earliest_ideal_height_for_version(STAGE_NET_FORKS.len() as u8 + 1)
- .is_none())
- }
-
- #[test]
- fn get_ideal_version_from_height_mainnet() {
- let hardforks = HardForks::new(Network::MainNet);
-
- for (height, version) in MAIN_NET_FORKS.iter().zip(1..MAIN_NET_FORKS.len() as u8) {
- assert_eq!(hardforks.get_ideal_version_from_height(*height), version);
- assert_eq!(
- hardforks.get_ideal_version_from_height(*height - 1),
- version - 1
- );
- }
- }
-
- #[test]
- fn get_ideal_version_from_height_testnet() {
- let hardforks = HardForks::new(Network::TestNet);
-
- for (height, version) in TEST_NET_FORKS.iter().zip(1..TEST_NET_FORKS.len() as u8) {
- assert_eq!(hardforks.get_ideal_version_from_height(*height), version);
- assert_eq!(
- hardforks.get_ideal_version_from_height(*height - 1),
- version - 1
- );
- }
- }
-
- #[test]
- fn get_ideal_version_from_height_stagenet() {
- let hardforks = HardForks::new(Network::StageNet);
-
- for (height, version) in STAGE_NET_FORKS.iter().zip(1..STAGE_NET_FORKS.len() as u8) {
- assert_eq!(hardforks.get_ideal_version_from_height(*height), version);
- assert_eq!(
- hardforks.get_ideal_version_from_height(*height - 1),
- version - 1
- );
- }
- }
-}
diff --git a/common/src/lib.rs b/common/src/lib.rs
deleted file mode 100644
index 79bdcfdf..00000000
--- a/common/src/lib.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-//pub mod hardforks;
-pub mod network;
-pub mod pruning;
-pub mod tower_utils;
-
-use std::fmt::Formatter;
-//pub use hardforks::HardForks;
-pub use network::Network;
-pub use pruning::{PruningError, PruningSeed};
-
-pub const CRYPTONOTE_MAX_BLOCK_NUMBER: u64 = 500000000;
-
-// pruning
-pub const CRYPTONOTE_PRUNING_LOG_STRIPES: u32 = 3;
-pub const CRYPTONOTE_PRUNING_STRIPE_SIZE: u64 = 4096;
-pub const CRYPTONOTE_PRUNING_TIP_BLOCKS: u64 = 5500;
-
-#[derive(Debug, Clone)]
-pub enum BlockID {
- Hash([u8; 32]),
- Height(u64),
-}
-
-impl std::fmt::Display for BlockID {
- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
- match self {
- BlockID::Hash(hash) => f.write_str(&format!("Hash: {}", hex::encode(hash))),
- BlockID::Height(height) => f.write_str(&format!("Height: {}", height)),
- }
- }
-}
-
-impl From for BlockID {
- fn from(value: u64) -> Self {
- BlockID::Height(value)
- }
-}
diff --git a/common/src/tower_utils.rs b/common/src/tower_utils.rs
deleted file mode 100644
index 6e512b0d..00000000
--- a/common/src/tower_utils.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-use std::{
- future::Future,
- pin::Pin,
- task::{Context, Poll},
-};
-
-use futures::channel::oneshot;
-use futures::FutureExt;
-
-/// A oneshot that doesn't return an Error. This requires the sender to always
-/// return a response.
-pub struct InfallibleOneshotReceiver(oneshot::Receiver);
-
-impl From> for InfallibleOneshotReceiver {
- fn from(value: oneshot::Receiver) -> Self {
- InfallibleOneshotReceiver(value)
- }
-}
-
-impl Future for InfallibleOneshotReceiver {
- type Output = T;
-
- fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll {
- self.0
- .poll_unpin(cx)
- .map(|res| res.expect("Oneshot must not be cancelled before response!"))
- }
-}
diff --git a/consensus/Cargo.toml b/consensus/Cargo.toml
index 64d74d65..30a13401 100644
--- a/consensus/Cargo.toml
+++ b/consensus/Cargo.toml
@@ -29,7 +29,7 @@ binaries = [
]
[dependencies]
-cuprate-common = {path = "../common"}
+cuprate-helper = { path = "../helper", default-features = false, features = ["std", "asynch", "num"] }
monero-consensus = {path = "./rules", features = ["rayon"]}
thiserror = { workspace = true }
diff --git a/consensus/rules/Cargo.toml b/consensus/rules/Cargo.toml
index 7a16341b..d553d516 100644
--- a/consensus/rules/Cargo.toml
+++ b/consensus/rules/Cargo.toml
@@ -9,8 +9,8 @@ proptest = ["dep:proptest", "dep:proptest-derive"]
rayon = ["dep:rayon"]
[dependencies]
+cuprate-helper = { path = "../../helper", default-features = false, features = ["std"] }
cryptonight-cuprate = {path = "../../cryptonight"}
-cuprate-common = {path = "../../common"}
monero-serai = { workspace = true, features = ["std"] }
multiexp = { workspace = true, features = ["std", "batch"] }
diff --git a/consensus/rules/src/genesis.rs b/consensus/rules/src/genesis.rs
index 73ba648a..aab99a7c 100644
--- a/consensus/rules/src/genesis.rs
+++ b/consensus/rules/src/genesis.rs
@@ -6,7 +6,7 @@ use monero_serai::{
transaction::Transaction,
};
-use cuprate_common::Network;
+use cuprate_helper::network::Network;
const fn genesis_nonce(network: &Network) -> u32 {
match network {
@@ -42,9 +42,7 @@ pub fn generate_genesis_block(network: &Network) -> Block {
#[cfg(test)]
mod tests {
- use cuprate_common::Network;
-
- use super::generate_genesis_block;
+ use super::*;
#[test]
fn generate_genesis_blocks() {
diff --git a/consensus/src/bin/scan_chain.rs b/consensus/src/bin/scan_chain.rs
index f8178771..d8665420 100644
--- a/consensus/src/bin/scan_chain.rs
+++ b/consensus/src/bin/scan_chain.rs
@@ -19,7 +19,7 @@ mod bin {
use tower::{Service, ServiceExt};
use tracing::level_filters::LevelFilter;
- use cuprate_common::Network;
+ use cuprate_helper::network::Network;
use cuprate_consensus::{
block::PrePreparedBlockExPOW,
diff --git a/consensus/src/bin/tx_pool.rs b/consensus/src/bin/tx_pool.rs
index c27c5cf8..dd596232 100644
--- a/consensus/src/bin/tx_pool.rs
+++ b/consensus/src/bin/tx_pool.rs
@@ -13,7 +13,7 @@ mod bin {
use monero_serai::transaction::Transaction;
use tower::{Service, ServiceExt};
- use cuprate_common::tower_utils::InfallibleOneshotReceiver;
+ use cuprate_helper::asynch::InfallibleOneshotReceiver;
use cuprate_consensus::{
context::{
diff --git a/consensus/src/context/difficulty.rs b/consensus/src/context/difficulty.rs
index b98f058a..055cd77b 100644
--- a/consensus/src/context/difficulty.rs
+++ b/consensus/src/context/difficulty.rs
@@ -3,9 +3,9 @@ use std::{collections::VecDeque, ops::Range};
use tower::ServiceExt;
use tracing::instrument;
-use crate::{
- helper::median, Database, DatabaseRequest, DatabaseResponse, ExtendedConsensusError, HardFork,
-};
+use cuprate_helper::num::median;
+
+use crate::{Database, DatabaseRequest, DatabaseResponse, ExtendedConsensusError, HardFork};
/// The amount of blocks we account for to calculate difficulty
const DIFFICULTY_WINDOW: usize = 720;
diff --git a/consensus/src/context/hardforks.rs b/consensus/src/context/hardforks.rs
index caf7c826..3f214ea8 100644
--- a/consensus/src/context/hardforks.rs
+++ b/consensus/src/context/hardforks.rs
@@ -79,9 +79,7 @@ impl HardForkState {
let DatabaseResponse::BlockExtendedHeader(ext_header) = database
.ready()
.await?
- .call(DatabaseRequest::BlockExtendedHeader(
- (chain_height - 1).into(),
- ))
+ .call(DatabaseRequest::BlockExtendedHeader(chain_height - 1))
.await?
else {
panic!("Database sent incorrect response!");
diff --git a/consensus/src/context/weight.rs b/consensus/src/context/weight.rs
index bc39ad4e..73da0b19 100644
--- a/consensus/src/context/weight.rs
+++ b/consensus/src/context/weight.rs
@@ -16,12 +16,10 @@ use rayon::prelude::*;
use tower::ServiceExt;
use tracing::instrument;
+use cuprate_helper::{asynch::rayon_spawn_async, num::median};
use monero_consensus::blocks::{penalty_free_zone, PENALTY_FREE_ZONE_5};
-use crate::{
- helper::{median, rayon_spawn_async},
- Database, DatabaseRequest, DatabaseResponse, ExtendedConsensusError, HardFork,
-};
+use crate::{Database, DatabaseRequest, DatabaseResponse, ExtendedConsensusError, HardFork};
const SHORT_TERM_WINDOW: u64 = 100;
const LONG_TERM_WINDOW: u64 = 100000;
diff --git a/consensus/src/helper.rs b/consensus/src/helper.rs
deleted file mode 100644
index 06fccf17..00000000
--- a/consensus/src/helper.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-use std::ops::{Add, Div, Mul, Sub};
-
-/// Spawns a task for the rayon thread pool and awaits the result without blocking the async runtime.
-pub(crate) async fn rayon_spawn_async(f: F) -> R
-where
- F: FnOnce() -> R + Send + 'static,
- R: Send + 'static,
-{
- let (tx, rx) = tokio::sync::oneshot::channel();
- rayon::spawn(|| {
- let _ = tx.send(f());
- });
- rx.await.expect("The sender must not be dropped")
-}
-
-pub(crate) fn get_mid(a: T, b: T) -> T
-where
- T: Add