From 1b255f4fa5a0d72d5488ab3dcbe3ff206769a86b Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Tue, 18 Jun 2024 21:36:54 +0100 Subject: [PATCH 01/17] add workflow --- .github/workflows/hack.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/hack.yml diff --git a/.github/workflows/hack.yml b/.github/workflows/hack.yml new file mode 100644 index 000000000..1fd4e2934 --- /dev/null +++ b/.github/workflows/hack.yml @@ -0,0 +1,31 @@ +name: Hack + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + workflow_dispatch: + +jobs: + hack: + + runs-on: ubuntu-latest + + steps: + - name: Cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo + target + key: ${{ matrix.os }}-hack + + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install dependencies + run: cargo install cargo-hack --locked + - name: Deny + run: cargo deny check \ No newline at end of file From 3bd7981d5fb264aaea6e0e6a38e87edcfb89e0b0 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Tue, 18 Jun 2024 21:54:21 +0100 Subject: [PATCH 02/17] fix errors --- .github/workflows/hack.yml | 5 +++-- helper/src/atomic.rs | 2 +- helper/src/lib.rs | 2 +- net/epee-encoding/src/container_as_blob.rs | 4 +++- net/epee-encoding/src/error.rs | 1 + net/epee-encoding/src/lib.rs | 1 + net/epee-encoding/src/value.rs | 6 +++--- p2p/monero-p2p/Cargo.toml | 2 +- 8 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/hack.yml b/.github/workflows/hack.yml index 1fd4e2934..268a776b9 100644 --- a/.github/workflows/hack.yml +++ b/.github/workflows/hack.yml @@ -27,5 +27,6 @@ jobs: - name: Install dependencies run: cargo install cargo-hack --locked - - name: Deny - run: cargo deny check \ No newline at end of file + - name: Hack Check + # TODO: remove the exclude when `cuprate-blockchain` errors are fixed + run: argo hack --workspace --exclude cuprate-blockchain check --feature-powerset --no-dev-deps \ No newline at end of file diff --git a/helper/src/atomic.rs b/helper/src/atomic.rs index f253737a6..17582c0df 100644 --- a/helper/src/atomic.rs +++ b/helper/src/atomic.rs @@ -6,7 +6,7 @@ use crossbeam::atomic::AtomicCell; #[allow(unused_imports)] // docs -use std::sync::atomic::{Ordering, Ordering::Acquire, Ordering::Release}; +use core::sync::atomic::{Ordering, Ordering::Acquire, Ordering::Release}; //---------------------------------------------------------------------------------------------------- Atomic Float /// Compile-time assertion that our floats are diff --git a/helper/src/lib.rs b/helper/src/lib.rs index 90f420d64..4d942d532 100644 --- a/helper/src/lib.rs +++ b/helper/src/lib.rs @@ -43,7 +43,7 @@ pub mod atomic; #[cfg(feature = "constants")] pub mod constants; -#[cfg(feature = "fs")] +#[cfg(all(feature = "fs", feature = "std"))] pub mod fs; pub mod network; diff --git a/net/epee-encoding/src/container_as_blob.rs b/net/epee-encoding/src/container_as_blob.rs index 084b43bb5..306bb0ab4 100644 --- a/net/epee-encoding/src/container_as_blob.rs +++ b/net/epee-encoding/src/container_as_blob.rs @@ -1,3 +1,5 @@ +use alloc::{string::ToString, vec, vec::Vec}; + use bytes::{Buf, BufMut, Bytes, BytesMut}; use ref_cast::RefCast; use sealed::sealed; @@ -72,7 +74,7 @@ pub trait Containerable { macro_rules! int_container_able { ($int:ty ) => { impl Containerable for $int { - const SIZE: usize = std::mem::size_of::<$int>(); + const SIZE: usize = core::mem::size_of::<$int>(); fn from_bytes(bytes: &[u8]) -> Self { <$int>::from_le_bytes(bytes.try_into().unwrap()) diff --git a/net/epee-encoding/src/error.rs b/net/epee-encoding/src/error.rs index 4b3c7b0d9..d00895844 100644 --- a/net/epee-encoding/src/error.rs +++ b/net/epee-encoding/src/error.rs @@ -1,3 +1,4 @@ +use alloc::string::{String, ToString}; use core::{ fmt::{Debug, Formatter}, num::TryFromIntError, diff --git a/net/epee-encoding/src/lib.rs b/net/epee-encoding/src/lib.rs index ffb0a1ea6..abdd62fa3 100644 --- a/net/epee-encoding/src/lib.rs +++ b/net/epee-encoding/src/lib.rs @@ -61,6 +61,7 @@ extern crate alloc; +use alloc::string::ToString; use core::{ops::Deref, str::from_utf8 as str_from_utf8}; use bytes::{Buf, BufMut, Bytes, BytesMut}; diff --git a/net/epee-encoding/src/value.rs b/net/epee-encoding/src/value.rs index ef42241bc..13f691653 100644 --- a/net/epee-encoding/src/value.rs +++ b/net/epee-encoding/src/value.rs @@ -1,6 +1,6 @@ -use alloc::{string::String, vec::Vec}; -/// This module contains a `sealed` [`EpeeValue`] trait and different impls for -/// the different possible base epee values. +//! This module contains a `sealed` [`EpeeValue`] trait and different impls for +//! the different possible base epee values. +use alloc::{string::String, vec, vec::Vec}; use core::fmt::Debug; use bytes::{Buf, BufMut, Bytes, BytesMut}; diff --git a/p2p/monero-p2p/Cargo.toml b/p2p/monero-p2p/Cargo.toml index e416fbbbb..0ffb5f85c 100644 --- a/p2p/monero-p2p/Cargo.toml +++ b/p2p/monero-p2p/Cargo.toml @@ -14,7 +14,7 @@ cuprate-helper = { path = "../../helper" } monero-wire = { path = "../../net/monero-wire", features = ["tracing"] } monero-pruning = { path = "../../pruning" } -tokio = { workspace = true, features = ["net", "sync", "macros", "time"]} +tokio = { workspace = true, features = ["net", "sync", "macros", "time", "rt"]} tokio-util = { workspace = true, features = ["codec"] } tokio-stream = { workspace = true, features = ["sync"]} futures = { workspace = true, features = ["std"] } From ced0d43a6a6721cc205b4635fad202b831c1e296 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Wed, 19 Jun 2024 01:43:00 +0100 Subject: [PATCH 03/17] fix workflow --- .github/workflows/hack.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hack.yml b/.github/workflows/hack.yml index 268a776b9..8ddab98af 100644 --- a/.github/workflows/hack.yml +++ b/.github/workflows/hack.yml @@ -29,4 +29,4 @@ jobs: run: cargo install cargo-hack --locked - name: Hack Check # TODO: remove the exclude when `cuprate-blockchain` errors are fixed - run: argo hack --workspace --exclude cuprate-blockchain check --feature-powerset --no-dev-deps \ No newline at end of file + run: cargo hack --workspace --exclude cuprate-blockchain check --feature-powerset --no-dev-deps \ No newline at end of file From e01e37faa82792ae6e8dc146cae5ac818fcb2993 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Wed, 19 Jun 2024 01:49:41 +0100 Subject: [PATCH 04/17] install dependencies --- .github/workflows/hack.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/hack.yml b/.github/workflows/hack.yml index 8ddab98af..bad16f032 100644 --- a/.github/workflows/hack.yml +++ b/.github/workflows/hack.yml @@ -26,7 +26,10 @@ jobs: submodules: recursive - name: Install dependencies - run: cargo install cargo-hack --locked + run: | + sudo apt install -y libboost-dev + cargo install cargo-hack --locked + - name: Hack Check # TODO: remove the exclude when `cuprate-blockchain` errors are fixed run: cargo hack --workspace --exclude cuprate-blockchain check --feature-powerset --no-dev-deps \ No newline at end of file From b46eea531bffbede2b2a922fba25363501d073ad Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 27 Jun 2024 01:44:45 +0100 Subject: [PATCH 05/17] fix more errors --- .github/workflows/hack.yml | 4 ++-- net/epee-encoding/src/value.rs | 2 +- storage/blockchain/Cargo.toml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/hack.yml b/.github/workflows/hack.yml index bad16f032..8a4e80157 100644 --- a/.github/workflows/hack.yml +++ b/.github/workflows/hack.yml @@ -31,5 +31,5 @@ jobs: cargo install cargo-hack --locked - name: Hack Check - # TODO: remove the exclude when `cuprate-blockchain` errors are fixed - run: cargo hack --workspace --exclude cuprate-blockchain check --feature-powerset --no-dev-deps \ No newline at end of file + # TODO: remove the exclude when `cuprate-database` errors are fixed + run: cargo hack --workspace --exclude cuprate-database check --feature-powerset --no-dev-deps \ No newline at end of file diff --git a/net/epee-encoding/src/value.rs b/net/epee-encoding/src/value.rs index 094f0ef13..7fa2f9d3f 100644 --- a/net/epee-encoding/src/value.rs +++ b/net/epee-encoding/src/value.rs @@ -1,7 +1,7 @@ //! This module contains a [`EpeeValue`] trait and //! impls for some possible base epee values. -use alloc::{string::String, vec::Vec}; +use alloc::{string::String, vec, vec::Vec}; use core::fmt::Debug; use bytes::{Buf, BufMut, Bytes, BytesMut}; diff --git a/storage/blockchain/Cargo.toml b/storage/blockchain/Cargo.toml index bab582d6f..36e94fd01 100644 --- a/storage/blockchain/Cargo.toml +++ b/storage/blockchain/Cargo.toml @@ -15,7 +15,7 @@ default = ["heed", "service"] heed = ["cuprate-database/heed"] redb = ["cuprate-database/redb"] redb-memory = ["cuprate-database/redb-memory"] -service = ["dep:crossbeam", "dep:futures", "dep:tokio", "dep:tokio-util", "dep:tower", "dep:rayon"] +service = ["dep:crossbeam", "dep:futures", "dep:tokio", "dep:tokio-util", "dep:tower", "dep:rayon", "dep:thread_local"] [dependencies] # FIXME: @@ -38,7 +38,7 @@ futures = { workspace = true, optional = true } tokio = { workspace = true, features = ["full"], optional = true } tokio-util = { workspace = true, features = ["full"], optional = true } tower = { workspace = true, features = ["full"], optional = true } -thread_local = { workspace = true } +thread_local = { workspace = true, optional = true } rayon = { workspace = true, optional = true } [dev-dependencies] From 362ef3119d5fb80ca3b72b9169b1f49ef8251fdf Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Thu, 27 Jun 2024 01:52:26 +0100 Subject: [PATCH 06/17] Update CONTRIBUTING.md --- CONTRIBUTING.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0c9c1f035..8e43f40a8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -107,7 +107,7 @@ It currently: - Runs [`clippy`](https://github.com/rust-lang/rust-clippy) (and fails on warnings) - Runs all tests - Builds all targets -- Automatically adds approriate [labels](#31-labels) to your PR +- Automatically adds appropriate [labels](#31-labels) to your PR Before pushing your code, please run the following at the root of the repository: @@ -120,12 +120,13 @@ Before pushing your code, please run the following at the root of the repository After that, ensure all other CI passes by running: -| Command | Does what | -|------------------------------------------------------------------------|-----------| -| `RUSTDOCFLAGS='-D warnings' cargo doc --workspace --all-features` | Checks documentation is OK -| `cargo clippy --workspace --all-features --all-targets -- -D warnings` | Checks clippy lints are satisfied -| `cargo test --all-features --workspace` | Runs all tests -| `cargo build --all-features --all-targets --workspace` | Builds all code +| Command | Does what | +|--------------------------------------------------------------------------------------------|-----------------------------------------------------------------------| +| `RUSTDOCFLAGS='-D warnings' cargo doc --workspace --all-features` | Checks documentation is OK | +| `cargo clippy --workspace --all-features --all-targets -- -D warnings` | Checks clippy lints are satisfied | +| `cargo test --all-features --workspace` | Runs all tests | +| `cargo build --all-features --all-targets --workspace` | Builds all code | +| `cargo hack --workspace --exclude cuprate-database check --feature-powerset --no-dev-deps` | Uses cargo hack to check our crates build with different features set | **Note: in order for some tests to work, you will need to place a [`monerod`](https://www.getmonero.org/downloads/) binary at the root of the repository.** From 29e1fbc0fc9564cb3b1937b0bfb57c890751cfa1 Mon Sep 17 00:00:00 2001 From: Boog900 Date: Sun, 30 Jun 2024 14:05:23 +0100 Subject: [PATCH 07/17] Update CONTRIBUTING.md Co-authored-by: hinto-janai --- CONTRIBUTING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8e43f40a8..8067c2b36 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -126,7 +126,9 @@ After that, ensure all other CI passes by running: | `cargo clippy --workspace --all-features --all-targets -- -D warnings` | Checks clippy lints are satisfied | | `cargo test --all-features --workspace` | Runs all tests | | `cargo build --all-features --all-targets --workspace` | Builds all code | -| `cargo hack --workspace --exclude cuprate-database check --feature-powerset --no-dev-deps` | Uses cargo hack to check our crates build with different features set | +| `cargo hack --workspace --exclude cuprate-database check --feature-powerset --no-dev-deps` | Uses `cargo hack` to check our crates build with different features set | + +`cargo hack` can be installed with `cargo` from: https://github.com/taiki-e/cargo-hack. **Note: in order for some tests to work, you will need to place a [`monerod`](https://www.getmonero.org/downloads/) binary at the root of the repository.** From 372d5cce20f91548076ced708a625a61d191b3f2 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Tue, 29 Oct 2024 17:39:24 +0000 Subject: [PATCH 08/17] fix hack + enable it for cuprate-database --- .github/workflows/hack.yml | 2 +- Cargo.lock | 1 - consensus/fast-sync/Cargo.toml | 2 +- helper/Cargo.toml | 2 +- net/epee-encoding/src/container_as_blob.rs | 2 ++ net/epee-encoding/src/lib.rs | 1 + p2p/address-book/Cargo.toml | 2 +- pruning/Cargo.toml | 2 +- rpc/interface/Cargo.toml | 8 ++--- rpc/types/src/bin.rs | 42 ++++++++++++++-------- rpc/types/src/json.rs | 10 +++--- rpc/types/src/lib.rs | 1 + rpc/types/src/misc/distribution.rs | 14 +++----- rpc/types/src/misc/misc.rs | 10 +++--- rpc/types/src/other.rs | 4 ++- storage/blockchain/Cargo.toml | 9 ++--- storage/database/Cargo.toml | 6 ++-- storage/database/src/backend/mod.rs | 2 ++ storage/service/Cargo.toml | 10 ++++-- storage/txpool/Cargo.toml | 10 +++--- storage/txpool/src/lib.rs | 3 -- types/Cargo.toml | 10 +++--- types/src/hex.rs | 1 + types/src/json/block.rs | 6 ++-- types/src/json/output.rs | 2 +- types/src/json/tx.rs | 6 ++-- 26 files changed, 96 insertions(+), 72 deletions(-) diff --git a/.github/workflows/hack.yml b/.github/workflows/hack.yml index 8a4e80157..c474f6ef3 100644 --- a/.github/workflows/hack.yml +++ b/.github/workflows/hack.yml @@ -32,4 +32,4 @@ jobs: - name: Hack Check # TODO: remove the exclude when `cuprate-database` errors are fixed - run: cargo hack --workspace --exclude cuprate-database check --feature-powerset --no-dev-deps \ No newline at end of file + run: cargo hack --workspace check --feature-powerset --no-dev-deps \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index ca0174ba6..4cba64eb3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -933,7 +933,6 @@ dependencies = [ "tempfile", "thiserror", "tokio", - "tower 0.5.1", ] [[package]] diff --git a/consensus/fast-sync/Cargo.toml b/consensus/fast-sync/Cargo.toml index 8e732a6fc..2836dbc32 100644 --- a/consensus/fast-sync/Cargo.toml +++ b/consensus/fast-sync/Cargo.toml @@ -9,7 +9,7 @@ name = "cuprate-fast-sync-create-hashes" path = "src/create.rs" [dependencies] -cuprate-blockchain = { workspace = true } +cuprate-blockchain = { workspace = true, features = ["service"] } cuprate-consensus = { workspace = true } cuprate-consensus-rules = { workspace = true } cuprate-consensus-context = { workspace = true } diff --git a/helper/Cargo.toml b/helper/Cargo.toml index ad78a4485..1b3158f13 100644 --- a/helper/Cargo.toml +++ b/helper/Cargo.toml @@ -17,7 +17,7 @@ asynch = ["dep:futures", "dep:rayon"] cast = [] constants = [] crypto = ["dep:curve25519-dalek", "dep:monero-serai", "std"] -fs = ["dep:dirs"] +fs = ["dep:dirs", "std"] num = [] map = ["cast", "dep:monero-serai", "dep:cuprate-constants"] time = ["dep:chrono", "std"] diff --git a/net/epee-encoding/src/container_as_blob.rs b/net/epee-encoding/src/container_as_blob.rs index 83078c2c8..363e157b2 100644 --- a/net/epee-encoding/src/container_as_blob.rs +++ b/net/epee-encoding/src/container_as_blob.rs @@ -1,3 +1,5 @@ +use alloc::{string::ToString, vec, vec::Vec}; + use bytes::{Buf, BufMut, Bytes, BytesMut}; use ref_cast::RefCast; diff --git a/net/epee-encoding/src/lib.rs b/net/epee-encoding/src/lib.rs index d55a54602..a6ff1b04f 100644 --- a/net/epee-encoding/src/lib.rs +++ b/net/epee-encoding/src/lib.rs @@ -64,6 +64,7 @@ use hex as _; extern crate alloc; +use alloc::string::ToString; use core::str::from_utf8 as str_from_utf8; use bytes::{Buf, BufMut, Bytes, BytesMut}; diff --git a/p2p/address-book/Cargo.toml b/p2p/address-book/Cargo.toml index 9cbba717a..a88819f7a 100644 --- a/p2p/address-book/Cargo.toml +++ b/p2p/address-book/Cargo.toml @@ -9,7 +9,7 @@ authors = ["Boog900"] [dependencies] cuprate-constants = { workspace = true } cuprate-pruning = { workspace = true } -cuprate-p2p-core = { workspace = true } +cuprate-p2p-core = { workspace = true, features = ["borsh"] } tower = { workspace = true, features = ["util"] } tokio = { workspace = true, features = ["time", "fs", "rt"]} diff --git a/pruning/Cargo.toml b/pruning/Cargo.toml index 6fcc74e25..4b03551d4 100644 --- a/pruning/Cargo.toml +++ b/pruning/Cargo.toml @@ -10,7 +10,7 @@ default = [] borsh = ["dep:borsh"] [dependencies] -cuprate-constants = { workspace = true } +cuprate-constants = { workspace = true, features = ["block"] } thiserror = { workspace = true } diff --git a/rpc/interface/Cargo.toml b/rpc/interface/Cargo.toml index ef62d349a..c5d4db70c 100644 --- a/rpc/interface/Cargo.toml +++ b/rpc/interface/Cargo.toml @@ -10,20 +10,20 @@ keywords = ["cuprate", "rpc", "interface"] [features] default = ["dummy", "serde"] -dummy = [] +dummy = ["dep:cuprate-helper", "dep:futures"] [dependencies] cuprate-epee-encoding = { workspace = true, default-features = false } cuprate-json-rpc = { workspace = true, default-features = false } cuprate-rpc-types = { workspace = true, features = ["serde", "epee"], default-features = false } -cuprate-helper = { workspace = true, features = ["asynch"], default-features = false } +cuprate-helper = { workspace = true, features = ["asynch"], default-features = false, optional = true } anyhow = { workspace = true } axum = { version = "0.7.5", features = ["json"], default-features = false } serde = { workspace = true, optional = true } -tower = { workspace = true } +tower = { workspace = true, features = ["util"] } paste = { workspace = true } -futures = { workspace = true } +futures = { workspace = true, optional = true } [dev-dependencies] cuprate-test-utils = { workspace = true } diff --git a/rpc/types/src/bin.rs b/rpc/types/src/bin.rs index a68d3e109..9e697b8a0 100644 --- a/rpc/types/src/bin.rs +++ b/rpc/types/src/bin.rs @@ -20,12 +20,14 @@ use cuprate_types::BlockCompleteEntry; use crate::{ base::AccessResponseBase, - defaults::{default_false, default_zero}, macros::{define_request, define_request_and_response, define_request_and_response_doc}, - misc::{BlockOutputIndices, GetOutputsOut, OutKeyBin, PoolInfoExtent, PoolTxInfo, Status}, + misc::{BlockOutputIndices, GetOutputsOut, OutKeyBin, PoolTxInfo, Status}, rpc_call::RpcCallValue, }; +#[cfg(any(feature = "epee", feature = "serde"))] +use crate::defaults::{default_false, default_zero}; + //---------------------------------------------------------------------------------------------------- Definitions define_request_and_response! { get_blocks_by_heightbin, @@ -137,15 +139,15 @@ define_request! { core_rpc_server_commands_defs, h, 162, 262, )] /// -/// This response's variant depends upon [`PoolInfoExtent`]. +/// This response's variant depends upon [`crate::misc::PoolInfoExtent`]. #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum GetBlocksResponse { - /// Will always serialize a [`PoolInfoExtent::None`] field. + /// Will always serialize a [`crate::misc::PoolInfoExtent::None`] field. PoolInfoNone(GetBlocksResponsePoolInfoNone), - /// Will always serialize a [`PoolInfoExtent::Incremental`] field. + /// Will always serialize a [`crate::misc::PoolInfoExtent::Incremental`] field. PoolInfoIncremental(GetBlocksResponsePoolInfoIncremental), - /// Will always serialize a [`PoolInfoExtent::Full`] field. + /// Will always serialize a [`crate::misc::PoolInfoExtent::Full`] field. PoolInfoFull(GetBlocksResponsePoolInfoFull), } @@ -254,7 +256,7 @@ pub struct __GetBlocksResponseEpeeBuilder { pub current_height: Option, pub output_indices: Option>, pub daemon_time: Option, - pub pool_info_extent: Option, + pub pool_info_extent: Option, pub added_pool_txs: Option>, pub remaining_added_pool_txids: Option>, pub removed_pool_txids: Option>, @@ -304,7 +306,7 @@ impl EpeeObjectBuilder for __GetBlocksResponseEpeeBuilder { let pool_info_extent = self.pool_info_extent.ok_or(ELSE)?; let this = match pool_info_extent { - PoolInfoExtent::None => { + crate::misc::PoolInfoExtent::None => { GetBlocksResponse::PoolInfoNone(GetBlocksResponsePoolInfoNone { status, untrusted, @@ -315,7 +317,7 @@ impl EpeeObjectBuilder for __GetBlocksResponseEpeeBuilder { daemon_time, }) } - PoolInfoExtent::Incremental => { + crate::misc::PoolInfoExtent::Incremental => { GetBlocksResponse::PoolInfoIncremental(GetBlocksResponsePoolInfoIncremental { status, untrusted, @@ -329,7 +331,7 @@ impl EpeeObjectBuilder for __GetBlocksResponseEpeeBuilder { removed_pool_txids: self.removed_pool_txids.ok_or(ELSE)?, }) } - PoolInfoExtent::Full => { + crate::misc::PoolInfoExtent::Full => { GetBlocksResponse::PoolInfoFull(GetBlocksResponsePoolInfoFull { status, untrusted, @@ -353,7 +355,7 @@ impl EpeeObject for GetBlocksResponse { type Builder = __GetBlocksResponseEpeeBuilder; fn number_of_fields(&self) -> u64 { - // [`PoolInfoExtent`] + inner struct fields. + // [`crate::misc::PoolInfoExtent`] + inner struct fields. let inner_fields = match self { Self::PoolInfoNone(s) => s.number_of_fields(), Self::PoolInfoIncremental(s) => s.number_of_fields(), @@ -367,15 +369,27 @@ impl EpeeObject for GetBlocksResponse { match self { Self::PoolInfoNone(s) => { s.write_fields(w)?; - write_field(PoolInfoExtent::None.to_u8(), "pool_info_extent", w)?; + write_field( + crate::misc::PoolInfoExtent::None.to_u8(), + "pool_info_extent", + w, + )?; } Self::PoolInfoIncremental(s) => { s.write_fields(w)?; - write_field(PoolInfoExtent::Incremental.to_u8(), "pool_info_extent", w)?; + write_field( + crate::misc::PoolInfoExtent::Incremental.to_u8(), + "pool_info_extent", + w, + )?; } Self::PoolInfoFull(s) => { s.write_fields(w)?; - write_field(PoolInfoExtent::Full.to_u8(), "pool_info_extent", w)?; + write_field( + crate::misc::PoolInfoExtent::Full.to_u8(), + "pool_info_extent", + w, + )?; } } diff --git a/rpc/types/src/json.rs b/rpc/types/src/json.rs index fd9ffa32b..6fb538c3f 100644 --- a/rpc/types/src/json.rs +++ b/rpc/types/src/json.rs @@ -8,10 +8,6 @@ use serde::{Deserialize, Serialize}; use crate::{ base::{AccessResponseBase, ResponseBase}, - defaults::{ - default_false, default_height, default_one, default_string, default_true, default_vec, - default_zero, - }, macros::define_request_and_response, misc::{ AuxPow, BlockHeader, ChainInfo, ConnectionInfo, Distribution, GetBan, @@ -21,6 +17,12 @@ use crate::{ rpc_call::RpcCallValue, }; +#[cfg(any(feature = "epee", feature = "serde"))] +use crate::defaults::{ + default_false, default_height, default_one, default_string, default_true, default_vec, + default_zero, +}; + //---------------------------------------------------------------------------------------------------- Macro /// Adds a (de)serialization doc-test to a type in `json.rs`. /// diff --git a/rpc/types/src/lib.rs b/rpc/types/src/lib.rs index be1069ecb..403a3ea3a 100644 --- a/rpc/types/src/lib.rs +++ b/rpc/types/src/lib.rs @@ -6,6 +6,7 @@ )] mod constants; +#[cfg(any(feature = "serde", feature = "epee"))] mod defaults; mod free; mod macros; diff --git a/rpc/types/src/misc/distribution.rs b/rpc/types/src/misc/distribution.rs index faac7ad72..e920d1293 100644 --- a/rpc/types/src/misc/distribution.rs +++ b/rpc/types/src/misc/distribution.rs @@ -20,8 +20,8 @@ use cuprate_epee_encoding::{ "rpc/core_rpc_server_commands_defs.h", 45..=55 )] -#[cfg(feature = "epee")] -fn compress_integer_array(_: &[u64]) -> error::Result> { +#[cfg(any(feature = "epee", feature = "serde"))] +fn compress_integer_array(_: &[u64]) -> Vec { todo!() } @@ -33,6 +33,7 @@ fn compress_integer_array(_: &[u64]) -> error::Result> { "rpc/core_rpc_server_commands_defs.h", 57..=72 )] +#[cfg(any(feature = "epee", feature = "serde"))] fn decompress_integer_array(_: &[u8]) -> Vec { todo!() } @@ -135,12 +136,7 @@ fn serialize_distribution_as_compressed_data(v: &Vec, s: S) -> Result compressed_data.serialize(s), - Err(_) => Err(serde::ser::Error::custom( - "error compressing distribution array", - )), - } + compress_integer_array(v).serialize(s) } /// Deserializer function for [`DistributionCompressedBinary::distribution`]. @@ -256,7 +252,7 @@ impl EpeeObject for Distribution { distribution, amount, }) => { - let compressed_data = compress_integer_array(&distribution)?; + let compressed_data = compress_integer_array(&distribution); start_height.write(w)?; base.write(w)?; diff --git a/rpc/types/src/misc/misc.rs b/rpc/types/src/misc/misc.rs index 842997bc5..4430dbee3 100644 --- a/rpc/types/src/misc/misc.rs +++ b/rpc/types/src/misc/misc.rs @@ -11,10 +11,10 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "epee")] use cuprate_epee_encoding::epee_object; -use crate::{ - defaults::{default_string, default_zero}, - macros::monero_definition_link, -}; +use crate::macros::monero_definition_link; + +#[cfg(any(feature = "epee", feature = "serde"))] +use crate::defaults::default_zero; //---------------------------------------------------------------------------------------------------- Macros /// This macro (local to this file) defines all the misc types. @@ -148,7 +148,7 @@ define_struct_and_impl_epee! { )] /// Used in [`crate::json::SetBansRequest`]. SetBan { - #[cfg_attr(feature = "serde", serde(default = "default_string"))] + #[cfg_attr(feature = "serde", serde(default = "crate::defaults::default_string"))] host: String, #[cfg_attr(feature = "serde", serde(default = "default_zero"))] ip: u32, diff --git a/rpc/types/src/other.rs b/rpc/types/src/other.rs index e7f3394c9..f743392fd 100644 --- a/rpc/types/src/other.rs +++ b/rpc/types/src/other.rs @@ -8,7 +8,6 @@ use serde::{Deserialize, Serialize}; use crate::{ base::{AccessResponseBase, ResponseBase}, - defaults::{default_false, default_string, default_true, default_vec, default_zero}, macros::define_request_and_response, misc::{ GetOutputsOut, OutKey, Peer, PublicNode, SpentKeyImageInfo, Status, TxEntry, TxInfo, @@ -17,6 +16,9 @@ use crate::{ RpcCallValue, }; +#[cfg(any(feature = "serde", feature = "epee"))] +use crate::defaults::{default_false, default_string, default_true, default_vec, default_zero}; + //---------------------------------------------------------------------------------------------------- Macro /// Adds a (de)serialization doc-test to a type in `other.rs`. /// diff --git a/storage/blockchain/Cargo.toml b/storage/blockchain/Cargo.toml index d0a43b3b1..28047e0f2 100644 --- a/storage/blockchain/Cargo.toml +++ b/storage/blockchain/Cargo.toml @@ -15,24 +15,25 @@ default = ["heed", "service"] heed = ["cuprate-database/heed"] redb = ["cuprate-database/redb"] redb-memory = ["cuprate-database/redb-memory"] -service = ["dep:thread_local", "dep:rayon", "cuprate-helper/thread"] +service = ["dep:tower", "dep:thread_local", "dep:rayon", "dep:rand", "cuprate-helper/thread"] +serde = ["dep:serde", "cuprate-database/serde", "cuprate-database-service/serde"] [dependencies] cuprate-database = { workspace = true } cuprate-database-service = { workspace = true } -cuprate-helper = { workspace = true, features = ["fs", "map", "crypto"] } +cuprate-helper = { workspace = true, features = ["fs", "map", "crypto", "tx"] } cuprate-types = { workspace = true, features = ["blockchain"] } cuprate-pruning = { workspace = true } bitflags = { workspace = true, features = ["std", "serde", "bytemuck"] } bytemuck = { workspace = true, features = ["must_cast", "derive", "min_const_generics", "extern_crate_alloc"] } curve25519-dalek = { workspace = true } -rand = { workspace = true } +rand = { workspace = true, features = ["std", "std_rng"], optional = true } monero-serai = { workspace = true, features = ["std"] } serde = { workspace = true, optional = true } # `service` feature. -tower = { workspace = true } +tower = { workspace = true, optional = true } thread_local = { workspace = true, optional = true } rayon = { workspace = true, optional = true } diff --git a/storage/database/Cargo.toml b/storage/database/Cargo.toml index 7a2f4ae15..feeaf8761 100644 --- a/storage/database/Cargo.toml +++ b/storage/database/Cargo.toml @@ -9,10 +9,10 @@ repository = "https://github.com/Cuprate/cuprate/tree/main/storage/database" keywords = ["cuprate", "database"] [features] -# default = ["heed"] +default = ["heed"] # default = ["redb"] # default = ["redb-memory"] -heed = ["dep:heed"] +heed = [] redb = ["dep:redb"] redb-memory = ["redb"] @@ -25,7 +25,7 @@ paste = { workspace = true } thiserror = { workspace = true } # Optional features. -heed = { version = "0.20.5", features = ["read-txn-no-tls"], optional = true } +heed = { version = "0.20.5", features = ["read-txn-no-tls"] } redb = { version = "2.1.3", optional = true } serde = { workspace = true, optional = true } diff --git a/storage/database/src/backend/mod.rs b/storage/database/src/backend/mod.rs index 11ae40b8b..ebe12d860 100644 --- a/storage/database/src/backend/mod.rs +++ b/storage/database/src/backend/mod.rs @@ -4,6 +4,8 @@ cfg_if::cfg_if! { // If both backends are enabled, fallback to `heed`. // This is useful when using `--all-features`. if #[cfg(all(feature = "redb", not(feature = "heed")))] { + use heed as _; + mod redb; pub use redb::ConcreteEnv; } else { diff --git a/storage/service/Cargo.toml b/storage/service/Cargo.toml index fa6971c56..ebdb13e80 100644 --- a/storage/service/Cargo.toml +++ b/storage/service/Cargo.toml @@ -8,14 +8,20 @@ authors = ["Boog900"] repository = "https://github.com/Cuprate/cuprate/tree/main/storage/service" keywords = ["cuprate", "service", "database"] +[features] +default = ["heed"] +heed = ["cuprate-database/heed"] +redb = ["cuprate-database/redb"] +redb-memorey = ["cuprate-database/redb-memory"] + [dependencies] cuprate-database = { workspace = true } -cuprate-helper = { workspace = true, features = ["fs", "thread", "map"] } +cuprate-helper = { workspace = true, features = ["fs", "thread", "map", "asynch"] } serde = { workspace = true, optional = true } rayon = { workspace = true } tower = { workspace = true } -futures = { workspace = true } +futures = { workspace = true, features = ["std"] } crossbeam = { workspace = true, features = ["std"] } [lints] diff --git a/storage/txpool/Cargo.toml b/storage/txpool/Cargo.toml index b9d42181f..c880fdd33 100644 --- a/storage/txpool/Cargo.toml +++ b/storage/txpool/Cargo.toml @@ -9,18 +9,17 @@ repository = "https://github.com/Cuprate/cuprate/tree/main/storage/txpool" keywords = ["cuprate", "txpool", "transaction", "pool", "database"] [features] -default = ["heed", "service"] +default = ["heed"] # default = ["redb", "service"] # default = ["redb-memory", "service"] heed = ["cuprate-database/heed"] redb = ["cuprate-database/redb"] redb-memory = ["cuprate-database/redb-memory"] -service = ["dep:tower", "dep:rayon", "dep:cuprate-database-service"] serde = ["dep:serde", "cuprate-database/serde", "cuprate-database-service/serde"] [dependencies] cuprate-database = { workspace = true, features = ["heed"] } -cuprate-database-service = { workspace = true, optional = true } +cuprate-database-service = { workspace = true } cuprate-types = { workspace = true } cuprate-helper = { workspace = true, default-features = false, features = ["constants"] } @@ -28,10 +27,9 @@ monero-serai = { workspace = true, features = ["std"] } bytemuck = { workspace = true, features = ["must_cast", "derive", "min_const_generics", "extern_crate_alloc"] } bitflags = { workspace = true, features = ["std", "serde", "bytemuck"] } thiserror = { workspace = true } -hex = { workspace = true } +hex = { workspace = true, features = ["std"] } -tower = { workspace = true, optional = true } -rayon = { workspace = true, optional = true } +rayon = { workspace = true } serde = { workspace = true, optional = true } diff --git a/storage/txpool/src/lib.rs b/storage/txpool/src/lib.rs index 5fb3b1439..c0827af3f 100644 --- a/storage/txpool/src/lib.rs +++ b/storage/txpool/src/lib.rs @@ -7,7 +7,6 @@ pub mod config; mod free; pub mod ops; -#[cfg(feature = "service")] pub mod service; pub mod tables; mod tx; @@ -20,8 +19,6 @@ pub use tx::TxEntry; //re-exports pub use cuprate_database; -// TODO: remove when used. -use tower as _; #[cfg(test)] mod test { use cuprate_test_utils as _; diff --git a/types/Cargo.toml b/types/Cargo.toml index 29887bdb9..e1ffb1961 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -12,21 +12,23 @@ keywords = ["cuprate", "types"] default = ["blockchain", "epee", "serde", "json", "hex"] blockchain = [] epee = ["dep:cuprate-epee-encoding"] -serde = ["dep:serde"] +serde = ["dep:serde", "hex"] proptest = ["dep:proptest", "dep:proptest-derive"] json = ["hex", "dep:cuprate-helper"] -hex = ["dep:hex"] +# We sadly have no choice but to enable serde here as otherwise we will get warnings from the `hex` dep being unused. +# This isn't too bad as `HexBytes` only makes sense with serde anyway. +hex = ["serde", "dep:hex"] [dependencies] cuprate-epee-encoding = { workspace = true, optional = true, features = ["std"] } cuprate-helper = { workspace = true, optional = true, features = ["cast"] } -cuprate-fixed-bytes = { workspace = true } +cuprate-fixed-bytes = { workspace = true, features = ["std", "serde"] } bytes = { workspace = true } curve25519-dalek = { workspace = true } monero-serai = { workspace = true } hex = { workspace = true, features = ["serde", "alloc"], optional = true } -serde = { workspace = true, features = ["derive"], optional = true } +serde = { workspace = true, features = ["std", "derive"], optional = true } strum = { workspace = true, features = ["derive"] } thiserror = { workspace = true } diff --git a/types/src/hex.rs b/types/src/hex.rs index 34da09d81..de4fc8163 100644 --- a/types/src/hex.rs +++ b/types/src/hex.rs @@ -22,6 +22,7 @@ pub struct HexBytes( #[cfg_attr(feature = "serde", serde(with = "hex::serde"))] pub [u8; N], ); +#[cfg(feature = "serde")] impl<'de, const N: usize> Deserialize<'de> for HexBytes where [u8; N]: hex::FromHex, diff --git a/types/src/json/block.rs b/types/src/json/block.rs index 1397f6fda..88f134d53 100644 --- a/types/src/json/block.rs +++ b/types/src/json/block.rs @@ -51,17 +51,17 @@ impl From for Block { /// [`Block::miner_tx`]. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[serde(untagged)] +#[cfg_attr(feature = "serde", serde(untagged))] pub enum MinerTransaction { V1 { /// This field is [flattened](https://serde.rs/field-attrs.html#flatten). - #[serde(flatten)] + #[cfg_attr(feature = "serde", serde(flatten))] prefix: MinerTransactionPrefix, signatures: [(); 0], }, V2 { /// This field is [flattened](https://serde.rs/field-attrs.html#flatten). - #[serde(flatten)] + #[cfg_attr(feature = "serde", serde(flatten))] prefix: MinerTransactionPrefix, rct_signatures: MinerTransactionRctSignatures, }, diff --git a/types/src/json/output.rs b/types/src/json/output.rs index 050132aef..182618cda 100644 --- a/types/src/json/output.rs +++ b/types/src/json/output.rs @@ -20,7 +20,7 @@ pub struct Output { /// [`Output::target`]. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[serde(untagged)] +#[cfg_attr(feature = "serde", serde(untagged))] pub enum Target { Key { key: HexBytes<32> }, TaggedKey { tagged_key: TaggedKey }, diff --git a/types/src/json/tx.rs b/types/src/json/tx.rs index 46ec827b2..a18dc89a6 100644 --- a/types/src/json/tx.rs +++ b/types/src/json/tx.rs @@ -24,17 +24,17 @@ use crate::{ /// - [`/get_transaction_pool` -> `tx_json`](https://www.getmonero.org/resources/developer-guides/daemon-rpc.html#get_transaction_pool) #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[serde(untagged)] +#[cfg_attr(feature = "serde", serde(untagged))] pub enum Transaction { V1 { /// This field is [flattened](https://serde.rs/field-attrs.html#flatten). - #[serde(flatten)] + #[cfg_attr(feature = "serde", serde(flatten))] prefix: TransactionPrefix, signatures: Vec>, }, V2 { /// This field is [flattened](https://serde.rs/field-attrs.html#flatten). - #[serde(flatten)] + #[cfg_attr(feature = "serde", serde(flatten))] prefix: TransactionPrefix, rct_signatures: RctSignatures, /// This field is [`Some`] if [`Self::V2::rct_signatures`] From 848f0b992d2f0afd29b45628b8c0343f0d462d42 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Tue, 29 Oct 2024 17:42:38 +0000 Subject: [PATCH 09/17] move hack to main CI --- .github/workflows/ci.yml | 161 +++++++++++++++++++------------------ .github/workflows/hack.yml | 35 -------- 2 files changed, 83 insertions(+), 113 deletions(-) delete mode 100644 .github/workflows/hack.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c2271d5d..775e15152 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,22 +29,22 @@ jobs: fmt: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Format - run: cargo fmt --all --check + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Format + run: cargo fmt --all --check # Run typo checker separately. # This will fast-cancel other CI early if this fails. typo: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Spell Check - uses: crate-ci/typos@master + - name: Checkout + uses: actions/checkout@v4 + - name: Spell Check + uses: crate-ci/typos@master # All other CI. ci: @@ -52,7 +52,7 @@ jobs: strategy: matrix: - os: [windows-latest, macos-latest, ubuntu-latest] + os: [ windows-latest, macos-latest, ubuntu-latest ] include: - os: windows-latest shell: msys2 {0} @@ -71,70 +71,75 @@ jobs: shell: ${{ matrix.shell }} steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Install Rust - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ matrix.rust }} - components: clippy - - - name: Cache - uses: actions/cache@v4 - with: - path: target - key: ${{ matrix.os }} - - - name: Download monerod - uses: ./.github/actions/monerod-download - - # Packages other than `Boost` used by `Monero` are listed here. - # https://github.com/monero-project/monero/blob/c444a7e002036e834bfb4c68f04a121ce1af5825/.github/workflows/build.yml#L71 - - - name: Install dependencies (Linux) - if: matrix.os == 'ubuntu-latest' - run: sudo apt install -y libboost-dev - - - name: Install dependencies (macOS) - if: matrix.os == 'macos-latest' - run: HOMEBREW_NO_AUTO_UPDATE=1 brew install boost - - - name: Install dependencies (Windows) - if: matrix.os == 'windows-latest' - uses: msys2/setup-msys2@v2 - with: - path-type: inherit - update: true - install: mingw-w64-x86_64-toolchain mingw-w64-x86_64-boost msys2-runtime-devel git mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja - - # HACK: 2024-05-14 - # GCC 14+ fails to build `lmdb-master-sys` with no clear error message: - # - # - # - MSYS2 repos carry older versions of packages - # - pacman lets us manually downgrade from package files - # - Note that `gcc` requires `gcc-libs` - - name: Downgrade to GCC 13.2 (Windows) - if: matrix.os == 'windows-latest' - run: | - wget https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-gcc-13.2.0-6-any.pkg.tar.zst https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-gcc-libs-13.2.0-6-any.pkg.tar.zst - pacman -U --noconfirm mingw-w64-x86_64-gcc-13.2.0-6-any.pkg.tar.zst mingw-w64-x86_64-gcc-libs-13.2.0-6-any.pkg.tar.zst - - - name: Documentation - run: cargo doc --workspace --all-features --no-deps - - - name: Clippy (fail on warnings) - run: cargo clippy --workspace --all-features --all-targets -- -D warnings - - # HACK: how to test both DB backends that are feature-gated? - - name: Test - run: | - cargo test --all-features --workspace - cargo test --package cuprate-blockchain --no-default-features --features redb --features service - - # TODO: upload binaries with `actions/upload-artifact@v3` - - name: Build - run: cargo build --all-features --all-targets --workspace + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.rust }} + components: clippy + + - name: Cache + uses: actions/cache@v4 + with: + path: target + key: ${{ matrix.os }} + + - name: Download monerod + uses: ./.github/actions/monerod-download + + # Packages other than `Boost` used by `Monero` are listed here. + # https://github.com/monero-project/monero/blob/c444a7e002036e834bfb4c68f04a121ce1af5825/.github/workflows/build.yml#L71 + + - name: Install dependencies (Linux) + if: matrix.os == 'ubuntu-latest' + run: sudo apt install -y libboost-dev + + - name: Install dependencies (macOS) + if: matrix.os == 'macos-latest' + run: HOMEBREW_NO_AUTO_UPDATE=1 brew install boost + + - name: Install dependencies (Windows) + if: matrix.os == 'windows-latest' + uses: msys2/setup-msys2@v2 + with: + path-type: inherit + update: true + install: mingw-w64-x86_64-toolchain mingw-w64-x86_64-boost msys2-runtime-devel git mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja + + # HACK: 2024-05-14 + # GCC 14+ fails to build `lmdb-master-sys` with no clear error message: + # + # + # - MSYS2 repos carry older versions of packages + # - pacman lets us manually downgrade from package files + # - Note that `gcc` requires `gcc-libs` + - name: Downgrade to GCC 13.2 (Windows) + if: matrix.os == 'windows-latest' + run: | + wget https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-gcc-13.2.0-6-any.pkg.tar.zst https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-gcc-libs-13.2.0-6-any.pkg.tar.zst + pacman -U --noconfirm mingw-w64-x86_64-gcc-13.2.0-6-any.pkg.tar.zst mingw-w64-x86_64-gcc-libs-13.2.0-6-any.pkg.tar.zst + + - name: Documentation + run: cargo doc --workspace --all-features --no-deps + + - name: Clippy (fail on warnings) + run: cargo clippy --workspace --all-features --all-targets -- -D warnings + + # HACK: how to test both DB backends that are feature-gated? + - name: Test + run: | + cargo test --all-features --workspace + cargo test --package cuprate-blockchain --no-default-features --features redb --features service + + - name: Hack Check + run: | + cargo install cargo-hack --locked + cargo hack --workspace check --feature-powerset --no-dev-deps + + # TODO: upload binaries with `actions/upload-artifact@v3` + - name: Build + run: cargo build --all-features --all-targets --workspace diff --git a/.github/workflows/hack.yml b/.github/workflows/hack.yml deleted file mode 100644 index c474f6ef3..000000000 --- a/.github/workflows/hack.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Hack - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - workflow_dispatch: - -jobs: - hack: - - runs-on: ubuntu-latest - - steps: - - name: Cache - uses: actions/cache@v4 - with: - path: | - ~/.cargo - target - key: ${{ matrix.os }}-hack - - - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Install dependencies - run: | - sudo apt install -y libboost-dev - cargo install cargo-hack --locked - - - name: Hack Check - # TODO: remove the exclude when `cuprate-database` errors are fixed - run: cargo hack --workspace check --feature-powerset --no-dev-deps \ No newline at end of file From 4fe250d13d7e233eed8ce256bd525706da758b52 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Tue, 29 Oct 2024 17:51:36 +0000 Subject: [PATCH 10/17] fix docs --- CONTRIBUTING.md | 167 ++++++++++++++++-------- storage/txpool/README.md | 2 +- storage/txpool/src/service.rs | 6 +- storage/txpool/src/service/interface.rs | 10 +- 4 files changed, 123 insertions(+), 62 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 805073c75..30eccb36e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,32 +1,34 @@ ## Contributing to Cuprate + Thank you for wanting to help out! Cuprate is in the stage where things are likely to change quickly, so it's recommended you ask questions in our public [Matrix room](https://matrix.to/#/#cuprate:monero.social). - [1. Submitting an issue](#1-submitting-an-issue) - - [1.1 Discussion](#11-discussion) - - [1.2 Proposal](#12-proposal) - - [1.3 Tracking issue](#13-tracking-issue) + - [1.1 Discussion](#11-discussion) + - [1.2 Proposal](#12-proposal) + - [1.3 Tracking issue](#13-tracking-issue) - [2. Submitting a pull request](#2-submitting-a-pull-request) - - [2.1 Rust toolchain](#21-rust-toolchain) - - [2.2 Draft PR](#22-draft-pr) - - [2.3 Passing CI](#23-passing-ci) - - [2.4 Ready for review](#24-ready-for-review) + - [2.1 Rust toolchain](#21-rust-toolchain) + - [2.2 Draft PR](#22-draft-pr) + - [2.3 Passing CI](#23-passing-ci) + - [2.4 Ready for review](#24-ready-for-review) - [3. Keeping track of issues and PRs](#3-keeping-track-of-issues-and-prs) - - [3.1 Labels](#31-labels) - - [3.2 Tracking issues](#32-tracking-issues) + - [3.1 Labels](#31-labels) + - [3.2 Tracking issues](#32-tracking-issues) - [4. Coding guidelines](#4-coding-guidelines) - - [4.1 General guidelines](#41-general-guidelines) - - [4.2 Crate names](#42-crate-names) - - [4.3 Pull request title and description](#43-pull-request-title-and-description) + - [4.1 General guidelines](#41-general-guidelines) + - [4.2 Crate names](#42-crate-names) + - [4.3 Pull request title and description](#43-pull-request-title-and-description) - [5. Documentation](#5-documentation) - [6. Books](#6-books) - - [6.1 Architecture book](#61-architecture-book) - - [6.2 Protocol book](#62-protocol-book) - - [6.3 User book](#63-user-book) + - [6.1 Architecture book](#61-architecture-book) + - [6.2 Protocol book](#62-protocol-book) + - [6.3 User book](#63-user-book) ## 1. Submitting an issue + Before starting work, consider opening an issue for discussion. If you have a plan already, you can jump straight into [submitting a pull request](#2-submitting-a-pull-request). @@ -34,49 +36,61 @@ If you have a plan already, you can jump straight into [submitting a pull reques Otherwise, see below for issue types and what they're used for. ### 1.1 Discussion + These are for general discussion on topics that have questions that aren't fully answered yet. -If you would like to discuss a topic and get some feedback, consider [opening a discussion](https://github.com/Cuprate/cuprate/issues/new/choose). +If you would like to discuss a topic and get some feedback, +consider [opening a discussion](https://github.com/Cuprate/cuprate/issues/new/choose). Examples: + - https://github.com/Cuprate/cuprate/issues/40 - https://github.com/Cuprate/cuprate/issues/53 - https://github.com/Cuprate/cuprate/issues/163 ### 1.2 Proposal + These are formal issues that specify changes that are _almost_ ready for implementation. These should answer some basic questions: + - **What** is this proposal for? - **Why** is this proposal needed? - **Where** will this proposal make changes to? - **How** will this proposal be implemented? -If you have a close to fully fleshed out idea, consider [opening a proposal](https://github.com/Cuprate/cuprate/issues/new/choose). +If you have a close to fully fleshed out idea, +consider [opening a proposal](https://github.com/Cuprate/cuprate/issues/new/choose). Opening a PR and writing the proposal in the PR description is also viable. Examples: + - https://github.com/Cuprate/cuprate/pull/146 - https://github.com/Cuprate/cuprate/issues/106 - https://github.com/Cuprate/cuprate/issues/153 - https://github.com/Cuprate/cuprate/issues/181 ### 1.3 Tracking issue + These are meta-issues that track an in-progress implementation. See [`Tracking issues`](#32-tracking-issues) for more info. ## 2. Submitting a pull request + Once you have found something you would like to work on after: + - Discussing an idea on an [issue](#1-submitting-an-issue) - Looking at the [open issues](https://github.com/Cuprate/cuprate/issues) -- Looking at issues with the [`A-help-wanted`](https://github.com/Cuprate/cuprate/issues?q=is%3Aissue+is%3Aopen+label%3AE-help-wanted) label +- Looking at issues with the [ + `A-help-wanted`](https://github.com/Cuprate/cuprate/issues?q=is%3Aissue+is%3Aopen+label%3AE-help-wanted) label - Joining Cuprate's [Matrix room](https://matrix.to/#/#cuprate:monero.social) and asking it is recommended to make your interest on working on that thing known so people don't duplicate work. Before starting, consider reading/using Cuprate's: + - [`Documentation`](#5-documentation) - [`Books`](#6-books) @@ -85,6 +99,7 @@ These may answer some questions you have, or may confirm an issue you would like _Note: Cuprate is currently a work-in-progress; documentation will be changing/unfinished._ ### 2.1 Rust toolchain + Cuprate is written in [Rust](https://rust-lang.org). If you are editing code, you will need Rust's toolchain and package manager, @@ -93,14 +108,19 @@ If you are editing code, you will need Rust's toolchain and package manager, Get started with Rust here: . ### 2.2 Draft PR + Consider opening a draft PR until you have passed all CI. -This is also the stage where you can ask for feedback from others. Keep in mind that feedback may take time especially if the change is large. +This is also the stage where you can ask for feedback from others. Keep in mind that feedback may take time especially +if the change is large. ### 2.3 Passing CI -Each commit pushed in a PR will trigger our [lovely, yet pedantic CI](https://github.com/Cuprate/cuprate/blob/main/.github/workflows/ci.yml). + +Each commit pushed in a PR will trigger +our [lovely, yet pedantic CI](https://github.com/Cuprate/cuprate/blob/main/.github/workflows/ci.yml). It currently: + - Checks code formatting - Checks documentation - Looks for typos @@ -111,76 +131,95 @@ It currently: Before pushing your code, please run the following at the root of the repository: -| Command | Does what | -|-------------------|-----------| -| `cargo fmt --all` | Formats code -| `typos -w` | Fixes typos +| Command | Does what | +|-------------------|--------------| +| `cargo fmt --all` | Formats code +| `typos -w` | Fixes typos `typos` can be installed with `cargo` from: https://github.com/crate-ci/typos. After that, ensure all other CI passes by running: -| Command | Does what | -|--------------------------------------------------------------------------------------------|-----------------------------------------------------------------------| -| `RUSTDOCFLAGS='-D warnings' cargo doc --workspace --all-features` | Checks documentation is OK | -| `cargo clippy --workspace --all-features --all-targets -- -D warnings` | Checks clippy lints are satisfied | -| `cargo test --all-features --workspace` | Runs all tests | -| `cargo build --all-features --all-targets --workspace` | Builds all code | -| `cargo hack --workspace --exclude cuprate-database check --feature-powerset --no-dev-deps` | Uses `cargo hack` to check our crates build with different features set | +| Command | Does what | +|------------------------------------------------------------------------|-------------------------------------------------------------------------| +| `RUSTDOCFLAGS='-D warnings' cargo doc --workspace --all-features` | Checks documentation is OK | +| `cargo clippy --workspace --all-features --all-targets -- -D warnings` | Checks clippy lints are satisfied | +| `cargo test --all-features --workspace` | Runs all tests | +| `cargo build --all-features --all-targets --workspace` | Builds all code | +| `cargo hack --workspace check --feature-powerset --no-dev-deps` | Uses `cargo hack` to check our crates build with different features set | `cargo hack` can be installed with `cargo` from: https://github.com/taiki-e/cargo-hack. -**Note: in order for some tests to work, you will need to place a [`monerod`](https://www.getmonero.org/downloads/) binary at the root of the repository.** +**Note: in order for some tests to work, you will need to place a [`monerod`](https://www.getmonero.org/downloads/) +binary at the root of the repository.** ### 2.4 Ready for review -Once your PR has passed all CI and is ready to go, open it for review. Others will leave their thoughts and may ask for changes to be made. + +Once your PR has passed all CI and is ready to go, open it for review. Others will leave their thoughts and may ask for +changes to be made. Finally, if everything looks good, we will merge your code! Thank you for contributing! ## 3. Keeping track of issues and PRs + The Cuprate GitHub repository has a lot of issues and PRs to keep track of. This section documents tools used to help with this. ### 3.1 Labels + Cuprate makes use of labels grouped by prefixes. -Some labels will be [automatically added/removed](https://github.com/Cuprate/cuprate/tree/main/.github/labeler.yml) if certain file paths have been changed in a PR. +Some labels will be [automatically added/removed](https://github.com/Cuprate/cuprate/tree/main/.github/labeler.yml) if +certain file paths have been changed in a PR. The following section explains the meaning of various labels used. This section is primarily targeted at maintainers. Most contributors aren't able to set these labels. -| Prefix | Description | Example | -|--------------|-------------|---------| -| [A-] | The **area** of the project an issue relates to. | `A-storage`, `A-rpc`, `A-docs` -| [C-] | The **category** of an issue. | `C-cleanup`, `C-optimization` -| [D-] | Issues for **diagnostics**. | `D-confusing`, `D-verbose` -| [E-] | The **experience** level necessary to fix an issue. | `E-easy`, `E-hard` -| [I-] | The **importance** of the issue. | `I-crash`, `I-memory` -| [O-] | The **operating system** or platform that the issue is specific to. | `O-windows`, `O-macos`, `O-linux` -| [P-] | The issue **priority**. These labels can be assigned by anyone that understand the issue and is able to prioritize it, and remove the [I-prioritize] label. | `P-high`, `P-low` +| Prefix | Description | Example | +|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------| +| [A-] | The **area** of the project an issue relates to. | `A-storage`, `A-rpc`, `A-docs` +| [C-] | The **category** of an issue. | `C-cleanup`, `C-optimization` +| [D-] | Issues for **diagnostics**. | `D-confusing`, `D-verbose` +| [E-] | The **experience** level necessary to fix an issue. | `E-easy`, `E-hard` +| [I-] | The **importance** of the issue. | `I-crash`, `I-memory` +| [O-] | The **operating system** or platform that the issue is specific to. | `O-windows`, `O-macos`, `O-linux` +| [P-] | The issue **priority**. These labels can be assigned by anyone that understand the issue and is able to prioritize it, and remove the [I-prioritize] label. | `P-high`, `P-low` [A-]: https://github.com/Cuprate/cuprate/labels?q=A + [C-]: https://github.com/Cuprate/cuprate/labels?q=C + [D-]: https://github.com/Cuprate/cuprate/labels?q=D + [E-]: https://github.com/Cuprate/cuprate/labels?q=E + [I-]: https://github.com/Cuprate/cuprate/labels?q=I + [O-]: https://github.com/Cuprate/cuprate/labels?q=O + [P-]: https://github.com/Cuprate/cuprate/labels?q=P ### 3.2 Tracking issues -If you are working on a larger effort, consider opening a [tracking issue](https://github.com/Cuprate/cuprate/issues/new/choose)! -The main purpose of these are to track efforts that may contain multiple PRs and/or are generally spread out. These don't usually contain the "why", but if they do, they are brief. These contain no implementation details or the how, as those are for the issues/PRs that are being tracked. +If you are working on a larger effort, consider opening +a [tracking issue](https://github.com/Cuprate/cuprate/issues/new/choose)! + +The main purpose of these are to track efforts that may contain multiple PRs and/or are generally spread out. These +don't usually contain the "why", but if they do, they are brief. These contain no implementation details or the how, as +those are for the issues/PRs that are being tracked. Examples: + - https://github.com/Cuprate/cuprate/issues/187 - https://github.com/Cuprate/cuprate/issues/183 ## 4. Coding guidelines + These are some rules that are not mandated by any automation, but contributors generally follow. ### 4.1 General guidelines + General guidelines you should keep these in mind when submitting code: - Separate and sort imports as `core`, `std`, `third-party`, Cuprate crates, current crate @@ -190,9 +229,11 @@ General guidelines you should keep these in mind when submitting code: - Avoid `unsafe` And the most important rule: + - Break any and all of the above rules when it makes sense ### 4.2 Crate names + All of Cuprate's crates (libraries) are prefixed with `cuprate-`. All directories containing crates however, are not. For example: @@ -204,43 +245,61 @@ For example: | `net/wire` | `cuprate-wire` | ### 4.3 Pull request title and description + In general, pull request titles should follow this syntax: + ``` : ``` For example: + ``` books: fix typo ``` -The description of pull requests should generally follow the template laid out in [`.github/pull_request_template.md`](.github/pull_request_template.md). +The description of pull requests should generally follow the template laid out in [ +`.github/pull_request_template.md`](.github/pull_request_template.md). -If your pull request is long and/or has sections that need clarifying, consider leaving a review on your own PR with comments explaining the changes. +If your pull request is long and/or has sections that need clarifying, consider leaving a review on your own PR with +comments explaining the changes. ## 5. Documentation -Cuprate's crates (libraries) have inline documentation, they are published from the `main` branch at https://doc.cuprate.org. -Documentation can be built and viewed using the `cargo` tool. For example, to build and view a specific crate's documentation, run the following command at the repository's root: +Cuprate's crates (libraries) have inline documentation, they are published from the `main` branch +at https://doc.cuprate.org. + +Documentation can be built and viewed using the `cargo` tool. For example, to build and view a specific crate's +documentation, run the following command at the repository's root: + ```bash cargo doc --open --package $CRATE ``` -`$CRATE` can be any package listed in the [root `Cargo.toml`](https://github.com/Cuprate/cuprate/tree/main/Cargo.toml)'s workspace members list, for example, `cuprate-blockchain`. + +`$CRATE` can be any package listed in the [root `Cargo.toml`](https://github.com/Cuprate/cuprate/tree/main/Cargo.toml)'s +workspace members list, for example, `cuprate-blockchain`. You can also build all documentation at once: + ```bash cargo doc ``` -and view by using a web-browser to open the `index.html` file within the build directory: `target/doc/$CRATE/index.html`, for example, `target/doc/cuprate_blockchain/index.html`. + +and view by using a web-browser to open the `index.html` file within the build directory: +`target/doc/$CRATE/index.html`, for example, `target/doc/cuprate_blockchain/index.html`. ## 6. Books -Cuprate has various documentation books whose source files live in [`books/`](https://github.com/Cuprate/cuprate/tree/main/books). -Please contribute if you found a mistake! The files are mostly [markdown](https://wikipedia.org/wiki/Markdown) files and can be easily edited. See the `books/` directory for more information. +Cuprate has various documentation books whose source files live in [ +`books/`](https://github.com/Cuprate/cuprate/tree/main/books). + +Please contribute if you found a mistake! The files are mostly [markdown](https://wikipedia.org/wiki/Markdown) files and +can be easily edited. See the `books/` directory for more information. These books are also good resources to understand how Cuprate and Monero work. ### 6.1 Architecture book + This book documents Cuprate's architecture and implementation. - @@ -248,6 +307,7 @@ This book documents Cuprate's architecture and implementation. - ### 6.2 Protocol book + This book documents the Monero protocol. - @@ -255,6 +315,7 @@ This book documents the Monero protocol. - ### 6.3 User book + This book is a user-guide for using Cuprate. - diff --git a/storage/txpool/README.md b/storage/txpool/README.md index 80d3b25b7..21ffa42c7 100644 --- a/storage/txpool/README.md +++ b/storage/txpool/README.md @@ -15,7 +15,7 @@ This crate does 3 things: 1. Uses [`cuprate_database`] as a base database layer 1. Implements various transaction pool related [operations](ops), [tables], and [types] -1. Exposes a [`tower::Service`] backed by a thread-pool +1. Exposes a `tower::Service` backed by a thread-pool Each layer builds on-top of the previous. diff --git a/storage/txpool/src/service.rs b/storage/txpool/src/service.rs index 91a7060c0..b3140e388 100644 --- a/storage/txpool/src/service.rs +++ b/storage/txpool/src/service.rs @@ -1,7 +1,7 @@ -//! [`tower::Service`] integeration + thread-pool. +//! `tower::Service` integeration + thread-pool. //! //! ## `service` -//! The `service` module implements the [`tower`] integration, +//! The `service` module implements the `tower` integration, //! along with the reader/writer thread-pool system. //! //! The thread-pool allows outside crates to communicate with it by @@ -42,7 +42,7 @@ //! To interact with the database (whether reading or writing data), //! a `Request` can be sent using one of the above handles. //! -//! Both the handles implement `tower::Service`, so they can be [`tower::Service::call`]ed. +//! Both the handles implement `tower::Service`, so they can be `tower::Service::call`ed. //! //! An `async`hronous channel will be returned from the call. //! This channel can be `.await`ed upon to (eventually) receive diff --git a/storage/txpool/src/service/interface.rs b/storage/txpool/src/service/interface.rs index 5cd518f5f..cb2f98c19 100644 --- a/storage/txpool/src/service/interface.rs +++ b/storage/txpool/src/service/interface.rs @@ -1,6 +1,6 @@ //! Tx-pool [`service`](super) interface. //! -//! This module contains `cuprate_txpool`'s [`tower::Service`] request and response enums. +//! This module contains `cuprate_txpool`'s `tower::Service` request and response enums. use std::{ collections::{HashMap, HashSet}, sync::Arc, @@ -14,7 +14,7 @@ use crate::{ }; //---------------------------------------------------------------------------------------------------- TxpoolReadRequest -/// The transaction pool [`tower::Service`] read request type. +/// The transaction pool `tower::Service` read request type. #[derive(Clone)] pub enum TxpoolReadRequest { /// Get the blob (raw bytes) of a transaction with the given hash. @@ -39,7 +39,7 @@ pub enum TxpoolReadRequest { } //---------------------------------------------------------------------------------------------------- TxpoolReadResponse -/// The transaction pool [`tower::Service`] read response type. +/// The transaction pool `service` read response type. #[expect(clippy::large_enum_variant)] pub enum TxpoolReadResponse { /// The response for [`TxpoolReadRequest::TxBlob`]. @@ -78,7 +78,7 @@ pub enum TxpoolReadResponse { } //---------------------------------------------------------------------------------------------------- TxpoolWriteRequest -/// The transaction pool [`tower::Service`] write request type. +/// The transaction pool `service` write request type. #[derive(Clone)] pub enum TxpoolWriteRequest { /// Add a transaction to the pool. @@ -108,7 +108,7 @@ pub enum TxpoolWriteRequest { } //---------------------------------------------------------------------------------------------------- TxpoolWriteResponse -/// The transaction pool [`tower::Service`] write response type. +/// The transaction pool `service` write response type. #[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq)] pub enum TxpoolWriteResponse { /// Response to: From a2fdf94aeda0f22f6f0ba6519e0363d2d16cf565 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Tue, 29 Oct 2024 22:27:57 +0000 Subject: [PATCH 11/17] fix ci formatting --- .github/workflows/ci.yml | 166 +++++++++++++++++++-------------------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 775e15152..151fea593 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,22 +29,22 @@ jobs: fmt: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Format - run: cargo fmt --all --check + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Format + run: cargo fmt --all --check # Run typo checker separately. # This will fast-cancel other CI early if this fails. typo: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Spell Check - uses: crate-ci/typos@master + - name: Checkout + uses: actions/checkout@v4 + - name: Spell Check + uses: crate-ci/typos@master # All other CI. ci: @@ -52,7 +52,7 @@ jobs: strategy: matrix: - os: [ windows-latest, macos-latest, ubuntu-latest ] + os: [windows-latest, macos-latest, ubuntu-latest] include: - os: windows-latest shell: msys2 {0} @@ -71,75 +71,75 @@ jobs: shell: ${{ matrix.shell }} steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Install Rust - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ matrix.rust }} - components: clippy - - - name: Cache - uses: actions/cache@v4 - with: - path: target - key: ${{ matrix.os }} - - - name: Download monerod - uses: ./.github/actions/monerod-download - - # Packages other than `Boost` used by `Monero` are listed here. - # https://github.com/monero-project/monero/blob/c444a7e002036e834bfb4c68f04a121ce1af5825/.github/workflows/build.yml#L71 - - - name: Install dependencies (Linux) - if: matrix.os == 'ubuntu-latest' - run: sudo apt install -y libboost-dev - - - name: Install dependencies (macOS) - if: matrix.os == 'macos-latest' - run: HOMEBREW_NO_AUTO_UPDATE=1 brew install boost - - - name: Install dependencies (Windows) - if: matrix.os == 'windows-latest' - uses: msys2/setup-msys2@v2 - with: - path-type: inherit - update: true - install: mingw-w64-x86_64-toolchain mingw-w64-x86_64-boost msys2-runtime-devel git mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja - - # HACK: 2024-05-14 - # GCC 14+ fails to build `lmdb-master-sys` with no clear error message: - # - # - # - MSYS2 repos carry older versions of packages - # - pacman lets us manually downgrade from package files - # - Note that `gcc` requires `gcc-libs` - - name: Downgrade to GCC 13.2 (Windows) - if: matrix.os == 'windows-latest' - run: | - wget https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-gcc-13.2.0-6-any.pkg.tar.zst https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-gcc-libs-13.2.0-6-any.pkg.tar.zst - pacman -U --noconfirm mingw-w64-x86_64-gcc-13.2.0-6-any.pkg.tar.zst mingw-w64-x86_64-gcc-libs-13.2.0-6-any.pkg.tar.zst - - - name: Documentation - run: cargo doc --workspace --all-features --no-deps - - - name: Clippy (fail on warnings) - run: cargo clippy --workspace --all-features --all-targets -- -D warnings - - # HACK: how to test both DB backends that are feature-gated? - - name: Test - run: | - cargo test --all-features --workspace - cargo test --package cuprate-blockchain --no-default-features --features redb --features service - - - name: Hack Check - run: | - cargo install cargo-hack --locked - cargo hack --workspace check --feature-powerset --no-dev-deps - - # TODO: upload binaries with `actions/upload-artifact@v3` - - name: Build - run: cargo build --all-features --all-targets --workspace + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.rust }} + components: clippy + + - name: Cache + uses: actions/cache@v4 + with: + path: target + key: ${{ matrix.os }} + + - name: Download monerod + uses: ./.github/actions/monerod-download + + # Packages other than `Boost` used by `Monero` are listed here. + # https://github.com/monero-project/monero/blob/c444a7e002036e834bfb4c68f04a121ce1af5825/.github/workflows/build.yml#L71 + + - name: Install dependencies (Linux) + if: matrix.os == 'ubuntu-latest' + run: sudo apt install -y libboost-dev + + - name: Install dependencies (macOS) + if: matrix.os == 'macos-latest' + run: HOMEBREW_NO_AUTO_UPDATE=1 brew install boost + + - name: Install dependencies (Windows) + if: matrix.os == 'windows-latest' + uses: msys2/setup-msys2@v2 + with: + path-type: inherit + update: true + install: mingw-w64-x86_64-toolchain mingw-w64-x86_64-boost msys2-runtime-devel git mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja + + # HACK: 2024-05-14 + # GCC 14+ fails to build `lmdb-master-sys` with no clear error message: + # + # + # - MSYS2 repos carry older versions of packages + # - pacman lets us manually downgrade from package files + # - Note that `gcc` requires `gcc-libs` + - name: Downgrade to GCC 13.2 (Windows) + if: matrix.os == 'windows-latest' + run: | + wget https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-gcc-13.2.0-6-any.pkg.tar.zst https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-gcc-libs-13.2.0-6-any.pkg.tar.zst + pacman -U --noconfirm mingw-w64-x86_64-gcc-13.2.0-6-any.pkg.tar.zst mingw-w64-x86_64-gcc-libs-13.2.0-6-any.pkg.tar.zst + + - name: Documentation + run: cargo doc --workspace --all-features --no-deps + + - name: Clippy (fail on warnings) + run: cargo clippy --workspace --all-features --all-targets -- -D warnings + + # HACK: how to test both DB backends that are feature-gated? + - name: Test + run: | + cargo test --all-features --workspace + cargo test --package cuprate-blockchain --no-default-features --features redb --features service + + - name: Hack Check + run: | + cargo install cargo-hack --locked + cargo hack --workspace check --feature-powerset --no-dev-deps + + # TODO: upload binaries with `actions/upload-artifact@v3` + - name: Build + run: cargo build --all-features --all-targets --workspace From 1d2a90281a5c25a6b5f80b5ba6367575ab1367ee Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Tue, 29 Oct 2024 22:48:55 +0000 Subject: [PATCH 12/17] fix txpool tests --- Cargo.lock | 1 + storage/txpool/Cargo.toml | 1 + storage/txpool/src/lib.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index aa9db1cc0..0f851dcd2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -965,6 +965,7 @@ dependencies = [ "tempfile", "thiserror", "tokio", + "tower 0.5.1", ] [[package]] diff --git a/storage/txpool/Cargo.toml b/storage/txpool/Cargo.toml index 69411feb6..f63687c22 100644 --- a/storage/txpool/Cargo.toml +++ b/storage/txpool/Cargo.toml @@ -38,6 +38,7 @@ serde = { workspace = true, optional = true } cuprate-test-utils = { workspace = true } tokio = { workspace = true } +tower = { workspace = true } tempfile = { workspace = true } hex-literal = { workspace = true } diff --git a/storage/txpool/src/lib.rs b/storage/txpool/src/lib.rs index ad535b0a4..dd2234646 100644 --- a/storage/txpool/src/lib.rs +++ b/storage/txpool/src/lib.rs @@ -25,4 +25,5 @@ mod test { use hex_literal as _; use tempfile as _; use tokio as _; + use tower as _; } From 62331b76c8f0cf7aaa6163b94e9ff904f1213fdb Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Wed, 30 Oct 2024 00:08:31 +0000 Subject: [PATCH 13/17] fix CONTRIBUTING.md formatting --- CONTRIBUTING.md | 155 +++++++++++++++--------------------------------- 1 file changed, 47 insertions(+), 108 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 30eccb36e..2d990601d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,34 +1,32 @@ ## Contributing to Cuprate - Thank you for wanting to help out! Cuprate is in the stage where things are likely to change quickly, so it's recommended you ask questions in our public [Matrix room](https://matrix.to/#/#cuprate:monero.social). - [1. Submitting an issue](#1-submitting-an-issue) - - [1.1 Discussion](#11-discussion) - - [1.2 Proposal](#12-proposal) - - [1.3 Tracking issue](#13-tracking-issue) + - [1.1 Discussion](#11-discussion) + - [1.2 Proposal](#12-proposal) + - [1.3 Tracking issue](#13-tracking-issue) - [2. Submitting a pull request](#2-submitting-a-pull-request) - - [2.1 Rust toolchain](#21-rust-toolchain) - - [2.2 Draft PR](#22-draft-pr) - - [2.3 Passing CI](#23-passing-ci) - - [2.4 Ready for review](#24-ready-for-review) + - [2.1 Rust toolchain](#21-rust-toolchain) + - [2.2 Draft PR](#22-draft-pr) + - [2.3 Passing CI](#23-passing-ci) + - [2.4 Ready for review](#24-ready-for-review) - [3. Keeping track of issues and PRs](#3-keeping-track-of-issues-and-prs) - - [3.1 Labels](#31-labels) - - [3.2 Tracking issues](#32-tracking-issues) + - [3.1 Labels](#31-labels) + - [3.2 Tracking issues](#32-tracking-issues) - [4. Coding guidelines](#4-coding-guidelines) - - [4.1 General guidelines](#41-general-guidelines) - - [4.2 Crate names](#42-crate-names) - - [4.3 Pull request title and description](#43-pull-request-title-and-description) + - [4.1 General guidelines](#41-general-guidelines) + - [4.2 Crate names](#42-crate-names) + - [4.3 Pull request title and description](#43-pull-request-title-and-description) - [5. Documentation](#5-documentation) - [6. Books](#6-books) - - [6.1 Architecture book](#61-architecture-book) - - [6.2 Protocol book](#62-protocol-book) - - [6.3 User book](#63-user-book) + - [6.1 Architecture book](#61-architecture-book) + - [6.2 Protocol book](#62-protocol-book) + - [6.3 User book](#63-user-book) ## 1. Submitting an issue - Before starting work, consider opening an issue for discussion. If you have a plan already, you can jump straight into [submitting a pull request](#2-submitting-a-pull-request). @@ -36,61 +34,49 @@ If you have a plan already, you can jump straight into [submitting a pull reques Otherwise, see below for issue types and what they're used for. ### 1.1 Discussion - These are for general discussion on topics that have questions that aren't fully answered yet. -If you would like to discuss a topic and get some feedback, -consider [opening a discussion](https://github.com/Cuprate/cuprate/issues/new/choose). +If you would like to discuss a topic and get some feedback, consider [opening a discussion](https://github.com/Cuprate/cuprate/issues/new/choose). Examples: - - https://github.com/Cuprate/cuprate/issues/40 - https://github.com/Cuprate/cuprate/issues/53 - https://github.com/Cuprate/cuprate/issues/163 ### 1.2 Proposal - These are formal issues that specify changes that are _almost_ ready for implementation. These should answer some basic questions: - - **What** is this proposal for? - **Why** is this proposal needed? - **Where** will this proposal make changes to? - **How** will this proposal be implemented? -If you have a close to fully fleshed out idea, -consider [opening a proposal](https://github.com/Cuprate/cuprate/issues/new/choose). +If you have a close to fully fleshed out idea, consider [opening a proposal](https://github.com/Cuprate/cuprate/issues/new/choose). Opening a PR and writing the proposal in the PR description is also viable. Examples: - - https://github.com/Cuprate/cuprate/pull/146 - https://github.com/Cuprate/cuprate/issues/106 - https://github.com/Cuprate/cuprate/issues/153 - https://github.com/Cuprate/cuprate/issues/181 ### 1.3 Tracking issue - These are meta-issues that track an in-progress implementation. See [`Tracking issues`](#32-tracking-issues) for more info. ## 2. Submitting a pull request - Once you have found something you would like to work on after: - - Discussing an idea on an [issue](#1-submitting-an-issue) - Looking at the [open issues](https://github.com/Cuprate/cuprate/issues) -- Looking at issues with the [ - `A-help-wanted`](https://github.com/Cuprate/cuprate/issues?q=is%3Aissue+is%3Aopen+label%3AE-help-wanted) label +- Looking at issues with the [`A-help-wanted`](https://github.com/Cuprate/cuprate/issues?q=is%3Aissue+is%3Aopen+label%3AE-help-wanted) label - Joining Cuprate's [Matrix room](https://matrix.to/#/#cuprate:monero.social) and asking it is recommended to make your interest on working on that thing known so people don't duplicate work. Before starting, consider reading/using Cuprate's: - - [`Documentation`](#5-documentation) - [`Books`](#6-books) @@ -99,7 +85,6 @@ These may answer some questions you have, or may confirm an issue you would like _Note: Cuprate is currently a work-in-progress; documentation will be changing/unfinished._ ### 2.1 Rust toolchain - Cuprate is written in [Rust](https://rust-lang.org). If you are editing code, you will need Rust's toolchain and package manager, @@ -108,33 +93,28 @@ If you are editing code, you will need Rust's toolchain and package manager, Get started with Rust here: . ### 2.2 Draft PR - Consider opening a draft PR until you have passed all CI. -This is also the stage where you can ask for feedback from others. Keep in mind that feedback may take time especially -if the change is large. +This is also the stage where you can ask for feedback from others. Keep in mind that feedback may take time especially if the change is large. ### 2.3 Passing CI - -Each commit pushed in a PR will trigger -our [lovely, yet pedantic CI](https://github.com/Cuprate/cuprate/blob/main/.github/workflows/ci.yml). +Each commit pushed in a PR will trigger our [lovely, yet pedantic CI](https://github.com/Cuprate/cuprate/blob/main/.github/workflows/ci.yml). It currently: - - Checks code formatting - Checks documentation - Looks for typos - Runs [`clippy`](https://github.com/rust-lang/rust-clippy) (and fails on warnings) - Runs all tests - Builds all targets -- Automatically adds appropriate [labels](#31-labels) to your PR +- Automatically adds approriate [labels](#31-labels) to your PR Before pushing your code, please run the following at the root of the repository: -| Command | Does what | -|-------------------|--------------| -| `cargo fmt --all` | Formats code -| `typos -w` | Fixes typos +| Command | Does what | +|-------------------|-----------| +| `cargo fmt --all` | Formats code +| `typos -w` | Fixes typos `typos` can be installed with `cargo` from: https://github.com/crate-ci/typos. @@ -150,76 +130,57 @@ After that, ensure all other CI passes by running: `cargo hack` can be installed with `cargo` from: https://github.com/taiki-e/cargo-hack. -**Note: in order for some tests to work, you will need to place a [`monerod`](https://www.getmonero.org/downloads/) -binary at the root of the repository.** +**Note: in order for some tests to work, you will need to place a [`monerod`](https://www.getmonero.org/downloads/) binary at the root of the repository.** ### 2.4 Ready for review - -Once your PR has passed all CI and is ready to go, open it for review. Others will leave their thoughts and may ask for -changes to be made. +Once your PR has passed all CI and is ready to go, open it for review. Others will leave their thoughts and may ask for changes to be made. Finally, if everything looks good, we will merge your code! Thank you for contributing! ## 3. Keeping track of issues and PRs - The Cuprate GitHub repository has a lot of issues and PRs to keep track of. This section documents tools used to help with this. ### 3.1 Labels - Cuprate makes use of labels grouped by prefixes. -Some labels will be [automatically added/removed](https://github.com/Cuprate/cuprate/tree/main/.github/labeler.yml) if -certain file paths have been changed in a PR. +Some labels will be [automatically added/removed](https://github.com/Cuprate/cuprate/tree/main/.github/labeler.yml) if certain file paths have been changed in a PR. The following section explains the meaning of various labels used. This section is primarily targeted at maintainers. Most contributors aren't able to set these labels. -| Prefix | Description | Example | -|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------| -| [A-] | The **area** of the project an issue relates to. | `A-storage`, `A-rpc`, `A-docs` -| [C-] | The **category** of an issue. | `C-cleanup`, `C-optimization` -| [D-] | Issues for **diagnostics**. | `D-confusing`, `D-verbose` -| [E-] | The **experience** level necessary to fix an issue. | `E-easy`, `E-hard` -| [I-] | The **importance** of the issue. | `I-crash`, `I-memory` -| [O-] | The **operating system** or platform that the issue is specific to. | `O-windows`, `O-macos`, `O-linux` -| [P-] | The issue **priority**. These labels can be assigned by anyone that understand the issue and is able to prioritize it, and remove the [I-prioritize] label. | `P-high`, `P-low` +| Prefix | Description | Example | +|--------------|-------------|---------| +| [A-] | The **area** of the project an issue relates to. | `A-storage`, `A-rpc`, `A-docs` +| [C-] | The **category** of an issue. | `C-cleanup`, `C-optimization` +| [D-] | Issues for **diagnostics**. | `D-confusing`, `D-verbose` +| [E-] | The **experience** level necessary to fix an issue. | `E-easy`, `E-hard` +| [I-] | The **importance** of the issue. | `I-crash`, `I-memory` +| [O-] | The **operating system** or platform that the issue is specific to. | `O-windows`, `O-macos`, `O-linux` +| [P-] | The issue **priority**. These labels can be assigned by anyone that understand the issue and is able to prioritize it, and remove the [I-prioritize] label. | `P-high`, `P-low` [A-]: https://github.com/Cuprate/cuprate/labels?q=A - [C-]: https://github.com/Cuprate/cuprate/labels?q=C - [D-]: https://github.com/Cuprate/cuprate/labels?q=D - [E-]: https://github.com/Cuprate/cuprate/labels?q=E - [I-]: https://github.com/Cuprate/cuprate/labels?q=I - [O-]: https://github.com/Cuprate/cuprate/labels?q=O - [P-]: https://github.com/Cuprate/cuprate/labels?q=P ### 3.2 Tracking issues +If you are working on a larger effort, consider opening a [tracking issue](https://github.com/Cuprate/cuprate/issues/new/choose)! -If you are working on a larger effort, consider opening -a [tracking issue](https://github.com/Cuprate/cuprate/issues/new/choose)! - -The main purpose of these are to track efforts that may contain multiple PRs and/or are generally spread out. These -don't usually contain the "why", but if they do, they are brief. These contain no implementation details or the how, as -those are for the issues/PRs that are being tracked. +The main purpose of these are to track efforts that may contain multiple PRs and/or are generally spread out. These don't usually contain the "why", but if they do, they are brief. These contain no implementation details or the how, as those are for the issues/PRs that are being tracked. Examples: - - https://github.com/Cuprate/cuprate/issues/187 - https://github.com/Cuprate/cuprate/issues/183 ## 4. Coding guidelines - These are some rules that are not mandated by any automation, but contributors generally follow. ### 4.1 General guidelines - General guidelines you should keep these in mind when submitting code: - Separate and sort imports as `core`, `std`, `third-party`, Cuprate crates, current crate @@ -229,11 +190,9 @@ General guidelines you should keep these in mind when submitting code: - Avoid `unsafe` And the most important rule: - - Break any and all of the above rules when it makes sense ### 4.2 Crate names - All of Cuprate's crates (libraries) are prefixed with `cuprate-`. All directories containing crates however, are not. For example: @@ -245,61 +204,43 @@ For example: | `net/wire` | `cuprate-wire` | ### 4.3 Pull request title and description - In general, pull request titles should follow this syntax: - ``` : ``` For example: - ``` books: fix typo ``` -The description of pull requests should generally follow the template laid out in [ -`.github/pull_request_template.md`](.github/pull_request_template.md). +The description of pull requests should generally follow the template laid out in [`.github/pull_request_template.md`](.github/pull_request_template.md). -If your pull request is long and/or has sections that need clarifying, consider leaving a review on your own PR with -comments explaining the changes. +If your pull request is long and/or has sections that need clarifying, consider leaving a review on your own PR with comments explaining the changes. ## 5. Documentation +Cuprate's crates (libraries) have inline documentation, they are published from the `main` branch at https://doc.cuprate.org. -Cuprate's crates (libraries) have inline documentation, they are published from the `main` branch -at https://doc.cuprate.org. - -Documentation can be built and viewed using the `cargo` tool. For example, to build and view a specific crate's -documentation, run the following command at the repository's root: - +Documentation can be built and viewed using the `cargo` tool. For example, to build and view a specific crate's documentation, run the following command at the repository's root: ```bash cargo doc --open --package $CRATE ``` - -`$CRATE` can be any package listed in the [root `Cargo.toml`](https://github.com/Cuprate/cuprate/tree/main/Cargo.toml)'s -workspace members list, for example, `cuprate-blockchain`. +`$CRATE` can be any package listed in the [root `Cargo.toml`](https://github.com/Cuprate/cuprate/tree/main/Cargo.toml)'s workspace members list, for example, `cuprate-blockchain`. You can also build all documentation at once: - ```bash cargo doc ``` - -and view by using a web-browser to open the `index.html` file within the build directory: -`target/doc/$CRATE/index.html`, for example, `target/doc/cuprate_blockchain/index.html`. +and view by using a web-browser to open the `index.html` file within the build directory: `target/doc/$CRATE/index.html`, for example, `target/doc/cuprate_blockchain/index.html`. ## 6. Books +Cuprate has various documentation books whose source files live in [`books/`](https://github.com/Cuprate/cuprate/tree/main/books). -Cuprate has various documentation books whose source files live in [ -`books/`](https://github.com/Cuprate/cuprate/tree/main/books). - -Please contribute if you found a mistake! The files are mostly [markdown](https://wikipedia.org/wiki/Markdown) files and -can be easily edited. See the `books/` directory for more information. +Please contribute if you found a mistake! The files are mostly [markdown](https://wikipedia.org/wiki/Markdown) files and can be easily edited. See the `books/` directory for more information. These books are also good resources to understand how Cuprate and Monero work. ### 6.1 Architecture book - This book documents Cuprate's architecture and implementation. - @@ -307,7 +248,6 @@ This book documents Cuprate's architecture and implementation. - ### 6.2 Protocol book - This book documents the Monero protocol. - @@ -315,7 +255,6 @@ This book documents the Monero protocol. - ### 6.3 User book - This book is a user-guide for using Cuprate. - From defef01dce7e36a63238e863cba47386f28a741f Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Wed, 30 Oct 2024 00:10:01 +0000 Subject: [PATCH 14/17] service -> tower::Service --- storage/txpool/src/service/interface.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/storage/txpool/src/service/interface.rs b/storage/txpool/src/service/interface.rs index cb2f98c19..b8f1a017b 100644 --- a/storage/txpool/src/service/interface.rs +++ b/storage/txpool/src/service/interface.rs @@ -39,7 +39,7 @@ pub enum TxpoolReadRequest { } //---------------------------------------------------------------------------------------------------- TxpoolReadResponse -/// The transaction pool `service` read response type. +/// The transaction pool `tower::Service` read response type. #[expect(clippy::large_enum_variant)] pub enum TxpoolReadResponse { /// The response for [`TxpoolReadRequest::TxBlob`]. @@ -78,7 +78,7 @@ pub enum TxpoolReadResponse { } //---------------------------------------------------------------------------------------------------- TxpoolWriteRequest -/// The transaction pool `service` write request type. +/// The transaction pool `tower::Service` write request type. #[derive(Clone)] pub enum TxpoolWriteRequest { /// Add a transaction to the pool. @@ -108,7 +108,7 @@ pub enum TxpoolWriteRequest { } //---------------------------------------------------------------------------------------------------- TxpoolWriteResponse -/// The transaction pool `service` write response type. +/// The transaction pool `tower::Service` write response type. #[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq)] pub enum TxpoolWriteResponse { /// Response to: From 6470c160da21a5f6f102f7db9ee0f31b59088105 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 1 Nov 2024 00:51:08 +0000 Subject: [PATCH 15/17] review fixes --- rpc/types/src/bin.rs | 38 +++++++++---------------- storage/txpool/Cargo.toml | 2 +- storage/txpool/README.md | 2 +- storage/txpool/src/lib.rs | 3 +- storage/txpool/src/service.rs | 6 ++-- storage/txpool/src/service/interface.rs | 10 +++---- 6 files changed, 26 insertions(+), 35 deletions(-) diff --git a/rpc/types/src/bin.rs b/rpc/types/src/bin.rs index 9e697b8a0..7b9419185 100644 --- a/rpc/types/src/bin.rs +++ b/rpc/types/src/bin.rs @@ -27,6 +27,8 @@ use crate::{ #[cfg(any(feature = "epee", feature = "serde"))] use crate::defaults::{default_false, default_zero}; +#[cfg(feature = "epee")] +use crate::misc::PoolInfoExtent; //---------------------------------------------------------------------------------------------------- Definitions define_request_and_response! { @@ -139,15 +141,15 @@ define_request! { core_rpc_server_commands_defs, h, 162, 262, )] /// -/// This response's variant depends upon [`crate::misc::PoolInfoExtent`]. +/// This response's variant depends upon [`PoolInfoExtent`]. #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum GetBlocksResponse { - /// Will always serialize a [`crate::misc::PoolInfoExtent::None`] field. + /// Will always serialize a [`PoolInfoExtent::None`] field. PoolInfoNone(GetBlocksResponsePoolInfoNone), - /// Will always serialize a [`crate::misc::PoolInfoExtent::Incremental`] field. + /// Will always serialize a [`PoolInfoExtent::Incremental`] field. PoolInfoIncremental(GetBlocksResponsePoolInfoIncremental), - /// Will always serialize a [`crate::misc::PoolInfoExtent::Full`] field. + /// Will always serialize a [`PoolInfoExtent::Full`] field. PoolInfoFull(GetBlocksResponsePoolInfoFull), } @@ -256,7 +258,7 @@ pub struct __GetBlocksResponseEpeeBuilder { pub current_height: Option, pub output_indices: Option>, pub daemon_time: Option, - pub pool_info_extent: Option, + pub pool_info_extent: Option, pub added_pool_txs: Option>, pub remaining_added_pool_txids: Option>, pub removed_pool_txids: Option>, @@ -306,7 +308,7 @@ impl EpeeObjectBuilder for __GetBlocksResponseEpeeBuilder { let pool_info_extent = self.pool_info_extent.ok_or(ELSE)?; let this = match pool_info_extent { - crate::misc::PoolInfoExtent::None => { + PoolInfoExtent::None => { GetBlocksResponse::PoolInfoNone(GetBlocksResponsePoolInfoNone { status, untrusted, @@ -317,7 +319,7 @@ impl EpeeObjectBuilder for __GetBlocksResponseEpeeBuilder { daemon_time, }) } - crate::misc::PoolInfoExtent::Incremental => { + PoolInfoExtent::Incremental => { GetBlocksResponse::PoolInfoIncremental(GetBlocksResponsePoolInfoIncremental { status, untrusted, @@ -331,7 +333,7 @@ impl EpeeObjectBuilder for __GetBlocksResponseEpeeBuilder { removed_pool_txids: self.removed_pool_txids.ok_or(ELSE)?, }) } - crate::misc::PoolInfoExtent::Full => { + PoolInfoExtent::Full => { GetBlocksResponse::PoolInfoFull(GetBlocksResponsePoolInfoFull { status, untrusted, @@ -355,7 +357,7 @@ impl EpeeObject for GetBlocksResponse { type Builder = __GetBlocksResponseEpeeBuilder; fn number_of_fields(&self) -> u64 { - // [`crate::misc::PoolInfoExtent`] + inner struct fields. + // [`PoolInfoExtent`] + inner struct fields. let inner_fields = match self { Self::PoolInfoNone(s) => s.number_of_fields(), Self::PoolInfoIncremental(s) => s.number_of_fields(), @@ -369,27 +371,15 @@ impl EpeeObject for GetBlocksResponse { match self { Self::PoolInfoNone(s) => { s.write_fields(w)?; - write_field( - crate::misc::PoolInfoExtent::None.to_u8(), - "pool_info_extent", - w, - )?; + write_field(PoolInfoExtent::None.to_u8(), "pool_info_extent", w)?; } Self::PoolInfoIncremental(s) => { s.write_fields(w)?; - write_field( - crate::misc::PoolInfoExtent::Incremental.to_u8(), - "pool_info_extent", - w, - )?; + write_field(PoolInfoExtent::Incremental.to_u8(), "pool_info_extent", w)?; } Self::PoolInfoFull(s) => { s.write_fields(w)?; - write_field( - crate::misc::PoolInfoExtent::Full.to_u8(), - "pool_info_extent", - w, - )?; + write_field(PoolInfoExtent::Full.to_u8(), "pool_info_extent", w)?; } } diff --git a/storage/txpool/Cargo.toml b/storage/txpool/Cargo.toml index f63687c22..c90826557 100644 --- a/storage/txpool/Cargo.toml +++ b/storage/txpool/Cargo.toml @@ -30,6 +30,7 @@ thiserror = { workspace = true } hex = { workspace = true, features = ["std"] } blake3 = { workspace = true, features = ["std"] } +tower = { workspace = true } rayon = { workspace = true } serde = { workspace = true, optional = true } @@ -38,7 +39,6 @@ serde = { workspace = true, optional = true } cuprate-test-utils = { workspace = true } tokio = { workspace = true } -tower = { workspace = true } tempfile = { workspace = true } hex-literal = { workspace = true } diff --git a/storage/txpool/README.md b/storage/txpool/README.md index 21ffa42c7..80d3b25b7 100644 --- a/storage/txpool/README.md +++ b/storage/txpool/README.md @@ -15,7 +15,7 @@ This crate does 3 things: 1. Uses [`cuprate_database`] as a base database layer 1. Implements various transaction pool related [operations](ops), [tables], and [types] -1. Exposes a `tower::Service` backed by a thread-pool +1. Exposes a [`tower::Service`] backed by a thread-pool Each layer builds on-top of the previous. diff --git a/storage/txpool/src/lib.rs b/storage/txpool/src/lib.rs index dd2234646..8b433b00b 100644 --- a/storage/txpool/src/lib.rs +++ b/storage/txpool/src/lib.rs @@ -4,6 +4,8 @@ clippy::significant_drop_tightening )] +use tower as _; + pub mod config; mod free; pub mod ops; @@ -25,5 +27,4 @@ mod test { use hex_literal as _; use tempfile as _; use tokio as _; - use tower as _; } diff --git a/storage/txpool/src/service.rs b/storage/txpool/src/service.rs index b3140e388..4ae238a42 100644 --- a/storage/txpool/src/service.rs +++ b/storage/txpool/src/service.rs @@ -1,7 +1,7 @@ -//! `tower::Service` integeration + thread-pool. +//! [`tower::Service`] integeration + thread-pool. //! //! ## `service` -//! The `service` module implements the `tower` integration, +//! The `service` module implements the [`tower`] integration, //! along with the reader/writer thread-pool system. //! //! The thread-pool allows outside crates to communicate with it by @@ -42,7 +42,7 @@ //! To interact with the database (whether reading or writing data), //! a `Request` can be sent using one of the above handles. //! -//! Both the handles implement `tower::Service`, so they can be `tower::Service::call`ed. +//! Both the handles implement [`tower::Service`], so they can be [`tower::Service::call`]ed. //! //! An `async`hronous channel will be returned from the call. //! This channel can be `.await`ed upon to (eventually) receive diff --git a/storage/txpool/src/service/interface.rs b/storage/txpool/src/service/interface.rs index b8f1a017b..5cd518f5f 100644 --- a/storage/txpool/src/service/interface.rs +++ b/storage/txpool/src/service/interface.rs @@ -1,6 +1,6 @@ //! Tx-pool [`service`](super) interface. //! -//! This module contains `cuprate_txpool`'s `tower::Service` request and response enums. +//! This module contains `cuprate_txpool`'s [`tower::Service`] request and response enums. use std::{ collections::{HashMap, HashSet}, sync::Arc, @@ -14,7 +14,7 @@ use crate::{ }; //---------------------------------------------------------------------------------------------------- TxpoolReadRequest -/// The transaction pool `tower::Service` read request type. +/// The transaction pool [`tower::Service`] read request type. #[derive(Clone)] pub enum TxpoolReadRequest { /// Get the blob (raw bytes) of a transaction with the given hash. @@ -39,7 +39,7 @@ pub enum TxpoolReadRequest { } //---------------------------------------------------------------------------------------------------- TxpoolReadResponse -/// The transaction pool `tower::Service` read response type. +/// The transaction pool [`tower::Service`] read response type. #[expect(clippy::large_enum_variant)] pub enum TxpoolReadResponse { /// The response for [`TxpoolReadRequest::TxBlob`]. @@ -78,7 +78,7 @@ pub enum TxpoolReadResponse { } //---------------------------------------------------------------------------------------------------- TxpoolWriteRequest -/// The transaction pool `tower::Service` write request type. +/// The transaction pool [`tower::Service`] write request type. #[derive(Clone)] pub enum TxpoolWriteRequest { /// Add a transaction to the pool. @@ -108,7 +108,7 @@ pub enum TxpoolWriteRequest { } //---------------------------------------------------------------------------------------------------- TxpoolWriteResponse -/// The transaction pool `tower::Service` write response type. +/// The transaction pool [`tower::Service`] write response type. #[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq)] pub enum TxpoolWriteResponse { /// Response to: From b91577780b92a8761dc3ccb61d94dce0315ed527 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 1 Nov 2024 14:50:27 +0000 Subject: [PATCH 16/17] review fixes --- binaries/cuprated/Cargo.toml | 2 +- consensus/fast-sync/Cargo.toml | 2 +- storage/blockchain/Cargo.toml | 14 ++++++-------- storage/blockchain/README.md | 5 +---- storage/blockchain/src/lib.rs | 6 +----- storage/blockchain/src/service/mod.rs | 2 -- storage/txpool/README.md | 4 ---- storage/txpool/src/lib.rs | 1 + storage/txpool/src/service.rs | 2 -- 9 files changed, 11 insertions(+), 27 deletions(-) diff --git a/binaries/cuprated/Cargo.toml b/binaries/cuprated/Cargo.toml index 880c2054f..d59b4c30f 100644 --- a/binaries/cuprated/Cargo.toml +++ b/binaries/cuprated/Cargo.toml @@ -24,7 +24,7 @@ cuprate-p2p-core = { workspace = true } cuprate-dandelion-tower = { workspace = true, features = ["txpool"] } cuprate-async-buffer = { workspace = true } cuprate-address-book = { workspace = true } -cuprate-blockchain = { workspace = true, features = ["service"] } +cuprate-blockchain = { workspace = true } cuprate-database-service = { workspace = true } cuprate-txpool = { workspace = true } cuprate-database = { workspace = true } diff --git a/consensus/fast-sync/Cargo.toml b/consensus/fast-sync/Cargo.toml index 2836dbc32..8e732a6fc 100644 --- a/consensus/fast-sync/Cargo.toml +++ b/consensus/fast-sync/Cargo.toml @@ -9,7 +9,7 @@ name = "cuprate-fast-sync-create-hashes" path = "src/create.rs" [dependencies] -cuprate-blockchain = { workspace = true, features = ["service"] } +cuprate-blockchain = { workspace = true } cuprate-consensus = { workspace = true } cuprate-consensus-rules = { workspace = true } cuprate-consensus-context = { workspace = true } diff --git a/storage/blockchain/Cargo.toml b/storage/blockchain/Cargo.toml index 28047e0f2..6fd973cd6 100644 --- a/storage/blockchain/Cargo.toml +++ b/storage/blockchain/Cargo.toml @@ -9,33 +9,31 @@ repository = "https://github.com/Cuprate/cuprate/tree/main/storage/cuprate-bloc keywords = ["cuprate", "blockchain", "database"] [features] -default = ["heed", "service"] +default = ["heed"] # default = ["redb", "service"] # default = ["redb-memory", "service"] heed = ["cuprate-database/heed"] redb = ["cuprate-database/redb"] redb-memory = ["cuprate-database/redb-memory"] -service = ["dep:tower", "dep:thread_local", "dep:rayon", "dep:rand", "cuprate-helper/thread"] serde = ["dep:serde", "cuprate-database/serde", "cuprate-database-service/serde"] [dependencies] cuprate-database = { workspace = true } cuprate-database-service = { workspace = true } -cuprate-helper = { workspace = true, features = ["fs", "map", "crypto", "tx"] } +cuprate-helper = { workspace = true, features = ["fs", "map", "crypto", "tx", "thread"] } cuprate-types = { workspace = true, features = ["blockchain"] } cuprate-pruning = { workspace = true } bitflags = { workspace = true, features = ["std", "serde", "bytemuck"] } bytemuck = { workspace = true, features = ["must_cast", "derive", "min_const_generics", "extern_crate_alloc"] } curve25519-dalek = { workspace = true } -rand = { workspace = true, features = ["std", "std_rng"], optional = true } +rand = { workspace = true, features = ["std", "std_rng"] } monero-serai = { workspace = true, features = ["std"] } serde = { workspace = true, optional = true } -# `service` feature. -tower = { workspace = true, optional = true } -thread_local = { workspace = true, optional = true } -rayon = { workspace = true, optional = true } +tower = { workspace = true } +thread_local = { workspace = true } +rayon = { workspace = true } [dev-dependencies] cuprate-constants = { workspace = true } diff --git a/storage/blockchain/README.md b/storage/blockchain/README.md index 480054696..3f97a3d63 100644 --- a/storage/blockchain/README.md +++ b/storage/blockchain/README.md @@ -32,9 +32,6 @@ use cuprate_blockchain::{ This ensures the types/traits used from `cuprate_database` are the same ones used by `cuprate_blockchain` internally. # Feature flags -The `service` module requires the `service` feature to be enabled. -See the module for more documentation. - Different database backends are enabled by the feature flags: - `heed` (LMDB) - `redb` @@ -45,7 +42,7 @@ The default is `heed`. # Invariants when not using `service` -`cuprate_blockchain` can be used without the `service` feature enabled but +`cuprate_blockchain` can be used without the `service` module but there are some things that must be kept in mind when doing so. Failing to uphold these invariants may cause panics. diff --git a/storage/blockchain/src/lib.rs b/storage/blockchain/src/lib.rs index f66cd99b9..7db8cc6ee 100644 --- a/storage/blockchain/src/lib.rs +++ b/storage/blockchain/src/lib.rs @@ -29,16 +29,12 @@ pub use free::open; pub mod config; pub mod ops; +pub mod service; pub mod tables; pub mod types; -//---------------------------------------------------------------------------------------------------- Feature-gated -#[cfg(feature = "service")] -pub mod service; - //---------------------------------------------------------------------------------------------------- Private #[cfg(test)] pub(crate) mod tests; -#[cfg(feature = "service")] // only needed in `service` for now pub(crate) mod unsafe_sendable; diff --git a/storage/blockchain/src/service/mod.rs b/storage/blockchain/src/service/mod.rs index 53bf1dfa3..c5eb80c2e 100644 --- a/storage/blockchain/src/service/mod.rs +++ b/storage/blockchain/src/service/mod.rs @@ -10,8 +10,6 @@ //! //! The system is managed by this crate, and only requires [`init`] by the user. //! -//! This module must be enabled with the `service` feature. -//! //! ## Handles //! The 2 handles to the database are: //! - [`BlockchainReadHandle`] diff --git a/storage/txpool/README.md b/storage/txpool/README.md index 80d3b25b7..d14f445bc 100644 --- a/storage/txpool/README.md +++ b/storage/txpool/README.md @@ -37,10 +37,6 @@ use cuprate_txpool::{ This ensures the types/traits used from `cuprate_database` are the same ones used by `cuprate_txpool` internally. # Feature flags - -The `service` module requires the `service` feature to be enabled. -See the module for more documentation. - Different database backends are enabled by the feature flags: - `heed` (LMDB) diff --git a/storage/txpool/src/lib.rs b/storage/txpool/src/lib.rs index 8b433b00b..53e53ecfe 100644 --- a/storage/txpool/src/lib.rs +++ b/storage/txpool/src/lib.rs @@ -4,6 +4,7 @@ clippy::significant_drop_tightening )] +// Used in docs: . use tower as _; pub mod config; diff --git a/storage/txpool/src/service.rs b/storage/txpool/src/service.rs index 4ae238a42..a82de5bf4 100644 --- a/storage/txpool/src/service.rs +++ b/storage/txpool/src/service.rs @@ -10,8 +10,6 @@ //! //! The system is managed by this crate, and only requires [`init`] by the user. //! -//! This module must be enabled with the `service` feature. -//! //! ## Handles //! The 2 handles to the database are: //! - [`TxpoolReadHandle`] From b4c0cc530957f8a82a96bd7cb92c06f84041360e Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Fri, 1 Nov 2024 19:53:47 +0000 Subject: [PATCH 17/17] fix CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 151fea593..367e8e14d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -133,7 +133,7 @@ jobs: - name: Test run: | cargo test --all-features --workspace - cargo test --package cuprate-blockchain --no-default-features --features redb --features service + cargo test --package cuprate-blockchain --no-default-features --features redb - name: Hack Check run: |