Skip to content

Commit

Permalink
Changes genesis to use blake2hash for wasm hash
Browse files Browse the repository at this point in the history
  • Loading branch information
crystalin committed Sep 28, 2023
1 parent 350c823 commit cd1f07c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions substrate/client/chain-spec/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@

//! Tool for creating the genesis block.

use std::{collections::hash_map::DefaultHasher, marker::PhantomData, sync::Arc};
use std::{marker::PhantomData, sync::Arc};

use sc_client_api::{backend::Backend, BlockImportOperation};
use sc_executor::RuntimeVersionOf;
use sp_core::storage::{well_known_keys, StateVersion, Storage};
use sp_core::{
storage::{
well_known_keys, StateVersion, Storage
},
Blake2Hasher
};

use sp_runtime::{
traits::{Block as BlockT, Hash as HashT, Header as HeaderT, Zero},
BuildStorage,
Expand All @@ -44,10 +50,8 @@ where
code_fetcher: &code_fetcher,
heap_pages: None,
hash: {
use std::hash::{Hash, Hasher};
let mut state = DefaultHasher::new();
wasm.hash(&mut state);
state.finish().to_le_bytes().to_vec()
use sp_core::Hasher;
Blake2Hasher::hash(&wasm.to_vec()).as_ref().to_vec()
},
};
let runtime_version = RuntimeVersionOf::runtime_version(executor, &mut ext, &runtime_code)
Expand Down

0 comments on commit cd1f07c

Please sign in to comment.