Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Treasury and Council Pallets with Enhanced Configuration and Benchmarking #716

Merged
merged 100 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
f1e3e4a
added preimage pallet
asiniscalchi Aug 6, 2024
d8d1775
added bench and try-runtime
asiniscalchi Aug 6, 2024
a313927
add preimage pallet
asiniscalchi Aug 6, 2024
e483045
runtime version 1802 -> 1803
asiniscalchi Aug 6, 2024
98911e8
back to version 1802
asiniscalchi Aug 7, 2024
225f0ac
initilize the pallet
asiniscalchi Aug 7, 2024
6c7b164
add license
asiniscalchi Aug 7, 2024
a2fc1a4
rollback weights
asiniscalchi Aug 7, 2024
1381084
license
asiniscalchi Aug 7, 2024
655d450
adding council
asiniscalchi Aug 7, 2024
cd77bd1
add pallet collective pallet in toml
asiniscalchi Aug 8, 2024
d9b31df
all settingS
asiniscalchi Aug 8, 2024
12a9932
council compiling
asiniscalchi Aug 8, 2024
82976e5
using locla weights
asiniscalchi Aug 8, 2024
1c2fee5
refactoring
asiniscalchi Aug 8, 2024
d14ba48
fix clippy
asiniscalchi Aug 8, 2024
1d0e9b7
pallet_collective weights
asiniscalchi Aug 8, 2024
63a95e9
init the pallet
asiniscalchi Aug 8, 2024
2ac6a53
fix xompilATION
asiniscalchi Aug 8, 2024
73cf876
add fast mode
asiniscalchi Aug 9, 2024
4f803c6
fast-mode compiles
asiniscalchi Aug 9, 2024
d6ab42e
added treasury with dummy configuration
asiniscalchi Aug 7, 2024
f4b46b5
better settings
asiniscalchi Aug 8, 2024
606854a
fmt
asiniscalchi Aug 8, 2024
fbe0246
Treasury uses Council
asiniscalchi Aug 8, 2024
0070457
added pallet treasury
asiniscalchi Aug 8, 2024
9f6b64d
fix compilation
asiniscalchi Aug 8, 2024
a2336db
refactoring
asiniscalchi Aug 8, 2024
3453306
less collators in zombinet
asiniscalchi Aug 9, 2024
aa8f6bf
test to check the treasury address
asiniscalchi Aug 9, 2024
62a8e6f
fast mode
asiniscalchi Aug 9, 2024
fd696b5
fast-mode compiles
asiniscalchi Aug 9, 2024
439a1d8
first try
asiniscalchi Aug 9, 2024
36e6d98
add election in toml
asiniscalchi Aug 9, 2024
64bd670
some deps
asiniscalchi Aug 9, 2024
af1d0b2
compiling
asiniscalchi Aug 9, 2024
be1b35d
identation
asiniscalchi Aug 12, 2024
cefbe39
refactoring
asiniscalchi Aug 12, 2024
54df68b
using 2 nodes2
asiniscalchi Aug 14, 2024
40d5290
Merge branch 'main' into feature/add_council
asiniscalchi Aug 23, 2024
22f1090
migrations module is a sigle file
asiniscalchi Aug 23, 2024
2f9115c
Merge branch 'feature/add_council' into feature/add_treasury
asiniscalchi Aug 23, 2024
2be8089
compiling
asiniscalchi Aug 23, 2024
49202ad
treasury fix
asiniscalchi Aug 23, 2024
3a1da4b
treasury fix
asiniscalchi Aug 23, 2024
6951fa2
some work on benchmark
asiniscalchi Aug 23, 2024
6768892
weight treasury
asiniscalchi Aug 23, 2024
e5b2d6f
add weights
asiniscalchi Aug 23, 2024
84a726a
compilation fix
asiniscalchi Aug 23, 2024
99aaad1
remove weights
asiniscalchi Aug 26, 2024
11f7e2c
Merge branch 'main' into feature/add_treasury
asiniscalchi Aug 26, 2024
2b1cad4
missing files
asiniscalchi Aug 26, 2024
9f1335f
treasury weigh2t
asiniscalchi Aug 26, 2024
105f1ff
Merge branch 'main' into feature/add_council
asiniscalchi Aug 26, 2024
f66107a
removed commented code
asiniscalchi Aug 27, 2024
e00b94f
Merge branch 'feature/add_council' into feature/add_treasury
asiniscalchi Aug 27, 2024
15423a2
compile council
asiniscalchi Aug 27, 2024
eef8a27
add pallet_collective
asiniscalchi Aug 27, 2024
a83e6d6
add weights
asiniscalchi Aug 27, 2024
48c0665
added councli
asiniscalchi Aug 27, 2024
81690df
colelctibve integrated
asiniscalchi Aug 27, 2024
d4ac88f
Merge branch 'feature/add_treasury' into feature/elections
asiniscalchi Aug 27, 2024
8d4f34b
Merge branch 'feature/elections' of github.com:freeverseio/laos into …
asiniscalchi Aug 27, 2024
7698b81
added dependecy
asiniscalchi Aug 27, 2024
cfc45ec
same time for voting and locking
asiniscalchi Aug 27, 2024
d3c6b12
add council to benchmarks
asiniscalchi Aug 28, 2024
bdeffd1
Merge branch 'feature/add_treasury' into feature/elections
asiniscalchi Aug 28, 2024
0dd7839
duplicate
asiniscalchi Aug 28, 2024
0fd914b
added weights
asiniscalchi Aug 28, 2024
e24aa5e
Loser cnadidate funds to Treasury
asiniscalchi Aug 28, 2024
8791a60
weights
asiniscalchi Aug 28, 2024
9c117ad
just 1 collator in zombienet
asiniscalchi Aug 28, 2024
7d5b75c
memebrs to be elected 7
asiniscalchi Aug 28, 2024
0f7f7d1
number index of pallet
asiniscalchi Aug 28, 2024
7d15828
Merge branch 'feature/add_treasury' into feature/elections
asiniscalchi Aug 28, 2024
05e48f1
compialtion conditional
asiniscalchi Aug 28, 2024
f64ddf6
compialtion conditional
asiniscalchi Aug 28, 2024
076ed82
conditional compilation
asiniscalchi Aug 28, 2024
6a5ab44
Merge branch 'feature/add_treasury' into feature/elections
asiniscalchi Aug 28, 2024
667c1df
fmt
asiniscalchi Aug 28, 2024
269fa10
Merge branch 'feature/add_treasury' into feature/elections
asiniscalchi Aug 28, 2024
e046634
low to 15 minutes
asiniscalchi Aug 28, 2024
1355783
typo
asiniscalchi Aug 28, 2024
4df6b9e
10 mins
asiniscalchi Aug 28, 2024
8d26dad
lint fixes + assign burn to `Permill::zero()`
luispdm Aug 29, 2024
ad04e8f
Review #723 (#751)
magecnion Aug 30, 2024
146f93b
increase e2e timeout
magecnion Aug 30, 2024
64c377d
increase gas price && add logs
luispdm Aug 30, 2024
eec8cc3
update truffle && revert gas price increase
luispdm Aug 30, 2024
dad853a
customize nonce when creating collection when event is emitted; remov…
luispdm Aug 30, 2024
1dc98ee
remove gas limit && add nonce logs
luispdm Aug 30, 2024
fc16558
decrease timeout to 10m
luispdm Aug 30, 2024
4dd8e6a
try inverting order of tests
luispdm Sep 2, 2024
e2503be
remove custom nonce
luispdm Sep 2, 2024
8e2f0df
try with 2 collators
luispdm Sep 2, 2024
799697e
restore order of tests and 3 collators in zombienet
luispdm Sep 2, 2024
1a9c4d7
restore gas limit in create collection tests
luispdm Sep 2, 2024
f991dba
restore timeout
luispdm Sep 2, 2024
4136e17
Merge pull request #723 from freeverseio/feature/elections
luispdm Sep 2, 2024
7783196
Merge remote-tracking branch 'origin' into feature/add_treasury
luispdm Sep 2, 2024
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
4 changes: 4 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch =
pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-elections-phragmen = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-treasury = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"mocha-steps": "^1.3.0",
"rimraf": "^5.0.0",
"solc": "^0.8.3",
"truffle": "^5.10.2",
"truffle": "^5.11.5",
"ts-node": "^10.9.1",
"typescript": "^4.9.5",
"wait-on": "^7.0.1",
Expand Down
1 change: 1 addition & 0 deletions primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sp-core = { workspace = true }
sp-runtime = { workspace = true }
sp-consensus-aura = { workspace = true }
cumulus-primitives-core = { workspace = true }
parachains-common = { workspace = true }

