From e93db419c40c352fdf6f7c635bbd47d8286b7326 Mon Sep 17 00:00:00 2001 From: Andrea Franz Date: Thu, 25 Jun 2026 15:18:52 +0200 Subject: [PATCH] chore(stablecoin): use alloy primitives --- Cargo.lock | 2 ++ programs/stablecoin/core/Cargo.toml | 6 +++++- programs/stablecoin/core/src/math.rs | 9 ++++----- programs/stablecoin/methods/guest/Cargo.lock | 2 ++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c5efd1c..6a2f9de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3654,9 +3654,11 @@ dependencies = [ name = "stablecoin_core" version = "0.1.0" dependencies = [ + "alloy-primitives", "borsh", "nssa_core", "risc0-zkvm", + "ruint", "serde", "spel-framework-macros", "twap_oracle_core", diff --git a/programs/stablecoin/core/Cargo.toml b/programs/stablecoin/core/Cargo.toml index f9dad0a..a5b0546 100644 --- a/programs/stablecoin/core/Cargo.toml +++ b/programs/stablecoin/core/Cargo.toml @@ -6,7 +6,11 @@ edition = "2021" [dependencies] nssa_core = { git = "https://github.com/logos-blockchain/logos-execution-zone.git", tag = "v0.2.0-rc3", features = ["host"] } borsh = { version = "1.5", features = ["derive"] } -primitive-types = { version = "0.13", default-features = false } +alloy-primitives = { version = "1", default-features = false } +# Pin ruint (transitive via alloy-primitives) below 1.18, which raised its MSRV to rustc 1.90. +# The risc0 guest toolchain ships rustc 1.88, so 1.18+ fails the guest build. 1.17.0 (MSRV 1.85) +# is the newest compatible release. Remove this pin once the risc0 toolchain advances past 1.90. +ruint = { version = "=1.17.0", default-features = false } serde = { version = "1.0", features = ["derive"] } twap_oracle_core = { path = "../../twap_oracle/core" } risc0-zkvm = { version = "=3.0.5", default-features = false } diff --git a/programs/stablecoin/core/src/math.rs b/programs/stablecoin/core/src/math.rs index d138a3e..720048a 100644 --- a/programs/stablecoin/core/src/math.rs +++ b/programs/stablecoin/core/src/math.rs @@ -4,7 +4,7 @@ //! `u128` integers scaled by [`FIXED_POINT_ONE`], so the integer `1.0` is //! `10^27`. Multiplications use `U256` intermediates to avoid overflow. -use primitive_types::U256; +use alloy_primitives::U256; /// The value `1.0` in our 27-decimal fixed-point representation. /// @@ -50,7 +50,7 @@ pub fn mul_div_ceil(a: u128, b: u128, c: u128) -> u128 { quotient } else { quotient - .checked_add(U256::one()) + .checked_add(U256::ONE) .expect("mul_div_ceil: ceil increment overflows U256") }; ceiled @@ -70,9 +70,8 @@ pub fn mul_div_ceil(a: u128, b: u128, c: u128) -> u128 { /// /// # Overflow /// NOT self-bounding. For any `per_millisecond_rate > FIXED_POINT_ONE` this -/// eventually overflows `u128` as `milliseconds_elapsed` grows — the §8 rate -/// bound alone does not prevent it. Callers MUST clamp the elapsed window to -/// `MAXIMUM_COMPOUNDING_WINDOW_MILLISECONDS` (spec §5.3) before calling. +/// eventually overflows `u128` as `milliseconds_elapsed` grows. Callers MUST +/// clamp the elapsed window to a bounded maximum before calling. #[must_use] pub fn compound_rate(per_millisecond_rate: u128, milliseconds_elapsed: u64) -> u128 { if milliseconds_elapsed == 0 { diff --git a/programs/stablecoin/methods/guest/Cargo.lock b/programs/stablecoin/methods/guest/Cargo.lock index 5a07e90..7768ed1 100644 --- a/programs/stablecoin/methods/guest/Cargo.lock +++ b/programs/stablecoin/methods/guest/Cargo.lock @@ -3551,9 +3551,11 @@ dependencies = [ name = "stablecoin_core" version = "0.1.0" dependencies = [ + "alloy-primitives", "borsh", "nssa_core", "risc0-zkvm", + "ruint", "serde", "spel-framework-macros", "twap_oracle_core",