From 6d3c875d76e7abc82336cdb74713557c72a5bb40 Mon Sep 17 00:00:00 2001 From: mustermeiszer Date: Sat, 10 Sep 2022 23:37:11 +0200 Subject: [PATCH] Format world --- core/src/builder/companion/src/expand/mod.rs | 4 +- core/src/builder/companion/src/lib.rs | 6 +- core/src/builder/companion/src/parse/mod.rs | 4 +- .../builder/companion/src/parse/parachain.rs | 3 +- core/src/builder/core.rs | 44 +++++++------- core/src/builder/parachain.rs | 21 ++++--- core/src/builder/relay_chain.rs | 58 ++++++++++--------- core/src/builder/stand_alone.rs | 21 ++++--- core/src/digest/aura.rs | 14 +++-- core/src/digest/babe.rs | 14 +++-- core/src/digest/mod.rs | 5 +- core/src/inherent/relay_parachain.rs | 3 +- core/src/inherent/timestamp.rs | 12 ++-- core/src/provider/externalities_provider.rs | 4 +- core/src/provider/mod.rs | 15 +++-- core/src/provider/state_provider.rs | 6 +- core/src/tests/parachain.rs | 20 ++++--- core/src/tests/relay_chain.rs | 16 ++--- core/src/tests/stand_alone.rs | 11 ++-- fudge/src/lib.rs | 8 +-- rustfmt.toml | 6 +- 21 files changed, 160 insertions(+), 135 deletions(-) diff --git a/core/src/builder/companion/src/expand/mod.rs b/core/src/builder/companion/src/expand/mod.rs index 6186fb0..ddf1071 100644 --- a/core/src/builder/companion/src/expand/mod.rs +++ b/core/src/builder/companion/src/expand/mod.rs @@ -10,13 +10,13 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use crate::parse::parachain; -use crate::parse::CompanionDef; use proc_macro2::{Ident, Span, TokenStream}; use proc_macro_crate::{crate_name, FoundCrate}; use quote::{quote, ToTokens}; use syn::Result as SynResult; +use crate::parse::{parachain, CompanionDef}; + fn get_fudge_crate() -> SynResult { let found_crate = crate_name("fudge").map_err(|_| { syn::Error::new( diff --git a/core/src/builder/companion/src/lib.rs b/core/src/builder/companion/src/lib.rs index acd15de..7277639 100644 --- a/core/src/builder/companion/src/lib.rs +++ b/core/src/builder/companion/src/lib.rs @@ -9,10 +9,10 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use crate::parse::CompanionDef; use proc_macro2::TokenStream; -use syn::spanned::Spanned; -use syn::{parse2, Result}; +use syn::{parse2, spanned::Spanned, Result}; + +use crate::parse::CompanionDef; mod expand; mod parse; diff --git a/core/src/builder/companion/src/parse/mod.rs b/core/src/builder/companion/src/parse/mod.rs index 35aa6f6..57ef3e3 100644 --- a/core/src/builder/companion/src/parse/mod.rs +++ b/core/src/builder/companion/src/parse/mod.rs @@ -10,8 +10,6 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use crate::parse::parachain::ParachainDef; -use crate::parse::relaychain::RelaychainDef; use proc_macro2::Span; use quote::ToTokens; use syn::{ @@ -21,6 +19,8 @@ use syn::{ Attribute, Error, Field, FieldsNamed, Ident, ItemStruct, Result, Visibility, }; +use crate::parse::{parachain::ParachainDef, relaychain::RelaychainDef}; + pub mod parachain; pub mod relaychain; diff --git a/core/src/builder/companion/src/parse/parachain.rs b/core/src/builder/companion/src/parse/parachain.rs index 2f5fc61..378b731 100644 --- a/core/src/builder/companion/src/parse/parachain.rs +++ b/core/src/builder/companion/src/parse/parachain.rs @@ -41,10 +41,11 @@ impl ToTokens for ParaId { } pub mod helper { - use crate::parse::CompanionDef; use proc_macro2::TokenStream; use quote::{quote, ToTokens}; + use crate::parse::CompanionDef; + pub fn parachain_ids(def: &CompanionDef) -> Vec { def.parachains.iter().map(|para| para.id.clone()).collect() } diff --git a/core/src/builder/core.rs b/core/src/builder/core.rs index 79345dd..6847b42 100644 --- a/core/src/builder/core.rs +++ b/core/src/builder/core.rs @@ -9,37 +9,35 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use crate::provider::ExternalitiesProvider; -use frame_support::pallet_prelude::TransactionSource; -use frame_support::sp_runtime::traits::NumberFor; -use sc_client_api::{AuxStore, Backend as BackendT, BlockOf, HeaderBackend, UsageProvider}; +use std::{marker::PhantomData, sync::Arc}; + +use frame_support::{pallet_prelude::TransactionSource, sp_runtime::traits::NumberFor}; +use sc_client_api::{ + backend::TransactionFor, blockchain::Backend as BlockchainBackend, AuxStore, + Backend as BackendT, BlockBackend, BlockImportOperation, BlockOf, HeaderBackend, NewBlockState, + UsageProvider, +}; use sc_client_db::Backend; -use sc_consensus::{BlockImport, BlockImportParams}; +use sc_consensus::{BlockImport, BlockImportParams, ImportResult}; use sc_executor::RuntimeVersionOf; -use sc_service::TFullClient; -use sp_api::{ApiExt, CallApiAt, ConstructRuntimeApi, ProvideRuntimeApi}; +use sc_service::{SpawnTaskHandle, TFullClient, TaskManager, TransactionPool}; +use sc_transaction_pool::{FullChainApi, RevalidationType}; +use sc_transaction_pool_api::{ChainEvent, MaintainedTransactionPool}; +use sp_api::{ApiExt, CallApiAt, ConstructRuntimeApi, HashFor, ProvideRuntimeApi}; use sp_block_builder::BlockBuilder; -use sp_consensus::Environment; +use sp_consensus::{Environment, InherentData, Proposal, Proposer}; use sp_core::traits::CodeExecutor; -use sp_runtime::{generic::BlockId, traits::One}; +use sp_runtime::{ + generic::BlockId, + traits::{Block as BlockT, BlockIdTo, Hash as HashT, Header as HeaderT, One, Zero}, + Digest, +}; use sp_state_machine::StorageProof; use sp_std::time::Duration; +use sp_storage::StateVersion; use sp_transaction_pool::runtime_api::TaggedTransactionQueue; -use std::{marker::PhantomData, sync::Arc}; -use crate::StoragePair; -use sc_client_api::backend::TransactionFor; -use sc_client_api::blockchain::Backend as BlockchainBackend; -use sc_client_api::{BlockBackend, BlockImportOperation, NewBlockState}; -use sc_consensus::ImportResult; -use sc_service::{SpawnTaskHandle, TaskManager, TransactionPool}; -use sc_transaction_pool::{FullChainApi, RevalidationType}; -use sc_transaction_pool_api::{ChainEvent, MaintainedTransactionPool}; -use sp_api::HashFor; -use sp_consensus::{InherentData, Proposal, Proposer}; -use sp_runtime::traits::{Block as BlockT, BlockIdTo, Hash as HashT, Header as HeaderT, Zero}; -use sp_runtime::Digest; -use sp_storage::StateVersion; +use crate::{provider::ExternalitiesProvider, StoragePair}; #[derive(Copy, Clone, Eq, PartialOrd, PartialEq, Ord, Hash)] pub enum Operation { diff --git a/core/src/builder/parachain.rs b/core/src/builder/parachain.rs index e5a0ba1..0113645 100644 --- a/core/src/builder/parachain.rs +++ b/core/src/builder/parachain.rs @@ -10,13 +10,6 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use crate::digest::DigestCreator; -use crate::inherent::ArgsProvider; -use crate::{ - builder::core::{Builder, Operation}, - types::StoragePair, - PoolState, -}; use codec::Encode; use polkadot_parachain::primitives::{BlockData, HeadData, Id, ValidationCode}; use sc_client_api::{ @@ -31,11 +24,21 @@ use sp_block_builder::BlockBuilder; use sp_consensus::{BlockOrigin, Proposal}; use sp_core::traits::CodeExecutor; use sp_inherents::{CreateInherentDataProviders, InherentDataProvider}; -use sp_runtime::traits::BlockIdTo; -use sp_runtime::{generic::BlockId, traits::Block as BlockT}; +use sp_runtime::{ + generic::BlockId, + traits::{Block as BlockT, BlockIdTo}, +}; use sp_std::{marker::PhantomData, sync::Arc, time::Duration}; use sp_transaction_pool::runtime_api::TaggedTransactionQueue; +use crate::{ + builder::core::{Builder, Operation}, + digest::DigestCreator, + inherent::ArgsProvider, + types::StoragePair, + PoolState, +}; + pub struct FudgeParaBuild { pub parent_head: HeadData, pub block: BlockData, diff --git a/core/src/builder/relay_chain.rs b/core/src/builder/relay_chain.rs index 94ab6d2..008d948 100644 --- a/core/src/builder/relay_chain.rs +++ b/core/src/builder/relay_chain.rs @@ -10,14 +10,6 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use crate::builder::parachain::FudgeParaChain; -use crate::digest::DigestCreator; -use crate::inherent::ArgsProvider; -use crate::{ - builder::core::{Builder, Operation}, - types::StoragePair, - PoolState, -}; use cumulus_primitives_parachain_inherent::ParachainInherentData; use cumulus_relay_chain_inprocess_interface::RelayChainInProcessInterface; use polkadot_core_primitives::Block as PBlock; @@ -36,20 +28,32 @@ use sp_api::{ApiExt, CallApiAt, ConstructRuntimeApi, ProvideRuntimeApi, StorageP use sp_block_builder::BlockBuilder; use sp_consensus::{BlockOrigin, NoNetwork, Proposal}; use sp_consensus_babe::BabeApi; -use sp_core::traits::CodeExecutor; -use sp_core::H256; +use sp_core::{traits::CodeExecutor, H256}; use sp_inherents::{CreateInherentDataProviders, InherentDataProvider}; -use sp_runtime::traits::BlockIdTo; -use sp_runtime::{generic::BlockId, traits::Block as BlockT}; +use sp_runtime::{ + generic::BlockId, + traits::{Block as BlockT, BlockIdTo}, +}; use sp_std::{marker::PhantomData, sync::Arc, time::Duration}; use sp_transaction_pool::runtime_api::TaggedTransactionQueue; use types::*; +use crate::{ + builder::{ + core::{Builder, Operation}, + parachain::FudgeParaChain, + }, + digest::DigestCreator, + inherent::ArgsProvider, + types::StoragePair, + PoolState, +}; + /// Recreating private storage types for easier handling storage access pub mod types { - use frame_support::traits::StorageInstance; use frame_support::{ storage::types::{StorageMap, StorageValue, ValueQuery}, + traits::StorageInstance, Identity, Twox64Concat, }; use polkadot_parachain::primitives::{ @@ -59,74 +63,74 @@ pub mod types { pub struct ParaLifecyclesPrefix; impl StorageInstance for ParaLifecyclesPrefix { + const STORAGE_PREFIX: &'static str = "Parachains"; + fn pallet_prefix() -> &'static str { "ParaLifecycles" } - - const STORAGE_PREFIX: &'static str = "Parachains"; } pub type ParaLifecycles = StorageMap; pub struct ParachainsPrefix; impl StorageInstance for ParachainsPrefix { + const STORAGE_PREFIX: &'static str = "Parachains"; + fn pallet_prefix() -> &'static str { "Paras" } - - const STORAGE_PREFIX: &'static str = "Parachains"; } pub type Parachains = StorageValue, ValueQuery>; pub struct HeadsPrefix; impl StorageInstance for HeadsPrefix { + const STORAGE_PREFIX: &'static str = "Heads"; + fn pallet_prefix() -> &'static str { "Paras" } - - const STORAGE_PREFIX: &'static str = "Heads"; } pub type Heads = StorageMap; pub struct CurrentCodeHashPrefix; impl StorageInstance for CurrentCodeHashPrefix { + const STORAGE_PREFIX: &'static str = "CurrentCodeHash"; + fn pallet_prefix() -> &'static str { "Paras" } - - const STORAGE_PREFIX: &'static str = "CurrentCodeHash"; } pub type CurrentCodeHash = StorageMap; pub struct CodeByHashPrefix; impl StorageInstance for CodeByHashPrefix { + const STORAGE_PREFIX: &'static str = "CodeByHash"; + fn pallet_prefix() -> &'static str { "Paras" } - - const STORAGE_PREFIX: &'static str = "CodeByHash"; } pub type CodeByHash = StorageMap; pub struct CodeByHashRefsPrefix; impl StorageInstance for CodeByHashRefsPrefix { + const STORAGE_PREFIX: &'static str = "CodeByHashRefs"; + fn pallet_prefix() -> &'static str { "Paras" } - - const STORAGE_PREFIX: &'static str = "CodeByHashRefs"; } pub type CodeByHashRefs = StorageMap; pub struct PastCodeHashPrefix; impl StorageInstance for PastCodeHashPrefix { + const STORAGE_PREFIX: &'static str = "PastCodeHash"; + fn pallet_prefix() -> &'static str { "Paras" } - - const STORAGE_PREFIX: &'static str = "PastCodeHash"; } #[allow(type_alias_bounds)] pub type PastCodeHash = diff --git a/core/src/builder/stand_alone.rs b/core/src/builder/stand_alone.rs index 893ce9b..25a1d3c 100644 --- a/core/src/builder/stand_alone.rs +++ b/core/src/builder/stand_alone.rs @@ -9,13 +9,6 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use crate::digest::DigestCreator; -use crate::inherent::ArgsProvider; -use crate::{ - builder::core::{Builder, Operation}, - types::StoragePair, - PoolState, -}; use sc_client_api::{ AuxStore, Backend as BackendT, BlockBackend, BlockOf, HeaderBackend, UsageProvider, }; @@ -28,12 +21,22 @@ use sp_block_builder::BlockBuilder; use sp_consensus::{BlockOrigin, Proposal}; use sp_core::traits::CodeExecutor; use sp_inherents::{CreateInherentDataProviders, InherentDataProvider}; -use sp_runtime::traits::BlockIdTo; -use sp_runtime::{generic::BlockId, traits::Block as BlockT}; +use sp_runtime::{ + generic::BlockId, + traits::{Block as BlockT, BlockIdTo}, +}; use sp_state_machine::StorageProof; use sp_std::{marker::PhantomData, sync::Arc, time::Duration}; use sp_transaction_pool::runtime_api::TaggedTransactionQueue; +use crate::{ + builder::core::{Builder, Operation}, + digest::DigestCreator, + inherent::ArgsProvider, + types::StoragePair, + PoolState, +}; + pub struct StandAloneBuilder< Block: BlockT, RtApi, diff --git a/core/src/digest/aura.rs b/core/src/digest/aura.rs index 514afef..c1ab6d6 100644 --- a/core/src/digest/aura.rs +++ b/core/src/digest/aura.rs @@ -10,18 +10,20 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use crate::digest::DigestProvider; use sc_client_api::{AuxStore, UsageProvider}; use sp_api::ProvideRuntimeApi; -use sp_consensus_aura::digests::CompatibleDigestItem; -use sp_consensus_aura::sr25519::{AuthorityId, AuthoritySignature}; -use sp_consensus_aura::{AuraApi, Slot, SlotDuration}; +use sp_consensus_aura::{ + digests::CompatibleDigestItem, + sr25519::{AuthorityId, AuthoritySignature}, + AuraApi, Slot, SlotDuration, +}; use sp_inherents::InherentData; -use sp_runtime::traits::Block; -use sp_runtime::{Digest as SPDigest, DigestItem}; +use sp_runtime::{traits::Block, Digest as SPDigest, DigestItem}; use sp_std::marker::PhantomData; use sp_timestamp::TimestampInherentData; +use crate::digest::DigestProvider; + pub struct Digest { slot_duration: SlotDuration, _phantom: PhantomData<(B, C)>, diff --git a/core/src/digest/babe.rs b/core/src/digest/babe.rs index 4fbd57d..421a14f 100644 --- a/core/src/digest/babe.rs +++ b/core/src/digest/babe.rs @@ -10,16 +10,18 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use crate::digest::DigestProvider; use codec::Encode; -use sp_consensus_babe::digests::{PreDigest, SecondaryPlainPreDigest}; -use sp_consensus_babe::inherents::BabeInherentData; -use sp_consensus_babe::BABE_ENGINE_ID; +use sp_consensus_babe::{ + digests::{PreDigest, SecondaryPlainPreDigest}, + inherents::BabeInherentData, + BABE_ENGINE_ID, +}; use sp_inherents::InherentData; -use sp_runtime::traits::Block as BlockT; -use sp_runtime::{Digest as SPDigest, DigestItem}; +use sp_runtime::{traits::Block as BlockT, Digest as SPDigest, DigestItem}; use sp_std::marker::PhantomData; +use crate::digest::DigestProvider; + pub struct Digest { _phantom: PhantomData, } diff --git a/core/src/digest/mod.rs b/core/src/digest/mod.rs index 1f4a03e..de54a4f 100644 --- a/core/src/digest/mod.rs +++ b/core/src/digest/mod.rs @@ -1,3 +1,5 @@ +pub use aura::Digest as FudgeAuraDigest; +pub use babe::Digest as FudgeBabeDigest; use sp_inherents::InherentData; // Copyright 2021 Centrifuge Foundation (centrifuge.io). // @@ -12,9 +14,6 @@ use sp_inherents::InherentData; // GNU General Public License for more details. use sp_runtime::Digest; -pub use aura::Digest as FudgeAuraDigest; -pub use babe::Digest as FudgeBabeDigest; - mod aura; mod babe; use sp_runtime::traits::Block; diff --git a/core/src/inherent/relay_parachain.rs b/core/src/inherent/relay_parachain.rs index db200d6..b491c58 100644 --- a/core/src/inherent/relay_parachain.rs +++ b/core/src/inherent/relay_parachain.rs @@ -9,7 +9,6 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use crate::builder::parachain::FudgeParaBuild; use polkadot_primitives::v2::{ BackedCandidate, InherentData as ParachainsInherentData, PARACHAINS_INHERENT_IDENTIFIER, }; @@ -17,6 +16,8 @@ use sp_inherents::{Error, InherentData, InherentDataProvider, InherentIdentifier use sp_runtime::traits::Header; use sp_std::sync::Arc; +use crate::builder::parachain::FudgeParaBuild; + pub struct DummyInherent { parent_head: HDR, } diff --git a/core/src/inherent/timestamp.rs b/core/src/inherent/timestamp.rs index 09e1080..feca4f3 100644 --- a/core/src/inherent/timestamp.rs +++ b/core/src/inherent/timestamp.rs @@ -15,10 +15,14 @@ use sp_core::sp_std::sync::Arc; use sp_inherents::{InherentData, InherentIdentifier}; use sp_runtime::SaturatedConversion; -use sp_std::collections::btree_map::BTreeMap; -use sp_std::sync::atomic::{AtomicU64, Ordering}; -use sp_std::sync::Mutex; -use sp_std::time::Duration; +use sp_std::{ + collections::btree_map::BTreeMap, + sync::{ + atomic::{AtomicU64, Ordering}, + Mutex, + }, + time::Duration, +}; use sp_timestamp::{InherentError, INHERENT_IDENTIFIER}; lazy_static::lazy_static!( diff --git a/core/src/provider/externalities_provider.rs b/core/src/provider/externalities_provider.rs index a6251be..1e283e8 100644 --- a/core/src/provider/externalities_provider.rs +++ b/core/src/provider/externalities_provider.rs @@ -10,11 +10,12 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. +use std::panic::{AssertUnwindSafe, UnwindSafe}; + use sp_core::Hasher; use sp_externalities::Externalities; use sp_state_machine::{Backend, Ext, OverlayedChanges, StorageChanges, StorageTransactionCache}; use sp_storage::StateVersion; -use std::panic::{AssertUnwindSafe, UnwindSafe}; pub struct ExternalitiesProvider<'a, H, B> where @@ -52,6 +53,7 @@ where None, ) } + /* /// Create a new instance_id of `TestExternalities` with storage. pub fn new(storage: Storage) -> Self { diff --git a/core/src/provider/mod.rs b/core/src/provider/mod.rs index 86df937..d23c3e8 100644 --- a/core/src/provider/mod.rs +++ b/core/src/provider/mod.rs @@ -10,23 +10,22 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use crate::provider::state_provider::StateProvider; +use std::path::PathBuf; + pub use externalities_provider::ExternalitiesProvider; use sc_executor::RuntimeVersionOf; -use sc_service::config::ExecutionStrategies; use sc_service::{ - ClientConfig, Configuration, KeystoreContainer, TFullBackend, TFullCallExecutor, TFullClient, - TaskManager, + config::ExecutionStrategies, ClientConfig, Configuration, KeystoreContainer, TFullBackend, + TFullCallExecutor, TFullClient, TaskManager, }; use sp_api::{BlockT, ConstructRuntimeApi}; use sp_core::traits::{CodeExecutor, SpawnNamed}; use sp_keystore::SyncCryptoStorePtr; use sp_runtime::BuildStorage; -use sp_std::marker::PhantomData; -use sp_std::str::FromStr; -use sp_std::sync::Arc; +use sp_std::{marker::PhantomData, str::FromStr, sync::Arc}; use sp_storage::Storage; -use std::path::PathBuf; + +use crate::provider::state_provider::StateProvider; mod externalities_provider; mod state_provider; diff --git a/core/src/provider/state_provider.rs b/core/src/provider/state_provider.rs index 658ad1b..acd8612 100644 --- a/core/src/provider/state_provider.rs +++ b/core/src/provider/state_provider.rs @@ -10,16 +10,16 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. +use std::path::PathBuf; + use sc_client_api::Backend; use sc_client_db::{BlocksPruning, DatabaseSettings, DatabaseSource}; use sc_service::PruningMode; use sp_core::storage::well_known_keys::CODE; use sp_database::MemDb; -use sp_runtime::traits::Block as BlockT; -use sp_runtime::BuildStorage; +use sp_runtime::{traits::Block as BlockT, BuildStorage}; use sp_std::{marker::PhantomData, sync::Arc}; use sp_storage::Storage; -use std::path::PathBuf; pub const CANONICALIZATION_DELAY: u64 = 4096; diff --git a/core/src/tests/parachain.rs b/core/src/tests/parachain.rs index bacb064..82f044f 100644 --- a/core/src/tests/parachain.rs +++ b/core/src/tests/parachain.rs @@ -10,15 +10,6 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use crate::builder::relay_chain::types::Heads; -///! Test for the ParachainBuilder -use crate::digest::{DigestCreator, DigestProvider, FudgeAuraDigest, FudgeBabeDigest}; -use crate::inherent::{ - FudgeDummyInherentRelayParachain, FudgeInherentParaParachain, FudgeInherentTimestamp, -}; -use crate::provider::EnvProvider; -use crate::RelaychainBuilder; -use crate::{FudgeParaChain, ParachainBuilder}; use centrifuge_runtime::{ AuraId, Block as PTestBlock, Runtime as PRuntime, RuntimeApi as PTestRtApi, WASM_BINARY as PCODE, @@ -38,6 +29,17 @@ use sp_runtime::Storage; use sp_std::sync::Arc; use tokio::runtime::Handle; +///! Test for the ParachainBuilder +use crate::digest::{DigestCreator, DigestProvider, FudgeAuraDigest, FudgeBabeDigest}; +use crate::{ + builder::relay_chain::types::Heads, + inherent::{ + FudgeDummyInherentRelayParachain, FudgeInherentParaParachain, FudgeInherentTimestamp, + }, + provider::EnvProvider, + FudgeParaChain, ParachainBuilder, RelaychainBuilder, +}; + type RelayBuilder = RelaychainBuilder< RTestBlock, RTestRtApi, diff --git a/core/src/tests/relay_chain.rs b/core/src/tests/relay_chain.rs index aec4b48..8457396 100644 --- a/core/src/tests/relay_chain.rs +++ b/core/src/tests/relay_chain.rs @@ -10,12 +10,6 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use crate::digest::{DigestCreator, DigestProvider, FudgeBabeDigest}; -use crate::inherent::{FudgeDummyInherentRelayParachain, FudgeInherentTimestamp}; -use crate::provider::EnvProvider; -use crate::FudgeParaChain; -use crate::RelayChainTypes; -use crate::RelaychainBuilder; use centrifuge_runtime::WASM_BINARY as PARA_CODE; use polkadot_parachain::primitives::{HeadData, Id, ValidationCode}; use polkadot_runtime::{Block as TestBlock, Runtime, RuntimeApi as TestRtApi, WASM_BINARY as CODE}; @@ -26,11 +20,17 @@ use sp_api::BlockId; use sp_consensus_babe::SlotDuration; use sp_core::H256; use sp_inherents::CreateInherentDataProviders; -use sp_runtime::traits::Hash as _; -use sp_runtime::Storage; +use sp_runtime::{traits::Hash as _, Storage}; use sp_std::sync::Arc; use tokio::runtime::Handle; +use crate::{ + digest::{DigestCreator, DigestProvider, FudgeBabeDigest}, + inherent::{FudgeDummyInherentRelayParachain, FudgeInherentTimestamp}, + provider::EnvProvider, + FudgeParaChain, RelayChainTypes, RelaychainBuilder, +}; + fn generate_default_setup_relay_chain( manager: &TaskManager, storage: Storage, diff --git a/core/src/tests/stand_alone.rs b/core/src/tests/stand_alone.rs index 621909b..2a8112c 100644 --- a/core/src/tests/stand_alone.rs +++ b/core/src/tests/stand_alone.rs @@ -10,10 +10,6 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use crate::digest::{DigestCreator, DigestProvider, FudgeBabeDigest}; -use crate::inherent::{FudgeDummyInherentRelayParachain, FudgeInherentTimestamp}; -use crate::provider::EnvProvider; -use crate::StandAloneBuilder; use frame_benchmarking::account; use polkadot_runtime::{Block as TestBlock, Runtime, RuntimeApi as TestRtApi, WASM_BINARY as CODE}; use sc_executor::{WasmExecutionMethod, WasmExecutor as TestExec}; @@ -26,6 +22,13 @@ use sp_runtime::{AccountId32, CryptoTypeId, KeyTypeId, MultiAddress, Storage}; use sp_std::sync::Arc; use tokio::runtime::Handle; +use crate::{ + digest::{DigestCreator, DigestProvider, FudgeBabeDigest}, + inherent::{FudgeDummyInherentRelayParachain, FudgeInherentTimestamp}, + provider::EnvProvider, + StandAloneBuilder, +}; + const KEY_TYPE: KeyTypeId = KeyTypeId(*b"test"); const CRYPTO_TYPE: CryptoTypeId = CryptoTypeId(*b"test"); diff --git a/fudge/src/lib.rs b/fudge/src/lib.rs index fa81c9a..7b23e15 100644 --- a/fudge/src/lib.rs +++ b/fudge/src/lib.rs @@ -10,6 +10,8 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. +pub use fudge_companion::companion; +pub use fudge_core::{digest, inherent, provider::EnvProvider}; ///! FUDGE - FUlly Decoupled Generic Environment for Substrate-based Chains ///! ///! Generally only this dependency is needed in order to use FUDGE. @@ -18,9 +20,6 @@ use sc_executor::WasmExecutor; use sc_service::{TFullBackend, TFullClient}; -pub use fudge_companion::companion; -pub use fudge_core::{digest, inherent, provider::EnvProvider}; - pub type ParachainBuilder = fudge_core::ParachainBuilder< Block, RtApi, @@ -56,8 +55,7 @@ pub type StandaloneBuilder = fudge_core::StandAloneBu >; pub mod primitives { - pub use fudge_core::FudgeParaChain; - pub use fudge_core::PoolState; + pub use fudge_core::{FudgeParaChain, PoolState}; pub use polkadot_parachain::primitives::Id as ParaId; #[derive(Copy, Clone, Eq, PartialOrd, PartialEq, Ord, Hash)] diff --git a/rustfmt.toml b/rustfmt.toml index c250de3..ddbf7ff 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +1,6 @@ hard_tabs = true -edition = '2018' +imports_granularity = "Crate" +reorder_impl_items = true +reorder_imports = true +group_imports = "StdExternalCrate" +reorder_modules = true \ No newline at end of file