Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8b4f417
switch to stable 1.85.1
onur-ozkan Jul 7, 2025
f999117
remove nightly compiler build flag
onur-ozkan Jul 7, 2025
f9b23c9
create `NotStandardStateMachine` and `NotInitialState` markers
onur-ozkan Jul 7, 2025
66ec22a
remove redundant trait implementation
onur-ozkan Jul 7, 2025
8245767
remove auto trait in state_machine
onur-ozkan Jul 7, 2025
d2b0a15
enable rustc_bootstrap
onur-ozkan Jul 8, 2025
01c0ead
make `mm2_p2p` nightly free
onur-ozkan Jul 8, 2025
ea23558
make `mm2_test_helpers` nightly free
onur-ozkan Jul 8, 2025
9c3a5d5
drop outdated `#![feature(stmt_expr_attributes)]`
onur-ozkan Jul 8, 2025
f9199c6
drop `#![feature(hash_raw_entry)]` features
onur-ozkan Jul 8, 2025
b0f8e93
stabilize `mm2_db`
onur-ozkan Jul 8, 2025
43a0704
allow nightly features only on specific crates
onur-ozkan Jul 17, 2025
172d89f
use stable parking lot
onur-ozkan Jul 17, 2025
4449b00
stabilize gstuff
onur-ozkan Jul 17, 2025
6c193bf
fix typo
onur-ozkan Jul 17, 2025
71c2566
document `RUSTC_BOOTSTRAP`
onur-ozkan Jul 17, 2025
a3258e5
re-utilize negative traits
onur-ozkan Jul 17, 2025
7c89569
remove experimental rustfmt feature
onur-ozkan Jul 17, 2025
305462c
handle test crates
onur-ozkan Jul 17, 2025
9adac55
update CI pipelines to install stable compiler
onur-ozkan Jul 17, 2025
e4a08e0
nit
onur-ozkan Jul 21, 2025
6dae698
Merge branch 'dev' of github.com:KomodoPlatform/komodo-defi-framework…
onur-ozkan Jul 22, 2025
3875a5b
remove unstable fmt rules
onur-ozkan Jul 22, 2025
5aea2c5
bless fmt
onur-ozkan Jul 22, 2025
48bc234
explain why `NotSend` is not `Send`
onur-ozkan Jul 23, 2025
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
10 changes: 9 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
[env]
# Enables unstable features for specific crates to take advantage of useful
# functionality not yet stabilized. Remove a crate from the list once all
# required features are stabilized.
#
# - mm2_state_machine: Depends on `negative_impls` and `auto_traits`.
# - mm2_err_handle: Depends on `negative_impls`, `auto_traits` and `allocator_api`.
RUSTC_BOOTSTRAP = "mm2_state_machine,mm2_err_handle"

JEMALLOC_SYS_WITH_MALLOC_CONF = "background_thread:true,narenas:1,tcache:false,dirty_decay_ms:0,muzzy_decay_ms:0,metadata_thp:auto"

[target.'cfg(all())']
rustflags = [ "-Zshare-generics=y", '--cfg=curve25519_dalek_backend="fiat"' ]
Comment thread
shamardy marked this conversation as resolved.
rustflags = [ '--cfg=curve25519_dalek_backend="fiat"' ]

# # Install lld using package manager
# [target.x86_64-unknown-linux-gnu]
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ futures-timer = "3.0"
futures-util = { version = "0.3", default-features = false, features = ["sink", "std"] }
fnv = "1.0.6"
group = "0.8.0"
gstuff = { version = "0.7", features = ["nightly"] }
gstuff = { version = "0.7" }
hash256-std-hasher = "0.15.2"
hash-db = "0.15.2"
hex = "0.4.2"
Expand Down
18 changes: 9 additions & 9 deletions mm2src/coins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ doctest = false

