Skip to content

Commit f64be85

Browse files
authored
refactor(hashing): move borsh hasher into tari_hashing crate (#6174)
Description --- Move common hashers and domains required to interact with base layer into common crate Motivation and Context --- In L2 we have a a borsh hasher that duplicates the functionality of the consensus hasher in tari_core. This crate allows us to use a common hasher implementation without depending on tari_core. TransactionHashDomain is also used in L1 and L2 so was moved into the common crate. How Has This Been Tested? --- CI What process can a PR reviewer use to test or verify this change? --- CI <!-- Checklist --> <!-- 1. Is the title of your PR in the form that would make nice release notes? The title, excluding the conventional commit tag, will be included exactly as is in the CHANGELOG, so please think about it carefully. --> Breaking Changes --- - [x] None - [ ] Requires data directory on base node to be deleted - [ ] Requires hard fork - [ ] Other - Please specify <!-- Does this include a breaking change? If so, include this line as a footer --> <!-- BREAKING CHANGE: Description what the user should do, e.g. delete a database, resync the chain -->
1 parent 75d773b commit f64be85

File tree

24 files changed

+255
-151
lines changed

24 files changed

+255
-151
lines changed

Cargo.lock

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ members = [
3131
"applications/minotari_merge_mining_proxy",
3232
"applications/minotari_miner",
3333
"integration_tests",
34-
"hash_domains",
34+
"hashing",
3535
]
3636

3737
# Add here until we move to edition=2021

applications/minotari_console_wallet/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ tari_utilities = { version = "0.7" }
2323
minotari_wallet = { path = "../../base_layer/wallet", features = [
2424
"bundled_sqlite",
2525
] }
26-
tari_hash_domains = { path = "../../hash_domains" }
26+
tari_hashing = { path = "../../hashing" }
2727

2828
# Uncomment for tokio tracing via tokio-console (needs "tracing" featurs)
2929
console-subscriber = "0.1.8"

applications/minotari_console_wallet/src/ui/components/register_template_tab.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use regex::Regex;
1111
use reqwest::StatusCode;
1212
use tari_core::transactions::{tari_amount::MicroMinotari, transaction_components::TemplateType};
1313
use tari_crypto::hashing::DomainSeparation;
14-
use tari_hash_domains::TariEngineHashDomain;
14+
use tari_hashing::TariEngineHashDomain;
1515
use tari_utilities::hex::Hex;
1616
use tokio::{
1717
runtime::{Handle, Runtime},

applications/minotari_console_wallet/src/ui/state/tasks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ use tari_core::{
4040
transactions::{
4141
tari_amount::MicroMinotari,
4242
transaction_components::{BuildInfo, OutputFeatures, TemplateType},
43-
TransactionHashDomain,
4443
},
4544
};
4645
use tari_crypto::{keys::PublicKey as PublicKeyTrait, ristretto::RistrettoPublicKey};
46+
use tari_hashing::TransactionHashDomain;
4747
use tari_key_manager::key_manager::KeyManager;
4848
use tari_utilities::{hex::Hex, ByteArray};
4949
use tokio::sync::{broadcast, watch};

base_layer/core/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ tari_utilities = { version = "0.7", features = ["borsh"] }
4444
tari_key_manager = { path = "../key_manager", features = [
4545
"key_manager_service",
4646
], version = "1.0.0-pre.9" }
47-
tari_common_sqlite = { path = "../../common_sqlite", version = "1.0.0-pre.9" }
48-
tari_hash_domains = { path = "../../hash_domains", version = "1.0.0-pre.9" }
47+
tari_common_sqlite = { path = "../../common_sqlite" }
48+
tari_hashing = { path = "../../hashing" }
4949

5050
async-trait = { version = "0.1.50" }
5151
bincode = "1.1.4"

base_layer/core/src/chain_storage/blockchain_database.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use tari_common_types::{
4040
chain_metadata::ChainMetadata,
4141
types::{BlockHash, Commitment, FixedHash, HashOutput, PublicKey, Signature},
4242
};
43+
use tari_hashing::TransactionHashDomain;
4344
use tari_mmr::{
4445
pruned_hashset::PrunedHashSet,
4546
sparse_merkle_tree::{DeleteResult, NodeKey, ValueHash},
@@ -89,10 +90,7 @@ use crate::{
8990
DomainSeparatedConsensusHasher,
9091
},
9192
proof_of_work::{monero_rx::MoneroPowData, PowAlgorithm, TargetDifficultyWindow},
92-
transactions::{
93-
transaction_components::{TransactionInput, TransactionKernel, TransactionOutput},
94-
TransactionHashDomain,
95-
},
93+
transactions::transaction_components::{TransactionInput, TransactionKernel, TransactionOutput},
9694
validation::{
9795
helpers::calc_median_timestamp,
9896
CandidateBlockValidator,

base_layer/core/src/common/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
use blake2::Blake2b;
2424
use digest::consts::U64;
25-
use tari_hash_domains::ConfidentialOutputHashDomain;
25+
use tari_hashing::ConfidentialOutputHashDomain;
2626

2727
use crate::consensus::DomainSeparatedConsensusHasher;
2828

base_layer/core/src/common/one_sided.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use tari_crypto::{
3131
hashing::{DomainSeparatedHash, DomainSeparatedHasher},
3232
keys::{PublicKey as PKtrait, SecretKey as SKtrait},
3333
};
34-
use tari_hash_domains::WalletOutputEncryptionKeysDomain;
34+
use tari_hashing::WalletOutputEncryptionKeysDomain;
3535
use tari_utilities::byte_array::ByteArrayError;
3636

3737
hash_domain!(

base_layer/core/src/consensus/consensus_encoding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mod bytes;
2424
mod hashing;
2525
mod string;
2626

27-
pub use hashing::{ConsensusHasher, DomainSeparatedConsensusHasher};
27+
pub use hashing::DomainSeparatedConsensusHasher;
2828
pub use string::MaxSizeString;
2929

3030
pub use self::bytes::MaxSizeBytes;

0 commit comments

Comments
 (0)