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

Conviction pallet uses fungible trait #1821

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f2e2deb
make it work
PieWol Oct 8, 2023
b6fb31f
traits at the right places
PieWol Oct 9, 2023
ab3dd13
propagate holding results
PieWol Oct 9, 2023
15ce5a1
adjust test config
PieWol Oct 9, 2023
a82c077
fix tests
PieWol Oct 9, 2023
cb5a46e
lock -> hold renaming
PieWol Oct 9, 2023
faf0769
Merge branch 'master' into conviction-use-fungible
PieWol Oct 9, 2023
ea9f072
move lib to freezes
PieWol Nov 20, 2023
302fb17
revamp to freezes
PieWol Nov 22, 2023
dff9968
Merge branch 'master' into conviction-use-fungible
PieWol Nov 22, 2023
b433650
Merge branch 'master' into conviction-use-fungible
PieWol Jan 1, 2024
6d6bf7b
make runtimes compile
PieWol Jan 4, 2024
093e605
Merge branch 'conviction-use-fungible' of github.com:PieWol/polkadot-…
PieWol Jan 4, 2024
fc656ae
add RFR to node runtime
PieWol Jan 4, 2024
cd2434d
Merge branch 'master' into conviction-use-fungible
PieWol Jan 4, 2024
d82af95
remove renaming in code
PieWol Jan 4, 2024
4cbadcf
conviction.rs comment fix
PieWol Jan 4, 2024
7859ba1
tests.rs renaming removed
PieWol Jan 4, 2024
78aeebb
further renaming removal
PieWol Jan 4, 2024
28f808b
spelling
PieWol Jan 4, 2024
2ca7f1a
Merge branch 'master' into conviction-use-fungible
PieWol Jan 4, 2024
1e4fcb9
how to fund?
PieWol Jan 4, 2024
37bcb43
compile benchmarks
PieWol Jan 9, 2024
6119321
fix clippy
PieWol Jan 10, 2024
f4871a5
fix benchmarks
PieWol Feb 25, 2024
782c0f0
Merge remote-tracking branch 'origin/master' into conviction-use-fung…
PieWol Feb 25, 2024
e4fdcb2
clean up
PieWol Feb 25, 2024
d1bcae2
changes integrity test?
PieWol Feb 25, 2024
620f7e7
thaw previous freezes
PieWol Feb 25, 2024
9273e25
fix clippy
PieWol Feb 26, 2024
b4fb279
integrity fix?
PieWol Feb 29, 2024
9581a7c
Merge branch 'paritytech:master' into conviction-use-fungible
PieWol Feb 29, 2024
82c54de
use mint_into
PieWol Mar 15, 2024
acc8806
issue with maxVotes?
PieWol Mar 15, 2024
bb9d555
clueless
PieWol Mar 15, 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
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl<T: frame_system::Config> pallet_conviction_voting::WeightInfo for WeightInf
/// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)
/// Storage: Balances Freezes (r:1 w:0)
/// Proof: Balances Freezes (max_values: None, max_size: Some(49), added: 2524, mode: MaxEncodedLen)
fn unlock() -> Weight {
fn release() -> Weight {
// Proof Size summary in bytes:
// Measured: `12218`
// Estimated: `30706`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl<T: frame_system::Config> pallet_conviction_voting::WeightInfo for WeightInf
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
/// Storage: `Balances::Freezes` (r:1 w:0)
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`)
fn unlock() -> Weight {
fn release() -> Weight {
// Proof Size summary in bytes:
// Measured: `12218`
// Estimated: `30706`
Expand Down
6 changes: 3 additions & 3 deletions substrate/frame/conviction-voting/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ benchmarks_instance_pallet! {
assert_matches!(VotingFor::<T, I>::get(&caller, &class), Voting::Casting(_));
}

unlock {
release {
let caller = funded_account::<T, I>("caller", 0);
let caller_lookup = T::Lookup::unlookup(caller.clone());
whitelist_account!(caller);
Expand All @@ -264,7 +264,7 @@ benchmarks_instance_pallet! {
let orig_usable = <T::Currency as fungible::Inspect<T::AccountId>>::reducible_balance(&caller, Expendable, Polite);
let polls = &all_polls[&class];

// Vote big on the class with the most ongoing votes of them to bump the lock and make it
// Vote big on the class with the most ongoing votes of them to bump the hold and make it
// hard to recompute when removed.
ConvictionVoting::<T, I>::vote(RawOrigin::Signed(caller.clone()).into(), polls[0], big_account_vote)?;
let now_usable = <T::Currency as fungible::Inspect<T::AccountId>>::reducible_balance(&caller, Expendable, Polite);
Expand All @@ -273,7 +273,7 @@ benchmarks_instance_pallet! {
// Remove the vote
ConvictionVoting::<T, I>::remove_vote(RawOrigin::Signed(caller.clone()).into(), Some(class.clone()), polls[0])?;

// We can now unlock on `class` from 200 to 100...
// We can now release on `class` from 200 to 100...
}: _(RawOrigin::Signed(caller.clone()), class, caller_lookup)
verify {
assert_eq!(orig_usable, <T::Currency as fungible::Inspect<T::AccountId>>::reducible_balance(&caller, Expendable, Polite));
Expand Down
68 changes: 34 additions & 34 deletions substrate/frame/conviction-voting/src/conviction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ use crate::types::Delegations;
MaxEncodedLen,
)]
pub enum Conviction {
/// 0.1x votes, unlocked.
/// 0.1x votes, not held.
None,
/// 1x votes, locked for an enactment period following a successful vote.
Locked1x,
/// 2x votes, locked for 2x enactment periods following a successful vote.
Locked2x,
/// 3x votes, locked for 4x...
Locked3x,
/// 4x votes, locked for 8x...
Locked4x,
/// 5x votes, locked for 16x...
Locked5x,
/// 6x votes, locked for 32x...
Locked6x,
/// 1x votes, held for an enactment period following a successful vote.
Held1x,
/// 2x votes, held for 2x enactment periods following a successful vote.
Held2x,
/// 3x votes, held for 4x...
Held3x,
/// 4x votes, held for 8x...
Held4x,
/// 5x votes, held for 16x...
Held5x,
/// 6x votes, held for 32x...
Held6x,
}

impl Default for Conviction {
Expand All @@ -67,12 +67,12 @@ impl From<Conviction> for u8 {
fn from(c: Conviction) -> u8 {
match c {
Conviction::None => 0,
Conviction::Locked1x => 1,
Conviction::Locked2x => 2,
Conviction::Locked3x => 3,
Conviction::Locked4x => 4,
Conviction::Locked5x => 5,
Conviction::Locked6x => 6,
Conviction::Held1x => 1,
Conviction::Held2x => 2,
Conviction::Held3x => 3,
Conviction::Held4x => 4,
Conviction::Held5x => 5,
Conviction::Held6x => 6,
}
}
}
Expand All @@ -82,29 +82,29 @@ impl TryFrom<u8> for Conviction {
fn try_from(i: u8) -> Result<Conviction, ()> {
Ok(match i {
0 => Conviction::None,
1 => Conviction::Locked1x,
2 => Conviction::Locked2x,
3 => Conviction::Locked3x,
4 => Conviction::Locked4x,
5 => Conviction::Locked5x,
6 => Conviction::Locked6x,
1 => Conviction::Held1x,
2 => Conviction::Held2x,
3 => Conviction::Held3x,
4 => Conviction::Held4x,
5 => Conviction::Held5x,
6 => Conviction::Held6x,
_ => return Err(()),
})
}
}

impl Conviction {
/// The amount of time (in number of periods) that our conviction implies a successful voter's
/// balance should be locked for.
pub fn lock_periods(self) -> u32 {
/// balance should be held for.
pub fn hold_periods(self) -> u32 {
match self {
Conviction::None => 0,
Conviction::Locked1x => 1,
Conviction::Locked2x => 2,
Conviction::Locked3x => 4,
Conviction::Locked4x => 8,
Conviction::Locked5x => 16,
Conviction::Locked6x => 32,
Conviction::Held1x => 1,
Conviction::Held2x => 2,
Conviction::Held3x => 4,
Conviction::Held4x => 8,
Conviction::Held5x => 16,
Conviction::Held6x => 32,
}
}

Expand All @@ -126,6 +126,6 @@ impl Bounded for Conviction {
Conviction::None
}
fn max_value() -> Self {
Conviction::Locked6x
Conviction::Held6x
}
}
Loading
Loading