parazyd преди 3 години
родител
ревизия
2d0e3b0d89
променени са 48 файла, в които са добавени 86 реда и са изтрити 126 реда
  1. 1 2
      Cargo.lock
  2. 1 3
      src/blockchain/block_store.rs
  3. 1 3
      src/blockchain/header_store.rs
  4. 1 3
      src/consensus/block.rs
  5. 1 3
      src/consensus/lead_coin.rs
  6. 1 3
      src/consensus/lead_info.rs
  7. 1 3
      src/consensus/rcpt.rs
  8. 1 3
      src/consensus/state.rs
  9. 1 3
      src/consensus/stx.rs
  10. 1 3
      src/consensus/tx.rs
  11. 2 0
      src/contract/consensus/Cargo.toml
  12. 3 0
      src/contract/consensus/src/model.rs
  13. 2 2
      src/contract/consensus/tests/genesis_stake_unstake.rs
  14. 6 6
      src/contract/consensus/tests/stake_unstake.rs
  15. 2 0
      src/contract/dao/Cargo.toml
  16. 1 1
      src/contract/dao/src/client/propose.rs
  17. 1 1
      src/contract/dao/src/client/vote.rs
  18. 3 0
      src/contract/dao/src/model.rs
  19. 6 0
      src/contract/deployooor/Cargo.toml
  20. 3 0
      src/contract/deployooor/src/model.rs
  21. 3 1
      src/contract/money/Cargo.toml
  22. 1 1
      src/contract/money/src/client/mod.rs
  23. 3 0
      src/contract/money/src/model.rs
  24. 2 2
      src/contract/money/tests/genesis_mint.rs
  25. 1 1
      src/contract/test-harness/Cargo.toml
  26. 2 6
      src/event_graph/model.rs
  27. 1 4
      src/event_graph/protocol_event.rs
  28. 2 3
      src/net/channel.rs
  29. 2 2
      src/net/message.rs
  30. 1 3
      src/sdk/Cargo.toml
  31. 1 4
      src/sdk/src/blockchain.rs
  32. 1 4
      src/sdk/src/crypto/contract_id.rs
  33. 1 4
      src/sdk/src/crypto/ecvrf.rs
  34. 1 4
      src/sdk/src/crypto/keypair.rs
  35. 3 5
      src/sdk/src/crypto/merkle_node.rs
  36. 3 5
      src/sdk/src/crypto/note.rs
  37. 1 4
      src/sdk/src/crypto/nullifier.rs
  38. 1 4
      src/sdk/src/crypto/schnorr.rs
  39. 1 4
      src/sdk/src/crypto/token_id.rs
  40. 1 4
      src/sdk/src/tx.rs
  41. 5 5
      src/serial/derive-internal/src/async_derive.rs
  42. 3 3
      src/serial/src/async_lib.rs
  43. 2 1
      src/serial/src/lib.rs
  44. 1 3
      src/tx/mod.rs
  45. 1 3
      src/util/time.rs
  46. 1 3
      src/validator/consensus/mod.rs
  47. 1 3
      src/zk/proof.rs
  48. 1 1
      src/zkas/error.rs

+ 1 - 2
Cargo.lock

