Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 109 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ env:
RUSTDOCFLAGS: '-D warnings'
# Enable debug information generation for build dependencies.
CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG: true
# Build commands.
CMD_DOC: cargo doc --all-features --no-deps
CMD_CLIPPY: cargo clippy --all-features --all-targets -- -D warnings
CMD_TEST: |
# HACK: how to test both DB backends that are feature-gated?
cargo test --all-features
cargo test --package cuprate-blockchain --no-default-features --features redb
CMD_TEST_CLI: cargo run --package cuprate-test-cli
CMD_TEST_RPC: cargo run --release --package cuprate-test-rpc
CMD_BUILD: cargo build --all-features --all-targets
CMD_HACK: |
cargo install cargo-hack --locked
cargo hack check --feature-powerset --no-dev-deps

jobs:
# Run format separately.
Expand Down Expand Up @@ -78,7 +91,7 @@ jobs:
- name: Build WASM 32-bit
run: cargo build --target wasm32-unknown-unknown -p ${{ matrix.crate }}

# All other CI.
# CI, runs on GitHub provided OSs.
ci:
runs-on: ${{ matrix.os }}

Expand All @@ -93,46 +106,105 @@ jobs:
]

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy

- name: Cache
uses: actions/cache@v4
with:
path: target
key: ${{ matrix.os }}
- name: Cache
uses: actions/cache@v4
with:
path: target
key: ${{ matrix.os }}

- name: Download monerod
uses: ./.github/actions/monerod-download
- name: Download monerod
uses: ./.github/actions/monerod-download

- name: Install dependencies (Windows)
if: matrix.os == 'windows-2022'
uses: lukka/get-cmake@v3.31.6 # Needed for `randomx-rs`
- name: Install dependencies (Windows)
if: matrix.os == 'windows-2022'
uses: lukka/get-cmake@v3.31.6 # Needed for `randomx-rs`

- name: Documentation
run: cargo doc --all-features --no-deps
- name: Documentation
run: ${{ env.CMD_DOC }}

- name: Clippy (fail on warnings)
run: cargo clippy --all-features --all-targets -- -D warnings
- name: Clippy (fail on warnings)
run: ${{ env.CMD_CLIPPY }}

# HACK: how to test both DB backends that are feature-gated?
- name: Test
run: |
cargo test --all-features
cargo test --package cuprate-blockchain --no-default-features --features redb

- name: Build
run: cargo build --all-features --all-targets

- name: Hack Check
run: |
cargo install cargo-hack --locked
cargo hack check --feature-powerset --no-dev-deps
- name: Test
run: ${{ env.CMD_TEST }}

- name: Test (cuprate-test-cli)
run: ${{ env.CMD_TEST_CLI }}

- name: Test (cuprate-test-rpc)
run: ${{ env.CMD_TEST_RPC }}

- name: Build
run: ${{ env.CMD_BUILD }}

- name: Hack Check
run: ${{ env.CMD_HACK }}

# CI, runs in a Docker image.
ci-docker:
runs-on: ubuntu-22.04
container:
image: ${{ matrix.os.image }}

strategy:
matrix:
os:
- { image: archlinux:latest, commands: "pacman -Syyu --noconfirm base-devel git cmake" }
- { image: debian:stable, commands: "apt update && apt -y install build-essential curl cmake git" }
- { image: fedora:latest, commands: "dnf install --assumeyes @development-tools gcc gcc-c++ cmake git" }

steps:
- name: Checkout
uses: actions/checkout@v4
with:
clean: false

- name: Cache
uses: actions/cache@v4
with:
path: target
key: ${{ matrix.os.image }}

- name: Dependencies
run: ${{ matrix.os.commands }}

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy

- name: Download monerod
uses: ./.github/actions/monerod-download

- name: Documentation
run: ${{ env.CMD_DOC }}

- name: Clippy (fail on warnings)
run: ${{ env.CMD_CLIPPY }}

- name: Test
run: ${{ env.CMD_TEST }}

- name: Test (cuprate-test-cli)
run: ${{ env.CMD_TEST_CLI }}

- name: Test (cuprate-test-rpc)
run: ${{ env.CMD_TEST_RPC }}

- name: Build
run: ${{ env.CMD_BUILD }}

- name: Hack Check
run: ${{ env.CMD_HACK }}
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ After that, ensure all other CI passes by running:
| `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 run --package cuprate-test-cli` | Tests that `cuprated` input/output and behavior are correct |
| `cargo run --release --package cuprate-compat-rpc` | Tests `cuprated`'s RPC compatibility with `monerod` |

`cargo hack` can be installed with `cargo` from: https://github.com/taiki-e/cargo-hack.

