diff --git a/runtime/g1/src/lib.rs b/runtime/g1/src/lib.rs index 5801ba07321614bf8fbf63ff00b30bbe41c30a73..f250effcb073878bee0d2e6d6f9b651af1d5f710 100644 --- a/runtime/g1/src/lib.rs +++ b/runtime/g1/src/lib.rs @@ -22,6 +22,9 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +mod parameters; + +pub use self::parameters::*; pub use common_runtime::{ constants::*, entities::{IdtyData, IdtyDid, IdtyRight, Planet}, @@ -78,15 +81,6 @@ pub use frame_support::{ pub mod opaque { use super::*; - pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; - - /// Opaque block header type. - pub type Header = generic::Header<BlockNumber, BlakeTwo256>; - /// Opaque block type. - pub type Block = generic::Block<Header, UncheckedExtrinsic>; - /// Opaque block identifier type. - pub type BlockId = generic::BlockId<Block>; - impl_opaque_keys! { pub struct SessionKeys { pub aura: Aura, @@ -99,8 +93,8 @@ pub mod opaque { // https://substrate.dev/docs/en/knowledgebase/runtime/upgrades#runtime-versioning #[sp_version::runtime_version] pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: create_runtime_str!("lc-core"), - impl_name: create_runtime_str!("lc-core"), + spec_name: create_runtime_str!("g1"), + impl_name: create_runtime_str!("g1"), authoring_version: 1, // The version of the runtime specification. A full node will not attempt to use its native // runtime in substitute for the on-chain Wasm runtime unless all of `spec_name`, @@ -211,10 +205,6 @@ impl pallet_grandpa::Config for Runtime { type WeightInfo = (); } -parameter_types! { - pub const MinimumPeriod: u64 = SLOT_DURATION / 2; -} - impl pallet_timestamp::Config for Runtime { /// A timestamp: milliseconds since the unix epoch. type Moment = u64; @@ -223,18 +213,12 @@ impl pallet_timestamp::Config for Runtime { type WeightInfo = (); } -parameter_types! { - pub const ExistentialDeposit: Balance = 500; - pub const MaxLocks: u32 = 50; -} - impl pallet_balances::Config for Runtime { type MaxLocks = MaxLocks; type MaxReserves = (); type ReserveIdentifier = [u8; 8]; /// The type for recording an account's balance. type Balance = Balance; - /// The ubiquitous event type. type Event = Event; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; @@ -242,10 +226,6 @@ impl pallet_balances::Config for Runtime { type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>; } -parameter_types! { - pub const TransactionByteFee: Balance = 0; -} - impl pallet_transaction_payment::Config for Runtime { type OnChargeTransaction = CurrencyAdapter<Balances, ()>; type TransactionByteFee = TransactionByteFee; @@ -260,16 +240,6 @@ impl pallet_sudo::Config for Runtime { // PALLET IDENTITY -const IDTY_CREATE_PERIOD: BlockNumber = 100; - -parameter_types! { - pub const ConfirmPeriod: BlockNumber = 12 * HOURS; - pub const MaxInactivityPeriod: BlockNumber = YEARS; - pub const MaxNoRightPeriod: BlockNumber = YEARS; - pub const IdtyRenewablePeriod: BlockNumber = 6 * MONTHS; - pub const ValidationPeriod: BlockNumber = 2 * MONTHS; -} - /// Configure the pallet identity impl pallet_identity::Config for Runtime { type ConfirmPeriod = ConfirmPeriod; @@ -292,16 +262,6 @@ impl pallet_identity::Config for Runtime { // PALLET CERTIFICATION -const MIN_STRONG_CERT_FOR_UD: u32 = 2; -const MIN_STRONG_CERT_FOR_STRONG_CERT: u32 = 3; - -parameter_types! { - pub const CertPeriod: BlockNumber = 15; - pub const MaxByIssuer: u8 = 100; - pub const StrongCertRenewablePeriod: BlockNumber = 50;//6 * MONTHS; - pub const ValidityPeriod: BlockNumber = 200;//2 * YEARS; -} - /// Configure the pallet certification impl pallet_certification::Config for Runtime { type AddCertOrigin = AddStrongCertOrigin<Runtime>; @@ -319,13 +279,6 @@ impl pallet_certification::Config for Runtime { // PALLET UNIVERSAL DIVIDEND -parameter_types! { - pub const SquareMoneyGrowthRate: Permill = Permill::one(); - pub const UdCreationPeriod: BlockNumber = 20; - pub const UdReevalPeriod: Balance = 10; - pub const UdReevalPeriodInBlocks: BlockNumber = 20 * 10; -} - pub struct UdAccountsProvider; impl Get<u64> for UdAccountsProvider { fn get() -> u64 { diff --git a/runtime/g1/src/parameters.rs b/runtime/g1/src/parameters.rs new file mode 100644 index 0000000000000000000000000000000000000000..3738ac605dc8afbebb9d19a1df2d9b8c44c1f52d --- /dev/null +++ b/runtime/g1/src/parameters.rs @@ -0,0 +1,64 @@ +// Copyright 2021 Axiom-Team +// +// This file is part of Substrate-Libre-Currency. +// +// Substrate-Libre-Currency is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// Substrate-Libre-Currency is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>. + +use common_runtime::constants::*; +use common_runtime::{Balance, BlockNumber}; +use frame_support::parameter_types; +use sp_arithmetic::Permill; + +// Timestamp +parameter_types! { + pub const MinimumPeriod: u64 = SLOT_DURATION / 2; +} + +// Balances +frame_support::parameter_types! { + pub const ExistentialDeposit: Balance = 500; + pub const MaxLocks: u32 = 50; +} + +// Transaction payment +frame_support::parameter_types! { + pub const TransactionByteFee: Balance = 0; +} + +// Identity +pub const IDTY_CREATE_PERIOD: BlockNumber = 100; +frame_support::parameter_types! { + pub const ConfirmPeriod: BlockNumber = 3 * DAYS; + pub const MaxInactivityPeriod: BlockNumber = YEARS; + pub const MaxNoRightPeriod: BlockNumber = YEARS; + pub const IdtyRenewablePeriod: BlockNumber = 6 * MONTHS; + pub const ValidationPeriod: BlockNumber = YEARS; +} + +// Certification +pub const MIN_STRONG_CERT_FOR_UD: u32 = 5; +pub const MIN_STRONG_CERT_FOR_STRONG_CERT: u32 = 5; +parameter_types! { + pub const CertPeriod: BlockNumber = 5 * DAYS; + pub const MaxByIssuer: u8 = 100; + pub const StrongCertRenewablePeriod: BlockNumber = 6 * MONTHS; + pub const ValidityPeriod: BlockNumber = 2 * YEARS; +} + +// Universal dividend +parameter_types! { + pub const SquareMoneyGrowthRate: Permill = Permill::from_parts(2_381_440); // 0.002_381_440 = 0.0488^2 + pub const UdCreationPeriod: BlockNumber = DAYS; + pub const UdReevalPeriod: Balance = 182; + pub const UdReevalPeriodInBlocks: BlockNumber = 2_620_800; // 86400 * 182 / 6 +} diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index 3c2c98e237cff0ca0ec31f2e918ae4235d3de0fc..48cc6c06eafeabd71e326ca40d821343f2cc8732 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -22,6 +22,9 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +mod parameters; + +pub use self::parameters::*; pub use common_runtime::{ constants::*, entities::{IdtyData, IdtyDid, IdtyRight, Planet}, @@ -196,11 +199,6 @@ impl pallet_grandpa::Config for Runtime { type WeightInfo = (); } -parameter_types! { - pub const ExistentialDeposit: Balance = 500; - pub const MaxLocks: u32 = 50; -} - impl pallet_balances::Config for Runtime { type MaxLocks = MaxLocks; type MaxReserves = (); @@ -215,10 +213,6 @@ impl pallet_balances::Config for Runtime { type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>; } -parameter_types! { - pub const TransactionByteFee: Balance = 0; -} - impl pallet_transaction_payment::Config for Runtime { type OnChargeTransaction = CurrencyAdapter<Balances, ()>; type TransactionByteFee = TransactionByteFee; @@ -233,16 +227,6 @@ impl pallet_sudo::Config for Runtime { // PALLET IDENTITY -const IDTY_CREATE_PERIOD: BlockNumber = 100; - -parameter_types! { - pub const ConfirmPeriod: BlockNumber = 12 * HOURS; - pub const MaxInactivityPeriod: BlockNumber = YEARS; - pub const MaxNoRightPeriod: BlockNumber = YEARS; - pub const IdtyRenewablePeriod: BlockNumber = 6 * MONTHS; - pub const ValidationPeriod: BlockNumber = 2 * MONTHS; -} - /// Configure the pallet identity impl pallet_identity::Config for Runtime { type ConfirmPeriod = ConfirmPeriod; @@ -265,16 +249,6 @@ impl pallet_identity::Config for Runtime { // PALLET CERTIFICATION -const MIN_STRONG_CERT_FOR_UD: u32 = 2; -const MIN_STRONG_CERT_FOR_STRONG_CERT: u32 = 3; - -parameter_types! { - pub const CertPeriod: BlockNumber = 15; - pub const MaxByIssuer: u8 = 100; - pub const StrongCertRenewablePeriod: BlockNumber = 50;//6 * MONTHS; - pub const ValidityPeriod: BlockNumber = 200;//2 * YEARS; -} - /// Configure the pallet certification impl pallet_certification::Config for Runtime { type AddCertOrigin = AddStrongCertOrigin<Runtime>; @@ -292,13 +266,6 @@ impl pallet_certification::Config for Runtime { // PALLET UNIVERSAL DIVIDEND -parameter_types! { - pub const SquareMoneyGrowthRate: Permill = Permill::one(); - pub const UdCreationPeriod: BlockNumber = 20; - pub const UdReevalPeriod: Balance = 10; - pub const UdReevalPeriodInBlocks: BlockNumber = 20 * 10; -} - pub struct UdAccountsProvider; impl Get<u64> for UdAccountsProvider { fn get() -> u64 { diff --git a/runtime/gdev/src/parameters.rs b/runtime/gdev/src/parameters.rs new file mode 100644 index 0000000000000000000000000000000000000000..d1c1e5afbe6de06f0923a4c1952f9dd0d2189061 --- /dev/null +++ b/runtime/gdev/src/parameters.rs @@ -0,0 +1,59 @@ +// Copyright 2021 Axiom-Team +// +// This file is part of Substrate-Libre-Currency. +// +// Substrate-Libre-Currency is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// Substrate-Libre-Currency is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>. + +use common_runtime::constants::*; +use common_runtime::{Balance, BlockNumber}; +use frame_support::parameter_types; +use sp_arithmetic::Permill; + +// Balances +frame_support::parameter_types! { + pub const ExistentialDeposit: Balance = 500; + pub const MaxLocks: u32 = 50; +} + +// Transaction payment +frame_support::parameter_types! { + pub const TransactionByteFee: Balance = 0; +} + +// Identity +pub const IDTY_CREATE_PERIOD: BlockNumber = 100; +frame_support::parameter_types! { + pub const ConfirmPeriod: BlockNumber = 12 * HOURS; + pub const MaxInactivityPeriod: BlockNumber = YEARS; + pub const MaxNoRightPeriod: BlockNumber = YEARS; + pub const IdtyRenewablePeriod: BlockNumber = 6 * MONTHS; + pub const ValidationPeriod: BlockNumber = 2 * MONTHS; +} + +// Certification +pub const MIN_STRONG_CERT_FOR_UD: u32 = 2; +pub const MIN_STRONG_CERT_FOR_STRONG_CERT: u32 = 3; +parameter_types! { + pub const CertPeriod: BlockNumber = 15; + pub const MaxByIssuer: u8 = 100; + pub const StrongCertRenewablePeriod: BlockNumber = 50;//6 * MONTHS; + pub const ValidityPeriod: BlockNumber = 200;//2 * YEARS; +} + +// Universal dividend +parameter_types! { + pub const SquareMoneyGrowthRate: Permill = Permill::one(); + pub const UdCreationPeriod: BlockNumber = 20; + pub const UdReevalPeriod: Balance = 10; + pub const UdReevalPeriodInBlocks: BlockNumber = 20 * 10; +} diff --git a/runtime/gtest/src/lib.rs b/runtime/gtest/src/lib.rs index ee9e25bf86658a5b2959a627dfa5116d7456fb7e..c1c42611bde63ba7eccb29db4725fe5b5a3a94be 100644 --- a/runtime/gtest/src/lib.rs +++ b/runtime/gtest/src/lib.rs @@ -22,6 +22,9 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +mod parameters; + +pub use self::parameters::*; pub use common_runtime::{ constants::*, entities::{IdtyData, IdtyDid, IdtyRight, Planet}, @@ -78,15 +81,6 @@ pub use frame_support::{ pub mod opaque { use super::*; - pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; - - /// Opaque block header type. - pub type Header = generic::Header<BlockNumber, BlakeTwo256>; - /// Opaque block type. - pub type Block = generic::Block<Header, UncheckedExtrinsic>; - /// Opaque block identifier type. - pub type BlockId = generic::BlockId<Block>; - impl_opaque_keys! { pub struct SessionKeys { pub aura: Aura, @@ -211,10 +205,6 @@ impl pallet_grandpa::Config for Runtime { type WeightInfo = (); } -parameter_types! { - pub const MinimumPeriod: u64 = SLOT_DURATION / 2; -} - impl pallet_timestamp::Config for Runtime { /// A timestamp: milliseconds since the unix epoch. type Moment = u64; @@ -223,18 +213,12 @@ impl pallet_timestamp::Config for Runtime { type WeightInfo = (); } -parameter_types! { - pub const ExistentialDeposit: Balance = 500; - pub const MaxLocks: u32 = 50; -} - impl pallet_balances::Config for Runtime { type MaxLocks = MaxLocks; type MaxReserves = (); type ReserveIdentifier = [u8; 8]; /// The type for recording an account's balance. type Balance = Balance; - /// The ubiquitous event type. type Event = Event; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; @@ -242,10 +226,6 @@ impl pallet_balances::Config for Runtime { type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>; } -parameter_types! { - pub const TransactionByteFee: Balance = 0; -} - impl pallet_transaction_payment::Config for Runtime { type OnChargeTransaction = CurrencyAdapter<Balances, ()>; type TransactionByteFee = TransactionByteFee; @@ -260,16 +240,6 @@ impl pallet_sudo::Config for Runtime { // PALLET IDENTITY -const IDTY_CREATE_PERIOD: BlockNumber = 100; - -parameter_types! { - pub const ConfirmPeriod: BlockNumber = 12 * HOURS; - pub const MaxInactivityPeriod: BlockNumber = YEARS; - pub const MaxNoRightPeriod: BlockNumber = YEARS; - pub const IdtyRenewablePeriod: BlockNumber = 6 * MONTHS; - pub const ValidationPeriod: BlockNumber = 2 * MONTHS; -} - /// Configure the pallet identity impl pallet_identity::Config for Runtime { type ConfirmPeriod = ConfirmPeriod; @@ -292,16 +262,6 @@ impl pallet_identity::Config for Runtime { // PALLET CERTIFICATION -const MIN_STRONG_CERT_FOR_UD: u32 = 2; -const MIN_STRONG_CERT_FOR_STRONG_CERT: u32 = 3; - -parameter_types! { - pub const CertPeriod: BlockNumber = 15; - pub const MaxByIssuer: u8 = 100; - pub const StrongCertRenewablePeriod: BlockNumber = 50;//6 * MONTHS; - pub const ValidityPeriod: BlockNumber = 200;//2 * YEARS; -} - /// Configure the pallet certification impl pallet_certification::Config for Runtime { type AddCertOrigin = AddStrongCertOrigin<Runtime>; @@ -319,13 +279,6 @@ impl pallet_certification::Config for Runtime { // PALLET UNIVERSAL DIVIDEND -parameter_types! { - pub const SquareMoneyGrowthRate: Permill = Permill::one(); - pub const UdCreationPeriod: BlockNumber = 20; - pub const UdReevalPeriod: Balance = 10; - pub const UdReevalPeriodInBlocks: BlockNumber = 20 * 10; -} - pub struct UdAccountsProvider; impl Get<u64> for UdAccountsProvider { fn get() -> u64 { diff --git a/runtime/gtest/src/parameters.rs b/runtime/gtest/src/parameters.rs new file mode 100644 index 0000000000000000000000000000000000000000..4b44b70812269f5ba869057ed0725e5c7d8719d3 --- /dev/null +++ b/runtime/gtest/src/parameters.rs @@ -0,0 +1,64 @@ +// Copyright 2021 Axiom-Team +// +// This file is part of Substrate-Libre-Currency. +// +// Substrate-Libre-Currency is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// Substrate-Libre-Currency is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>. + +use common_runtime::constants::*; +use common_runtime::{Balance, BlockNumber}; +use frame_support::parameter_types; +use sp_arithmetic::Permill; + +// Timestamp +parameter_types! { + pub const MinimumPeriod: u64 = SLOT_DURATION / 2; +} + +// Balances +frame_support::parameter_types! { + pub const ExistentialDeposit: Balance = 500; + pub const MaxLocks: u32 = 50; +} + +// Transaction payment +frame_support::parameter_types! { + pub const TransactionByteFee: Balance = 0; +} + +// Identity +pub const IDTY_CREATE_PERIOD: BlockNumber = 100; +frame_support::parameter_types! { + pub const ConfirmPeriod: BlockNumber = DAYS; + pub const MaxInactivityPeriod: BlockNumber = 73 * DAYS; + pub const MaxNoRightPeriod: BlockNumber = 73 * DAYS; + pub const IdtyRenewablePeriod: BlockNumber = 12 * DAYS; + pub const ValidationPeriod: BlockNumber = 73 * DAYS; +} + +// Certification +pub const MIN_STRONG_CERT_FOR_UD: u32 = 5; +pub const MIN_STRONG_CERT_FOR_STRONG_CERT: u32 = 5; +parameter_types! { + pub const CertPeriod: BlockNumber = DAYS; + pub const MaxByIssuer: u8 = 100; + pub const StrongCertRenewablePeriod: BlockNumber = 12 * DAYS; + pub const ValidityPeriod: BlockNumber = 146 * DAYS; +} + +// Universal dividend +parameter_types! { + pub const SquareMoneyGrowthRate: Permill = Permill::from_parts(2_381_440); // 0.002_381_440 = 0.0488^2 + pub const UdCreationPeriod: BlockNumber = DAYS; + pub const UdReevalPeriod: Balance = 7; + pub const UdReevalPeriodInBlocks: BlockNumber = 100800; // 86400 *7 / 6 +}