Skip to content

Commit

Permalink
chore: tokio 1 and other crate upgrades (#3258)
Browse files Browse the repository at this point in the history
Description
---
- upgrades to tokio 1.10
- upgrade multiaddr to 1.13
- updates select loops to use tokio::select!
- updates to use tokio mpsc and oneshot channels
- remove max_threads config
- removed tari_wallet dependency from tari base node
- moved emoji id library out of tari wallet into tari core (in order to
  remove dependency on `tari_wallet` for tari base node)
- Wait for bootstrap with mempool sync moved to the initializer
- Unit and integration test fixup
- Upgraded following crates that use or are required by tokio 1:
  `bytes`, `prost`, `tonic`, `reqwest`, `hyper`, `trust-dns-client`

~~Include changes from #3237 merged

Motivation and Context
---
Tokio runtime is perhaps the most critical dependency we have and was very out of date (was 0.2.x).
This PR takes advantage of bug fixes and optimisations of tokio 1.10.

How Has This Been Tested?
---
- Existing unit and integration tests run and pass
- Existing cucumber tests pass
- Ran all tari applications (base node, console wallet, miner, mm proxy, stratum transcoder)
- Ran a washing machine test on two upgraded wallets connected to an upgraded base node
  • Loading branch information
sdbondi authored Aug 30, 2021
1 parent 0f6d3b1 commit 504fbb8
Show file tree
Hide file tree
Showing 296 changed files with 5,657 additions and 5,517 deletions.
865 changes: 411 additions & 454 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions applications/tari_app_grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ edition = "2018"
[dependencies]
tari_common_types = { version = "^0.9", path = "../../base_layer/common_types"}
tari_core = { path = "../../base_layer/core"}
tari_wallet = { path = "../../base_layer/wallet"}
tari_crypto = "0.11.1"
tari_wallet = { path = "../../base_layer/wallet", optional = true}
tari_comms = { path = "../../comms"}

chrono = "0.4.6"
prost = "0.6"
prost-types = "0.6.1"
tonic = "0.2"
prost = "0.8"
prost-types = "0.8"
tonic = "0.5.2"

[build-dependencies]
tonic-build = "0.2"
tonic-build = "0.5.2"

[features]
wallet = ["tari_wallet"]
8 changes: 6 additions & 2 deletions applications/tari_app_grpc/src/conversions/block_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ use crate::{
tari_rpc as grpc,
};
use std::convert::TryFrom;
use tari_core::{blocks::BlockHeader, proof_of_work::ProofOfWork, transactions::types::BlindingFactor};
use tari_crypto::tari_utilities::{ByteArray, Hashable};
use tari_core::{
blocks::BlockHeader,
crypto::tari_utilities::{ByteArray, Hashable},
proof_of_work::ProofOfWork,
transactions::types::BlindingFactor,
};

impl From<BlockHeader> for grpc::BlockHeader {
fn from(h: BlockHeader) -> Self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use std::convert::TryFrom;
use tari_crypto::tari_utilities::ByteArray;
use tari_core::crypto::tari_utilities::ByteArray;

use crate::tari_rpc as grpc;
use tari_core::transactions::types::{ComSignature, Commitment, PrivateKey};
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_app_grpc/src/conversions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub use self::{

use crate::{tari_rpc as grpc, tari_rpc::BlockGroupRequest};
use prost_types::Timestamp;
use tari_crypto::tari_utilities::epoch_time::EpochTime;
use tari_core::crypto::tari_utilities::epoch_time::EpochTime;

/// Utility function that converts a `EpochTime` to a `prost::Timestamp`
pub fn datetime_to_timestamp(datetime: EpochTime) -> Timestamp {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ use crate::tari_rpc as grpc;
use std::convert::{TryFrom, TryInto};
use tari_core::{
blocks::{NewBlockHeaderTemplate, NewBlockTemplate},
crypto::tari_utilities::ByteArray,
proof_of_work::ProofOfWork,
transactions::types::BlindingFactor,
};
use tari_crypto::tari_utilities::ByteArray;
impl From<NewBlockTemplate> for grpc::NewBlockTemplate {
fn from(block: NewBlockTemplate) -> Self {
let header = grpc::NewBlockHeaderTemplate {
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_app_grpc/src/conversions/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use crate::{conversions::datetime_to_timestamp, tari_rpc as grpc};
use tari_comms::{connectivity::ConnectivityStatus, net_address::MutliaddrWithStats, peer_manager::Peer};
use tari_crypto::tari_utilities::ByteArray;
use tari_core::crypto::tari_utilities::ByteArray;

impl From<Peer> for grpc::Peer {
fn from(peer: Peer) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_app_grpc/src/conversions/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use std::convert::TryFrom;
use tari_crypto::tari_utilities::ByteArray;
use tari_core::crypto::tari_utilities::ByteArray;

use crate::tari_rpc as grpc;
use tari_core::transactions::types::{PrivateKey, PublicKey, Signature};
Expand Down
65 changes: 36 additions & 29 deletions applications/tari_app_grpc/src/conversions/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@

use crate::tari_rpc as grpc;
use std::convert::{TryFrom, TryInto};
use tari_core::transactions::transaction::Transaction;
use tari_crypto::{ristretto::RistrettoSecretKey, tari_utilities::ByteArray};
use tari_wallet::{output_manager_service::TxId, transaction_service::storage::models};
use tari_core::{
crypto::{ristretto::RistrettoSecretKey, tari_utilities::ByteArray},
transactions::transaction::Transaction,
};

impl From<Transaction> for grpc::Transaction {
fn from(source: Transaction) -> Self {
Expand Down Expand Up @@ -53,38 +54,44 @@ impl TryFrom<grpc::Transaction> for Transaction {
}
}

impl From<models::TransactionStatus> for grpc::TransactionStatus {
fn from(status: models::TransactionStatus) -> Self {
use models::TransactionStatus::*;
match status {
Completed => grpc::TransactionStatus::Completed,
Broadcast => grpc::TransactionStatus::Broadcast,
MinedUnconfirmed => grpc::TransactionStatus::MinedUnconfirmed,
MinedConfirmed => grpc::TransactionStatus::MinedConfirmed,
Imported => grpc::TransactionStatus::Imported,
Pending => grpc::TransactionStatus::Pending,
Coinbase => grpc::TransactionStatus::Coinbase,
#[cfg(feature = "wallet")]
mod wallet {
use super::*;
use tari_wallet::{output_manager_service::TxId, transaction_service::storage::models};

impl From<models::TransactionStatus> for grpc::TransactionStatus {
fn from(status: models::TransactionStatus) -> Self {
use models::TransactionStatus::*;
match status {
Completed => grpc::TransactionStatus::Completed,
Broadcast => grpc::TransactionStatus::Broadcast,
MinedUnconfirmed => grpc::TransactionStatus::MinedUnconfirmed,
MinedConfirmed => grpc::TransactionStatus::MinedConfirmed,
Imported => grpc::TransactionStatus::Imported,
Pending => grpc::TransactionStatus::Pending,
Coinbase => grpc::TransactionStatus::Coinbase,
}
}
}
}

impl From<models::TransactionDirection> for grpc::TransactionDirection {
fn from(status: models::TransactionDirection) -> Self {
use models::TransactionDirection::*;
match status {
Unknown => grpc::TransactionDirection::Unknown,
Inbound => grpc::TransactionDirection::Inbound,
Outbound => grpc::TransactionDirection::Outbound,
impl From<models::TransactionDirection> for grpc::TransactionDirection {
fn from(status: models::TransactionDirection) -> Self {
use models::TransactionDirection::*;
match status {
Unknown => grpc::TransactionDirection::Unknown,
Inbound => grpc::TransactionDirection::Inbound,
Outbound => grpc::TransactionDirection::Outbound,
}
}
}
}

impl grpc::TransactionInfo {
pub fn not_found(tx_id: TxId) -> Self {
Self {
tx_id,
status: grpc::TransactionStatus::NotFound as i32,
..Default::default()
impl grpc::TransactionInfo {
pub fn not_found(tx_id: TxId) -> Self {
Self {
tx_id,
status: grpc::TransactionStatus::NotFound as i32,
..Default::default()
}
}
}
}
16 changes: 9 additions & 7 deletions applications/tari_app_grpc/src/conversions/transaction_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@

use crate::tari_rpc as grpc;
use std::convert::{TryFrom, TryInto};
use tari_core::transactions::{
transaction::TransactionInput,
types::{Commitment, PublicKey},
};
use tari_crypto::{
script::{ExecutionStack, TariScript},
tari_utilities::{ByteArray, Hashable},
use tari_core::{
crypto::{
script::{ExecutionStack, TariScript},
tari_utilities::{ByteArray, Hashable},
},
transactions::{
transaction::TransactionInput,
types::{Commitment, PublicKey},
},
};

impl TryFrom<grpc::TransactionInput> for TransactionInput {
Expand Down
12 changes: 7 additions & 5 deletions applications/tari_app_grpc/src/conversions/transaction_kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@

use crate::tari_rpc as grpc;
use std::convert::{TryFrom, TryInto};
use tari_core::transactions::{
tari_amount::MicroTari,
transaction::{KernelFeatures, TransactionKernel},
types::Commitment,
use tari_core::{
crypto::tari_utilities::{ByteArray, Hashable},
transactions::{
tari_amount::MicroTari,
transaction::{KernelFeatures, TransactionKernel},
types::Commitment,
},
};
use tari_crypto::tari_utilities::{ByteArray, Hashable};

impl TryFrom<grpc::TransactionKernel> for TransactionKernel {
type Error = String;
Expand Down
18 changes: 10 additions & 8 deletions applications/tari_app_grpc/src/conversions/transaction_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@

use crate::tari_rpc as grpc;
use std::convert::{TryFrom, TryInto};
use tari_core::transactions::{
bullet_rangeproofs::BulletRangeProof,
transaction::TransactionOutput,
types::{Commitment, PublicKey},
};
use tari_crypto::{
script::TariScript,
tari_utilities::{ByteArray, Hashable},
use tari_core::{
crypto::{
script::TariScript,
tari_utilities::{ByteArray, Hashable},
},
transactions::{
bullet_rangeproofs::BulletRangeProof,
transaction::TransactionOutput,
types::{Commitment, PublicKey},
},
};

impl TryFrom<grpc::TransactionOutput> for TransactionOutput {
Expand Down
18 changes: 10 additions & 8 deletions applications/tari_app_grpc/src/conversions/unblinded_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@

use crate::tari_rpc as grpc;
use std::convert::{TryFrom, TryInto};
use tari_core::transactions::{
tari_amount::MicroTari,
transaction::UnblindedOutput,
types::{PrivateKey, PublicKey},
};
use tari_crypto::{
script::{ExecutionStack, TariScript},
tari_utilities::ByteArray,
use tari_core::{
crypto::{
script::{ExecutionStack, TariScript},
tari_utilities::ByteArray,
},
transactions::{
tari_amount::MicroTari,
transaction::UnblindedOutput,
types::{PrivateKey, PublicKey},
},
};

impl From<UnblindedOutput> for grpc::UnblindedOutput {
Expand Down
14 changes: 9 additions & 5 deletions applications/tari_app_utilities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ tari_comms = { path = "../../comms"}
tari_crypto = "0.11.1"
tari_common = { path = "../../common" }
tari_p2p = { path = "../../base_layer/p2p", features = ["auto-update"] }
tari_wallet = { path = "../../base_layer/wallet" }
tari_wallet = { path = "../../base_layer/wallet", optional = true }

config = { version = "0.9.3" }
futures = { version = "^0.3.1", default-features = false, features = ["alloc"]}
futures = { version = "^0.3.16", default-features = false, features = ["alloc"]}
qrcode = { version = "0.12" }
dirs-next = "1.0.2"
serde_json = "1.0"
log = { version = "0.4.8", features = ["std"] }
rand = "0.8"
tokio = { version="0.2.10", features = ["signal"] }
tokio = { version="^1.10", features = ["signal"] }
structopt = { version = "0.3.13", default_features = false }
strum = "^0.19"
strum_macros = "^0.19"
thiserror = "^1.0.20"
tonic = "0.2"
thiserror = "^1.0.26"
tonic = "0.5.2"

[dependencies.tari_core]
path = "../../base_layer/core"
Expand All @@ -33,3 +33,7 @@ features = ["transactions"]

[build-dependencies]
tari_common = { path = "../../common", features = ["build", "static-application-info"] }

[features]
# TODO: This crate is supposed to hold common logic. Move code from this feature into the crate that is more specific to the wallet
wallet = ["tari_wallet"]
Loading

0 comments on commit 504fbb8

Please sign in to comment.