# EVM
fp-account = { workspace = true, features = ["serde"] }
Expand Down
29 changes: 7 additions & 22 deletions primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,15 @@
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]

use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_SECOND, IdentityFee, Weight};
use frame_support::weights::IdentityFee;
use frame_system::limits;
pub use parachains_common::{MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO};
use sp_core::Hasher as HasherT;
use sp_runtime::{
traits::{BlakeTwo256, IdentifyAccount, Verify},
Perbill,
};
use sp_runtime::traits::{BlakeTwo256, IdentifyAccount, Verify};

/// Authority ID used in parachain.
pub type AuraId = sp_consensus_aura::sr25519::AuthorityId;

/// Maximal weight of single LaosParachain block.
///
/// This represents 0.5 seconds of compute assuming a target block time of 12 seconds.
///
/// Max PoV size is set to `5Mb` as all Cumulus-based parachains do.
pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
);

/// Represents the portion of a block that will be used by Normal extrinsics.
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);

/// Block number type used in Laos chain.
pub type BlockNumber = u32;

Expand Down Expand Up @@ -76,21 +61,21 @@ pub type WeightToFee = IdentityFee<Balance>;

frame_support::parameter_types! {
/// Size limit of the Laos parachain blocks.
pub BlockLength: limits::BlockLength =
pub RuntimeBlockLength: limits::BlockLength =
limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
/// Weight limit of the Laos parachain blocks.
pub BlockWeights: limits::BlockWeights =
pub RuntimeBlockWeights: limits::BlockWeights =
luispdm marked this conversation as resolved.
Show resolved Hide resolved
limits::BlockWeights::with_sensible_defaults(MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO);
}