Expand Down
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 42 additions & 32 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ members = [
"cryptonight",
"helper",
"pruning",
"test-utils",

# Tests
"test/cli",
"test/rpc",
"test/utils",

# Fuzz
"fuzz"
Expand Down Expand Up @@ -106,7 +110,11 @@ default-members = [
"cryptonight",
"helper",
"pruning",
"test-utils",

# Tests
"test/cli",
"test/rpc",
"test/utils",
]

[profile.release]
Expand All @@ -131,36 +139,38 @@ opt-level = 3

[workspace.dependencies]
# Cuprate members
cuprate-fast-sync = { path = "consensus/fast-sync", default-features = false }
cuprate-consensus-rules = { path = "consensus/rules", default-features = false }
cuprate-constants = { path = "constants", default-features = false }
cuprate-consensus = { path = "consensus", default-features = false }
cuprate-consensus-context = { path = "consensus/context", default-features = false }
cuprate-cryptonight = { path = "cryptonight", default-features = false }
cuprate-helper = { path = "helper", default-features = false }
cuprate-epee-encoding = { path = "net/epee-encoding", default-features = false }
cuprate-levin = { path = "net/levin", default-features = false }
cuprate-wire = { path = "net/wire", default-features = false }
cuprate-async-buffer = { path = "p2p/async-buffer", default-features = false }
cuprate-p2p = { path = "p2p/p2p", default-features = false }
cuprate-p2p-core = { path = "p2p/p2p-core", default-features = false }
cuprate-p2p-bucket = { path = "p2p/p2p-bucket", default-features = false }
cuprate-p2p-transport = { path = "p2p/p2p-transport", default-features = false }
cuprate-dandelion-tower = { path = "p2p/dandelion-tower", default-features = false }
cuprate-address-book = { path = "p2p/address-book", default-features = false }
cuprate-blockchain = { path = "storage/blockchain", default-features = false }
cuprate-database = { path = "storage/database", default-features = false }
cuprate-database-service = { path = "storage/service", default-features = false }
cuprate-txpool = { path = "storage/txpool", default-features = false }
cuprate-pruning = { path = "pruning", default-features = false }
cuprate-test-utils = { path = "test-utils", default-features = false }
cuprate-types = { path = "types/types", default-features = false }
cuprate-hex = { path = "types/hex", default-features = false }
cuprate-fixed-bytes = { path = "types/fixed-bytes", default-features = false }
cuprate-json-rpc = { path = "rpc/json-rpc", default-features = false }
cuprate-rpc-types = { path = "rpc/types", default-features = false }
cuprate-rpc-interface = { path = "rpc/interface", default-features = false }
cuprate-zmq-types = { path = "zmq/types", default-features = false }
cuprate-fast-sync = { path = "consensus/fast-sync", default-features = false }
cuprate-consensus-rules = { path = "consensus/rules", default-features = false }
cuprate-constants = { path = "constants", default-features = false }
cuprate-consensus = { path = "consensus", default-features = false }
cuprate-consensus-context = { path = "consensus/context", default-features = false }
cuprate-cryptonight = { path = "cryptonight", default-features = false }
cuprate-helper = { path = "helper", default-features = false }
cuprate-epee-encoding = { path = "net/epee-encoding", default-features = false }
cuprate-levin = { path = "net/levin", default-features = false }
cuprate-wire = { path = "net/wire", default-features = false }
cuprate-async-buffer = { path = "p2p/async-buffer", default-features = false }
cuprate-p2p = { path = "p2p/p2p", default-features = false }
cuprate-p2p-core = { path = "p2p/p2p-core", default-features = false }
cuprate-p2p-bucket = { path = "p2p/p2p-bucket", default-features = false }
cuprate-p2p-transport = { path = "p2p/p2p-transport", default-features = false }
cuprate-dandelion-tower = { path = "p2p/dandelion-tower", default-features = false }
cuprate-address-book = { path = "p2p/address-book", default-features = false }
cuprate-blockchain = { path = "storage/blockchain", default-features = false }
cuprate-database = { path = "storage/database", default-features = false }
cuprate-database-service = { path = "storage/service", default-features = false }
cuprate-txpool = { path = "storage/txpool", default-features = false }
cuprate-pruning = { path = "pruning", default-features = false }
cuprate-test-cli = { path = "test/cli", default-features = false }
cuprate-test-rpc = { path = "test/rpc", default-features = false }
cuprate-test-utils = { path = "test/utils", default-features = false }
cuprate-types = { path = "types/types", default-features = false }
cuprate-hex = { path = "types/hex", default-features = false }
cuprate-fixed-bytes = { path = "types/fixed-bytes", default-features = false }
cuprate-json-rpc = { path = "rpc/json-rpc", default-features = false }
cuprate-rpc-types = { path = "rpc/types", default-features = false }
cuprate-rpc-interface = { path = "rpc/interface", default-features = false }
cuprate-zmq-types = { path = "zmq/types", default-features = false }

# External dependencies
axum = { version = "0.7", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion binaries/cuprated/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ cuprate-hex = { workspace = true }
serde_json = { workspace = true, features = ["std"] }

[lints]
workspace = true
workspace = true
8 changes: 7 additions & 1 deletion books/architecture/src/appendix/crates.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ cargo doc --open --package cuprate-blockchain
| [`cuprate-database-service`](https://doc.cuprate.org/cuprate_database_service) | [`storage/database-service/`](https://github.com/Cuprate/cuprate/tree/main/storage/database-service) | `tower::Service` + thread-pool abstraction built on-top of `cuprate-database`
| [`cuprate-txpool`](https://doc.cuprate.org/cuprate_txpool) | [`storage/txpool/`](https://github.com/Cuprate/cuprate/tree/main/storage/txpool) | Transaction pool database built on-top of `cuprate-database` & `cuprate-database-service`

## Tests
| Crate | In-tree path | Purpose |
|-------|--------------|---------|
| [`cuprate-test-cli`](https://doc.cuprate.org/cuprate_test_cli) | [`test/cli/`](https://github.com/Cuprate/cuprate/tree/main/test/cli) | Input, output, and behavior testing harness for `cuprated`'s CLI
| [`cuprate-test-rpc`](https://doc.cuprate.org/cuprate_test_rpc) | [`test/rpc/`](https://github.com/Cuprate/cuprate/tree/main/test/rpc) | Type and value RPC compatibility testing harness for `cuprated` and `monerod`
| [`cuprate-test-utils`](https://doc.cuprate.org/cuprate_test_utils) | [`test/utils/`](https://github.com/Cuprate/cuprate/tree/main/test/utils) | Testing utilities for Cuprate

## Types
| Crate | In-tree path | Purpose |
|-------|--------------|---------|
Expand Down Expand Up @@ -72,4 +79,3 @@ cargo doc --open --package cuprate-blockchain
| [`cuprate-cryptonight`](https://doc.cuprate.org/cuprate_cryptonight) | [`cryptonight/`](https://github.com/Cuprate/cuprate/tree/main/cryptonight) | CryptoNight hash functions
| [`cuprate-pruning`](https://doc.cuprate.org/cuprate_pruning) | [`pruning/`](https://github.com/Cuprate/cuprate/tree/main/pruning) | Monero pruning logic/types
| [`cuprate-helper`](https://doc.cuprate.org/cuprate_helper) | [`helper/`](https://github.com/Cuprate/cuprate/tree/main/helper) | Kitchen-sink helper crate for Cuprate
| [`cuprate-test-utils`](https://doc.cuprate.org/cuprate_test_utils) | [`test-utils/`](https://github.com/Cuprate/cuprate/tree/main/test-utils) | Testing utilities for Cuprate
37 changes: 22 additions & 15 deletions constants/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,30 @@ fn set_commit_env() {

println!("cargo:rerun-if-changed={PATH}");

// FIXME: This could also be `std::fs::read({PATH}/{branch})`
// so the machine building doesn't need `git`, although:
// 1. Having `git` as a build dependency is probably ok
// 2. It causes issues on PRs that aren't the `main` branch
let output = std::process::Command::new("git")
.arg("rev-parse")
.arg("HEAD")
.output()
.unwrap();

let commit = std::str::from_utf8(&output.stdout)
let commit = if let Ok(t) = std::env::var("GITHUB_SHA") {
t
} else {
// FIXME: This could also be `std::fs::read({PATH}/{branch})`
// so the machine building doesn't need `git`, although:
// 1. Having `git` as a build dependency is probably ok
// 2. It causes issues on PRs that aren't the `main` branch
String::from_utf8(
std::process::Command::new("git")
.args(["show", "-s", "--format=%H"])
.output()
.unwrap()
.stdout,
)
.unwrap()
.trim()
.to_lowercase();
}
.trim()
.to_lowercase();

// Commit hash should always be 40 bytes long.
assert_eq!(commit.len(), 40);
assert_eq!(
commit.len(),
40,
"Commit hash should always be 40 bytes long."
);

println!("cargo:rustc-env=COMMIT={commit}");
}
9 changes: 9 additions & 0 deletions test/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "cuprate-test-cli"
version = "0.1.0"
edition = "2024"

[dependencies]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions test/cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}
9 changes: 9 additions & 0 deletions test/rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "cuprate-test-rpc"
version = "0.0.1"
edition = "2024"

[dependencies]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions test/rpc/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ extend-ignore-identifiers-re = [
extend-exclude = [
"/misc/gpg_keys/",
"cryptonight/",
"/test-utils/src/rpc/data/json.rs",
"/test/utils/src/rpc/data/json.rs",
"rpc/types/src/json.rs",
]