Skip to content

Commit

Permalink
update dependencies and merge development
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeantonio21 committed Nov 21, 2022
2 parents 68bc795 + d7b4699 commit f0a16bc
Show file tree
Hide file tree
Showing 64 changed files with 1,044 additions and 1,049 deletions.
649 changes: 391 additions & 258 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions applications/tari_app_grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ authors = ["The Tari Development Community"]
description = "This crate is to provide a single source for all cross application grpc files and conversions to and from tari::core"
repository = "https://github.com/tari-project/tari"
license = "BSD-3-Clause"
version = "0.39.0"
version = "0.40.2"
edition = "2018"

[dependencies]
tari_common_types = { version = "^0.39", path = "../../base_layer/common_types" }
tari_common_types = { version = "^0.40", path = "../../base_layer/common_types" }
tari_comms = { path = "../../comms/core" }
tari_core = { path = "../../base_layer/core" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.16.0" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.16.2" }
tari_script = { path = "../../infrastructure/tari_script" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag="v0.4.7" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag="v0.4.9" }

argon2 = { version = "0.4.1", features = ["std", "password-hash"] }
base64 = "0.13.0"
Expand Down
6 changes: 3 additions & 3 deletions applications/tari_app_utilities/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "tari_app_utilities"
version = "0.39.0"
version = "0.40.2"
authors = ["The Tari Development Community"]
edition = "2018"
license = "BSD-3-Clause"

[dependencies]
tari_comms = { path = "../../comms/core" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.16.0" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.16.2" }
tari_common = { path = "../../common" }
tari_common_types = { path = "../../base_layer/common_types" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag="v0.4.7" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag="v0.4.9" }

clap = { version = "3.2.0", features = ["derive", "env"] }
config = { version = "0.13.0" }
Expand Down
6 changes: 3 additions & 3 deletions applications/tari_base_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ authors = ["The Tari Development Community"]
description = "The tari full base node implementation"
repository = "https://github.com/tari-project/tari"
license = "BSD-3-Clause"
version = "0.39.0"
version = "0.40.2"
edition = "2018"

[dependencies]
Expand All @@ -15,14 +15,14 @@ tari_comms = { path = "../../comms/core", features = ["rpc"] }
tari_common_types = { path = "../../base_layer/common_types" }
tari_comms_dht = { path = "../../comms/dht" }
tari_core = { path = "../../base_layer/core", default-features = false, features = ["transactions"] }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.16.0" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.16.2" }
tari_libtor = { path = "../../infrastructure/libtor", optional = true }
tari_mmr = { path = "../../base_layer/mmr", features = ["native_bitmap"] }
tari_p2p = { path = "../../base_layer/p2p", features = ["auto-update"] }
tari_storage = {path="../../infrastructure/storage"}
tari_service_framework = { path = "../../base_layer/service_framework" }
tari_shutdown = { path = "../../infrastructure/shutdown" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag="v0.4.7" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag="v0.4.9" }

