Skip to content

Commit

Permalink
Move cryptographic hashing procedures to crypto folder. (#2306)
Browse files Browse the repository at this point in the history
Step towards #1975

As reported
#1975 (comment)
I'd like to encapsulate crypto related stuff in a dedicated folder.

Currently all cryptographic primitive wrappers are all sparsed in
`substrate/core` which contains "misc core" stuff.

To simplify the process, as the first step with this PR I propose to
move the cryptographic hashing there.

The `substrate/crypto` folder was already created to contains `ec-utils`
crate.

Notes:
- rename `sp-core-hashing` to `sp-crypto-hashing`
- rename `sp-core-hashing-proc-macro` to `sp-crypto-hashing-proc-macro`
- As the crates name is changed I took the freedom to restart fresh from
version 0.1.0 for both crates

---------

Co-authored-by: Robert Hambrock <roberthambrock@gmail.com>
  • Loading branch information
davxy and Lederstrumpf authored Jan 22, 2024
1 parent 95ff9b2 commit 4c10fd2
Show file tree
Hide file tree
Showing 96 changed files with 484 additions and 326 deletions.
80 changes: 60 additions & 20 deletions Cargo.lock

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

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ members = [
"substrate/client/transaction-pool",
"substrate/client/transaction-pool/api",
"substrate/client/utils",
"substrate/deprecated/hashing",
"substrate/deprecated/hashing/proc-macro",
"substrate/frame",
"substrate/frame/alliance",
"substrate/frame/asset-conversion",
Expand Down Expand Up @@ -432,9 +434,9 @@ members = [
"substrate/primitives/consensus/slots",
"substrate/primitives/core",
"substrate/primitives/core/fuzz",
"substrate/primitives/core/hashing",
"substrate/primitives/core/hashing/proc-macro",
"substrate/primitives/crypto/ec-utils",
"substrate/primitives/crypto/hashing",
"substrate/primitives/crypto/hashing/proc-macro",
"substrate/primitives/database",
"substrate/primitives/debug-derive",
"substrate/primitives/externalities",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ hex-literal = { version = "0.4.1" }
env_logger = "0.9"
hex = "0.4"
array-bytes = "4.1"
sp-crypto-hashing = { path = "../../../../../../substrate/primitives/crypto/hashing" }

[features]
default = ["std"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ where
mod tests {
use super::*;
use hex_literal::hex;
use sp_core::keccak_256;
use sp_crypto_hashing::keccak_256;
use sp_runtime::traits::Keccak256;

fn make_leaves(count: u64) -> Vec<H256> {
Expand Down
2 changes: 1 addition & 1 deletion cumulus/client/parachain-inherent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tracing = { version = "0.1.37" }
# Substrate
sc-client-api = { path = "../../../substrate/client/api" }
sp-api = { path = "../../../substrate/primitives/api" }
sp-core = { path = "../../../substrate/primitives/core" }
sp-crypto-hashing = { path = "../../../substrate/primitives/crypto/hashing" }
sp-inherents = { path = "../../../substrate/primitives/inherents" }
sp-runtime = { path = "../../../substrate/primitives/runtime" }
sp-state-machine = { path = "../../../substrate/primitives/state-machine" }
Expand Down
2 changes: 1 addition & 1 deletion cumulus/client/parachain-inherent/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use cumulus_primitives_core::{
};
use cumulus_primitives_parachain_inherent::MessageQueueChain;
use sc_client_api::{Backend, StorageProvider};
use sp_core::twox_128;
use sp_crypto_hashing::twox_128;
use sp_inherents::{InherentData, InherentDataProvider};
use sp_runtime::traits::Block;
use std::collections::BTreeMap;
Expand Down
1 change: 1 addition & 0 deletions cumulus/pallets/parachain-system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ futures = "0.3.28"
# Substrate
sc-client-api = { path = "../../../substrate/client/api" }
sp-keyring = { path = "../../../substrate/primitives/keyring" }
sp-crypto-hashing = { path = "../../../substrate/primitives/crypto/hashing" }
sp-tracing = { path = "../../../substrate/primitives/tracing" }
sp-version = { path = "../../../substrate/primitives/version" }

Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/parachain-system/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ fn upgrade_version_checks_should_work() {
ext.register_extension(sp_core::traits::ReadRuntimeVersionExt::new(read_runtime_version));
ext.execute_with(|| {
let new_code = vec![1, 2, 3, 4];
let new_code_hash = H256(sp_core::blake2_256(&new_code));
let new_code_hash = H256(sp_crypto_hashing::blake2_256(&new_code));

#[allow(deprecated)]
let _authorize = ParachainSystem::authorize_upgrade(RawOrigin::Root.into(), new_code_hash, true);
Expand Down
Loading

0 comments on commit 4c10fd2

Please sign in to comment.