[dependencies]
async-std = { workspace = true, features = ["unstable"] }
async-trait.workspace = true
async-trait.workspace = true
base64.workspace = true
bip32.workspace = true
bitcoin_hashes.workspace = true
Expand Down Expand Up @@ -56,7 +56,7 @@ futures-util.workspace = true
futures-ticker.workspace = true
futures = { workspace = true, features = ["compat", "async-await"] }
group.workspace = true
gstuff.workspace = true
gstuff.workspace = true
hex.workspace = true
http.workspace = true
itertools = { workspace = true, features = ["use_std"] }
Expand All @@ -78,7 +78,7 @@ mm2_rpc = { path = "../mm2_rpc" }
mm2_state_machine = { path = "../mm2_state_machine" }
mocktopus = { workspace = true, optional = true }
num-traits.workspace = true
parking_lot = { workspace = true, features = ["nightly"] }
parking_lot = { workspace = true }
primitives = { path = "../mm2_bitcoin/primitives" }
prost.workspace = true
protobuf.workspace = true
Expand All @@ -91,7 +91,7 @@ rmp-serde.workspace = true
rpc = { path = "../mm2_bitcoin/rpc" }
rpc_task = { path = "../rpc_task" }
script = { path = "../mm2_bitcoin/script" }
secp256k1.workspace = true
secp256k1.workspace = true
ser_error = { path = "../derives/ser_error" }
ser_error_derive = { path = "../derives/ser_error_derive" }
serde.workspace = true
Expand All @@ -109,17 +109,17 @@ utxo_signer = { path = "utxo_signer" }
tendermint-rpc.workspace = true
tokio-tungstenite-wasm = { workspace = true, features = ["rustls-tls-native-roots"]}
url.workspace = true
uuid.workspace = true
uuid.workspace = true
# One of web3 dependencies is the old `tokio-uds 0.1.7` which fails cross-compiling to ARM.
# We don't need the default web3 features at all since we added our own web3 transport using shared HYPER instance.
web3 = { workspace = true, default-features = false }
zbase32.workspace = true
zcash_client_backend.workspace = true
zcash_extras.workspace = true
zcash_primitives.workspace = true
zcash_primitives.workspace = true

[target.'cfg(target_arch = "wasm32")'.dependencies]
blake2b_simd.workspace = true
blake2b_simd.workspace = true
ff.workspace = true
futures-util.workspace = true
jubjub.workspace = true
Expand Down Expand Up @@ -154,7 +154,7 @@ tokio.workspace = true
tokio-rustls.workspace = true
tonic = { workspace = true, features = ["codegen", "prost", "gzip", "tls", "tls-webpki-roots"] }
webpki-roots.workspace = true
zcash_client_sqlite.workspace = true
zcash_client_sqlite.workspace = true
zcash_proofs = { workspace = true, features = ["local-prover", "multicore"] }

[target.'cfg(windows)'.dependencies]
Expand All @@ -169,7 +169,7 @@ jubjub.workspace = true
reqwest.workspace = true

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wagyu-zcash-parameters.workspace = true
wagyu-zcash-parameters.workspace = true

[build-dependencies]
prost-build.workspace = true
Expand Down
3 changes: 0 additions & 3 deletions mm2src/coins/lp_coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
clippy::needless_lifetimes // mocktopus requires explicit lifetimes
)]
#![allow(uncommon_codepoints)]
#![feature(hash_raw_entry)]
#![feature(stmt_expr_attributes)]
#![feature(result_flattening)]

#[macro_use] extern crate common;
#[macro_use] extern crate gstuff;
Expand Down
2 changes: 1 addition & 1 deletion mm2src/coins_activation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mm2_err_handle = { path = "../mm2_err_handle" }
mm2_event_stream = { path = "../mm2_event_stream" }
mm2_metrics = { path = "../mm2_metrics" }
mm2_number = { path = "../mm2_number" }
parking_lot = { workspace = true, features = ["nightly"] }
parking_lot = { workspace = true }
rpc = { path = "../mm2_bitcoin/rpc" }
rpc_task = { path = "../rpc_task" }
secp256k1 = { version = "0.24" }
Expand Down
4 changes: 2 additions & 2 deletions mm2src/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ http-body.workspace = true
itertools.workspace = true
lazy_static.workspace = true
log.workspace = true
parking_lot = { workspace = true, features = ["nightly"] }
parking_lot_core.workspace = true
parking_lot = { workspace = true }
parking_lot_core.workspace = true
paste.workspace = true
primitive-types.workspace = true
rand = { workspace = true, features = ["std", "small_rng"] }
Expand Down
27 changes: 18 additions & 9 deletions mm2src/common/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
//! binary

