Merge pull request #125 from mempool/junderw/freebsd-ci

Add FreeBSD CI job, update to 1.87 (FreeBSD 14.3) and fix clippy lints
This commit is contained in:
wiz 2025-10-09 06:29:07 +07:00 committed by GitHub
commit 3c1de78f49
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 109 additions and 115 deletions

View File

@ -12,7 +12,7 @@ jobs:
name: Compile Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Rust
uses: './.github/actions/ci-rust-setup'
with:
@ -23,7 +23,7 @@ jobs:
name: Formatter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Rust
uses: './.github/actions/ci-rust-setup'
with:
@ -34,13 +34,55 @@ jobs:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Rust
uses: './.github/actions/ci-rust-setup'
with:
cache-name: test
- run: cargo test --lib --all-features
compile-freebsd:
runs-on: ubuntu-latest
name: Run Compile Checks in FreeBSD
env:
FREEBSD_VER: "14.3"
steps:
- uses: actions/checkout@v4
- name: Cache dependencies for FreeBSD
uses: actions/cache@v3
with:
path: |
.cargohome/registry
.cargohome/git
target
key: freebsd-${{ env.FREEBSD_VER }}-cargo-checks-${{ hashFiles('**/Cargo.lock') }}
- name: Compile Checks in FreeBSD
uses: vmactions/freebsd-vm@v1
with:
usesh: true
release: "${{ env.FREEBSD_VER }}"
arch: amd64
prepare: |
mkdir -p ~/.cargo/
mkdir -p ./.cargohome/registry/
mkdir -p ./.cargohome/git/
mv ./.cargohome/registry ~/.cargo/
mv ./.cargohome/git ~/.cargo/
rm -rf ./.cargohome
pkg install -y git rsync gmake llvm rust
run: |
cargo check --no-default-features
cargo check -F liquid
cargo check -F electrum-discovery
cargo check -F electrum-discovery,liquid
rm -rf ./.cargohome
mkdir -p ~/.cargo/registry/
mkdir -p ~/.cargo/git/
mkdir -p ./.cargohome/
mv ~/.cargo/registry ./.cargohome/
mv ~/.cargo/git ./.cargohome/
clippy:
name: Linter
runs-on: ubuntu-latest
@ -54,7 +96,7 @@ jobs:
'-F electrum-discovery,liquid',
]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Rust
uses: './.github/actions/ci-rust-setup'
with:

