mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 07:27:55 +00:00
Reduce usage of Blake2Hasher (#5132)
This reduces the usage of `Blake2Hasher` in the code base and replaces it with `BlakeTwo256`. The most important change is the removal of the custom extern function for `Blake2Hasher`. The runtime `Hash` trait is now also simplified and directly requires that the implementing type implements `Hashable`.
This commit is contained in:
committed by
GitHub
parent
406fa981bb
commit
5a33228ea9
@@ -21,13 +21,11 @@ use frame_support::{
|
||||
weights::{GetDispatchInfo, DispatchInfo, DispatchClass},
|
||||
};
|
||||
use sp_core::{
|
||||
Blake2Hasher, NeverNativeValue, map,
|
||||
traits::Externalities,
|
||||
storage::{well_known_keys, Storage},
|
||||
NeverNativeValue, map, traits::Externalities, storage::{well_known_keys, Storage},
|
||||
};
|
||||
use sp_runtime::{
|
||||
ApplyExtrinsicResult, Fixed64,
|
||||
traits::{Hash as HashT, Convert},
|
||||
traits::{Hash as HashT, Convert, BlakeTwo256},
|
||||
transaction_validity::InvalidTransaction,
|
||||
};
|
||||
use pallet_contracts::ContractAddressFor;
|
||||
@@ -93,7 +91,6 @@ fn changes_trie_block() -> (Vec<u8>, Hash) {
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
/// block 1 and 2 must be created together to ensure transactions are only signed once (since they
|
||||
/// are not guaranteed to be deterministic) and to ensure that the correct state is propagated
|
||||
/// from block1's execution to block2 to derive the correct storage_root.
|
||||
@@ -161,7 +158,7 @@ fn block_with_size(time: u64, nonce: u32, size: usize) -> (Vec<u8>, Hash) {
|
||||
|
||||
#[test]
|
||||
fn panic_execution_with_foreign_code_gives_error() {
|
||||
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(BLOATY_CODE, Storage {
|
||||
let mut t = TestExternalities::<BlakeTwo256>::new_with_code(BLOATY_CODE, Storage {
|
||||
top: map![
|
||||
<frame_system::Account<Runtime>>::hashed_key_for(alice()) => {
|
||||
(69u128, 0u8, 0u128, 0u128, 0u128).encode()
|
||||
@@ -197,7 +194,7 @@ fn panic_execution_with_foreign_code_gives_error() {
|
||||
|
||||
#[test]
|
||||
fn bad_extrinsic_with_native_equivalent_code_gives_error() {
|
||||
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, Storage {
|
||||
let mut t = TestExternalities::<BlakeTwo256>::new_with_code(COMPACT_CODE, Storage {
|
||||
top: map![
|
||||
<frame_system::Account<Runtime>>::hashed_key_for(alice()) => {
|
||||
(0u32, 0u8, 69u128, 0u128, 0u128, 0u128).encode()
|
||||
@@ -233,7 +230,7 @@ fn bad_extrinsic_with_native_equivalent_code_gives_error() {
|
||||
|
||||
#[test]
|
||||
fn successful_execution_with_native_equivalent_code_gives_ok() {
|
||||
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, Storage {
|
||||
let mut t = TestExternalities::<BlakeTwo256>::new_with_code(COMPACT_CODE, Storage {
|
||||
top: map![
|
||||
<frame_system::Account<Runtime>>::hashed_key_for(alice()) => {
|
||||
(0u32, 0u8, 111 * DOLLARS, 0u128, 0u128, 0u128).encode()
|
||||
@@ -275,7 +272,7 @@ fn successful_execution_with_native_equivalent_code_gives_ok() {
|
||||
|
||||
#[test]
|
||||
fn successful_execution_with_foreign_code_gives_ok() {
|
||||
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(BLOATY_CODE, Storage {
|
||||
let mut t = TestExternalities::<BlakeTwo256>::new_with_code(BLOATY_CODE, Storage {
|
||||
top: map![
|
||||
<frame_system::Account<Runtime>>::hashed_key_for(alice()) => {
|
||||
(0u32, 0u8, 111 * DOLLARS, 0u128, 0u128, 0u128).encode()
|
||||
@@ -700,7 +697,7 @@ fn native_big_block_import_fails_on_fallback() {
|
||||
|
||||
#[test]
|
||||
fn panic_execution_gives_error() {
|
||||
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(BLOATY_CODE, Storage {
|
||||
let mut t = TestExternalities::<BlakeTwo256>::new_with_code(BLOATY_CODE, Storage {
|
||||
top: map![
|
||||
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
|
||||
0_u128.encode()
|
||||
@@ -731,7 +728,7 @@ fn panic_execution_gives_error() {
|
||||
|
||||
#[test]
|
||||
fn successful_execution_gives_ok() {
|
||||
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, Storage {
|
||||
let mut t = TestExternalities::<BlakeTwo256>::new_with_code(COMPACT_CODE, Storage {
|
||||
top: map![
|
||||
<frame_system::Account<Runtime>>::hashed_key_for(alice()) => {
|
||||
(0u32, 0u8, 111 * DOLLARS, 0u128, 0u128, 0u128).encode()
|
||||
|
||||
Reference in New Issue
Block a user