Skip to content
Merged
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 Cargo.lock

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

6 changes: 6 additions & 0 deletions mithril-stm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.5.5 (10-13-2025)

### Fixed

- Fixed compilation issues with `rug` when targeting `musl` environment.

## 0.5.4 (10-07-2025)

### Added
Expand Down
6 changes: 3 additions & 3 deletions mithril-stm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-stm"
version = "0.5.4"
version = "0.5.5"
edition = { workspace = true }
authors = { workspace = true }
homepage = { workspace = true }
Expand Down Expand Up @@ -30,13 +30,13 @@ rayon = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }

[target.'cfg(any(target_family = "wasm", windows))'.dependencies]
[target.'cfg(any(target_family = "wasm", target_env = "musl", windows))'.dependencies]
# WASM and Windows don't support rug backend, fallback to num-integer only
num-bigint = { version = "0.4.6" }
num-rational = { version = "0.4.2" }
num-traits = { version = "0.2.19" }

[target.'cfg(not(any(target_family = "wasm", windows)))'.dependencies]
[target.'cfg(not(any(target_family = "wasm", target_env = "musl", windows)))'.dependencies]
num-bigint = { version = "0.4.6", optional = true }
num-rational = { version = "0.4.2", optional = true }
num-traits = { version = "0.2.19", optional = true }
Expand Down
21 changes: 18 additions & 3 deletions mithril-stm/src/eligibility_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ use {
std::ops::Neg,
};

#[cfg(any(feature = "num-integer-backend", target_family = "wasm", windows))]
#[cfg(any(
feature = "num-integer-backend",
target_family = "wasm",
target_env = "musl",
windows
))]
/// Checks that ev is successful in the lottery. In particular, it compares the output of `phi`
/// (a real) to the output of `ev` (a hash). It uses the same technique used in the
/// [Cardano ledger](https://github.com/input-output-hk/cardano-ledger/). In particular,
Expand Down Expand Up @@ -49,7 +54,12 @@ pub(crate) fn is_lottery_won(phi_f: f64, ev: [u8; 64], stake: Stake, total_stake
taylor_comparison(1000, q, x)
}

#[cfg(any(feature = "num-integer-backend", target_family = "wasm", windows))]
#[cfg(any(
feature = "num-integer-backend",
target_family = "wasm",
target_env = "musl",
windows
))]
/// Checks if cmp < exp(x). Uses error approximation for an early stop. Whenever the value being
/// compared, `cmp`, is smaller (or greater) than the current approximation minus an `error_term`
/// (plus an `error_term` respectively), then we stop approximating. The choice of the `error_term`
Expand Down Expand Up @@ -82,7 +92,12 @@ fn taylor_comparison(bound: usize, cmp: Ratio<BigInt>, x: Ratio<BigInt>) -> bool
false
}

#[cfg(not(any(feature = "num-integer-backend", target_family = "wasm", windows)))]
#[cfg(not(any(
feature = "num-integer-backend",
target_family = "wasm",
target_env = "musl",
windows
)))]
/// The crate `rug` has sufficient optimizations to not require a taylor approximation with early
/// stop. The difference between the current implementation and the one using the optimization
/// above is around 10% faster. We perform the computations with 117 significant bits of
Expand Down
Loading