Skip to content

Commit

Permalink
Downscope usage of futures
Browse files Browse the repository at this point in the history
  • Loading branch information
kayabaNerve committed Dec 11, 2023
1 parent 32bea92 commit 6caf45e
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 22 deletions.
10 changes: 6 additions & 4 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions coins/monero/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ frost = { package = "modular-frost", path = "../../crypto/frost", version = "0.8

monero-generators = { path = "generators", version = "0.4", default-features = false }

futures = { version = "0.3", default-features = false, features = ["alloc"], optional = true }
async-lock = { version = "3", default-features = false, optional = true }

hex-literal = "0.4"
hex = { version = "0.4", default-features = false, features = ["alloc"] }
Expand Down Expand Up @@ -92,7 +92,7 @@ std = [

"monero-generators/std",

"futures?/std",
"async-lock?/std",

"hex/std",
"serde/std",
Expand All @@ -101,7 +101,7 @@ std = [
"base58-monero/std",
]

cache-distribution = ["futures"]
cache-distribution = ["async-lock"]
http-rpc = ["digest_auth", "simple-request", "tokio"]
multisig = ["transcript", "frost", "dleq", "std"]
binaries = ["tokio/rt-multi-thread", "tokio/macros", "http-rpc"]
Expand Down
2 changes: 1 addition & 1 deletion coins/monero/src/wallet/decoys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std_shims::sync::OnceLock;
#[cfg(all(feature = "cache-distribution", not(feature = "std")))]
use std_shims::sync::Mutex;
#[cfg(all(feature = "cache-distribution", feature = "std"))]
use futures::lock::Mutex;
use async_lock::Mutex;

use zeroize::{Zeroize, ZeroizeOnDrop};

Expand Down
3 changes: 1 addition & 2 deletions coordinator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ borsh = { version = "1", default-features = false, features = ["std", "derive",
log = { version = "0.4", default-features = false, features = ["std"] }
env_logger = { version = "0.10", default-features = false, features = ["humantime"] }

futures = { version = "0.3", default-features = false, features = ["std"] }
tokio = { version = "1", default-features = false, features = ["rt-multi-thread", "sync", "time", "macros"] }
libp2p = { version = "0.52", default-features = false, features = ["tokio", "tcp", "noise", "yamux", "gossipsub", "mdns", "macros"] }

[dev-dependencies]
futures = { version = "0.3", default-features = false, features = ["std"] }
futures-util = { version = "0.3", default-features = false, features = ["std"] }
tributary = { package = "tributary-chain", path = "./tributary", features = ["tests"] }
sp-application-crypto = { git = "https://github.com/serai-dex/substrate", default-features = false, features = ["std"] }
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false, features = ["std"] }
Expand Down
2 changes: 1 addition & 1 deletion coordinator/src/tests/tributary/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{

use zeroize::Zeroizing;
use rand_core::{RngCore, CryptoRng, OsRng};
use futures::{task::Poll, poll};
use futures_util::{task::Poll, poll};

use ciphersuite::{
group::{ff::Field, GroupEncoding},
Expand Down
3 changes: 2 additions & 1 deletion coordinator/tributary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ log = { version = "0.4", default-features = false, features = ["std"] }
serai-db = { path = "../../common/db" }

scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["std", "derive"] }
futures = { version = "0.3", default-features = false, features = ["std"] }
futures-util = { version = "0.3", default-features = false, features = ["std", "sink", "channel"] }
futures-channel = { version = "0.3", default-features = false, features = ["std", "sink"] }
tendermint = { package = "tendermint-machine", path = "./tendermint" }

tokio = { version = "1", default-features = false, features = ["sync", "time", "rt"] }
Expand Down
3 changes: 2 additions & 1 deletion coordinator/tributary/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use zeroize::Zeroizing;
use ciphersuite::{Ciphersuite, Ristretto};

use scale::Decode;
use futures::{StreamExt, SinkExt, channel::mpsc::UnboundedReceiver};
use futures_channel::mpsc::UnboundedReceiver;
use futures_util::{StreamExt, SinkExt};
use ::tendermint::{
ext::{BlockNumber, Commit, Block as BlockTrait, Network},
SignedMessageFor, SyncedBlock, SyncedBlockSender, SyncedBlockResultReceiver, MessageSender,
Expand Down
3 changes: 2 additions & 1 deletion coordinator/tributary/tendermint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ log = { version = "0.4", default-features = false, features = ["std"] }

parity-scale-codec = { version = "3", default-features = false, features = ["std", "derive"] }

futures = { version = "0.3", default-features = false, features = ["std", "async-await"] }
futures-util = { version = "0.3", default-features = false, features = ["std", "async-await-macro", "sink", "channel"] }
futures-channel = { version = "0.3", default-features = false, features = ["std", "sink"] }
tokio = { version = "1", default-features = false, features = ["time"] }

[dev-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions coordinator/tributary/tendermint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use std::{

use parity_scale_codec::{Encode, Decode};

use futures::{
use futures_channel::mpsc;
use futures_util::{
FutureExt, StreamExt, SinkExt,
future::{self, Fuse},
channel::mpsc,
};
use tokio::time::sleep;

Expand Down Expand Up @@ -367,7 +367,7 @@ impl<N: Network + 'static> TendermintMachine<N> {
let mut queue_future =
if self.queue.is_empty() { Fuse::terminated() } else { future::ready(()).fuse() };

if let Some((our_message, msg, mut sig)) = futures::select_biased! {
if let Some((our_message, msg, mut sig)) = futures_util::select_biased! {
// Handle a new block occurring externally (an external sync loop)
// Has the highest priority as it makes all other futures here irrelevant
msg = self.synced_block_recv.next() => {
Expand Down
6 changes: 3 additions & 3 deletions coordinator/tributary/tendermint/src/round.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
collections::HashMap,
};

use futures::{FutureExt, future};
use futures_util::{FutureExt, future};
use tokio::time::sleep;

use crate::{
Expand Down Expand Up @@ -80,9 +80,9 @@ impl<N: Network> RoundData<N> {
let propose_timeout = timeout_future(Step::Propose);
let prevote_timeout = timeout_future(Step::Prevote);
let precommit_timeout = timeout_future(Step::Precommit);
futures::pin_mut!(propose_timeout, prevote_timeout, precommit_timeout);
futures_util::pin_mut!(propose_timeout, prevote_timeout, precommit_timeout);

futures::select_biased! {
futures_util::select_biased! {
step = propose_timeout => step,
step = prevote_timeout => step,
step = precommit_timeout => step,
Expand Down
2 changes: 1 addition & 1 deletion coordinator/tributary/tendermint/tests/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use async_trait::async_trait;

use parity_scale_codec::{Encode, Decode};

use futures::SinkExt;
use futures_util::sink::SinkExt;
use tokio::{sync::RwLock, time::sleep};

use tendermint_machine::{
Expand Down
2 changes: 1 addition & 1 deletion tests/no-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ dkg = { path = "../../crypto/dkg", default-features = false }
bitcoin-serai = { path = "../../coins/bitcoin", default-features = false, features = ["hazmat"] }

monero-generators = { path = "../../coins/monero/generators", default-features = false }
monero-serai = { path = "../../coins/monero", default-features = false }
monero-serai = { path = "../../coins/monero", default-features = false, features = ["cache-distribution"] }

0 comments on commit 6caf45e

Please sign in to comment.