mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 14:41:11 +00:00
Try to fix the build
This commit is contained in:
+5
-9
@@ -5,17 +5,17 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-codec", version = "4.1.1", default-features = false, features = [ "derive" ] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.5", default-features = false, features = [ "derive" ] }
|
||||
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
|
||||
runtime-primitives = { package = "sr-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
|
||||
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
|
||||
rio = { package = "sr-io", git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
|
||||
executive = { package = "srml-executive", git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
|
||||
substrate-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
|
||||
memory-db = { version = "0.14.0", default-features = false }
|
||||
hash-db = { version = "0.14.0", default-features = false }
|
||||
trie-db = { version = "0.14.0", default-features = false }
|
||||
hashbrown = "0.5.0"
|
||||
memory-db = { version = "0.15.2", default-features = false }
|
||||
hash-db = { version = "0.15.2", default-features = false }
|
||||
trie-db = { version = "0.15.2", default-features = false }
|
||||
hashbrown = "0.6.0"
|
||||
|
||||
[dev-dependencies]
|
||||
keyring = { package = "substrate-keyring", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||
@@ -37,7 +37,3 @@ std = [
|
||||
"trie-db/std",
|
||||
"substrate-trie/std",
|
||||
]
|
||||
no_std = [
|
||||
"hashbrown/nightly",
|
||||
"rio/wasm-nice-panic-message",
|
||||
]
|
||||
|
||||
@@ -21,12 +21,13 @@ use runtime_primitives::traits::{
|
||||
Block as BlockT, Header as HeaderT, Hash as HashT
|
||||
};
|
||||
use executive::ExecuteBlock;
|
||||
use primitives::{Blake2Hasher, H256};
|
||||
|
||||
use substrate_trie::{MemoryDB, read_trie_value, delta_trie_root};
|
||||
use substrate_trie::{MemoryDB, read_trie_value, delta_trie_root, Layout};
|
||||
|
||||
use rstd::{slice, ptr, cmp, vec::Vec, boxed::Box, mem};
|
||||
|
||||
use hash_db::HashDB;
|
||||
use hash_db::{HashDB, EMPTY_PREFIX};
|
||||
|
||||
static mut STORAGE: Option<Box<dyn Storage>> = None;
|
||||
/// The message to use as expect message while accessing the `STORAGE`.
|
||||
@@ -55,7 +56,7 @@ trait Storage {
|
||||
/// Validate a given parachain block on a validator.
|
||||
#[cfg(not(feature = "std"))]
|
||||
#[doc(hidden)]
|
||||
pub fn validate_block<B: BlockT, E: ExecuteBlock<B>>(
|
||||
pub fn validate_block<B: BlockT<Hash = H256>, E: ExecuteBlock<B>>(
|
||||
mut arguments: &[u8],
|
||||
) {
|
||||
use codec::Decode;
|
||||
@@ -90,12 +91,12 @@ pub fn validate_block<B: BlockT, E: ExecuteBlock<B>>(
|
||||
/// The storage implementation used when validating a block that is using the
|
||||
/// witness data as source.
|
||||
struct WitnessStorage<B: BlockT> {
|
||||
witness_data: MemoryDB<<HashingOf<B> as HashT>::Hasher>,
|
||||
witness_data: MemoryDB<Blake2Hasher>,
|
||||
overlay: hashbrown::HashMap<Vec<u8>, Option<Vec<u8>>>,
|
||||
storage_root: B::Hash,
|
||||
}
|
||||
|
||||
impl<B: BlockT> WitnessStorage<B> {
|
||||
impl<B: BlockT<Hash = H256>> WitnessStorage<B> {
|
||||
/// Initialize from the given witness data and storage root.
|
||||
///
|
||||
/// Returns an error if given storage root was not found in the witness data.
|
||||
@@ -104,9 +105,9 @@ impl<B: BlockT> WitnessStorage<B> {
|
||||
storage_root: B::Hash,
|
||||
) -> Result<Self, &'static str> {
|
||||
let mut db = MemoryDB::default();
|
||||
data.into_iter().for_each(|i| { db.insert(&[], &i); });
|
||||
data.into_iter().for_each(|i| { db.insert(EMPTY_PREFIX, &i); });
|
||||
|
||||
if !db.contains(&storage_root, &[]) {
|
||||
if !db.contains(&storage_root, EMPTY_PREFIX) {
|
||||
return Err("Witness data does not contain given storage root.")
|
||||
}
|
||||
|
||||
@@ -118,10 +119,10 @@ impl<B: BlockT> WitnessStorage<B> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: BlockT> Storage for WitnessStorage<B> {
|
||||
impl<B: BlockT<Hash = H256>> Storage for WitnessStorage<B> {
|
||||
fn get(&self, key: &[u8]) -> Option<Vec<u8>> {
|
||||
self.overlay.get(key).cloned().or_else(|| {
|
||||
read_trie_value(
|
||||
read_trie_value::<Layout<Blake2Hasher>, _>(
|
||||
&self.witness_data,
|
||||
&self.storage_root,
|
||||
key,
|
||||
@@ -138,7 +139,7 @@ impl<B: BlockT> Storage for WitnessStorage<B> {
|
||||
}
|
||||
|
||||
fn storage_root(&mut self) -> [u8; STORAGE_ROOT_LEN] {
|
||||
let root = match delta_trie_root(
|
||||
let root = match delta_trie_root::<Layout<Blake2Hasher>, _, _, _, _>(
|
||||
&mut self.witness_data,
|
||||
self.storage_root.clone(),
|
||||
self.overlay.drain()
|
||||
@@ -230,4 +231,4 @@ unsafe fn ext_storage_root(result: *mut u8) {
|
||||
let res = STORAGE.as_mut().expect(STORAGE_SET_EXPECT).storage_root();
|
||||
let result = slice::from_raw_parts_mut(result, STORAGE_ROOT_LEN);
|
||||
result.copy_from_slice(&res);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user