#![allow(uncommon_codepoints)]
#![feature(hash_raw_entry)]

#[macro_use] extern crate arrayref;
#[macro_use] extern crate gstuff;
Expand Down Expand Up @@ -175,6 +174,7 @@ use std::panic::{set_hook, PanicHookInfo};
use std::path::{Path, PathBuf};
use std::ptr::read_volatile;
use std::sync::atomic::Ordering;
use std::sync::OnceLock;
use std::time::{Duration, SystemTime, SystemTimeError};
use uuid::Uuid;

Expand Down Expand Up @@ -230,6 +230,15 @@ lazy_static! {
/// Converts u64 satoshis to f64
pub fn sat_to_f(sat: u64) -> f64 { sat as f64 / SATOSHIS as f64 }

/// Marker type to indicate that a type is `!Send` in a stable way.
pub struct NotSend(std::marker::PhantomData<*const ()>);
Comment thread
mariocynicys marked this conversation as resolved.

impl Default for NotSend {
fn default() -> NotSend {
NotSend(std::marker::PhantomData)
}
}

#[allow(non_camel_case_types)]
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
#[repr(transparent)]
Expand Down Expand Up @@ -331,13 +340,13 @@ pub fn black_box<T>(v: T) -> T {

/// Using a static buffer in order to minimize the chance of heap and stack allocations in the signal handler.
fn trace_buf() -> PaMutexGuard<'static, [u8; 256]> {
static TRACE_BUF: PaMutex<[u8; 256]> = PaMutex::new([0; 256]);
TRACE_BUF.lock()
static TRACE_BUF: OnceLock<PaMutex<[u8; 256]>> = OnceLock::new();
TRACE_BUF.get_or_init(|| PaMutex::new([0; 256])).lock()
Comment thread
mariocynicys marked this conversation as resolved.
}

fn trace_name_buf() -> PaMutexGuard<'static, [u8; 128]> {
static TRACE_NAME_BUF: PaMutex<[u8; 128]> = PaMutex::new([0; 128]);
TRACE_NAME_BUF.lock()
static TRACE_NAME_BUF: OnceLock<PaMutex<[u8; 128]>> = OnceLock::new();
TRACE_NAME_BUF.get_or_init(|| PaMutex::new([0; 128])).lock()
}

/// Shortcut to path->filename conversion.
Expand Down Expand Up @@ -529,7 +538,7 @@ pub fn set_panic_hook() {
}))
}

