Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 21 additions & 5 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ use sp_runtime::Perbill;

use node_runtime::{
versioned_store::InputValidationLengthConstraint as VsInputValidation,
AuthorityDiscoveryConfig, BabeConfig, Balance, BalancesConfig, ContentWorkingGroupConfig,
CouncilConfig, CouncilElectionConfig, DataObjectStorageRegistryConfig,
DataObjectTypeRegistryConfig, ElectionParameters, GrandpaConfig, ImOnlineConfig, MembersConfig,
ProposalsCodexConfig, SessionConfig, SessionKeys, Signature, StakerStatus, StakingConfig,
StorageWorkingGroupConfig, SudoConfig, SystemConfig, VersionedStoreConfig, DAYS, WASM_BINARY,
AuthorityDiscoveryConfig, BabeConfig, Balance, BalancesConfig, ContentDirectoryConfig,
ContentDirectoryWorkingGroupConfig, ContentWorkingGroupConfig, CouncilConfig,
CouncilElectionConfig, DataObjectStorageRegistryConfig, DataObjectTypeRegistryConfig,
ElectionParameters, GrandpaConfig, ImOnlineConfig, MembersConfig, ProposalsCodexConfig,
SessionConfig, SessionKeys, Signature, StakerStatus, StakingConfig, StorageWorkingGroupConfig,
SudoConfig, SystemConfig, VersionedStoreConfig, DAYS, WASM_BINARY,
};