#[cfg(test)]
mod tests {
use super::*;
use frame_support::dispatch::DispatchClass;
use frame_support::{dispatch::DispatchClass, weights::Weight};

#[test]
fn test_block_weights() {
let weights = BlockWeights::get();
let weights = RuntimeBlockWeights::get();

assert_eq!(weights.base_block, Weight::from_parts(453383000, 0));
assert_eq!(weights.max_block, Weight::from_parts(500000000000, 5242880));
Expand Down
13 changes: 13 additions & 0 deletions runtime/laos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ pallet-message-queue = { workspace = true }
pallet-multisig = { workspace = true }
pallet-session = { workspace = true }
pallet-sudo = { workspace = true }
pallet-treasury = { workspace = true }
pallet-preimage = { workspace = true }
pallet-timestamp = { workspace = true }
pallet-collective = { workspace = true }
pallet-elections-phragmen = { workspace = true }
pallet-transaction-payment = { workspace = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true }
pallet-vesting = { workspace = true }
Expand Down Expand Up @@ -119,6 +122,7 @@ test-utils = { workspace = true }
ethereum = { workspace = true }

[features]
fast-mode=[]
default = [
"std",
]
Expand All @@ -141,8 +145,11 @@ std = [
"pallet-aura/std",
"pallet-authorship/std",
"pallet-balances/std",
"pallet-elections-phragmen/std",
"pallet-session/std",
"pallet-sudo/std",
"pallet-treasury/std",
"pallet-collective/std",
"pallet-preimage/std",
"pallet-laos-evolution/std",
"pallet-asset-metadata-extender/std",
Expand Down Expand Up @@ -210,10 +217,13 @@ runtime-benchmarks = [
"frame-system/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-laos-evolution/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-treasury/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-elections-phragmen/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"staging-xcm-builder/runtime-benchmarks",
Expand Down Expand Up @@ -250,10 +260,13 @@ try-runtime = [
"pallet-balances/try-runtime",
"pallet-session/try-runtime",
"pallet-sudo/try-runtime",
"pallet-collective/try-runtime",
"pallet-preimage/try-runtime",
"pallet-laos-evolution/try-runtime",
"pallet-multisig/try-runtime",
"pallet-elections-phragmen/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-treasury/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-xcm/try-runtime",
"staging-parachain-info/try-runtime",
Expand Down
2 changes: 1 addition & 1 deletion runtime/laos/src/apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ impl_runtime_apis! {
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
let weight = Executive::try_runtime_upgrade(checks).unwrap();
(weight, laos_primitives::BlockWeights::get().max_block)
(weight, laos_primitives::RuntimeBlockWeights::get().max_block)
}

fn execute_block(
Expand Down
3 changes: 3 additions & 0 deletions runtime/laos/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ frame_benchmarking::define_benchmarks!(
[pallet_laos_evolution, LaosEvolution]
[pallet_asset_metadata_extender, AssetMetadataExtender]
[pallet_precompiles_benchmark, PrecompilesBenchmark]
[pallet_collective, Council]
[pallet_elections_phragmen, Elections]
[pallet_preimage, Preimage]
[pallet_vesting, Vesting]
[pallet_message_queue, MessageQueue]
[cumulus_pallet_parachain_system, ParachainSystem]
[pallet_treasury, Treasury]
// TODO pallet_xcm?
);
36 changes: 36 additions & 0 deletions runtime/laos/src/configs/collective_council.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use crate::{weights, AccountId, BlockNumber, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin};
use frame_support::{pallet_prelude::Weight, parameter_types};
use frame_system::EnsureRoot;
use laos_primitives::RuntimeBlockWeights;
#[cfg(not(feature = "fast-mode"))]
use parachains_common::DAYS;
asiniscalchi marked this conversation as resolved.
Show resolved Hide resolved
#[cfg(feature = "fast-mode")]
use parachains_common::MINUTES;
use sp_runtime::Perbill;

#[cfg(feature = "fast-mode")]
pub const COUNCIL_MOTION_DURATION: BlockNumber = 5 * MINUTES;
#[cfg(not(feature = "fast-mode"))]
pub const COUNCIL_MOTION_DURATION: BlockNumber = 7 * DAYS;

parameter_types! {
pub const CouncilMotionDuration: BlockNumber = COUNCIL_MOTION_DURATION;
pub const CouncilMaxProposals: u32 = 7;
pub const CouncilMaxMembers: u32 = 20;
pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block;
pub MaxCollectivesProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block;
}

pub type CouncilCollective = pallet_collective::Instance1;
impl pallet_collective::Config<CouncilCollective> for Runtime {
type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote;
type MaxMembers = CouncilMaxMembers;
type MaxProposalWeight = MaxCollectivesProposalWeight;
type MaxProposals = CouncilMaxProposals;
type MotionDuration = CouncilMotionDuration;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type SetMembersOrigin = EnsureRoot<AccountId>;
type WeightInfo = weights::pallet_collective::WeightInfo<Runtime>;
}
61 changes: 61 additions & 0 deletions runtime/laos/src/configs/election_phragmen.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
use crate::{
currency::UNIT, weights, Balance, Balances, BlockNumber, Council, Runtime, RuntimeEvent,
Treasury,
};
use frame_support::{parameter_types, traits::LockIdentifier};
#[cfg(not(feature = "fast-mode"))]
use parachains_common::DAYS;
#[cfg(feature = "fast-mode")]
use parachains_common::MINUTES;
use polkadot_runtime_common::CurrencyToVote;

#[cfg(feature = "fast-mode")]
pub const TERM_DURATION: BlockNumber = 10 * MINUTES;
#[cfg(not(feature = "fast-mode"))]
pub const TERM_DURATION: BlockNumber = 28 * DAYS;

#[cfg(feature = "fast-mode")]
pub const ELECTION_VOTING_LOCK_DURATION: BlockNumber = 10 * MINUTES;
#[cfg(not(feature = "fast-mode"))]
pub const ELECTION_VOTING_LOCK_DURATION: BlockNumber = 28 * DAYS;

parameter_types! {
pub const CandidacyBond: Balance = 1000 * UNIT;
pub TermDuration: BlockNumber = TERM_DURATION;
pub VotingLockPeriod: BlockNumber = ELECTION_VOTING_LOCK_DURATION;
pub const DesiredMembers: u32 = 7;
pub const DesiredRunnersUp: u32 = 20;
pub const MaxCandidates: u32 = 30;
pub const MaxVoters: u32 = 200;
pub const MaxVotesPerVoter: u32 = 8;
pub const VotingBondBase: Balance = 1000 * UNIT;
pub const VotingBondFactor: Balance = 100 * UNIT;
pub const ElectionsPhragmenPalletId: LockIdentifier = *b"phrelect";
}

impl pallet_elections_phragmen::Config for Runtime {
/// How much should be locked up in order to submit one's candidacy.
type CandidacyBond = CandidacyBond;
type ChangeMembers = Council;
type Currency = Balances;
type CurrencyToVote = CurrencyToVote;
/// Number of members to elect.
type DesiredMembers = DesiredMembers;
/// Number of runners_up to keep.
type DesiredRunnersUp = DesiredRunnersUp;
type InitializeMembers = Council;
type LoserCandidate = Treasury;
type MaxCandidates = MaxCandidates;
type MaxVoters = MaxVoters;
type MaxVotesPerVoter = MaxVotesPerVoter;
type PalletId = ElectionsPhragmenPalletId;
type RuntimeEvent = RuntimeEvent;
/// How long each seat is kept. This defines the next block number at which
/// an election round will happen. If set to zero, no elections are ever
/// triggered and the module will be in passive mode.
type TermDuration = TermDuration;
type VotingBondBase = VotingBondBase;
type VotingBondFactor = VotingBondFactor;
type KickedMember = ();
type WeightInfo = weights::pallet_elections_phragmen::WeightInfo<Runtime>;
}
3 changes: 3 additions & 0 deletions runtime/laos/src/configs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ mod authorship;
mod balances;
mod base_fee;
mod benchmark;
mod collective_council;
mod cumulus_parachain_system;
mod cumulus_xcmp_queue;
mod election_phragmen;
mod ethereum;
pub(crate) mod evm;
pub(crate) mod laos_evolution;
Expand All @@ -34,6 +36,7 @@ mod sudo;
pub mod system;
mod timestamp;
mod transaction_payment;
mod treasury;
mod utility;
mod vesting;
pub(crate) mod xcm_config;
Expand Down
4 changes: 2 additions & 2 deletions runtime/laos/src/configs/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ impl frame_system::Config for Runtime {
/// Weight information for the extrinsics of this pallet.
type SystemWeightInfo = ();
/// Block & extrinsics weights: base values and limits.
type BlockWeights = laos_primitives::BlockWeights;
type BlockWeights = laos_primitives::RuntimeBlockWeights;
/// The maximum length of a block (in bytes).
type BlockLength = laos_primitives::BlockLength;
type BlockLength = laos_primitives::RuntimeBlockLength;
/// This is used as an identifier of the chain. 42 is the generic substrate prefix.
type SS58Prefix = SS58Prefix;
/// The action to take on a Runtime Upgrade
Expand Down
Loading
Loading