mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 07:55:42 +00:00
Try to fix the build
This commit is contained in:
Generated
+2235
-1351
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -16,6 +16,6 @@ polkadot-collator = { git = "https://github.com/paritytech/polkadot", branch = "
|
|||||||
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "bkchr-cumulus-branch" }
|
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "bkchr-cumulus-branch" }
|
||||||
|
|
||||||
# other deps
|
# other deps
|
||||||
log = "0.4.6"
|
log = "0.4.8"
|
||||||
codec = { package = "parity-codec", version = "4.1.1", features = [ "derive" ] }
|
codec = { package = "parity-scale-codec", version = "1.0.5", features = [ "derive" ] }
|
||||||
futures = "0.1.27"
|
futures = "0.1.29"
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch =
|
|||||||
polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "bkchr-cumulus-branch" }
|
polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "bkchr-cumulus-branch" }
|
||||||
|
|
||||||
# other deps
|
# other deps
|
||||||
futures = "0.1.21"
|
futures = "0.1.29"
|
||||||
tokio = "0.1.8"
|
futures03 = { package = "futures-preview", version = "0.3.0-alpha.18"}
|
||||||
parity-codec = "4.1.1"
|
tokio = "0.1.22"
|
||||||
|
codec = { package = "parity-scale-codec", version = "1.0.5", features = [ "derive" ] }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|||||||
+48
-44
@@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use substrate_client::{backend::Backend, CallExecutor, Client, BlockchainEvents};
|
use substrate_client::{backend::{Backend, Finalizer}, CallExecutor, Client, BlockchainEvents};
|
||||||
use substrate_client::error::{Error as ClientError, Result as ClientResult};
|
use substrate_client::error::{Error as ClientError, Result as ClientResult};
|
||||||
use substrate_primitives::{Blake2Hasher, H256};
|
use substrate_primitives::{Blake2Hasher, H256};
|
||||||
use sr_primitives::generic::BlockId;
|
use sr_primitives::generic::BlockId;
|
||||||
@@ -22,8 +22,10 @@ use sr_primitives::traits::{Block as BlockT, Header as HeaderT, ProvideRuntimeAp
|
|||||||
use polkadot_primitives::{Hash as PHash, Block as PBlock};
|
use polkadot_primitives::{Hash as PHash, Block as PBlock};
|
||||||
use polkadot_primitives::parachain::{Id as ParaId, ParachainHost};
|
use polkadot_primitives::parachain::{Id as ParaId, ParachainHost};
|
||||||
|
|
||||||
use futures::{prelude::*, stream};
|
use futures03::{
|
||||||
use parity_codec::{Encode, Decode};
|
Stream, stream, StreamExt, TryStreamExt, TryStream, future, Future, TryFutureExt, FutureExt,
|
||||||
|
};
|
||||||
|
use codec::{Encode, Decode};
|
||||||
use log::warn;
|
use log::warn;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -44,11 +46,9 @@ pub trait LocalClient {
|
|||||||
|
|
||||||
/// Errors that can occur while following the polkadot relay-chain.
|
/// Errors that can occur while following the polkadot relay-chain.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error<P> {
|
pub enum Error {
|
||||||
/// An underlying client error.
|
/// An underlying client error.
|
||||||
Client(ClientError),
|
Client(ClientError),
|
||||||
/// Polkadot client error.
|
|
||||||
Polkadot(P),
|
|
||||||
/// Head data returned was not for our parachain.
|
/// Head data returned was not for our parachain.
|
||||||
InvalidHeadData,
|
InvalidHeadData,
|
||||||
}
|
}
|
||||||
@@ -68,38 +68,37 @@ pub trait PolkadotClient: Clone {
|
|||||||
type Error: std::fmt::Debug + Send;
|
type Error: std::fmt::Debug + Send;
|
||||||
|
|
||||||
/// A stream that yields updates to the parachain head.
|
/// A stream that yields updates to the parachain head.
|
||||||
type HeadUpdates: Stream<Item=HeadUpdate, Error=Self::Error> + Send;
|
type HeadUpdates: Stream<Item = HeadUpdate> + Send;
|
||||||
/// A stream that yields finalized head-data for a certain parachain.
|
/// A stream that yields finalized head-data for a certain parachain.
|
||||||
type Finalized: Stream<Item=Vec<u8>, Error=Self::Error> + Send;
|
type Finalized: Stream<Item = Vec<u8>> + Send;
|
||||||
|
|
||||||
/// Get a stream of head updates.
|
/// Get a stream of head updates.
|
||||||
fn head_updates(&self, para_id: ParaId) -> Self::HeadUpdates;
|
fn head_updates(&self, para_id: ParaId) -> ClientResult<Self::HeadUpdates>;
|
||||||
/// Get a stream of finalized heads.
|
/// Get a stream of finalized heads.
|
||||||
fn finalized_heads(&self, para_id: ParaId) -> Self::Finalized;
|
fn finalized_heads(&self, para_id: ParaId) -> ClientResult<Self::Finalized>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Spawns a future that follows the Polkadot relay chain for the given parachain.
|
/// Spawns a future that follows the Polkadot relay chain for the given parachain.
|
||||||
pub fn follow_polkadot<'a, L: 'a, P: 'a>(para_id: ParaId, local: Arc<L>, polkadot: P)
|
pub fn follow_polkadot<'a, L: 'a, P: 'a>(para_id: ParaId, local: Arc<L>, polkadot: P)
|
||||||
-> impl Future<Item=(),Error=()> + Send + 'a
|
-> ClientResult<impl Future<Output = ()> + Send + 'a>
|
||||||
where
|
where
|
||||||
L: LocalClient + Send + Sync,
|
L: LocalClient + Send + Sync,
|
||||||
P: PolkadotClient + Send + Sync,
|
P: PolkadotClient + Send + Sync,
|
||||||
{
|
{
|
||||||
let head_updates = polkadot.head_updates(para_id);
|
let head_updates = polkadot.head_updates(para_id)?;
|
||||||
let finalized_heads = polkadot.finalized_heads(para_id);
|
let finalized_heads = polkadot.finalized_heads(para_id)?;
|
||||||
|
|
||||||
let follow_best = {
|
let follow_best = {
|
||||||
let local = local.clone();
|
let local = local.clone();
|
||||||
|
|
||||||
head_updates
|
head_updates
|
||||||
.map_err(Error::Polkadot)
|
.map(|update| {
|
||||||
.and_then(|update| -> Result<Option<<L::Block as BlockT>::Header>, _> {
|
<Option<<L::Block as BlockT>::Header>>::decode(&mut &update.head_data[..])
|
||||||
Decode::decode(&mut &update.head_data[..]).ok_or_else(|| Error::InvalidHeadData)
|
.map_err(|_| Error::InvalidHeadData)
|
||||||
})
|
})
|
||||||
.filter_map(|h| h)
|
.try_filter_map(|h| future::ready(Ok(h)))
|
||||||
.for_each(move |p_head| {
|
.try_for_each(move |p_head| {
|
||||||
let _synced = local.mark_best(p_head.hash()).map_err(Error::Client)?;
|
future::ready(local.mark_best(p_head.hash()).map_err(Error::Client).map(|_| ()))
|
||||||
Ok(())
|
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -107,20 +106,21 @@ pub fn follow_polkadot<'a, L: 'a, P: 'a>(para_id: ParaId, local: Arc<L>, polkado
|
|||||||
let local = local.clone();
|
let local = local.clone();
|
||||||
|
|
||||||
finalized_heads
|
finalized_heads
|
||||||
.map_err(Error::Polkadot)
|
.map(|head_data| {
|
||||||
.and_then(|head_data| -> Result<Option<<L::Block as BlockT>::Header>, _> {
|
<Option<<L::Block as BlockT>::Header>>::decode(&mut &head_data[..])
|
||||||
Decode::decode(&mut &head_data[..]).ok_or_else(|| Error::InvalidHeadData)
|
.map_err(|_| Error::InvalidHeadData)
|
||||||
})
|
})
|
||||||
.filter_map(|h| h)
|
.try_filter_map(|h| future::ready(Ok(h)))
|
||||||
.for_each(move |p_head| {
|
.try_for_each(move |p_head| {
|
||||||
let _synced = local.finalize(p_head.hash()).map_err(Error::Client)?;
|
future::ready(local.finalize(p_head.hash()).map_err(Error::Client).map(|_| ()))
|
||||||
Ok(())
|
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
follow_best.join(follow_finalized)
|
Ok(
|
||||||
.map_err(|e| warn!("Could not follow relay-chain: {:?}", e))
|
future::try_join(follow_best, follow_finalized)
|
||||||
.map(|((), ())| ())
|
.map_err(|e| warn!("Could not follow relay-chain: {:?}", e))
|
||||||
|
.map(|_| ())
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<B, E, Block, RA> LocalClient for Client<B, E, Block, RA> where
|
impl<B, E, Block, RA> LocalClient for Client<B, E, Block, RA> where
|
||||||
@@ -168,41 +168,45 @@ impl<B, E, RA> PolkadotClient for Arc<Client<B, E, PBlock, RA>> where
|
|||||||
{
|
{
|
||||||
type Error = ClientError;
|
type Error = ClientError;
|
||||||
|
|
||||||
type HeadUpdates = Box<dyn Stream<Item=HeadUpdate, Error=Self::Error> + Send>;
|
type HeadUpdates = Box<dyn Stream<Item=HeadUpdate> + Send + Unpin>;
|
||||||
type Finalized = Box<dyn Stream<Item=Vec<u8>, Error=Self::Error> + Send>;
|
type Finalized = Box<dyn Stream<Item=Vec<u8>> + Send + Unpin>;
|
||||||
|
|
||||||
fn head_updates(&self, para_id: ParaId) -> Self::HeadUpdates {
|
fn head_updates(&self, para_id: ParaId) -> ClientResult<Self::HeadUpdates> {
|
||||||
let parachain_key = parachain_key(para_id);
|
let parachain_key = parachain_key(para_id);
|
||||||
let stream = stream::once(self.storage_changes_notification_stream(Some(&[parachain_key.clone()]), None))
|
let stream = self.storage_changes_notification_stream(Some(&[parachain_key.clone()]), None)?;
|
||||||
.map(|s| s.map_err(|()| panic!("unbounded receivers never yield errors; qed")))
|
|
||||||
.flatten();
|
|
||||||
|
|
||||||
let s = stream.filter_map(move |(hash, changes)| {
|
let s = stream.filter_map(move |(hash, changes)| {
|
||||||
let head_data = changes.iter()
|
let head_data = changes.iter()
|
||||||
.filter_map(|(_, k, v)| if k == ¶chain_key { Some(v) } else { None })
|
.filter_map(|(_, k, v)| if k == ¶chain_key { Some(v) } else { None })
|
||||||
.next();
|
.next();
|
||||||
|
|
||||||
match head_data {
|
let res = match head_data {
|
||||||
Some(Some(head_data)) => Some(HeadUpdate {
|
Some(Some(head_data)) => Some(HeadUpdate {
|
||||||
relay_hash: hash,
|
relay_hash: hash,
|
||||||
head_data: head_data.0.clone(),
|
head_data: head_data.0.clone(),
|
||||||
}),
|
}),
|
||||||
Some(None) | None => None,
|
Some(None) | None => None,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
future::ready(res)
|
||||||
});
|
});
|
||||||
|
|
||||||
Box::new(s)
|
Ok(Box::new(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn finalized_heads(&self, para_id: ParaId) -> Self::Finalized {
|
fn finalized_heads(&self, para_id: ParaId) -> ClientResult<Self::Finalized> {
|
||||||
let polkadot = self.clone();
|
let polkadot = self.clone();
|
||||||
let parachain_key = parachain_key(para_id);
|
let parachain_key = parachain_key(para_id);
|
||||||
|
|
||||||
let s = self.finality_notification_stream()
|
let s = self.finality_notification_stream()
|
||||||
.map_err(|()| panic!("unbounded receivers never yield errors; qed"))
|
.filter_map(move |n|
|
||||||
.and_then(move |n| polkadot.storage(&BlockId::hash(n.hash), ¶chain_key))
|
future::ready(
|
||||||
.filter_map(|d| d.map(|d| d.0));
|
polkadot.storage(&BlockId::hash(n.hash), ¶chain_key)
|
||||||
|
.ok()
|
||||||
|
.and_then(|d| d.map(|d| d.0)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
Box::new(s)
|
Ok(Box::new(s))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-9
@@ -5,17 +5,17 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[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" }
|
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" }
|
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" }
|
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" }
|
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" }
|
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" }
|
substrate-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "bkchr-cumulus-branch" }
|
||||||
memory-db = { version = "0.14.0", default-features = false }
|
memory-db = { version = "0.15.2", default-features = false }
|
||||||
hash-db = { version = "0.14.0", default-features = false }
|
hash-db = { version = "0.15.2", default-features = false }
|
||||||
trie-db = { version = "0.14.0", default-features = false }
|
trie-db = { version = "0.15.2", default-features = false }
|
||||||
hashbrown = "0.5.0"
|
hashbrown = "0.6.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
keyring = { package = "substrate-keyring", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
keyring = { package = "substrate-keyring", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||||
@@ -37,7 +37,3 @@ std = [
|
|||||||
"trie-db/std",
|
"trie-db/std",
|
||||||
"substrate-trie/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
|
Block as BlockT, Header as HeaderT, Hash as HashT
|
||||||
};
|
};
|
||||||
use executive::ExecuteBlock;
|
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 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;
|
static mut STORAGE: Option<Box<dyn Storage>> = None;
|
||||||
/// The message to use as expect message while accessing the `STORAGE`.
|
/// 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.
|
/// Validate a given parachain block on a validator.
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
#[doc(hidden)]
|
#[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],
|
mut arguments: &[u8],
|
||||||
) {
|
) {
|
||||||
use codec::Decode;
|
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
|
/// The storage implementation used when validating a block that is using the
|
||||||
/// witness data as source.
|
/// witness data as source.
|
||||||
struct WitnessStorage<B: BlockT> {
|
struct WitnessStorage<B: BlockT> {
|
||||||
witness_data: MemoryDB<<HashingOf<B> as HashT>::Hasher>,
|
witness_data: MemoryDB<Blake2Hasher>,
|
||||||
overlay: hashbrown::HashMap<Vec<u8>, Option<Vec<u8>>>,
|
overlay: hashbrown::HashMap<Vec<u8>, Option<Vec<u8>>>,
|
||||||
storage_root: B::Hash,
|
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.
|
/// Initialize from the given witness data and storage root.
|
||||||
///
|
///
|
||||||
/// Returns an error if given storage root was not found in the witness data.
|
/// 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,
|
storage_root: B::Hash,
|
||||||
) -> Result<Self, &'static str> {
|
) -> Result<Self, &'static str> {
|
||||||
let mut db = MemoryDB::default();
|
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.")
|
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>> {
|
fn get(&self, key: &[u8]) -> Option<Vec<u8>> {
|
||||||
self.overlay.get(key).cloned().or_else(|| {
|
self.overlay.get(key).cloned().or_else(|| {
|
||||||
read_trie_value(
|
read_trie_value::<Layout<Blake2Hasher>, _>(
|
||||||
&self.witness_data,
|
&self.witness_data,
|
||||||
&self.storage_root,
|
&self.storage_root,
|
||||||
key,
|
key,
|
||||||
@@ -138,7 +139,7 @@ impl<B: BlockT> Storage for WitnessStorage<B> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn storage_root(&mut self) -> [u8; STORAGE_ROOT_LEN] {
|
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,
|
&mut self.witness_data,
|
||||||
self.storage_root.clone(),
|
self.storage_root.clone(),
|
||||||
self.overlay.drain()
|
self.overlay.drain()
|
||||||
|
|||||||
@@ -9,3 +9,6 @@ test-client = { package = "substrate-test-client", git = "https://github.com/par
|
|||||||
runtime = { package = "cumulus-test-runtime", path = "../runtime" }
|
runtime = { package = "cumulus-test-runtime", path = "../runtime" }
|
||||||
runtime_primitives = { package = "sr-primitives", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
runtime_primitives = { package = "sr-primitives", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||||
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||||
|
keyring = { package = "substrate-keyring", git = "https://github.com/paritytech/substrate", branch = "bkchr-cumulus-branch" }
|
||||||
|
codec = { package = "parity-scale-codec", version = "1.0.5", default-features = false, features = [ "derive" ] }
|
||||||
|
|
||||||
|
|||||||
+30
-17
@@ -20,7 +20,8 @@ pub use test_client::*;
|
|||||||
pub use runtime;
|
pub use runtime;
|
||||||
use runtime::{Block, genesismap::{GenesisConfig, additional_storage_with_genesis}};
|
use runtime::{Block, genesismap::{GenesisConfig, additional_storage_with_genesis}};
|
||||||
use runtime_primitives::traits::{Hash as HashT, Header as HeaderT, Block as BlockT};
|
use runtime_primitives::traits::{Hash as HashT, Header as HeaderT, Block as BlockT};
|
||||||
use primitives::storage::well_known_keys;
|
use primitives::{storage::well_known_keys, sr25519};
|
||||||
|
use keyring::{Sr25519Keyring, AccountKeyring};
|
||||||
|
|
||||||
mod local_executor {
|
mod local_executor {
|
||||||
use test_client::executor::native_executor_instance;
|
use test_client::executor::native_executor_instance;
|
||||||
@@ -28,7 +29,6 @@ mod local_executor {
|
|||||||
pub LocalExecutor,
|
pub LocalExecutor,
|
||||||
runtime::api::dispatch,
|
runtime::api::dispatch,
|
||||||
runtime::native_version,
|
runtime::native_version,
|
||||||
runtime::WASM_BINARY
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,16 +58,23 @@ pub struct GenesisParameters {
|
|||||||
|
|
||||||
impl test_client::GenesisInit for GenesisParameters {
|
impl test_client::GenesisInit for GenesisParameters {
|
||||||
fn genesis_storage(&self) -> (StorageOverlay, ChildrenStorageOverlay) {
|
fn genesis_storage(&self) -> (StorageOverlay, ChildrenStorageOverlay) {
|
||||||
|
use codec::Encode;
|
||||||
let mut storage = genesis_config(self.support_changes_trie).genesis_map();
|
let mut storage = genesis_config(self.support_changes_trie).genesis_map();
|
||||||
storage.insert(well_known_keys::CODE.to_vec(), runtime::WASM_BINARY.to_vec());
|
storage.0.insert(well_known_keys::CODE.to_vec(), runtime::WASM_BINARY.to_vec());
|
||||||
|
|
||||||
let state_root = <<<Block as BlockT>::Header as HeaderT>::Hashing as HashT>::trie_root(
|
let child_roots = storage.1.iter().map(|(sk, child_map)| {
|
||||||
storage.clone().into_iter()
|
let state_root = <<<runtime::Block as BlockT>::Header as HeaderT>::Hashing as HashT>::trie_root(
|
||||||
|
child_map.clone().into_iter().collect()
|
||||||
|
);
|
||||||
|
(sk.clone(), state_root.encode())
|
||||||
|
});
|
||||||
|
let state_root = <<<runtime::Block as BlockT>::Header as HeaderT>::Hashing as HashT>::trie_root(
|
||||||
|
storage.0.clone().into_iter().chain(child_roots).collect()
|
||||||
);
|
);
|
||||||
let block: runtime::Block = client::genesis::construct_genesis_block(state_root);
|
let block: runtime::Block = client::genesis::construct_genesis_block(state_root);
|
||||||
storage.extend(additional_storage_with_genesis(&block));
|
storage.0.extend(additional_storage_with_genesis(&block));
|
||||||
|
|
||||||
(storage, Default::default())
|
storage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,15 +116,21 @@ impl DefaultTestClientBuilderExt for TestClientBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn genesis_config(support_changes_trie: bool) -> GenesisConfig {
|
fn genesis_config(support_changes_trie: bool) -> GenesisConfig {
|
||||||
GenesisConfig::new(support_changes_trie, vec![
|
GenesisConfig::new(
|
||||||
AuthorityKeyring::Alice.into(),
|
support_changes_trie,
|
||||||
AuthorityKeyring::Bob.into(),
|
vec![
|
||||||
AuthorityKeyring::Charlie.into(),
|
sr25519::Public::from(Sr25519Keyring::Alice).into(),
|
||||||
], vec![
|
sr25519::Public::from(Sr25519Keyring::Bob).into(),
|
||||||
AccountKeyring::Alice.into(),
|
sr25519::Public::from(Sr25519Keyring::Charlie).into(),
|
||||||
AccountKeyring::Bob.into(),
|
],
|
||||||
AccountKeyring::Charlie.into(),
|
vec![
|
||||||
],
|
AccountKeyring::Alice.into(),
|
||||||
1000
|
AccountKeyring::Bob.into(),
|
||||||
|
AccountKeyring::Charlie.into(),
|
||||||
|
],
|
||||||
|
1000,
|
||||||
|
None,
|
||||||
|
Default::default(),
|
||||||
|
Default::default(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,3 @@ std = [
|
|||||||
"runtime/std",
|
"runtime/std",
|
||||||
"substrate-test-runtime/std",
|
"substrate-test-runtime/std",
|
||||||
]
|
]
|
||||||
no_std = [
|
|
||||||
"runtime/no_std",
|
|
||||||
"substrate-test-runtime/no_std",
|
|
||||||
]
|
|
||||||
|
|||||||
@@ -17,5 +17,5 @@
|
|||||||
use wasm_builder_runner::{build_current_project, WasmBuilderSource};
|
use wasm_builder_runner::{build_current_project, WasmBuilderSource};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
build_current_project("wasm_binary.rs", WasmBuilderSource::Crates("1.0.4"));
|
build_current_project("wasm_binary.rs", WasmBuilderSource::Crates("1.0.7"));
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user