Skip to content

Commit

Permalink
Merge branch 'development' into feature-dan
Browse files Browse the repository at this point in the history
* development:
  feat: add deepsource config
  v0.38.7
  test: remove cucumber tests, simplify others (tari-project#4794)
  fix(miner): clippy error (tari-project#4793)
  fix(core): only resize db if migration is required (tari-project#4792)
  v0.38.6
  fix(dht): remove some invalid saf failure cases (tari-project#4787)
  feat: move nonce to first in sha hash (tari-project#4778)
  feat: optimize transaction service queries (tari-project#4775)
  fix(tari-script): use tari script encoding for execution stack serde de/serialization (tari-project#4791)
  fix(p2p/liveness): remove fallible unwrap (tari-project#4784)
  fix: fix config.toml bug (tari-project#4780)
  fix: batch rewind operations (tari-project#4752)
  • Loading branch information
sdbondi committed Oct 18, 2022
2 parents 9e81c7b + dceea99 commit 6387137
Show file tree
Hide file tree
Showing 72 changed files with 1,394 additions and 1,171 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ commands:
- run:
name: Build miner
command: cargo build --release --bin tari_miner
- run:
name: Build wallet FFI
command: cargo build --release --package tari_wallet_ffi
- run:
name: Run cucumber scenarios
no_output_timeout: 20m
Expand Down
10 changes: 10 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version = 1


[[analyzers]]
name = "rust"
enabled = true

[analyzers.meta]
msrv = "stable"

46 changes: 23 additions & 23 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion applications/tari_app_grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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.38.5"
version = "0.38.7"
edition = "2018"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ impl TryFrom<TransactionInput> for grpc::TransactionInput {
script: input
.script()
.map_err(|_| "Non-compact Transaction input should contain script".to_string())?
.as_bytes(),
input_data: input.input_data.as_bytes(),
.to_bytes(),
input_data: input.input_data.to_bytes(),
script_signature,
sender_offset_public_key: input
.sender_offset_public_key()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl From<TransactionOutput> for grpc::TransactionOutput {
features: Some(output.features.into()),
commitment: Vec::from(output.commitment.as_bytes()),
range_proof: Vec::from(output.proof.as_bytes()),
script: output.script.as_bytes(),
script: output.script.to_bytes(),
sender_offset_public_key: output.sender_offset_public_key.as_bytes().to_vec(),
metadata_signature: Some(grpc::ComSignature {
public_nonce_commitment: Vec::from(output.metadata_signature.public_nonce().as_bytes()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ impl From<UnblindedOutput> for grpc::UnblindedOutput {
value: u64::from(output.value),
spending_key: output.spending_key.as_bytes().to_vec(),
features: Some(output.features.into()),
script: output.script.as_bytes(),
input_data: output.input_data.as_bytes(),
script: output.script.to_bytes(),
input_data: output.input_data.to_bytes(),
script_private_key: output.script_private_key.as_bytes().to_vec(),
sender_offset_public_key: output.sender_offset_public_key.as_bytes().to_vec(),
metadata_signature: Some(grpc::ComSignature {
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_app_utilities/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tari_app_utilities"
version = "0.38.5"
version = "0.38.7"
authors = ["The Tari Development Community"]
edition = "2018"
license = "BSD-3-Clause"
Expand Down
2 changes: 1 addition & 1 deletion 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.38.5"
version = "0.38.7"
edition = "2018"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_console_wallet/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tari_console_wallet"
version = "0.38.5"
version = "0.38.7"
authors = ["The Tari Development Community"]
edition = "2018"
license = "BSD-3-Clause"
Expand Down
2 changes: 1 addition & 1 deletion 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.38.5"
version = "0.38.7"
edition = "2018"

[features]
Expand Down
2 changes: 1 addition & 1 deletion 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.38.5"
version = "0.38.7"
edition = "2018"

[dependencies]
Expand Down
34 changes: 3 additions & 31 deletions applications/tari_miner/src/difficulty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@

use std::convert::TryInto;

use sha3::{Digest, Sha3_256};
use tari_app_grpc::tari_rpc::BlockHeader as grpc_header;
use tari_core::{blocks::BlockHeader, large_ints::U256};
use tari_core::{blocks::BlockHeader, proof_of_work::sha3_difficulty};
use tari_utilities::epoch_time::EpochTime;

use crate::errors::MinerError;
Expand All @@ -34,7 +33,6 @@ pub type Difficulty = u64;
#[derive(Clone)]
pub struct BlockHeaderSha3 {
pub header: BlockHeader,
hash_merge_mining: Sha3_256,
pub hashes: u64,
}

Expand All @@ -43,19 +41,7 @@ impl BlockHeaderSha3 {
#[allow(clippy::cast_sign_loss)]
pub fn new(header: grpc_header) -> Result<Self, MinerError> {
let header: BlockHeader = header.try_into().map_err(MinerError::BlockHeader)?;

let hash_merge_mining = Sha3_256::new().chain(header.mining_hash());

Ok(Self {
hash_merge_mining,
header,
hashes: 0,
})
}

#[inline]
fn get_hash_before_nonce(&self) -> Sha3_256 {
self.hash_merge_mining.clone()
Ok(Self { header, hashes: 0 })
}

/// This function will update the timestamp of the header, but only if the new timestamp is greater than the current
Expand All @@ -65,7 +51,6 @@ impl BlockHeaderSha3 {
// should only change the timestamp if we move it forward.
if timestamp > self.header.timestamp.as_u64() {
self.header.timestamp = EpochTime::from(timestamp);
self.hash_merge_mining = Sha3_256::new().chain(self.header.mining_hash());
}
}

Expand All @@ -82,13 +67,7 @@ impl BlockHeaderSha3 {
#[inline]
pub fn difficulty(&mut self) -> Difficulty {
self.hashes = self.hashes.saturating_add(1);
let hash = self
.get_hash_before_nonce()
.chain(self.header.nonce.to_le_bytes())
.chain(self.header.pow.to_bytes())
.finalize();
let hash = Sha3_256::digest(&hash);
big_endian_difficulty(&hash)
sha3_difficulty(&self.header).into()
}

#[allow(clippy::cast_possible_wrap)]
Expand All @@ -102,13 +81,6 @@ impl BlockHeaderSha3 {
}
}

/// This will provide the difficulty of the hash assuming the hash is big_endian
fn big_endian_difficulty(hash: &[u8]) -> Difficulty {
let scalar = U256::from_big_endian(hash); // Big endian so the hash has leading zeroes
let result = U256::MAX / scalar;
result.low_u64()
}

#[cfg(test)]
pub mod test {
use chrono::{DateTime, NaiveDate, Utc};
Expand Down
2 changes: 1 addition & 1 deletion base_layer/common_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "tari_common_types"
authors = ["The Tari Development Community"]
description = "Tari cryptocurrency common types"
license = "BSD-3-Clause"
version = "0.38.5"
version = "0.38.7"
edition = "2018"

[dependencies]
Expand Down
Loading

0 comments on commit 6387137

Please sign in to comment.