Skip to content

Commit

Permalink
Feat/adjust fast mode governance (#164)
Browse files Browse the repository at this point in the history
* chore: update lock

* feat: add weights

* feat: tweak fast-mode params

* feat: extend the voting period

* feat: cleanup base runtime depcencies

* chore: use workspace version

* chore: cleanup the profiles
  • Loading branch information
lrazovic authored Feb 12, 2024
1 parent f554953 commit abba0d5
Show file tree
Hide file tree
Showing 8 changed files with 386 additions and 70 deletions.
32 changes: 14 additions & 18 deletions Cargo.lock

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

11 changes: 1 addition & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ panic = "unwind"
opt-level = 3
strip = "debuginfo"


[profile.dev]
split-debuginfo = "unpacked"
# make sure dev builds with backtrace do
# not slow us down
# Make sure dev builds with backtrace do not slow us down
[profile.dev.package.backtrace]
inherits = "release"

Expand All @@ -41,11 +37,6 @@ inherits = "release"
lto = true
codegen-units = 1

[profile.testnet]
inherits = "release"
debug = 1 # debug symbols are useful for profilers
debug-assertions = true
overflow-checks = true

[workspace.dependencies]
# Testing deps
Expand Down
12 changes: 2 additions & 10 deletions runtimes/base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ version.workspace = true
substrate-wasm-builder.workspace = true

[dependencies]
parity-scale-codec = { version = "3.6.5", default-features = false, features = [
parity-scale-codec = { workspace= true, default-features = false, features = [
"derive",
] }
hex-literal = { version = "0.3.4", optional = true }
log.workspace = true
scale-info = { version = "2.9.0", default-features = false, features = [
scale-info = { workspace= true, default-features = false, features = [
"derive",
] }
smallvec = "1.11.0"

# Local
pallet-parachain-staking.workspace = true
Expand Down Expand Up @@ -57,7 +55,6 @@ pallet-transaction-payment-rpc-runtime-api.workspace = true
pallet-treasury.workspace = true
pallet-utility.workspace = true
pallet-vesting.workspace = true
sp-arithmetic.workspace = true
sp-api.workspace = true
sp-block-builder.workspace = true
sp-consensus-aura.workspace = true
Expand Down Expand Up @@ -90,7 +87,6 @@ cumulus-primitives-timestamp.workspace = true
cumulus-primitives-utility.workspace = true
parachain-info.workspace = true
parachains-common.workspace = true
polkadot-primitives.workspace = true

# ORML
orml-oracle.workspace = true
Expand Down Expand Up @@ -145,12 +141,10 @@ std = [
"parity-scale-codec/std",
"polimec-common/std",
"polkadot-parachain/std",
"polkadot-primitives/std",
"polkadot-runtime-common/std",
"scale-info/std",
"shared-configuration/std",
"sp-api/std",
"sp-arithmetic/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
"sp-core/std",
Expand All @@ -174,7 +168,6 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"hex-literal",
"pallet-balances/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-democracy/runtime-benchmarks",
Expand All @@ -194,7 +187,6 @@ runtime-benchmarks = [
"pallet-xcm/runtime-benchmarks",
"polimec-common/runtime-benchmarks",
"polkadot-parachain/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"shared-configuration/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
Expand Down
35 changes: 20 additions & 15 deletions runtimes/base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@
#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;

use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use frame_support::{
construct_runtime, parameter_types,
traits::{fungible::{Credit, Inspect}, tokens, ConstU32, Contains, EitherOfDiverse, InstanceFilter, PrivilegeCmp},
traits::{
fungible::{Credit, Inspect},
tokens, ConstU32, Contains, EitherOfDiverse, InstanceFilter, PrivilegeCmp,
},
weights::{ConstantMultiplier, Weight},
};
use frame_system::{EnsureRoot, EnsureSigned};
Expand All @@ -34,10 +38,7 @@ use parachains_common::AssetIdForTrustBackedAssets as AssetId;
use parity_scale_codec::Encode;
use polkadot_runtime_common::{BlockHashCount, CurrencyToVote, SlowAdjustingFeeUpdate};
use sp_api::impl_runtime_apis;
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{
Expand All @@ -46,27 +47,31 @@ use sp_runtime::{
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedU128, MultiSignature, SaturatedConversion,
};
pub use sp_runtime::{MultiAddress, Perbill, Permill};
use sp_std::{cmp::Ordering, prelude::*};

#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;

// XCM Imports
use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin};
use xcm_executor::XcmExecutor;

// Polimec Shared Imports
pub use shared_configuration::{currency::*, fee::*, funding::*, governance::*, proxy::*, staking::*, weights::*};

pub use pallet_parachain_staking;
pub use shared_configuration::{currency::*, fee::*, funding::*, governance::*, proxy::*, staking::*, weights::*};
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
pub use sp_runtime::{MultiAddress, Perbill, Permill};

// Make the WASM binary available.
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

#[cfg(feature = "std")]
use sp_version::NativeVersion;

#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;

mod custom_migrations;
mod weights;
pub mod xcm_config;

/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
Expand Down Expand Up @@ -190,7 +195,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polimec-mainnet"),
impl_name: create_runtime_str!("polimec-mainnet"),
authoring_version: 1,
spec_version: 0_005_000,
spec_version: 0_005_001,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down Expand Up @@ -482,7 +487,7 @@ impl pallet_elections_phragmen::Config for Runtime {
/// triggered and the module will be in passive mode.
type TermDuration = TermDuration;
type VotingLockPeriod = VotingLockPeriod;
type WeightInfo = pallet_elections_phragmen::weights::SubstrateWeight<Runtime>;
type WeightInfo = weights::pallet_elections_phragmen::WeightInfo<Runtime>;
}

pub struct Electorate;
Expand Down Expand Up @@ -550,7 +555,7 @@ pub struct EqualOrGreatestRootCmp;
impl PrivilegeCmp<OriginCaller> for EqualOrGreatestRootCmp {
fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option<Ordering> {
if left == right {
return Some(Ordering::Equal)
return Some(Ordering::Equal);
}
match (left, right) {
// Root is greater than anything.
Expand Down Expand Up @@ -832,11 +837,11 @@ mod benches {
// Monetary stuff.
[pallet_balances, Balances]
[pallet_vesting, Vesting]

// Collator support.
[pallet_session, SessionBench::<Runtime>]
[pallet_parachain_staking, ParachainStaking]

// XCM helpers.
[cumulus_pallet_xcmp_queue, XcmpQueue]
[pallet_xcm, PolkadotXcm]
Expand Down
20 changes: 20 additions & 0 deletions runtimes/base/src/weights/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Polimec Blockchain – https://www.polimec.org/
// Copyright (C) Polimec 2022. All rights reserved.

// The Polimec Blockchain is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// The Polimec Blockchain 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 General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

// the generated files do not pass clippy
#![allow(clippy::all)]

pub mod pallet_elections_phragmen;
Loading

0 comments on commit abba0d5

Please sign in to comment.