Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ jobs:
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.93.0
toolchain: 1.95.0
components: rustfmt, clippy

- name: Set up cache
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ members = [
]

[workspace.package]
rust-version = "1.91.0"
rust-version = "1.95.0"
version = "2.0.0"
authors = ["Kaspa developers"]
license = "ISC"
Expand Down
3 changes: 1 addition & 2 deletions consensus/src/processes/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use itertools::Itertools;
use kaspa_consensus_core::errors::sync::{SyncManagerError, SyncManagerResult};
use kaspa_database::prelude::StoreResultExt;
use kaspa_hashes::Hash;
use kaspa_math::uint::malachite_base::num::arithmetic::traits::CeilingLogBase2;
use parking_lot::RwLock;

use crate::model::{
Expand Down Expand Up @@ -141,7 +140,7 @@ impl<
return Err(SyncManagerError::LowHashHigherThanHighHash(low, high));
}

let mut locator = Vec::with_capacity((high_index - low_index).ceiling_log_base_2() as usize);
let mut locator = Vec::with_capacity(kaspa_math::ceil_log_2(high_index - low_index) as usize);
let mut step = 1;
let mut current_index = high_index;
while current_index > low_index {
Expand Down
7 changes: 6 additions & 1 deletion crypto/muhash/src/u3072.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ impl U3072 {
if a == Self::zero() {
return a;
}
let inv = Self { limbs: Uint3072(a.limbs).mod_inverse(Self::UINT_PRIME).expect("Cannot fail, 0 < a < prime").0 };
let inv = {
let mut out = [0u64; LIMBS];
let invertible = kaspa_math::lehmer::invert::<kaspa_math::Uint3072>(a.limbs, Self::UINT_PRIME.0, &mut out);
assert!(invertible, "Cannot fail, 0 < a < prime");
Self { limbs: out }
};
if cfg!(debug_assertions) {
let mut one = inv;
one *= a;
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.kaspa-wallet
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ---------------------------------------- Chef image -------------------------------------------
FROM rust:1.91-alpine3.23 AS chef
FROM rust:1.95-alpine3.23 AS chef
RUN apk --no-cache add \
musl-dev \
protobuf-dev \
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.kaspad
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ---------------------------------------- Chef image -------------------------------------------
FROM rust:1.91-alpine3.23 AS chef
FROM rust:1.95-alpine3.23 AS chef
RUN apk --no-cache add \
musl-dev \
protobuf-dev \
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.rothschild
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ---------------------------------------- Chef image -------------------------------------------
FROM rust:1.91-alpine3.23 AS chef
FROM rust:1.95-alpine3.23 AS chef
RUN apk --no-cache add \
musl-dev \
protobuf-dev \
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.simpa
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ---------------------------------------- Chef image -------------------------------------------
FROM rust:1.91-alpine3.23 AS chef
FROM rust:1.95-alpine3.23 AS chef
RUN apk --no-cache add \
musl-dev \
protobuf-dev \
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.stratum-bridge
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ---------------------------------------- Chef image -------------------------------------------
FROM rust:1.91-alpine3.23 AS chef
FROM rust:1.95-alpine3.23 AS chef
RUN apk --no-cache add \
musl-dev \
protobuf-dev \
Expand Down
29 changes: 27 additions & 2 deletions math/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ borsh.workspace = true
faster-hex.workspace = true
js-sys.workspace = true
kaspa-utils = { workspace = true, features = ["mem_size"] }
malachite-base.workspace = true
malachite-nz.workspace = true
serde-wasm-bindgen.workspace = true
serde.workspace = true
thiserror.workspace = true
Expand All @@ -27,10 +25,37 @@ workflow-wasm.workspace = true
[dev-dependencies]
rand_chacha.workspace = true
criterion.workspace = true
# malachite (LGPL) is no longer a production dependency: it backed only `mod_inverse` (now the
# in-repo MIT `lehmer::invert`) and `CeilingLogBase2` (now std). It remains a dev-dependency purely
# as the cross-check oracle for `lehmer.rs` / `lib.rs` tests and the `candidates` bench baseline.
malachite-base.workspace = true
malachite-nz.workspace = true
# The modinv-candidate comparison is settled (Lehmer ext-gcd won), so the third-party candidate
# deps are removed. Their bench arms in benches/candidates.rs are commented out and can be revived
# by re-adding the deps:
# dashu-int = "0.4" # gcd_ext modinv (~23us) + the Uint192/256/320 production-pattern comparator.
# # the mul tuning from https://github.com/cmpute/dashu/pull/74 was also
# # benched (local clone; broken gitlink) and showed no effect at 48 limbs.
# crypto-bigint = "0.7" # safegcd vartime/const-time modinv (~114/126us, 7-8x slower)
# num-bigint = "0.4" # ~513us, ruled out
# ruint = "1" # ~72us, ruled out

[features]
# Bench/diagnostics only: accumulate per-inverse operation counts in `lehmer`
# (matrices, divides, apply-limb iterations) into atomics. Off by default; has
# zero effect on the production path.
lehmer-instrument = []
# Promote the `lehmer` invariant checks from `debug_assert!` to always-on
# `assert!`, independent of `debug-assertions`.
strict-asserts = []

[[bench]]
name = "bench"
harness = false

[[bench]]
name = "candidates"
harness = false

[lints]
workspace = true
6 changes: 5 additions & 1 deletion math/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ fn bench_uint3072(c: &mut Criterion) {
uint3072_c.bench_function("mod_inv Muhash prime", |b| {
b.iter(|| {
for &a in &uint3072_one[..uint3072_one.len() / 4] {
black_box(a.mod_inverse(PRIME));
// generic mod_inverse was removed; inverse the reduced value via lehmer::invert
let mut out = [0u64; 48];
let invertible = kaspa_math::lehmer::invert::<Uint3072>((a % PRIME).0, PRIME.0, &mut out);
black_box(invertible);
black_box(&out);
}
});
});
Expand Down
Loading