/// RPC response, returned by the RPC handlers.
/// RPC response, returned by the RPC handlers.
/// NB: By default the future is executed on the shared asynchronous reactor (`CORE`),
/// the handler is responsible for spawning the future on another reactor if it doesn't fit the `CORE` well.
pub type HyRes = Box<dyn Future<Item = Response<Vec<u8>>, Error = String> + Send>;
Expand Down Expand Up @@ -719,8 +728,8 @@ pub fn now_sec_i64() -> i64 {
#[cfg(not(target_arch = "wasm32"))]
pub fn temp_dir() -> PathBuf { env::temp_dir() }

/// If the `MM_LOG` variable is present then tries to open that file.
/// Prints a warning to `stdout` if there's a problem opening the file.
/// If the `MM_LOG` variable is present then tries to open that file.
/// Prints a warning to `stdout` if there's a problem opening the file.
/// Returns `None` if `MM_LOG` variable is not present or if the specified path can't be opened.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) fn open_log_file() -> Option<std::fs::File> {
Expand Down Expand Up @@ -1190,7 +1199,7 @@ pub fn http_uri_to_ws_address(uri: http::Uri) -> String {
#[inline]
pub fn u256_to_hex(value: U256) -> String { format!("0x{:x}", value) }

/// If 0x prefix exists in an str strip it or return the str as-is
/// If 0x prefix exists in an str strip it or return the str as-is
#[macro_export]
macro_rules! str_strip_0x {
($s: expr) => {
Expand Down
2 changes: 1 addition & 1 deletion mm2src/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ lazy_static.workspace = true
mm2_core = { path = "../mm2_core" }
mm2_err_handle = { path = "../mm2_err_handle" }
num-traits.workspace = true
parking_lot = { workspace = true, features = ["nightly"] }
parking_lot = { workspace = true }
primitives = { path = "../mm2_bitcoin/primitives" }
rpc = { path = "../mm2_bitcoin/rpc" }
rpc_task = { path = "../rpc_task" }
Expand Down
2 changes: 1 addition & 1 deletion mm2src/kdf_walletconnect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ hkdf.workspace = true
mm2_db = { path = "../mm2_db" }
mm2_core = { path = "../mm2_core" }
mm2_err_handle = { path = "../mm2_err_handle" }
parking_lot = { workspace = true, features = ["nightly"] }
parking_lot = { workspace = true }
pairing_api.workspace = true
rand = "0.8"
relay_client.workspace = true
Expand Down
3 changes: 1 addition & 2 deletions mm2src/mm2_db/src/indexed_db/db_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ pub struct IdbDatabaseImpl {
db: IdbDatabase,
db_name: String,
tables: HashSet<String>,
_not_send: common::NotSend
}

impl !Send for IdbDatabaseImpl {}

impl fmt::Debug for IdbDatabaseImpl {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
Expand Down
1 change: 1 addition & 0 deletions mm2src/mm2_db/src/indexed_db/drivers/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl IdbDatabaseBuilder {
db,
db_name: self.db_name,
tables: table_names,
_not_send: common::NotSend::default(),
});
},
}
Expand Down
3 changes: 1 addition & 2 deletions mm2src/mm2_db/src/indexed_db/drivers/object_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ use web_sys::{IdbIndex, IdbObjectStore, IdbRequest};
pub struct IdbObjectStoreImpl {
pub(crate) object_store: IdbObjectStore,
pub(crate) aborted: Arc<AtomicBool>,
pub(crate) _not_send: common::NotSend
}

impl !Send for IdbObjectStoreImpl {}

impl IdbObjectStoreImpl {
pub(crate) fn aborted(&self) -> bool { self.aborted.load(Ordering::Relaxed) }

Expand Down
5 changes: 3 additions & 2 deletions mm2src/mm2_db/src/indexed_db/drivers/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ pub struct IdbTransactionImpl {
/// It's not used directly, but we need to hold the closures in memory till `transaciton` exists.
#[allow(dead_code)]
onabort_closure: Closure<dyn FnMut(JsValue)>,
_not_send: common::NotSend
}

impl !Send for IdbTransactionImpl {}

impl IdbTransactionImpl {
pub(crate) fn aborted(&self) -> bool { self.aborted.load(Ordering::Relaxed) }

Expand All @@ -79,6 +78,7 @@ impl IdbTransactionImpl {
Ok(object_store) => Ok(IdbObjectStoreImpl {
object_store,
aborted: self.aborted.clone(),
_not_send: common::NotSend::default(),
}),
Err(e) => MmError::err(DbTransactionError::ErrorOpeningTable {
table: table_name.to_owned(),
Expand All @@ -101,6 +101,7 @@ impl IdbTransactionImpl {
tables,
aborted,
onabort_closure,
_not_send: common::NotSend::default()
}
}
}
2 changes: 0 additions & 2 deletions mm2src/mm2_db/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(negative_impls)]

#[cfg(target_arch = "wasm32")]
#[path = "indexed_db/indexed_db.rs"]
pub mod indexed_db;
2 changes: 1 addition & 1 deletion mm2src/mm2_main/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ mm2_state_machine = { path = "../mm2_state_machine" }
trading_api = { path = "../trading_api" }
num-traits.workspace = true
parity-util-mem.workspace = true
parking_lot = { workspace = true, features = ["nightly"] }
parking_lot = { workspace = true }
primitives = { path = "../mm2_bitcoin/primitives" }
primitive-types.workspace = true
prost.workspace = true
Expand Down
1 change: 0 additions & 1 deletion mm2src/mm2_main/tests/docker_tests_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![feature(custom_test_frameworks)]
#![feature(test)]
#![test_runner(docker_tests_runner)]
#![feature(hash_raw_entry)]

#[cfg(test)]
#[macro_use]
Expand Down
1 change: 0 additions & 1 deletion mm2src/mm2_main/tests/docker_tests_sia_unique.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![feature(custom_test_frameworks)]
#![feature(test)]
#![feature(hash_raw_entry)]
#![cfg(feature = "enable-sia")]
#![cfg(not(target_arch = "wasm32"))]
#![allow(unused_imports, dead_code)]
Expand Down
4 changes: 2 additions & 2 deletions mm2src/mm2_metamask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ derive_more.workspace = true
futures = { workspace = true }
itertools.workspace = true
js-sys.workspace = true
jsonrpc-core.workspace = true
jsonrpc-core.workspace = true
lazy_static.workspace = true
mm2_err_handle = { path = "../mm2_err_handle" }
mm2_eth = { path = "../mm2_eth" }
parking_lot = { workspace = true, features = ["nightly"] }
parking_lot = { workspace = true }
serde.workspace = true
serde_json = { workspace = true, features = ["preserve_order", "raw_value"] }
serde_derive.workspace = true
Expand Down
20 changes: 20 additions & 0 deletions mm2src/mm2_net/src/ip_addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,23 @@ pub fn addr_to_ipv4_string(address: &str) -> Result<String, MmError<ParseAddress
address: address.to_owned(),
})
}

/// Stable port of `Ipv4Addr::is_global` which should be removed once
/// stabilized on std.
pub fn is_global_ipv4(ip: &Ipv4Addr) -> bool {
!(ip.octets()[0] == 0 // "This network"
|| ip.is_private()
|| ip.octets()[0] == 100 && (ip.octets()[1] & 0b1100_0000 == 0b0100_0000)
Comment thread
mariocynicys marked this conversation as resolved.
|| ip.is_loopback()
|| ip.is_link_local()
// addresses reserved for future protocols (`192.0.0.0/24`)
// .9 and .10 are documented as globally reachable so they're excluded
|| (
ip.octets()[0] == 192 && ip.octets()[1] == 0 && ip.octets()[2] == 0
&& ip.octets()[3] != 9 && ip.octets()[3] != 10
)
|| ip.is_documentation()
|| ip.octets()[0] == 198 && (ip.octets()[1] & 0xfe) == 18
|| ip.octets()[0] & 240 == 240 && !ip.is_broadcast()
Comment thread
mariocynicys marked this conversation as resolved.
|| ip.is_broadcast())
}
4 changes: 2 additions & 2 deletions mm2src/mm2_p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mm2_core = { path = "../mm2_core" }
mm2_event_stream = { path = "../mm2_event_stream" }
mm2_net = { path = "../mm2_net" }
mm2_number = { path = "../mm2_number", optional = true }
parking_lot = { workspace = true, features = ["nightly"] }
parking_lot = { workspace = true }
rand = { workspace = true, features = ["wasm-bindgen"] }
regex.workspace = true
rmp-serde.workspace = true
Expand All @@ -34,7 +34,7 @@ serde_bytes.workspace = true
serde_json = { workspace = true, features = ["preserve_order", "raw_value"] }
sha2.workspace = true
smallvec.workspace = true
void.workspace = true
void.workspace = true

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
futures-rustls.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion mm2src/mm2_p2p/src/behaviours/atomicdex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use libp2p::swarm::{ConnectionDenied, ConnectionId, NetworkBehaviour, SwarmEvent
use libp2p::{identity, noise, PeerId, Swarm};
use libp2p::{Multiaddr, Transport};
use log::{debug, error, info};
use mm2_net::ip_addr::is_global_ipv4;
use rand::seq::SliceRandom;
use std::collections::hash_map::DefaultHasher;
use std::collections::HashMap;
Expand Down Expand Up @@ -965,7 +966,7 @@ fn announce_my_addresses(swarm: &mut AtomicDexSwarm) {
.filter(|listener| {
for protocol in listener.iter() {
if let Protocol::Ip4(ip) = protocol {
return ip.is_global();
return is_global_ipv4(&ip);
}
}
false
Expand Down
Loading
Loading