Skip to content

Commit

Permalink
Merge pull request #35 from centrifuge/format-world
Browse files Browse the repository at this point in the history
Format world
  • Loading branch information
mustermeiszer authored Sep 10, 2022
2 parents 3b8991e + 6d3c875 commit 212d66a
Show file tree
Hide file tree
Showing 21 changed files with 160 additions and 135 deletions.
4 changes: 2 additions & 2 deletions core/src/builder/companion/src/expand/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TokenStream> {
let found_crate = crate_name("fudge").map_err(|_| {
syn::Error::new(
Expand Down
6 changes: 3 additions & 3 deletions core/src/builder/companion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions core/src/builder/companion/src/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion core/src/builder/companion/src/parse/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TokenStream> {
def.parachains.iter().map(|para| para.id.clone()).collect()
}
Expand Down
44 changes: 21 additions & 23 deletions core/src/builder/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 12 additions & 9 deletions core/src/builder/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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,
Expand Down
58 changes: 31 additions & 27 deletions core/src/builder/relay_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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::{
Expand All @@ -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<ParaLifecyclesPrefix, Twox64Concat, ParaId, ParaLifecycle>;

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<ParachainsPrefix, Vec<ParaId>, 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<HeadsPrefix, Twox64Concat, ParaId, HeadData>;

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<CurrentCodeHashPrefix, Twox64Concat, ParaId, ValidationCodeHash>;

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<CodeByHashPrefix, Identity, ValidationCodeHash, ValidationCode>;

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<CodeByHashRefsPrefix, Identity, ValidationCodeHash, u32, ValueQuery>;

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<T: frame_system::Config> =
Expand Down
21 changes: 12 additions & 9 deletions core/src/builder/stand_alone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -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,
Expand Down
14 changes: 8 additions & 6 deletions core/src/digest/aura.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<B, C> {
slot_duration: SlotDuration,
_phantom: PhantomData<(B, C)>,
Expand Down
14 changes: 8 additions & 6 deletions core/src/digest/babe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<B> {
_phantom: PhantomData<B>,
}
Expand Down
Loading

0 comments on commit 212d66a

Please sign in to comment.