Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
[WIP][Society] Adding benchmarking to the v2. (#11776)
Browse files Browse the repository at this point in the history
* [Society] Adding benchmarking to the v2.

* [Society] Code review.

* [Society] Better code.

* Using clear() + clear_prefix() and adding more tests.

* Benchmarking again...
  • Loading branch information
arturgontijo authored Dec 3, 2022
1 parent 1bbc803 commit be940c1
Show file tree
Hide file tree
Showing 12 changed files with 955 additions and 80 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

10 changes: 1 addition & 9 deletions bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,7 @@ pub fn testnet_genesis(
grandpa: GrandpaConfig { authorities: vec![] },
technical_membership: Default::default(),
treasury: Default::default(),
society: SocietyConfig {
members: endowed_accounts
.iter()
.take((num_endowed_accounts + 1) / 2)
.cloned()
.collect(),
pot: 0,
max_members: 999,
},
society: SocietyConfig { pot: 0 },
vesting: Default::default(),
assets: Default::default(),
gilt: Default::default(),
Expand Down
24 changes: 12 additions & 12 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1313,14 +1313,14 @@ impl pallet_recovery::Config for Runtime {
}

parameter_types! {
pub const CandidateDeposit: Balance = 10 * DOLLARS;
pub const WrongSideDeduction: Balance = 2 * DOLLARS;
pub const MaxStrikes: u32 = 10;
pub const RotationPeriod: BlockNumber = 80 * HOURS;
pub const GraceStrikes: u32 = 10;
pub const SocietyVotingPeriod: BlockNumber = 80 * HOURS;
pub const ClaimPeriod: BlockNumber = 80 * HOURS;
pub const PeriodSpend: Balance = 500 * DOLLARS;
pub const MaxLockDuration: BlockNumber = 36 * 30 * DAYS;
pub const ChallengePeriod: BlockNumber = 7 * DAYS;
pub const MaxCandidateIntake: u32 = 10;
pub const MaxPayouts: u32 = 10;
pub const MaxBids: u32 = 10;
pub const SocietyPalletId: PalletId = PalletId(*b"py/socie");
}

Expand All @@ -1329,18 +1329,17 @@ impl pallet_society::Config for Runtime {
type PalletId = SocietyPalletId;
type Currency = Balances;
type Randomness = RandomnessCollectiveFlip;
type CandidateDeposit = CandidateDeposit;
type WrongSideDeduction = WrongSideDeduction;
type MaxStrikes = MaxStrikes;
type GraceStrikes = GraceStrikes;
type PeriodSpend = PeriodSpend;
type MembershipChanged = ();
type RotationPeriod = RotationPeriod;
type VotingPeriod = SocietyVotingPeriod;
type ClaimPeriod = ClaimPeriod;
type MaxLockDuration = MaxLockDuration;
type FounderSetOrigin =
pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>;
type JudgementOrigin = pallet_society::EnsureFounder<Runtime>;
type MaxCandidateIntake = MaxCandidateIntake;
type ChallengePeriod = ChallengePeriod;
type MaxPayouts = MaxPayouts;
type MaxBids = MaxBids;
type WeightInfo = pallet_society::weights::SubstrateWeight<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -1658,6 +1657,7 @@ mod benches {
[pallet_remark, Remark]
[pallet_scheduler, Scheduler]
[pallet_session, SessionBench::<Runtime>]
[pallet_society, Society]
[pallet_staking, Staking]
[pallet_state_trie_migration, StateTrieMigration]
[frame_system, SystemBench::<Runtime>]
Expand Down
2 changes: 1 addition & 1 deletion bin/node/testing/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec<AccountId>) -> Gen
elections: Default::default(),
sudo: Default::default(),
treasury: Default::default(),
society: SocietyConfig { members: vec![alice(), bob()], pot: 0, max_members: 999 },
society: SocietyConfig { pot: 0 },
vesting: Default::default(),
assets: Default::default(),
gilt: Default::default(),
Expand Down
4 changes: 4 additions & 0 deletions frame/society/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ rand_chacha = { version = "0.2", default-features = false }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
sp-runtime = { version = "6.0.0", default-features = false, path = "../../primitives/runtime" }
sp-std = { version = "4.0.0", default-features = false, path = "../../primitives/std" }
sp-io = { version = "6.0.0", default-features = false, path = "../../primitives/io" }
sp-arithmetic = { version = "5.0.0", default-features = false, path = "../../primitives/arithmetic" }
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" }
frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" }
frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" }
hex-literal = "0.3.4"
Expand All @@ -39,9 +41,11 @@ std = [
"scale-info/std",
"sp-runtime/std",
"sp-std/std",
"sp-io/std",
]
runtime-benchmarks = [
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
]
try-runtime = ["frame-support/try-runtime"]
Loading

0 comments on commit be940c1

Please sign in to comment.