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
7 changes: 5 additions & 2 deletions crates/rbitcoin-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ rbitcoin-log = { workspace = true }
bitcoin_hashes = { workspace = true }
# fallocate / punch-hole for multi‑GiB grows without zero-fill storms (Linux).
libc = "0.2"
# Bulk pread submission for head-resolve / confirm body load (Linux).
io-uring = "0.7"
# Datadir store.secret CSPRNG.
getrandom = "0.2"
# Sealed segment binary fuse8 (~9 bits/key).
Expand All @@ -24,6 +22,11 @@ bincode = { workspace = true }
# Product bin only (store_bench); library tests keep the platform allocator.
mimalloc = { workspace = true }

# Bulk pread submission for head-resolve / confirm body load. Linux-only crate;
# all uses in src are #[cfg(target_os = "linux")]-gated with darwin fallbacks.
[target.'cfg(target_os = "linux")'.dependencies]
io-uring = "0.7"

[[bin]]
name = "rbitcoin-store-bench"
path = "src/bin/store_bench.rs"
Expand Down
5 changes: 5 additions & 0 deletions crates/rbitcoin-store/src/bulk_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use std::os::fd::RawFd;
use std::sync::atomic::{AtomicBool, AtomicU8, AtomicUsize, Ordering};

/// SQ/CQ depth for bulk batch sessions.
#[cfg(target_os = "linux")]
const RING_ENTRIES: u32 = crate::uring_session::DEFAULT_ENTRIES;

/// One independent pread. Caller owns `buf` for the full submit/wait.
Expand All @@ -43,6 +44,8 @@ pub struct ReadOp<'a> {
/// Filled: bytes read (≥0) or negated errno on failure.
pub result: i32,
/// When true, SQE uses [`crate::uring_session::RWF_DONTCACHE`].
// Only read on the Linux io_uring submit path.
#[cfg_attr(not(target_os = "linux"), allow(dead_code))]
pub dontcache: bool,
}

Expand All @@ -54,6 +57,8 @@ pub struct WriteOp<'a> {
/// Filled: bytes written (≥0) or negated errno on failure.
pub result: i32,
/// When true, SQE uses [`crate::uring_session::RWF_DONTCACHE`].
// Only read on the Linux io_uring submit path.
#[cfg_attr(not(target_os = "linux"), allow(dead_code))]
pub dontcache: bool,
}

Expand Down
1 change: 1 addition & 0 deletions crates/rbitcoin-store/src/uring_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use crate::error::StoreError;
use std::os::fd::RawFd;
#[cfg(target_os = "linux")]
use std::path::Path;

/// Default SQ/CQ depth for all store io_uring sessions (bulk, plan head-resolve,
Expand Down
29 changes: 18 additions & 11 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = nixpkgs.lib.genAttrs systems;

Expand All @@ -34,19 +36,23 @@
config = { };
overlays = [ ];
};
# Optional dynamic glibc package (Nix-store linked; not portable off-store).
rbitcoin-glibc = mkRbitcoin pkgs;
# Primary / default: fully static musl — portable operator binary.
rbitcoin-musl = mkRbitcoin pkgs.pkgsStatic;
isLinux = nixpkgs.lib.hasSuffix "-linux" system;
# Native build (Nix-store linked): glibc on Linux, plain darwin stdenv on macOS.
rbitcoin-native = mkRbitcoin pkgs;
# Primary / default on Linux: fully static musl — portable operator binary.
# musl is Linux-only, so darwin defaults to the native build instead.
rbitcoin-default = if isLinux then mkRbitcoin pkgs.pkgsStatic else rbitcoin-native;
in
{
default = rbitcoin-musl;
rbitcoin = rbitcoin-musl;
rbitcoin-node = rbitcoin-musl;
rbitcoin-cli = rbitcoin-musl;
rbitcoin-musl = rbitcoin-musl;
default = rbitcoin-default;
rbitcoin = rbitcoin-default;
rbitcoin-node = rbitcoin-default;
rbitcoin-cli = rbitcoin-default;
}
// nixpkgs.lib.optionalAttrs isLinux {
rbitcoin-musl = rbitcoin-default;
# Kept for store-native Nix environments / optional dual-platform repro.
rbitcoin-glibc = rbitcoin-glibc;
rbitcoin-glibc = rbitcoin-native;
}
// nixpkgs.lib.optionalAttrs (system == "x86_64-linux") {
# Optional third platform: aarch64-linux cross from x86_64 (heavy toolchain).
Expand Down Expand Up @@ -103,7 +109,8 @@
checks = forAllSystems (
system:
{
rbitcoin = self.packages.${system}.rbitcoin-musl;
# musl on Linux, native on darwin — matches the default package.
rbitcoin = self.packages.${system}.default;
}
);
};
Expand Down
2 changes: 1 addition & 1 deletion nix/rbitcoin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ let
asl20
];
mainProgram = "rbitcoin-node";
platforms = platforms.linux;
platforms = platforms.linux ++ platforms.darwin;
};
}
);
Expand Down