anyhow = "1.0.53"
async-trait = "0.1.52"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl CommandContext {
normalized_solve_time,
pow_algo,
chrono::DateTime::<Utc>::from_utc(
NaiveDateTime::from_timestamp(header.header().timestamp.as_u64() as i64, 0),
NaiveDateTime::from_timestamp_opt(header.header().timestamp.as_u64() as i64, 0).unwrap_or_default(),
Utc
),
target_diff.get(pow_algo).len(),
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_base_node/src/commands/command/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl CommandContext {
.await?
.ok_or_else(|| anyhow!("No last header"))?;
let last_block_time = DateTime::<Utc>::from_utc(
NaiveDateTime::from_timestamp(last_header.header().timestamp.as_u64() as i64, 0),
NaiveDateTime::from_timestamp_opt(last_header.header().timestamp.as_u64() as i64, 0).unwrap_or_default(),
Utc,
);
status_line.add_field(
Expand Down
6 changes: 3 additions & 3 deletions applications/tari_console_wallet/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "tari_console_wallet"
version = "0.39.0"
version = "0.40.2"
authors = ["The Tari Development Community"]
edition = "2018"
license = "BSD-3-Clause"

[dependencies]
tari_wallet = { path = "../../base_layer/wallet", features = ["bundled_sqlite"] }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.16.0" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.16.2" }
tari_common = { path = "../../common" }
tari_app_utilities = { path = "../tari_app_utilities" }
tari_comms = { path = "../../comms/core" }
Expand All @@ -18,7 +18,7 @@ tari_p2p = { path = "../../base_layer/p2p", features = ["auto-update"] }
tari_app_grpc = { path = "../tari_app_grpc" }
tari_shutdown = { path = "../../infrastructure/shutdown" }
tari_key_manager = { path = "../../base_layer/key_manager" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag="v0.4.7" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag="v0.4.9" }

# Uncomment for tokio tracing via tokio-console (needs "tracing" featurs)
#console-subscriber = "0.1.3"
Expand Down
4 changes: 2 additions & 2 deletions applications/tari_console_wallet/src/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub async fn change_password(
let passphrase = prompt_password("New wallet password: ")?;
let confirmed = prompt_password("Confirm new password: ")?;

if passphrase != confirmed {
if passphrase.reveal() != confirmed.reveal() {
return Err(ExitError::new(ExitCode::InputError, "Passwords don't match!"));
}

Expand Down Expand Up @@ -376,7 +376,7 @@ pub async fn init_wallet(
let password = prompt_password("Create wallet password: ")?;
let confirmed = prompt_password("Confirm wallet password: ")?;

if password != confirmed {
if password.reveal() != confirmed.reveal() {
return Err(ExitError::new(ExitCode::InputError, "Passwords don't match!"));
}

Expand Down
6 changes: 3 additions & 3 deletions applications/tari_merge_mining_proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ authors = ["The Tari Development Community"]
description = "The Tari merge mining proxy for xmrig"
repository = "https://github.com/tari-project/tari"
license = "BSD-3-Clause"
version = "0.39.0"
version = "0.40.2"
edition = "2018"

[features]
Expand All @@ -15,8 +15,8 @@ tari_common = { path = "../../common" }
tari_comms = { path = "../../comms/core" }
tari_core = { path = "../../base_layer/core", default-features = false, features = ["transactions"] }
tari_app_utilities = { path = "../tari_app_utilities" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.16.0" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag="v0.4.7" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.16.2" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag="v0.4.9" }
tari_base_node_grpc_client = {path="../../clients/rust/base_node_grpc_client" }
tari_wallet_grpc_client = {path="../../clients/rust/wallet_grpc_client" }

Expand Down
6 changes: 3 additions & 3 deletions applications/tari_miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ authors = ["The Tari Development Community"]
description = "The tari miner implementation"
repository = "https://github.com/tari-project/tari"
license = "BSD-3-Clause"
version = "0.39.0"
version = "0.40.2"
edition = "2018"

[dependencies]
Expand All @@ -14,8 +14,8 @@ tari_common_types = { path = "../../base_layer/common_types" }
tari_comms = { path = "../../comms/core" }
tari_app_utilities = { path = "../tari_app_utilities" }
tari_app_grpc = { path = "../tari_app_grpc" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.16.0" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag="v0.4.7" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.16.2" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag="v0.4.9" }

crossterm = { version = "0.25.0" }
clap = { version = "3.1.1", features = ["derive"] }
Expand Down
12 changes: 9 additions & 3 deletions applications/tari_miner/src/difficulty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,15 @@ pub mod test {
#[allow(clippy::cast_sign_loss)]
pub fn get_header() -> (grpc_header, BlockHeader) {
let mut header = BlockHeader::new(0);
header.timestamp =
(DateTime::<Utc>::from_utc(NaiveDate::from_ymd(2000, 1, 1).and_hms(1, 1, 1), Utc).timestamp() as u64)
.into();
header.timestamp = (DateTime::<Utc>::from_utc(
NaiveDate::from_ymd_opt(2000, 1, 1)
.unwrap()
.and_hms_opt(1, 1, 1)
.unwrap(),
Utc,
)
.timestamp() as u64)
.into();
header.pow.pow_algo = tari_core::proof_of_work::PowAlgorithm::Sha3;
(header.clone().into(), header)
}
Expand Down
8 changes: 4 additions & 4 deletions base_layer/common_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ name = "tari_common_types"
authors = ["The Tari Development Community"]
description = "Tari cryptocurrency common types"
license = "BSD-3-Clause"
version = "0.39.0"
version = "0.40.2"
edition = "2018"

[dependencies]
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.16.0" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag="v0.4.7" }
tari_common = { version = "^0.39", path = "../../common" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.16.2" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag="v0.4.9" }
tari_common = { version = "^0.40", path = "../../common" }

base64 = "0.13.0"
digest = "0.9.0"
Expand Down
34 changes: 17 additions & 17 deletions base_layer/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repository = "https://github.com/tari-project/tari"
homepage = "https://tari.com"
readme = "README.md"
license = "BSD-3-Clause"
version = "0.39.0"
version = "0.40.2"
edition = "2018"

[features]
Expand All @@ -19,21 +19,21 @@ avx2 = ["tari_crypto/simd_backend"]
benches = ["base_node", "criterion"]

[dependencies]
tari_common = { version = "^0.39", path = "../../common" }
tari_common_types = { version = "^0.39", path = "../../base_layer/common_types" }
tari_comms = { version = "^0.39", path = "../../comms/core" }
tari_comms_dht = { version = "^0.39", path = "../../comms/dht" }
tari_comms_rpc_macros = { version = "^0.39", path = "../../comms/rpc_macros" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.16.0" }
tari_common = { version = "^0.40", path = "../../common" }
tari_common_types = { version = "^0.40", path = "../../base_layer/common_types" }
tari_comms = { version = "^0.40", path = "../../comms/core" }
tari_comms_dht = { version = "^0.40", path = "../../comms/dht" }
tari_comms_rpc_macros = { version = "^0.40", path = "../../comms/rpc_macros" }
tari_crypto = { git = "https://github.com/tari-project/tari-crypto.git", tag = "v0.16.2" }
tari_metrics = { path = "../../infrastructure/metrics" }
tari_mmr = { version = "^0.39", path = "../../base_layer/mmr", optional = true, features = ["native_bitmap"] }
tari_p2p = { version = "^0.39", path = "../../base_layer/p2p" }
tari_mmr = { version = "^0.40", path = "../../base_layer/mmr", optional = true, features = ["native_bitmap"] }
tari_p2p = { version = "^0.40", path = "../../base_layer/p2p" }
tari_script = { path = "../../infrastructure/tari_script" }
tari_service_framework = { version = "^0.39", path = "../service_framework" }
tari_shutdown = { version = "^0.39", path = "../../infrastructure/shutdown" }
tari_storage = { version = "^0.39", path = "../../infrastructure/storage" }
tari_test_utils = { version = "^0.39", path = "../../infrastructure/test_utils" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag="v0.4.7" }
tari_service_framework = { version = "^0.40", path = "../service_framework" }
tari_shutdown = { version = "^0.40", path = "../../infrastructure/shutdown" }
tari_storage = { version = "^0.40", path = "../../infrastructure/storage" }
tari_test_utils = { version = "^0.40", path = "../../infrastructure/test_utils" }
tari_utilities = { git = "https://github.com/tari-project/tari_utilities.git", tag="v0.4.9" }

async-trait = "0.1.50"
bincode = "1.1.4"
Expand Down Expand Up @@ -76,15 +76,15 @@ tracing-attributes = "*"
uint = { version = "0.9", default-features = false }

[dev-dependencies]
tari_p2p = { version = "^0.39", path = "../../base_layer/p2p", features = ["test-mocks"] }
tari_test_utils = { version = "^0.39", path = "../../infrastructure/test_utils" }
tari_p2p = { version = "^0.40", path = "../../base_layer/p2p", features = ["test-mocks"] }
tari_test_utils = { version = "^0.40", path = "../../infrastructure/test_utils" }

config = { version = "0.13.0" }
env_logger = "0.7.0"
tempfile = "3.1.0"

[build-dependencies]
tari_common = { version = "^0.39", path = "../../common", features = ["build"] }
tari_common = { version = "^0.40", path = "../../common", features = ["build"] }

[[bench]]
name = "mempool"
Expand Down
2 changes: 1 addition & 1 deletion base_layer/core/src/base_node/rpc/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ impl<B: BlockchainBackend + 'static> BaseNodeWalletService for BaseNodeWalletRpc
.fetch_tip_header()
.await
.rpc_status_internal_error(LOG_TARGET)?;

let mut left_height = 0u64;
let mut right_height = tip_header.height();

Expand Down Expand Up @@ -580,7 +581,6 @@ impl<B: BlockchainBackend + 'static> BaseNodeWalletService for BaseNodeWalletRpc
.ok_or_else(|| {
RpcStatus::not_found(&format!("Header not found during search at height {}", mid_height - 1))
})?;

if requested_epoch_time < mid_header.timestamp.as_u64() &&
requested_epoch_time >= before_mid_header.timestamp.as_u64()
{
Expand Down
3 changes: 2 additions & 1 deletion base_layer/core/src/blocks/block_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ impl BlockHeader {
}

pub fn to_chrono_datetime(&self) -> DateTime<Utc> {
let dt = NaiveDateTime::from_timestamp(i64::try_from(self.timestamp.as_u64()).unwrap_or(i64::MAX), 0);
let dt = NaiveDateTime::from_timestamp_opt(i64::try_from(self.timestamp.as_u64()).unwrap_or(i64::MAX), 0)
.unwrap_or(NaiveDateTime::MAX);
DateTime::from_utc(dt, Utc)
}

Expand Down
20 changes: 0 additions & 20 deletions base_layer/core/src/chain_storage/lmdb_db/key_prefix_cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,6 @@ where V: DeserializeOwned
}
}

/// Returns the item on or before the given seek key, progressing backwards until the key prefix no longer matches
#[allow(dead_code)]
pub fn prev(&mut self) -> Result<Option<(Vec<u8>, V)>, ChainStorageError> {
if !self.has_seeked {
let prefix_key = self.prefix_key;
if let Some((k, val)) = self.seek_gte(prefix_key)? {
// seek_range_k returns the greater key, so we only want to return the current value that was seeked to
// if it exactly matches the prefix_key
if k == prefix_key {
return Ok(Some((k, val)));
}
}
}

match self.cursor.prev(&self.access).to_opt()? {
Some((k, v)) => Self::deserialize_if_matches(self.prefix_key, k, v),
None => Ok(None),
}
}

// This function could be used later in cases where multiple seeks are required.
#[cfg(test)]
pub fn reset_to(&mut self, prefix_key: &'a [u8]) {
Expand Down
49 changes: 0 additions & 49 deletions base_layer/core/src/chain_storage/lmdb_db/lmdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,52 +445,3 @@ pub fn lmdb_clear(txn: &WriteTransaction<'_>, db: &Database) -> Result<usize, Ch
}
Ok(num_deleted)
}

/// Used for migrations, you probably dont want to use this as it loops though the entire database.
#[allow(dead_code)]
pub(super) fn lmdb_map_inplace<F, V, R>(
txn: &WriteTransaction<'_>,
db: &Database,
f: F,
) -> Result<(), ChainStorageError>
where
F: Fn(V) -> Option<R>,
V: DeserializeOwned,
R: Serialize,
{
let mut access = txn.access();
let mut cursor = txn.cursor(db).map_err(|e| {
error!(target: LOG_TARGET, "Could not get read cursor from lmdb: {:?}", e);
ChainStorageError::AccessError(e.to_string())
})?;
let iter = CursorIter::new(
MaybeOwned::Borrowed(&mut cursor),
&access,
|c, a| c.first(a),
Cursor::next::<[u8], [u8]>,
)?;
let items = iter
.map(|r| r.map(|(k, v)| (k.to_vec(), v.to_vec())))
.collect::<Result<Vec<_>, _>>()?;

for (key, val) in items {
// let (key, val) = row?;
let val = deserialize::<V>(&val)?;
if let Some(ret) = f(val) {
let ret_bytes = serialize(&ret)?;
access.put(db, &key, &ret_bytes, put::Flags::empty()).map_err(|e| {
if let lmdb_zero::Error::Code(code) = &e {
if *code == lmdb_zero::error::MAP_FULL {
return ChainStorageError::DbResizeRequired;
}
}
error!(
target: LOG_TARGET,
"Could not replace value in lmdb transaction: {:?}", e
);
ChainStorageError::AccessError(e.to_string())
})?;
}
}
Ok(())
}
10 changes: 8 additions & 2 deletions base_layer/core/src/proof_of_work/sha3_pow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,14 @@ pub mod test {
let mut header = BlockHeader::new(2);

#[allow(clippy::cast_sign_loss)]
let epoch_secs =
DateTime::<Utc>::from_utc(NaiveDate::from_ymd(2000, 1, 1).and_hms(1, 1, 1), Utc).timestamp() as u64;
let epoch_secs = DateTime::<Utc>::from_utc(
NaiveDate::from_ymd_opt(2000, 1, 1)
.unwrap()
.and_hms_opt(1, 1, 1)
.unwrap(),
Utc,
)
.timestamp() as u64;
header.timestamp = EpochTime::from_secs_since_epoch(epoch_secs);
header.pow.pow_algo = PowAlgorithm::Sha3;
header
Expand Down
Loading

0 comments on commit f0a16bc

Please sign in to comment.