133
Cargo.lock generated
View File

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4
[[package]]
name = "addr2line"
@ -23,7 +23,7 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -46,7 +46,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -127,7 +127,7 @@ dependencies = [
"regex",
"rustc-hash",
"shlex",
"syn 2.0.26",
"syn 2.0.106",
]
[[package]]
@ -221,11 +221,12 @@ dependencies = [
[[package]]
name = "cc"
version = "1.0.73"
version = "1.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
checksum = "e9e8aabfac534be767c909e0690571677d49f41bd8465ae876fe043d52ba5292"
dependencies = [
"jobserver",
"libc",
]
[[package]]
@ -253,7 +254,7 @@ dependencies = [
"num-integer",
"num-traits",
"time 0.1.43",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -388,7 +389,7 @@ checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
dependencies = [
"libc",
"redox_users",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -426,27 +427,6 @@ dependencies = [
"slip21",
]
[[package]]
name = "errno"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
dependencies = [
"errno-dragonfly",
"libc",
"winapi 0.3.9",
]
[[package]]
name = "errno-dragonfly"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "error-chain"
version = "0.12.4"
@ -689,9 +669,9 @@ checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
[[package]]
name = "jobserver"
version = "0.1.24"
version = "0.1.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa"
checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0"
dependencies = [
"libc",
]
@ -705,16 +685,6 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "kernel32-sys"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
dependencies = [
"winapi 0.2.8",
"winapi-build",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -740,7 +710,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd"
dependencies = [
"cfg-if",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -791,9 +761,9 @@ dependencies = [
[[package]]
name = "lz4-sys"
version = "1.9.4"
version = "1.11.1+lz4-1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57d27b317e207b10f69f5e75494119e391a96f48861ae870d1da6edac98ca900"
checksum = "6bd8c0d6c6ed0cd30b3652886bb8711dc4bb01d637a68105a3d5158039b418e6"
dependencies = [
"cc",
"libc",
@ -855,7 +825,6 @@ dependencies = [
"signal-hook",
"socket2",
"stderrlog",
"sysconf",
"tempfile",
"time 0.3.9",
"tiny_http",
@ -889,7 +858,7 @@ dependencies = [
"miow",
"ntapi",
"wasi 0.11.0+wasi-snapshot-preview1",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -898,7 +867,7 @@ version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
dependencies = [
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -917,7 +886,7 @@ version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f"
dependencies = [
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -980,7 +949,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eebde548fbbf1ea81a99b128872779c437752fb99f217c45245e1a61dcd9edcd"
dependencies = [
"libc",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1005,7 +974,7 @@ dependencies = [
"libc",
"redox_syscall",
"smallvec",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1060,19 +1029,19 @@ checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
[[package]]
name = "prettyplease"
version = "0.2.10"
version = "0.2.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92139198957b410250d43fad93e630d956499a625c527eda65175c8680f83387"
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
dependencies = [
"proc-macro2",
"syn 2.0.26",
"syn 2.0.106",
]
[[package]]
name = "proc-macro2"
version = "1.0.66"
version = "1.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
dependencies = [
"unicode-ident",
]
@ -1100,9 +1069,9 @@ checksum = "cf7e6d18738ecd0902d30d1ad232c9125985a3422929b16c65517b38adc14f96"
[[package]]
name = "quote"
version = "1.0.31"
version = "1.0.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fe8a65d69dd0808184ebb5f836ab526bb259db23c657efa38711b1072ee47f0"
checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1"
dependencies = [
"proc-macro2",
]
@ -1123,7 +1092,7 @@ dependencies = [
"rand_os",
"rand_pcg",
"rand_xorshift",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1177,7 +1146,7 @@ checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b"
dependencies = [
"libc",
"rand_core 0.4.2",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1191,7 +1160,7 @@ dependencies = [
"libc",
"rand_core 0.4.2",
"rdrand",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1287,7 +1256,7 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1302,7 +1271,7 @@ dependencies = [
"spin",
"untrusted",
"web-sys",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1519,7 +1488,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0"
dependencies = [
"libc",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1530,7 +1499,7 @@ checksum = "f0c3dbbd9ae980613c6dd8e28a9407b50509d3803b57624d5dfe8315218cd58b"
dependencies = [
"byteorder",
"libc",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1571,27 +1540,15 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.26"
version = "2.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45c3457aacde3c65315de5031ec191ce46604304d2446e803d71ade03308d970"
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "sysconf"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59e93f5d45535f49b6a05ef7ac2f0f795d28de494cf53a512751602c9849bea3"
dependencies = [
"errno",
"kernel32-sys",
"libc",
"winapi 0.2.8",
]
[[package]]
name = "tempfile"
version = "3.3.0"
@ -1603,7 +1560,7 @@ dependencies = [
"libc",
"redox_syscall",
"remove_dir_all",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1660,7 +1617,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
dependencies = [
"libc",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1721,7 +1678,7 @@ dependencies = [
"pin-project-lite",
"socket2",
"tokio-macros",
"winapi 0.3.9",
"winapi",
]
[[package]]
@ -1947,12 +1904,6 @@ dependencies = [
"webpki",
]
[[package]]
name = "winapi"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
[[package]]
name = "winapi"
version = "0.3.9"
@ -1963,12 +1914,6 @@ dependencies = [
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-build"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
@ -1981,7 +1926,7 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi 0.3.9",
"winapi",
]
[[package]]

View File

@ -39,7 +39,7 @@ glob = "0.3"
hex = "0.4.2"
itertools = "0.10"
lazy_static = "1.3.0"
libc = "0.2.81"
libc = "0.2"
log = "0.4.11"
socket2 = { version = "0.4", features = ["all"] }
num_cpus = "1.12.0"
@ -53,7 +53,6 @@ serde_json = "1.0.60"
sha2 = "0.10.7"
signal-hook = "0.3"
stderrlog = "0.5.0"
sysconf = ">=0.3.4"
time = { version = "0.3", features = ["formatting"] }
tiny_http = "0.11"
url = "2.2.0"

View File

@ -1 +1 @@
1.83
1.87

View File

@ -183,7 +183,7 @@ impl DiscoveryManager {
.filter(|service| {
existing_services
.get(&addr)
.map_or(true, |s| !s.contains(service))
.is_none_or(|s| !s.contains(service))
})
.map(|service| {
HealthCheck::new(addr.clone(), hostname.clone(), service, Some(added_by))
@ -235,9 +235,9 @@ impl DiscoveryManager {
/// Run the next health check in the queue (a single one)
fn run_health_check(&self) -> Result<()> {
// abort if there are no entries in the queue, or its still too early for the next one up
if self.queue.read().unwrap().peek().map_or(true, |next| {
if self.queue.read().unwrap().peek().is_none_or(|next| {
next.last_check
.map_or(false, |t| t.elapsed() < HEALTH_CHECK_FREQ)
.is_some_and(|t| t.elapsed() < HEALTH_CHECK_FREQ)
}) {
return Ok(());
}

View File

@ -33,6 +33,7 @@ fn parse_asset_id(sl: &[u8]) -> AssetId {
#[derive(Serialize)]
#[serde(untagged)]
#[allow(clippy::large_enum_variant)]
pub enum LiquidAsset {
Issued(IssuedAsset),
Native(PeggedAsset),

View File

@ -1,3 +1,4 @@
#![allow(unexpected_cfgs)]
error_chain! {
types {
Error, ErrorKind, ResultExt, Result;

View File

@ -5,7 +5,6 @@ use std::io;
use std::net::SocketAddr;
use std::thread;
use std::time::Duration;
use sysconf;
use tiny_http;
pub use prometheus::{
@ -98,6 +97,14 @@ struct Stats {
fds: usize,
}
fn get_ticks_per_second() -> Result<f64> {
// Safety: This code is taken directly from sysconf
match unsafe { libc::sysconf(libc::_SC_CLK_TCK) } {
-1 => Err("Clock Tick unsupported".into()),
ret => Ok(ret as f64),
}
}
fn parse_stats() -> Result<Stats> {
if cfg!(target_os = "macos") {
return Ok(Stats {
@ -109,8 +116,7 @@ fn parse_stats() -> Result<Stats> {
let value = fs::read_to_string("/proc/self/stat").chain_err(|| "failed to read stats")?;
let parts: Vec<&str> = value.split_whitespace().collect();
let page_size = page_size::get() as u64;
let ticks_per_second = sysconf::raw::sysconf(sysconf::raw::SysconfVariable::ScClkTck)
.expect("failed to get _SC_CLK_TCK") as f64;
let ticks_per_second = get_ticks_per_second().expect("failed to get _SC_CLK_TCK");
let parse_part = |index: usize, name: &str| -> Result<u64> {
parts

View File

@ -165,7 +165,7 @@ impl Mempool {
// TODO seek directly to last seen tx without reading earlier rows
.skip_while(|txid| {
// skip until we reach the last_seen_txid
last_seen_txid.map_or(false, |last_seen_txid| last_seen_txid != txid)
last_seen_txid.is_some_and(|last_seen_txid| last_seen_txid != txid)
})
.skip(match last_seen_txid {
Some(_) => 1, // skip the last_seen_txid itself
@ -196,7 +196,7 @@ impl Mempool {
// TODO seek directly to last seen tx without reading earlier rows
.skip_while(|txid| {
// skip until we reach the last_seen_txid
last_seen_txid.map_or(false, |last_seen_txid| last_seen_txid != txid)
last_seen_txid.is_some_and(|last_seen_txid| last_seen_txid != txid)
})
.skip(match last_seen_txid {
Some(_) => 1, // skip the last_seen_txid itself

View File

@ -663,11 +663,11 @@ impl ChainQuery {
.unique_by(|(txid, info, _)| (*txid, info.get_vin_or_vout(), info.has_vin()))
.skip_while(|(txid, _, _)| {
// skip until we reach the last_seen_txid
last_seen_txid.map_or(false, |last_seen_txid| last_seen_txid != txid)
last_seen_txid.is_some_and(|last_seen_txid| last_seen_txid != txid)
})
.skip_while(|(txid, _, _)| {
// skip the last_seen_txid itself
last_seen_txid.map_or(false, |last_seen_txid| last_seen_txid == txid)
last_seen_txid == Some(txid)
})
.filter_map(|(txid, info, tx_position)| {
self.tx_confirming_block(&txid)
@ -824,7 +824,7 @@ impl ChainQuery {
// TODO seek directly to last seen tx without reading earlier rows
.skip_while(move |row| {
// skip until we reach the last_seen_txid
last_seen_txid.map_or(false, |last_seen_txid| last_seen_txid != &row.get_txid())
last_seen_txid.is_some_and(|last_seen_txid| last_seen_txid != &row.get_txid())
})
.skip(match last_seen_txid {
Some(_) => 1, // skip the last_seen_txid itself
@ -893,7 +893,7 @@ impl ChainQuery {
.skip_while(move |row| {
// we already seeked to the last txid at this height
// now skip just past the last_seen_txid itself
last_seen_txid.map_or(false, |last_seen_txid| last_seen_txid != &row.get_txid())
last_seen_txid.is_some_and(|last_seen_txid| last_seen_txid != &row.get_txid())
})
.skip(match last_seen_txid {
Some(_) => 1, // skip the last_seen_txid itself

View File

@ -128,7 +128,7 @@ impl BlockValue {
/// https://github.com/bitcoin/bitcoin/blob/v25.0/src/rpc/blockchain.cpp#L75-L97
#[cfg_attr(feature = "liquid", allow(dead_code))]
fn difficulty_new(bh: &bitcoin::BlockHeader) -> f64 {
let mut n_shift = bh.bits >> 24 & 0xff;
let mut n_shift = (bh.bits >> 24) & 0xff;
let mut d_diff = (0x0000ffff as f64) / ((bh.bits & 0x00ffffff) as f64);
while n_shift < 29 {

View File

@ -52,7 +52,7 @@ pub fn get_innerscripts(txin: &TxIn, prevout: &TxOut) -> InnerScripts {
// Wrapped witnessScript for P2WSH or P2SH-P2WSH spends
let witness_script = if prevout.script_pubkey.is_v0_p2wsh()
|| prevout.script_pubkey.is_v1_p2tr()
|| redeem_script.as_ref().map_or(false, |s| s.is_v0_p2wsh())
|| redeem_script.as_ref().is_some_and(|s| s.is_v0_p2wsh())
{
let witness = &txin.witness;
#[cfg(feature = "liquid")]