pub use node_runtime::{AccountId, GenesisConfig};
Expand Down Expand Up @@ -292,6 +293,13 @@ pub fn testnet_genesis(
worker_application_human_readable_text_constraint: default_text_constraint,
worker_exit_rationale_text_constraint: default_text_constraint,
}),
working_group_Instance3: Some(ContentDirectoryWorkingGroupConfig {
phantom: Default::default(),
storage_working_group_mint_capacity: 0,
opening_human_readable_text_constraint: default_text_constraint,
worker_application_human_readable_text_constraint: default_text_constraint,
worker_exit_rationale_text_constraint: default_text_constraint,
}),
versioned_store: Some(VersionedStoreConfig {
class_by_id: vec![],
entity_by_id: vec![],
Expand Down Expand Up @@ -326,6 +334,14 @@ pub fn testnet_genesis(
channel_banner_constraint: InputValidationLengthConstraint::new(5, 1024),
channel_title_constraint: InputValidationLengthConstraint::new(5, 1024),
}),
content_directory: Some({
ContentDirectoryConfig {
curator_group_by_id: vec![],
next_class_id: 1,
next_entity_id: 1,
next_curator_group_id: 1,
}
}),
proposals_codex: Some(ProposalsCodexConfig {
set_validator_count_proposal_voting_period: cpcp
.set_validator_count_proposal_voting_period,
Expand Down
2 changes: 1 addition & 1 deletion runtime-modules/content-directory/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pub struct InputValidationLengthConstraint {

impl InputValidationLengthConstraint {
/// Create new `InputValidationLengthConstraint` constraint
pub fn new(min: u16, max_min_diff: u16) -> Self {
pub const fn new(min: u16, max_min_diff: u16) -> Self {
Self { min, max_min_diff }
}

Expand Down
20 changes: 7 additions & 13 deletions runtime-modules/content-directory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ pub use operations::*;
pub use permissions::*;
pub use schema::*;

use core::fmt::Debug;
use core::hash::Hash;
use core::ops::AddAssign;

Expand All @@ -145,21 +144,22 @@ use frame_support::storage::IterableStorageMap;
use frame_support::{
decl_event, decl_module, decl_storage, dispatch::DispatchResult, ensure, traits::Get, Parameter,
};
#[cfg(feature = "std")]
pub use serde::{Deserialize, Serialize};
use sp_arithmetic::traits::{BaseArithmetic, One, Zero};
use sp_runtime::traits::{MaybeSerializeDeserialize, Member};
use sp_std::borrow::ToOwned;
use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet};
use sp_std::vec;
use sp_std::vec::Vec;
use system::ensure_signed;

#[cfg(feature = "std")]
pub use serde::{Deserialize, Serialize};

pub use errors::Error;

use core::debug_assert;

/// Type, used in diffrent numeric constraints representations
type MaxNumber = u32;
pub type MaxNumber = u32;

/// Module configuration trait for this Substrate module.
pub trait Trait: system::Trait + ActorAuthenticator + Clone {
Expand All @@ -174,8 +174,6 @@ pub trait Trait: system::Trait + ActorAuthenticator + Clone {
+ Default
+ Copy
+ Clone
+ One
+ Zero
+ MaybeSerializeDeserialize
+ Eq
+ PartialEq
Expand All @@ -190,9 +188,7 @@ pub trait Trait: system::Trait + ActorAuthenticator + Clone {
+ Default
+ Copy
+ Clone
+ One
+ Hash
+ Zero
+ MaybeSerializeDeserialize
+ Eq
+ PartialEq
Expand All @@ -207,8 +203,6 @@ pub trait Trait: system::Trait + ActorAuthenticator + Clone {
+ Copy
+ Clone
+ Hash
+ One
+ Zero
+ MaybeSerializeDeserialize
+ Eq
+ PartialEq
Expand Down Expand Up @@ -266,10 +260,10 @@ decl_storage! {
trait Store for Module<T: Trait> as ContentDirectory {

/// Map, representing ClassId -> Class relation
pub ClassById get(fn class_by_id) config(): map hasher(blake2_128_concat) T::ClassId => Class<T>;
pub ClassById get(fn class_by_id): map hasher(blake2_128_concat) T::ClassId => Class<T>;

/// Map, representing EntityId -> Entity relation
pub EntityById get(fn entity_by_id) config(): map hasher(blake2_128_concat) T::EntityId => Entity<T>;
pub EntityById get(fn entity_by_id): map hasher(blake2_128_concat) T::EntityId => Entity<T>;

/// Map, representing CuratorGroupId -> CuratorGroup relation
pub CuratorGroupById get(fn curator_group_by_id) config(): map hasher(blake2_128_concat) T::CuratorGroupId => CuratorGroup<T>;
Expand Down
31 changes: 0 additions & 31 deletions runtime-modules/content-directory/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,16 @@ thread_local! {
static PROPERTY_DESCRIPTION_CONSTRAINT: RefCell<InputValidationLengthConstraint> = RefCell::new(InputValidationLengthConstraint::default());
static CLASS_NAME_CONSTRAINT: RefCell<InputValidationLengthConstraint> = RefCell::new(InputValidationLengthConstraint::default());
static CLASS_DESCRIPTION_CONSTRAINT: RefCell<InputValidationLengthConstraint> = RefCell::new(InputValidationLengthConstraint::default());

static MAX_NUMBER_OF_CLASSES: RefCell<MaxNumber> = RefCell::new(0);
static MAX_NUMBER_OF_MAINTAINERS_PER_CLASS: RefCell<MaxNumber> = RefCell::new(0);
static MAX_NUMBER_OF_SCHEMAS_PER_CLASS: RefCell<MaxNumber> = RefCell::new(0);
static MAX_NUMBER_OF_PROPERTIES_PER_CLASS: RefCell<MaxNumber> = RefCell::new(0);
static MAX_NUMBER_OF_ENTITIES_PER_CLASS: RefCell<EntityId> = RefCell::new(0);

static MAX_NUMBER_OF_CURATORS_PER_GROUP: RefCell<MaxNumber> = RefCell::new(0);

static MAX_NUMBER_OF_OPERATIONS_DURING_ATOMIC_BATCHING: RefCell<MaxNumber> = RefCell::new(0);

static VEC_MAX_LENGTH_CONSTRAINT: RefCell<VecMaxLength> = RefCell::new(0);
static TEXT_MAX_LENGTH_CONSTRAINT: RefCell<TextMaxLength> = RefCell::new(0);
static HASHED_TEXT_MAX_LENGTH_CONSTRAINT: RefCell<HashedTextMaxLength> = RefCell::new(Some(0));

static INDIVIDUAL_ENTITIES_CREATION_LIMIT: RefCell<EntityId> = RefCell::new(0);
}

Expand Down Expand Up @@ -252,31 +247,23 @@ impl_outer_event! {

impl Trait for Runtime {
type Event = TestEvent;

type Nonce = u64;

type ClassId = u64;
type EntityId = u64;

type PropertyNameLengthConstraint = PropertyNameLengthConstraint;
type PropertyDescriptionLengthConstraint = PropertyDescriptionLengthConstraint;
type ClassNameLengthConstraint = ClassNameLengthConstraint;
type ClassDescriptionLengthConstraint = ClassDescriptionLengthConstraint;

type MaxNumberOfClasses = MaxNumberOfClasses;
type MaxNumberOfMaintainersPerClass = MaxNumberOfMaintainersPerClass;
type MaxNumberOfSchemasPerClass = MaxNumberOfSchemasPerClass;
type MaxNumberOfPropertiesPerSchema = MaxNumberOfPropertiesPerSchema;
type MaxNumberOfEntitiesPerClass = MaxNumberOfEntitiesPerClass;

type MaxNumberOfCuratorsPerGroup = MaxNumberOfCuratorsPerGroup;

type MaxNumberOfOperationsDuringAtomicBatching = MaxNumberOfOperationsDuringAtomicBatching;

type VecMaxLengthConstraint = VecMaxLengthConstraint;
type TextMaxLengthConstraint = TextMaxLengthConstraint;
type HashedTextMaxLengthConstraint = HashedTextMaxLengthConstraint;

type IndividualEntitiesCreationLimit = IndividualEntitiesCreationLimit;
}

Expand Down Expand Up @@ -311,21 +298,16 @@ pub struct ExtBuilder {
property_description_constraint: InputValidationLengthConstraint,
class_name_constraint: InputValidationLengthConstraint,
class_description_constraint: InputValidationLengthConstraint,

max_number_of_classes: MaxNumber,
max_number_of_maintainers_per_class: MaxNumber,
max_number_of_schemas_per_class: MaxNumber,
max_number_of_properties_per_class: MaxNumber,
max_number_of_entities_per_class: EntityId,

max_number_of_curators_per_group: MaxNumber,

max_number_of_operations_during_atomic_batching: MaxNumber,

vec_max_length_constraint: VecMaxLength,
text_max_length_constraint: TextMaxLength,
hashed_text_max_length_constraint: HashedTextMaxLength,

individual_entities_creation_limit: EntityId,
}

Expand All @@ -336,21 +318,16 @@ impl Default for ExtBuilder {
property_description_constraint: InputValidationLengthConstraint::new(1, 500),
class_name_constraint: InputValidationLengthConstraint::new(1, 49),
class_description_constraint: InputValidationLengthConstraint::new(1, 500),

max_number_of_classes: 100,
max_number_of_maintainers_per_class: 10,
max_number_of_schemas_per_class: 20,
max_number_of_properties_per_class: 40,
max_number_of_entities_per_class: 400,

max_number_of_curators_per_group: 50,

max_number_of_operations_during_atomic_batching: 500,

vec_max_length_constraint: 200,
text_max_length_constraint: 5000,
hashed_text_max_length_constraint: Some(25000),

individual_entities_creation_limit: 50,
}
}
Expand All @@ -363,7 +340,6 @@ impl ExtBuilder {
.with(|v| *v.borrow_mut() = self.property_description_constraint);
CLASS_NAME_CONSTRAINT.with(|v| *v.borrow_mut() = self.class_name_constraint);
CLASS_DESCRIPTION_CONSTRAINT.with(|v| *v.borrow_mut() = self.class_description_constraint);

MAX_NUMBER_OF_CLASSES.with(|v| *v.borrow_mut() = self.max_number_of_classes);
MAX_NUMBER_OF_MAINTAINERS_PER_CLASS
.with(|v| *v.borrow_mut() = self.max_number_of_maintainers_per_class);
Expand All @@ -373,19 +349,14 @@ impl ExtBuilder {
.with(|v| *v.borrow_mut() = self.max_number_of_properties_per_class);
MAX_NUMBER_OF_ENTITIES_PER_CLASS
.with(|v| *v.borrow_mut() = self.max_number_of_entities_per_class);

MAX_NUMBER_OF_CURATORS_PER_GROUP
.with(|v| *v.borrow_mut() = self.max_number_of_curators_per_group);

MAX_NUMBER_OF_OPERATIONS_DURING_ATOMIC_BATCHING
.with(|v| *v.borrow_mut() = self.max_number_of_operations_during_atomic_batching);

VEC_MAX_LENGTH_CONSTRAINT.with(|v| *v.borrow_mut() = self.vec_max_length_constraint);
TEXT_MAX_LENGTH_CONSTRAINT.with(|v| *v.borrow_mut() = self.text_max_length_constraint);

HASHED_TEXT_MAX_LENGTH_CONSTRAINT
.with(|v| *v.borrow_mut() = self.hashed_text_max_length_constraint);

INDIVIDUAL_ENTITIES_CREATION_LIMIT
.with(|v| *v.borrow_mut() = self.individual_entities_creation_limit);
}
Expand All @@ -405,8 +376,6 @@ impl ExtBuilder {

fn default_content_directory_genesis_config() -> GenesisConfig<Runtime> {
GenesisConfig {
class_by_id: vec![],
entity_by_id: vec![],
curator_group_by_id: vec![],
next_class_id: 1,
next_entity_id: 1,
Expand Down
1 change: 0 additions & 1 deletion runtime-modules/content-directory/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ pub enum OperationType<T: Trait> {
}

impl<T: Trait> core::fmt::Debug for OperationType<T> {
#[cfg(feature = "std")]
fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(formatter, "OperationType {:?}", self)
}
Expand Down
2 changes: 0 additions & 2 deletions runtime-modules/content-directory/src/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ pub trait ActorAuthenticator: system::Trait {
+ Member
+ BaseArithmetic
+ Codec
+ One
+ Default
+ Copy
+ Clone
Expand Down Expand Up @@ -122,7 +121,6 @@ impl<T: Trait> Default for Actor<T> {
}

impl<T: Trait> core::fmt::Debug for Actor<T> {
#[cfg(feature = "std")]
fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove conditional compilation for this and other Debug implementations>

Copy link
Contributor Author

@iorveth iorveth Sep 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still getting errors, related to T: Trait inheritance, when conditional compilation enabled here. I hope this will be fixed with further refactoring.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Please, keep in mind to remove those implemented traits after the refactoring.

write!(formatter, "Actor {:?}", self)
}
Expand Down
1 change: 0 additions & 1 deletion runtime-modules/content-directory/src/permissions/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub struct ClassPermissions<T: Trait> {
}

impl<T: Trait> core::fmt::Debug for ClassPermissions<T> {
#[cfg(feature = "std")]
fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(formatter, "ClassPermissions {:?}", self)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ impl<T: Trait> Default for EntityController<T> {
}

impl<T: Trait> core::fmt::Debug for EntityController<T> {
#[cfg(feature = "std")]
fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(formatter, "EntityController {:?}", self)
}
Expand Down
1 change: 0 additions & 1 deletion runtime-modules/content-directory/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ impl<T: Trait> Default for Property<T> {
}

impl<T: Trait> core::fmt::Debug for Property<T> {
#[cfg(feature = "std")]
fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(formatter, "Property {:?}", self)
}
Expand Down
4 changes: 1 addition & 3 deletions runtime-modules/content-directory/src/schema/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub enum InputPropertyValue<T: Trait> {
}

impl<T: Trait> core::fmt::Debug for InputPropertyValue<T> {
#[cfg(feature = "std")]
fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(formatter, "InputPropertyValue {:?}", self)
}
Expand Down Expand Up @@ -81,8 +80,7 @@ pub enum InputValue<T: Trait> {
}

impl<T: Trait> core::fmt::Debug for InputValue<T> {
#[cfg(feature = "std")]
fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> sp_std::fmt::Result {
write!(formatter, "InputValue {:?}", self)
}
}
Expand Down
3 changes: 2 additions & 1 deletion runtime-modules/working-group/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,8 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
Ok(worker)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment for a public method, please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 9d6bbb0

fn ensure_worker_exists(worker_id: &WorkerId<T>) -> Result<WorkerOf<T>, Error<T, I>> {
/// Ensures worker under given id already exists
pub fn ensure_worker_exists(worker_id: &WorkerId<T>) -> Result<WorkerOf<T>, Error<T, I>> {
ensure!(
WorkerById::<T, I>::contains_key(worker_id),
Error::<T, I>::WorkerDoesNotExist
Expand Down
2 changes: 2 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ service-discovery = { package = 'pallet-service-discovery', default-features = f
proposals-engine = { package = 'pallet-proposals-engine', default-features = false, path = '../runtime-modules/proposals/engine'}
proposals-discussion = { package = 'pallet-proposals-discussion', default-features = false, path = '../runtime-modules/proposals/discussion'}
proposals-codex = { package = 'pallet-proposals-codex', default-features = false, path = '../runtime-modules/proposals/codex'}
content-directory = { package = 'pallet-content-directory', default-features = false, path = '../runtime-modules/content-directory' }

[dev-dependencies]
sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
Expand Down Expand Up @@ -152,6 +153,7 @@ std = [
'proposals-engine/std',
'proposals-discussion/std',
'proposals-codex/std',
'content-directory/std',
]
runtime-benchmarks = [
"system/runtime-benchmarks",
Expand Down
Loading