Files
cuprate-for-explorer/.github/workflows/ci.yml
SyntheticBird 9c2c942d2f Add Tor support to Cuprate (Arti, Tor Daemon, Dandelion router) (#509)
In `workspace`:
- New dependencies: `arti_client`, `Cuprate/tokio-socks.git`, `tor-cell`, `tor-config-path`, `tor-hsservice`, `tor-persist`, `tor-proto`, `tor-rtcompat` (yes nothing was exported).
- In `deny.toml`, whitelisted `Unlicense` license for `arti_client`.

In `cuprate-p2p-transport`:
- Implemented `Transport<ClearNet>` and `Transport<Tor>` for `Arti`. New `ArtiClientConfig`, `ArtiServerConfig` configuration. New `OnionListener` for accepting inbound connections from arti's generated onion service.
- Implemented `Transport<Tor>` for `Daemon`. New `DaemonClientConfig`, `DaemonServerConfig` configuration. New `DaemonInboundStream` listening for incoming TCP  connections from the tor daemon.
- `DisabledListener` as a polyfill for transports with inbound disabled, such as `Transport<ClearNet> for Arti` and in the future `Transport<ClearNet> for Socks5`.

In `cuprate-p2p-core`:
- Removed `Default` and `Debug` bound from `Transport::ClientConfig` and `Transport::ServerConfig`.
- Removed `Clone` bound from `Transport::ServerConfig`.

In `cuprate-p2p`:
- Changed some function visibility to `pub(super)` instead of `pub`.

In `cuprate-wire`:
- Added `borsh` dependency and `BorshSerialize` and `BorshDeserialize` derived implementation to `OnionAddr` for `BorshNetworkZone` requirement in address book.

In `cuprated`:
- New `tor` module containing the initialization of Arti, config helpers and context structure `TorContext` to pass down to p2p initialization function and other helpers.
- New `config/tor` module containing the `[tor]` configuration table. It define tor daemon related variables, as well as arti settings.
- Added `enable_inbound` field to `ClearNetConfig` to disable incoming listener by default.
- Added `proxy` field to `ClearNetConfig` for enabling clearnet over arti and in the future proxy urls.
- Added `TorNetConfig` for setting `Tor` network zone parameters such as listening ports, enabling arti inbound server, or setting an anonymous inbound onion address from an external daemon.
- Modified `initialize_zones_p2p` to now start Tor network zone and use the correct transport depending on user configuration.
- In `txpool/*`, generalized `DiffuseService`, `OutboundPeerStream` and `ConcreteDandelionRouter` for `Z: NetworkZone`. Created a new `MainDandelionRouter` service that will route local txs to a Tor router instead of clearnet if available. Adapted initialization to the changes.

---------

Co-authored-by: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com>
2025-08-04 15:31:25 +01:00

198 lines
5.2 KiB
YAML

name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
env:
# Show colored output in CI.
CARGO_TERM_COLOR: always
# Show full panics.
RUST_BACKTRACE: "full"
# Increase thread stack size to 8 megabytes.
RUST_MIN_STACK: 8000000
# Fail on documentation warnings.
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_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.
#
# This will fast-cancel other CI early if this fails.
#
# `cargo fmt` checks _all_ code, regardless of the OS
# or any `#[cfg]`'s, so this only needs to run on Linux.
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt
- 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
# Run 32-bit WASM support check separately.
wasm-32-bit-support:
runs-on: ubuntu-latest
strategy:
matrix:
# The list of crates to check for WASM 32 bit support
# TODO: check features.
crate: [
cuprate-epee-encoding,
cuprate-rpc-types,
cuprate-fixed-bytes,
]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: wasm32-unknown-unknown
- name: Build WASM 32-bit
run: cargo build --target wasm32-unknown-unknown -p ${{ matrix.crate }}
# CI, runs on GitHub provided OSs.
ci:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [
windows-2022, # EOL = 2026-10-13 | <https://endoflife.date/windows-server>
macos-15, # EOL = 2027-09-16 | <https://endoflife.date/macos>
macos-13, # EOL = 2025-10-24 | For x64.
ubuntu-22.04, # EOL = 2027-04-01 | <https://endoflife.date/ubuntu>
ubuntu-22.04-arm,
]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- 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: 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: Documentation
run: ${{ env.CMD_DOC }}
- name: Clippy (fail on warnings)
run: ${{ env.CMD_CLIPPY }}
- name: Test
run: ${{ env.CMD_TEST }}
- name: Build
run: ${{ env.CMD_BUILD }}
- name: Hack Check
run: ${{ env.CMD_HACK }}
# CI, runs in a Docker image.
ci-docker:
runs-on: ubuntu-latest
container:
image: ${{ matrix.os.image }}
strategy:
matrix:
os:
# TODO: support musl <https://github.com/Cuprate/cuprate/issues/336>
# - { image: alpine:latest, commands: "apk update && apk add alpine-sdk cmake curl bash" }
- { image: archlinux:latest, commands: "pacman -Syyu --noconfirm base-devel git cmake openssl" }
- { image: debian:stable, commands: "apt update && apt -y install build-essential curl cmake git pkg-config libssl-dev" }
- { image: fedora:latest, commands: "dnf install --assumeyes @development-tools gcc gcc-c++ cmake git openssl-devel perl-core" }
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: Build
run: ${{ env.CMD_BUILD }}
- name: Hack Check
run: ${{ env.CMD_HACK }}