@@ -1513,6 +1513,7 @@ dependencies = [
 name = "darkfi-deployooor-contract"
 version = "0.4.1"
 dependencies = [
+ "async-trait",
  "darkfi-sdk",
  "darkfi-serial",
  "getrandom 0.2.10",
@@ -1563,14 +1564,12 @@ dependencies = [
 name = "darkfi-sdk"
 version = "0.4.1"
 dependencies = [
- "async-trait",
  "blake2b_simd",
  "blake3",
  "bridgetree",
  "bs58",
  "chacha20poly1305",
  "darkfi-serial",
- "futures-lite",
  "halo2_gadgets",
  "halo2_proofs",
  "lazy_static",

+ 1 - 3
src/blockchain/block_store.rs

@@ -16,14 +16,12 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use async_trait::async_trait;
 use darkfi_sdk::{
     blockchain::Slot,
     crypto::schnorr::Signature,
     pasta::{group::ff::Field, pallas},
 };
-use darkfi_serial::{deserialize, serialize, SerialDecodable, SerialEncodable};
-use smol::io::{AsyncRead, AsyncWrite};
+use darkfi_serial::{async_trait, deserialize, serialize, SerialDecodable, SerialEncodable};
 
 use crate::{tx::Transaction, Error, Result};
 

+ 1 - 3
src/blockchain/header_store.rs

@@ -16,10 +16,8 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use async_trait::async_trait;
 use darkfi_sdk::crypto::{MerkleNode, MerkleTree};
-use darkfi_serial::{deserialize, serialize, SerialDecodable, SerialEncodable};
-use smol::io::{AsyncRead, AsyncWrite};
+use darkfi_serial::{async_trait, deserialize, serialize, SerialDecodable, SerialEncodable};
 
 use crate::{util::time::Timestamp, Error, Result};
 

+ 1 - 3
src/consensus/block.rs

@@ -18,13 +18,11 @@
 
 use std::fmt;
 
-use async_trait::async_trait;
 use darkfi_sdk::{
     crypto::{MerkleNode, MerkleTree},
     pasta::pallas,
 };
-use darkfi_serial::{serialize, SerialDecodable, SerialEncodable};
-use smol::io::{AsyncRead, AsyncWrite};
+use darkfi_serial::{async_trait, serialize, SerialDecodable, SerialEncodable};
 
 use super::{
     constants::{BLOCK_MAGIC_BYTES, BLOCK_VERSION},

+ 1 - 3
src/consensus/lead_coin.rs

@@ -16,7 +16,6 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use async_trait::async_trait;
 use darkfi_sdk::{
     crypto::{
         pedersen::{pedersen_commitment_base, pedersen_commitment_u64},
@@ -26,11 +25,10 @@ use darkfi_sdk::{
     },
     pasta::{arithmetic::CurveAffine, group::Curve, pallas},
 };
-use darkfi_serial::{SerialDecodable, SerialEncodable};
+use darkfi_serial::{async_trait, SerialDecodable, SerialEncodable};
 use halo2_proofs::{arithmetic::Field, circuit::Value};
 use log::info;
 use rand::rngs::OsRng;
-use smol::io::{AsyncRead, AsyncWrite};
 
 use super::constants::EPOCH_LENGTH;
 use crate::{

+ 1 - 3
src/consensus/lead_info.rs

@@ -16,14 +16,12 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use async_trait::async_trait;
 use darkfi_sdk::{
     crypto::{schnorr::Signature, Keypair, PublicKey},
     pasta::pallas,
 };
-use darkfi_serial::{SerialDecodable, SerialEncodable};
+use darkfi_serial::{async_trait, SerialDecodable, SerialEncodable};
 use log::error;
-use smol::io::{AsyncRead, AsyncWrite};
 
 use crate::{
     zk::proof::{Proof, VerifyingKey},

+ 1 - 3
src/consensus/rcpt.rs

@@ -16,7 +16,6 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use async_trait::async_trait;
 use crypto_api_chachapoly::ChachaPolyIetf;
 use darkfi_sdk::{
     crypto::{
@@ -26,9 +25,8 @@ use darkfi_sdk::{
     },
     pasta::pallas,
 };
-use darkfi_serial::{Decodable, Encodable, SerialDecodable, SerialEncodable};
+use darkfi_serial::{async_trait, Decodable, Encodable, SerialDecodable, SerialEncodable};
 use rand::rngs::OsRng;
-use smol::io::{AsyncRead, AsyncWrite};
 
 use crate::Error;
 

+ 1 - 3
src/consensus/state.rs

@@ -16,16 +16,14 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use async_trait::async_trait;
 use darkfi_sdk::{
     blockchain::{PidOutput, PreviousSlot, Slot},
     crypto::MerkleTree,
     pasta::{group::ff::PrimeField, pallas},
 };
-use darkfi_serial::{deserialize, serialize, SerialDecodable, SerialEncodable};
+use darkfi_serial::{async_trait, deserialize, serialize, SerialDecodable, SerialEncodable};
 use log::info;
 use rand::{thread_rng, Rng};
-use smol::io::{AsyncRead, AsyncWrite};
 
 use super::{
     constants,

+ 1 - 3
src/consensus/stx.rs

@@ -16,18 +16,16 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use async_trait::async_trait;
 use darkfi_sdk::{
     crypto::MerkleNode,
     pasta::{arithmetic::CurveAffine, group::Curve, pallas},
 };
-use smol::io::{AsyncRead, AsyncWrite};
+use darkfi_serial::{async_trait, SerialDecodable, SerialEncodable};
 
 use crate::{
     zk::{proof::VerifyingKey, Proof},
     Error, Result,
 };
-use darkfi_serial::{SerialDecodable, SerialEncodable};
 
 #[derive(Debug, Clone, SerialDecodable, SerialEncodable)]
 pub struct TransferStx {

+ 1 - 3
src/consensus/tx.rs

@@ -16,9 +16,7 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use async_trait::async_trait;
-use darkfi_serial::{SerialDecodable, SerialEncodable};
-use smol::io::{AsyncRead, AsyncWrite};
+use darkfi_serial::{async_trait, SerialDecodable, SerialEncodable};
 
 use crate::consensus::{EncryptedTxRcpt, TransferStx};
 

+ 2 - 0
src/contract/consensus/Cargo.toml

@@ -43,8 +43,10 @@ default = []
 no-entrypoint = []
 client = [
     "darkfi",
+    "darkfi-serial/async",
     "darkfi-money-contract/client",
     "darkfi-money-contract/no-entrypoint",
+
     "rand",
     "chacha20poly1305",
     "log",

+ 3 - 0
src/contract/consensus/src/model.rs

@@ -23,6 +23,9 @@ use darkfi_sdk::{
 };
 use darkfi_serial::{SerialDecodable, SerialEncodable};
 
+#[cfg(feature = "client")]
+use darkfi_serial::async_trait;
+
 /// Parameters for `Consensus::GenesisStake`
 #[derive(Clone, Debug, SerialEncodable, SerialDecodable)]
 // ANCHOR: ConsensusGenesisStakeParams

+ 2 - 2
src/contract/consensus/tests/genesis_stake_unstake.rs

@@ -63,7 +63,7 @@ fn consensus_contract_genesis_stake_unstake() -> Result<()> {
         th.execute_erroneous_txs(
             TxAction::ConsensusGenesisStake,
             &Holder::Alice,
-            &vec![genesis_stake_tx.clone(), genesis_stake_tx.clone()],
+            &[genesis_stake_tx.clone(), genesis_stake_tx.clone()],
             current_slot,
             1,
         )
@@ -75,7 +75,7 @@ fn consensus_contract_genesis_stake_unstake() -> Result<()> {
         th.execute_erroneous_txs(
             TxAction::ConsensusGenesisStake,
             &Holder::Alice,
-            &vec![genesis_stake_tx.clone()],
+            &[genesis_stake_tx.clone()],
             current_slot + 1,
             1,
         )

+ 6 - 6
src/contract/consensus/tests/stake_unstake.rs

@@ -111,7 +111,7 @@ fn consensus_contract_stake_unstake() -> Result<()> {
         th.execute_erroneous_txs(
             TxAction::ConsensusStake,
             &Holder::Alice,
-            &vec![stake_tx],
+            &[stake_tx],
             current_slot,
             1,
         )
@@ -129,7 +129,7 @@ fn consensus_contract_stake_unstake() -> Result<()> {
         th.execute_erroneous_txs(
             TxAction::ConsensusProposal,
             &Holder::Alice,
-            &vec![proposal_tx],
+            &[proposal_tx],
             current_slot,
             1,
         )
@@ -144,7 +144,7 @@ fn consensus_contract_stake_unstake() -> Result<()> {
         th.execute_erroneous_txs(
             TxAction::ConsensusUnstakeRequest,
             &Holder::Alice,
-            &vec![unstake_request_tx],
+            &[unstake_request_tx],
             current_slot,
             1,
         )
@@ -166,7 +166,7 @@ fn consensus_contract_stake_unstake() -> Result<()> {
         th.execute_erroneous_txs(
             TxAction::ConsensusUnstakeRequest,
             &Holder::Alice,
-            &vec![unstake_request_tx],
+            &[unstake_request_tx],
             current_slot,
             1,
         )
@@ -187,7 +187,7 @@ fn consensus_contract_stake_unstake() -> Result<()> {
         th.execute_erroneous_txs(
             TxAction::ConsensusUnstake,
             &Holder::Alice,
-            &vec![unstake_tx],
+            &[unstake_tx],
             current_slot,
             1,
         )
@@ -217,7 +217,7 @@ fn consensus_contract_stake_unstake() -> Result<()> {
         th.execute_erroneous_txs(
             TxAction::ConsensusProposal,
             &Holder::Alice,
-            &vec![proposal_tx],
+            &[proposal_tx],
             current_slot,
             1,
         )

+ 2 - 0
src/contract/dao/Cargo.toml

@@ -42,8 +42,10 @@ default = []
 no-entrypoint = []
 client = [
     "darkfi",
+    "darkfi-serial/async",
     "darkfi-money-contract/client",
     "darkfi-money-contract/no-entrypoint",
+
     "rand",
     "chacha20poly1305",
     "log",

+ 1 - 1
src/contract/dao/src/client/propose.rs

@@ -25,7 +25,7 @@ use darkfi_sdk::{
     },
     pasta::pallas,
 };
-use darkfi_serial::{SerialDecodable, SerialEncodable};
+use darkfi_serial::{async_trait, SerialDecodable, SerialEncodable};
 use rand::rngs::OsRng;
 
 use darkfi::{

+ 1 - 1
src/contract/dao/src/client/vote.rs

@@ -25,7 +25,7 @@ use darkfi_sdk::{
     },
     pasta::pallas,
 };
-use darkfi_serial::{SerialDecodable, SerialEncodable};
+use darkfi_serial::{async_trait, SerialDecodable, SerialEncodable};
 use log::debug;
 use rand::rngs::OsRng;
 

+ 3 - 0
src/contract/dao/src/model.rs

@@ -26,6 +26,9 @@ use darkfi_sdk::{
 };
 use darkfi_serial::{SerialDecodable, SerialEncodable};
 
+#[cfg(feature = "client")]
+use darkfi_serial::async_trait;
+
 /// A `DaoBulla` represented in the state
 #[derive(Debug, Copy, Clone, Eq, PartialEq, SerialEncodable, SerialDecodable)]
 pub struct DaoBulla(pallas::Base);

+ 6 - 0
src/contract/deployooor/Cargo.toml

@@ -13,6 +13,8 @@ darkfi-sdk = { path = "../../sdk" }
 darkfi-serial = { path = "../../serial", features = ["derive", "crypto"] }
 thiserror = "1.0.47"
 
+async-trait = { version = "0.1.73", optional = true }
+
 # We need to disable random using "custom" which makes the crate a noop
 # so the wasm32-unknown-unknown target is enabled.
 [target.'cfg(target_arch = "wasm32")'.dependencies]
@@ -21,3 +23,7 @@ getrandom = { version = "0.2.8", features = ["custom"] }
 [features]
 default = []
 no-entrypoint = []
+client = [
+    "darkfi-sdk/async",
+    "darkfi-serial/async",
+]

+ 3 - 0
src/contract/deployooor/src/model.rs

@@ -16,6 +16,9 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
+#[cfg(feature = "client")]
+use darkfi_serial::async_trait;
+
 use darkfi_sdk::crypto::{ContractId, PublicKey};
 use darkfi_serial::{SerialDecodable, SerialEncodable};
 

+ 3 - 1
src/contract/money/Cargo.toml

@@ -16,8 +16,8 @@ thiserror = "1.0.47"
 
 # The following dependencies are used for the client API and
 # probably shouldn't be in WASM
-chacha20poly1305 = { version = "0.10.1", optional = true }
 darkfi = { path = "../../../", features = ["zk", "rpc", "blockchain"], optional = true }
+chacha20poly1305 = { version = "0.10.1", optional = true }
 halo2_proofs = { version = "0.3.0", optional = true }
 log = { version = "0.4.20", optional = true }
 rand = { version = "0.8.5", optional = true }
@@ -40,6 +40,8 @@ default = []
 no-entrypoint = []
 client = [
     "darkfi",
+    "darkfi-serial/async",
+
     "rand",
     "chacha20poly1305",
     "log",

+ 1 - 1
src/contract/money/src/client/mod.rs

@@ -31,7 +31,7 @@ use darkfi_sdk::{
     crypto::{pasta_prelude::*, Nullifier, SecretKey, TokenId, DARK_TOKEN_ID},
     pasta::pallas,
 };
-use darkfi_serial::{SerialDecodable, SerialEncodable};
+use darkfi_serial::{async_trait, SerialDecodable, SerialEncodable};
 
 use crate::model::Coin;
 

+ 3 - 0
src/contract/money/src/model.rs

@@ -26,6 +26,9 @@ use darkfi_sdk::{
 };
 use darkfi_serial::{SerialDecodable, SerialEncodable};
 
+#[cfg(feature = "client")]
+use darkfi_serial::async_trait;
+
 /// A `Coin` represented in the Money state
 #[derive(Debug, Clone, Copy, Eq, PartialEq, SerialEncodable, SerialDecodable)]
 pub struct Coin(pallas::Base);

+ 2 - 2
src/contract/money/tests/genesis_mint.rs

@@ -72,7 +72,7 @@ fn genesis_mint() -> Result<()> {
         th.execute_erroneous_txs(
             TxAction::MoneyGenesisMint,
             &Holder::Alice,
-            &vec![genesis_mint_tx.clone(), genesis_mint_tx.clone()],
+            &[genesis_mint_tx.clone(), genesis_mint_tx.clone()],
             current_slot,
             1,
         )
@@ -84,7 +84,7 @@ fn genesis_mint() -> Result<()> {
         th.execute_erroneous_txs(
             TxAction::MoneyGenesisMint,
             &Holder::Alice,
-            &vec![genesis_mint_tx.clone()],
+            &[genesis_mint_tx.clone()],
             current_slot + 1,
             1,
         )

+ 1 - 1
src/contract/test-harness/Cargo.toml

@@ -12,7 +12,7 @@ darkfi-serial = {path = "../../../src/serial", features = ["derive", "crypto"]}
 darkfi-dao-contract = {path = "../dao", features = ["client", "no-entrypoint"]}
 darkfi-money-contract = {path = "../money", features = ["client", "no-entrypoint"]}
 darkfi-consensus-contract = {path = "../consensus", features = ["client", "no-entrypoint"]}
-darkfi-deployooor-contract = {path = "../deployooor", features = ["no-entrypoint"]}
+darkfi-deployooor-contract = {path = "../deployooor", features = ["client", "no-entrypoint"]}
 
 blake3 = "1.4.1"
 bs58 = "0.5.0"

+ 2 - 6
src/event_graph/model.rs

@@ -18,15 +18,11 @@
 
 use std::{cmp::Ordering, collections::HashMap, fmt::Debug, path::Path, sync::Arc};
 
-use async_trait::async_trait;
 use darkfi_serial::{
-    deserialize, serialize, Decodable, Encodable, SerialDecodable, SerialEncodable,
+    async_trait, deserialize, serialize, Decodable, Encodable, SerialDecodable, SerialEncodable,
 };
 use log::{error, info};
-use smol::{
-    io::{AsyncRead, AsyncWrite},
-    lock::Mutex,
-};
+use smol::lock::Mutex;
 use tinyjson::JsonValue;
 
 use crate::{

+ 1 - 4
src/event_graph/protocol_event.rs

@@ -21,10 +21,7 @@ use std::{fmt::Debug, sync::Arc};
 use async_trait::async_trait;
 use darkfi_serial::{Decodable, Encodable, SerialDecodable, SerialEncodable};
 use log::debug;
-use smol::{
-    io::{AsyncRead, AsyncWrite},
-    lock::Mutex,
-};
+use smol::lock::Mutex;
 
 use super::EventMsg;
 use crate::{

+ 2 - 3
src/net/channel.rs

@@ -18,12 +18,11 @@
 
 use std::sync::Arc;
 
-use async_trait::async_trait;
-use darkfi_serial::{serialize, SerialDecodable, SerialEncodable};
+use darkfi_serial::{async_trait, serialize, SerialDecodable, SerialEncodable};
 use log::{debug, error, info};
 use rand::{rngs::OsRng, Rng};
 use smol::{
-    io::{self, AsyncRead, AsyncWrite, ReadHalf, WriteHalf},
+    io::{self, ReadHalf, WriteHalf},
     lock::Mutex,
     Executor,
 };

+ 2 - 2
src/net/message.rs

@@ -16,9 +16,9 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use async_trait::async_trait;
 use darkfi_serial::{
-    AsyncDecodable, AsyncEncodable, Decodable, Encodable, SerialDecodable, SerialEncodable, VarInt,
+    async_trait, AsyncDecodable, AsyncEncodable, Decodable, Encodable, SerialDecodable,
+    SerialEncodable, VarInt,
 };
 use log::trace;
 use smol::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};

+ 1 - 3
src/sdk/Cargo.toml

@@ -13,15 +13,13 @@ doctest = false
 
 [features]
 default = []
-async = ["async-trait", "futures-lite"]
+async = ["darkfi-serial/async"]
 
 [dependencies]
 # Error handling
 thiserror = "1.0.47"
 
 # Serialization
-async-trait = {version = "0.1.73", optional = true}
-futures-lite = {version = "1.13.0", optional = true}
 darkfi-serial = {version = "0.4.1", path = "../serial", features = ["derive", "crypto"]}
 
 # Encoding

+ 1 - 4
src/sdk/src/blockchain.rs

@@ -16,11 +16,8 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#[cfg(feature = "async-trait")]
-use async_trait::async_trait;
 #[cfg(feature = "async")]
-use futures_lite::{AsyncRead, AsyncWrite};
-
+use darkfi_serial::async_trait;
 use darkfi_serial::{SerialDecodable, SerialEncodable};
 use pasta_curves::{group::ff::Field, pallas};
 

+ 1 - 4
src/sdk/src/crypto/contract_id.rs

@@ -17,10 +17,7 @@
  */
 
 #[cfg(feature = "async")]
-use async_trait::async_trait;
-#[cfg(feature = "async")]
-use futures_lite::{AsyncRead, AsyncWrite};
-
+use darkfi_serial::async_trait;
 use darkfi_serial::{serialize, SerialDecodable, SerialEncodable};
 use lazy_static::lazy_static;
 use pasta_curves::{group::ff::PrimeField, pallas};

+ 1 - 4
src/sdk/src/crypto/ecvrf.rs

@@ -20,10 +20,7 @@
 #![allow(non_snake_case)]
 
 #[cfg(feature = "async")]
-use async_trait::async_trait;
-#[cfg(feature = "async")]
-use futures_lite::{AsyncRead, AsyncWrite};
-
+use darkfi_serial::async_trait;
 use darkfi_serial::{SerialDecodable, SerialEncodable};
 use halo2_gadgets::ecc::chip::FixedPoint;
 use pasta_curves::{

+ 1 - 4
src/sdk/src/crypto/keypair.rs

@@ -19,10 +19,7 @@
 use core::str::FromStr;
 
 #[cfg(feature = "async")]
-use async_trait::async_trait;
-#[cfg(feature = "async")]
-use futures_lite::{AsyncRead, AsyncWrite};
-
+use darkfi_serial::async_trait;
 use darkfi_serial::{SerialDecodable, SerialEncodable};
 use halo2_gadgets::ecc::chip::FixedPoint;
 use pasta_curves::{

+ 3 - 5
src/sdk/src/crypto/merkle_node.rs

@@ -19,11 +19,6 @@
 use core::{fmt, str::FromStr};
 use std::{io, iter};
 
-#[cfg(feature = "async")]
-use async_trait::async_trait;
-#[cfg(feature = "async")]
-use futures_lite::{AsyncRead, AsyncWrite};
-
 use bridgetree::{BridgeTree, Hashable, Level};
 use darkfi_serial::{SerialDecodable, SerialEncodable};
 use halo2_gadgets::sinsemilla::primitives::HashDomain;
@@ -34,6 +29,9 @@ use pasta_curves::{
 };
 use subtle::{Choice, ConditionallySelectable};
 
+#[cfg(feature = "async")]
+use darkfi_serial::async_trait;
+
 use crate::crypto::constants::{
     sinsemilla::{i2lebsp_k, L_ORCHARD_MERKLE, MERKLE_CRH_PERSONALIZATION},
     MERKLE_DEPTH,

+ 3 - 5
src/sdk/src/crypto/note.rs

@@ -16,16 +16,14 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-#[cfg(feature = "async")]
-use async_trait::async_trait;
-#[cfg(feature = "async")]
-use futures_lite::{AsyncRead, AsyncWrite};
-
 use chacha20poly1305::{AeadInPlace, ChaCha20Poly1305, KeyInit};
 use darkfi_serial::{Decodable, Encodable, SerialDecodable, SerialEncodable};
 use pasta_curves::{group::ff::Field, pallas};
 use rand_core::{CryptoRng, RngCore};
 
+#[cfg(feature = "async")]
+use darkfi_serial::async_trait;
+
 use super::{diffie_hellman, poseidon_hash, util::mod_r_p, PublicKey, SecretKey};
 use crate::error::ContractError;
 

+ 1 - 4
src/sdk/src/crypto/nullifier.rs

@@ -17,10 +17,7 @@
  */
 
 #[cfg(feature = "async")]
-use async_trait::async_trait;
-#[cfg(feature = "async")]
-use futures_lite::{AsyncRead, AsyncWrite};
-
+use darkfi_serial::async_trait;
 use darkfi_serial::{SerialDecodable, SerialEncodable};
 use pasta_curves::{group::ff::PrimeField, pallas};
 

+ 1 - 4
src/sdk/src/crypto/schnorr.rs

@@ -17,10 +17,7 @@
  */
 
 #[cfg(feature = "async")]
-use async_trait::async_trait;
-#[cfg(feature = "async")]
-use futures_lite::{AsyncRead, AsyncWrite};
-
+use darkfi_serial::async_trait;
 use darkfi_serial::{SerialDecodable, SerialEncodable};
 use halo2_gadgets::ecc::chip::FixedPoint;
 use pasta_curves::{

+ 1 - 4
src/sdk/src/crypto/token_id.rs

@@ -17,10 +17,7 @@
  */
 
 #[cfg(feature = "async")]
-use async_trait::async_trait;
-#[cfg(feature = "async")]
-use futures_lite::{AsyncRead, AsyncWrite};
-
+use darkfi_serial::async_trait;
 use darkfi_serial::{SerialDecodable, SerialEncodable};
 use lazy_static::lazy_static;
 use pasta_curves::{group::ff::PrimeField, pallas};

+ 1 - 4
src/sdk/src/tx.rs

@@ -17,10 +17,7 @@
  */
 
 #[cfg(feature = "async")]
-use async_trait::async_trait;
-#[cfg(feature = "async")]
-use futures_lite::{AsyncRead, AsyncWrite};
-
+use darkfi_serial::async_trait;
 use darkfi_serial::{SerialDecodable, SerialEncodable};
 
 use super::crypto::ContractId;

+ 5 - 5
src/serial/derive-internal/src/async_derive.rs

@@ -157,7 +157,7 @@ pub fn async_enum_ser(input: &ItemEnum, cratename: Ident) -> syn::Result<TokenSt
     Ok(quote! {
     #[async_trait]
     impl #impl_generics #cratename::AsyncEncodable for #enum_ident #ty_generics #where_clause {
-        async fn encode_async<S: AsyncWrite + Unpin + Send>(&self, s: &mut S) -> ::std::io::Result<usize> {
+        async fn encode_async<S: #cratename::AsyncWrite + Unpin + Send>(&self, s: &mut S) -> ::std::io::Result<usize> {
             let variant_idx: u8 = match self {
                 #all_variants_idx_body
             };
@@ -255,7 +255,7 @@ pub fn async_enum_de(input: &ItemEnum, cratename: Ident) -> syn::Result<TokenStr
     Ok(quote! {
     #[async_trait]
     impl #impl_generics #cratename::AsyncDecodable for #name #ty_generics #where_clause {
-        async fn decode_async<D: AsyncRead + Unpin + Send>(d: &mut D) -> ::std::io::Result<Self> {
+        async fn decode_async<D: #cratename::AsyncRead + Unpin + Send>(d: &mut D) -> ::std::io::Result<Self> {
             let variant_tag: u8 = #cratename::AsyncDecodable::decode_async(d).await?;
 
             let mut return_value =
@@ -322,7 +322,7 @@ pub fn async_struct_ser(input: &ItemStruct, cratename: Ident) -> syn::Result<Tok
     Ok(quote! {
     #[async_trait]
     impl #impl_generics #cratename::AsyncEncodable for #name #ty_generics #where_clause {
-        async fn encode_async<S: AsyncWrite + Unpin + Send>(&self, s: &mut S) -> ::std::io::Result<usize> {
+        async fn encode_async<S: #cratename::AsyncWrite + Unpin + Send>(&self, s: &mut S) -> ::std::io::Result<usize> {
             let mut len = 0;
             #body
             Ok(len)
@@ -392,7 +392,7 @@ pub fn async_struct_de(input: &ItemStruct, cratename: Ident) -> syn::Result<Toke
         Ok(quote! {
         #[async_trait]
         impl #impl_generics #cratename::AsyncDecodable for #name #ty_generics #where_clause {
-            async fn decode_async<D: AsyncRead + Unpin + Send>(d: &mut D) -> ::std::io::Result<Self> {
+            async fn decode_async<D: #cratename::AsyncRead + Unpin + Send>(d: &mut D) -> ::std::io::Result<Self> {
                 let mut return_value = #return_value;
                 return_value.#method_ident();
                 Ok(return_value)
@@ -403,7 +403,7 @@ pub fn async_struct_de(input: &ItemStruct, cratename: Ident) -> syn::Result<Toke
         Ok(quote! {
         #[async_trait]
         impl #impl_generics #cratename::AsyncDecodable for #name #ty_generics #where_clause {
-            async fn decode_async<D: AsyncRead + Unpin + Send>(d: &mut D) -> ::std::io::Result<Self> {
+            async fn decode_async<D: #cratename::AsyncRead + Unpin + Send>(d: &mut D) -> ::std::io::Result<Self> {
                 Ok(#return_value)
             }
         }

+ 3 - 3
src/serial/src/async_lib.rs

@@ -21,11 +21,11 @@ use std::{
     io::{Error, ErrorKind, Result},
 };
 
-use async_trait::async_trait;
+pub use async_trait::async_trait;
 use futures_lite::{
-    io::Cursor, AsyncRead, AsyncReadExt as FutAsyncReadExt, AsyncWrite,
-    AsyncWriteExt as FutAsyncWriteExt,
+    io::Cursor, AsyncReadExt as FutAsyncReadExt, AsyncWriteExt as FutAsyncWriteExt,
 };
+pub use futures_lite::{AsyncRead, AsyncWrite};
 
 use crate::{endian, VarInt};
 

+ 2 - 1
src/serial/src/lib.rs

@@ -28,7 +28,8 @@ pub use darkfi_derive::{SerialDecodable, SerialEncodable};
 mod async_lib;
 #[cfg(feature = "async")]
 pub use async_lib::{
-    deserialize_async, deserialize_async_partial, serialize_async, AsyncDecodable, AsyncEncodable,
+    async_trait, deserialize_async, deserialize_async_partial, serialize_async, AsyncDecodable,
+    AsyncEncodable, AsyncRead, AsyncWrite,
 };
 
 mod endian;

+ 1 - 3
src/tx/mod.rs

@@ -18,7 +18,6 @@
 
 use std::collections::HashMap;
 
-use async_trait::async_trait;
 use darkfi_sdk::{
     crypto::{
         schnorr::{SchnorrPublic, SchnorrSecret, Signature},
@@ -27,10 +26,9 @@ use darkfi_sdk::{
     pasta::pallas,
     tx::ContractCall,
 };
-use darkfi_serial::{serialize, Encodable, SerialDecodable, SerialEncodable};
+use darkfi_serial::{async_trait, serialize, Encodable, SerialDecodable, SerialEncodable};
 use log::{debug, error};
 use rand::{CryptoRng, RngCore};
-use smol::io::{AsyncRead, AsyncWrite};
 
 use crate::{
     error::TxVerifyFailed,

+ 1 - 3
src/util/time.rs

@@ -18,9 +18,7 @@
 
 use std::{fmt, time::UNIX_EPOCH};
 
-use async_trait::async_trait;
-use darkfi_serial::{SerialDecodable, SerialEncodable};
-use smol::io::{AsyncRead, AsyncWrite};
+use darkfi_serial::{async_trait, SerialDecodable, SerialEncodable};
 
 use crate::Result;
 

+ 1 - 3
src/validator/consensus/mod.rs

@@ -16,16 +16,14 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use async_trait::async_trait;
 use darkfi_sdk::{
     blockchain::{PidOutput, PreviousSlot, Slot},
     crypto::{schnorr::SchnorrSecret, MerkleNode, MerkleTree, SecretKey},
     pasta::{group::ff::PrimeField, pallas},
 };
-use darkfi_serial::{serialize, SerialDecodable, SerialEncodable};
+use darkfi_serial::{async_trait, serialize, SerialDecodable, SerialEncodable};
 use log::{error, info, warn};
 use rand::rngs::OsRng;
-use smol::io::{AsyncRead, AsyncWrite};
 
 use crate::{
     blockchain::{

+ 1 - 3
src/zk/proof.rs

@@ -17,9 +17,8 @@
  */
 use std::{io, io::Cursor};
 
-use async_trait::async_trait;
 use darkfi_sdk::pasta::{pallas, vesta};
-use darkfi_serial::{SerialDecodable, SerialEncodable};
+use darkfi_serial::{async_trait, SerialDecodable, SerialEncodable};
 use halo2_proofs::{
     helpers::SerdeFormat,
     plonk,
@@ -28,7 +27,6 @@ use halo2_proofs::{
     transcript::{Blake2bRead, Blake2bWrite},
 };
 use rand::RngCore;
-use smol::io::{AsyncRead, AsyncWrite};
 
 #[derive(Clone, Debug)]
 pub struct VerifyingKey {

+ 1 - 1
src/zkas/error.rs

@@ -55,7 +55,7 @@ impl ErrorEmitter {
     }
 
     pub fn emit(&self, typ: &str, msg: &str) {
-        if let Ok(_) = std::env::var("ZKAS_SILENT") {
+        if std::env::var("ZKAS_SILENT").is_ok() {
             return
         }