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

pallet-vesting: Configurable block number provider #2403

Merged
merged 20 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d5db28a
pallet-vesting: Configurable block number provider
arrudagates Nov 19, 2023
8608fa7
Changed pallet-vesting impl in rococo and westend
arrudagates Nov 19, 2023
155630f
Fixing fmt issue
arrudagates Nov 20, 2023
21b1ea5
Missing changes to pallet-vesting impls
arrudagates Nov 20, 2023
b117f5e
typo fix
arrudagates Nov 20, 2023
9b4673f
Merge branch 'master' into gabriel-vesting_block_provider
bkchr Nov 20, 2023
4f2ecbf
another missing impl
arrudagates Nov 20, 2023
6f3fa28
Change benchmarks to use BlockNumberProvider
arrudagates Nov 24, 2023
81876fe
Merge branch 'master' into gabriel-vesting_block_provider
arrudagates Nov 24, 2023
b197d24
Merge branch 'master' into gabriel-vesting_block_provider
bkchr Nov 24, 2023
b711d68
Merge branch 'master' into gabriel-vesting_block_provider
arrudagates Dec 8, 2023
6f7079e
Merge branch 'master' into gabriel-vesting_block_provider
bkchr Dec 8, 2023
1687c09
Merge branch 'master' into gabriel-vesting_block_provider
bkchr Dec 11, 2023
5d7297d
Added PRDoc file
arrudagates Dec 11, 2023
e940dbd
Undo some auto formatting
arrudagates Dec 11, 2023
215977c
Merge branch 'master' into gabriel-vesting_block_provider
arrudagates Dec 11, 2023
491596b
Update prdoc/pr_2403.prdoc
bkchr Dec 11, 2023
2d86aea
Implement set_block_number for frame-system
arrudagates Dec 11, 2023
aeeb282
Merge branch 'gabriel-vesting_block_provider' of https://github.com/a…
arrudagates Dec 11, 2023
3bce87a
Merge branch 'master' into gabriel-vesting_block_provider
arrudagates Dec 11, 2023
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
2 changes: 1 addition & 1 deletion polkadot/runtime/common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ impl<T: Config> Pallet<T> {

let vesting = Vesting::<T>::get(&signer);
if vesting.is_some() && T::VestingSchedule::vesting_balance(&dest).is_some() {
return Err(Error::<T>::VestedBalanceExists.into());
return Err(Error::<T>::VestedBalanceExists.into())
}

// We first need to deposit the balance to ensure that the account exists.
Expand Down
4 changes: 2 additions & 2 deletions polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pub struct OriginPrivilegeCmp;
impl PrivilegeCmp<OriginCaller> for OriginPrivilegeCmp {
fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option<Ordering> {
if left == right {
return Some(Ordering::Equal);
return Some(Ordering::Equal)
}

match (left, right) {
Expand Down Expand Up @@ -2407,7 +2407,7 @@ mod remote_tests {
#[tokio::test]
async fn run_migrations() {
if var("RUN_MIGRATION_TESTS").is_err() {
return;
return
}

sp_tracing::try_init_simple();
Expand Down
2 changes: 1 addition & 1 deletion polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2461,7 +2461,7 @@ mod remote_tests {
#[tokio::test]
async fn run_migrations() {
if var("RUN_MIGRATION_TESTS").is_err() {
return;
return
}

sp_tracing::try_init_simple();
Expand Down
9 changes: 9 additions & 0 deletions prdoc/pr_2403.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: Configurable block number provider in pallet-vesting

doc:
- audience: Runtime Dev
description: |
Adds `BlockNumberProvider` type to pallet-vesting Config trait, allowing for custom providers instead of hardcoding frame-system.
This is particularly useful for parachains wanting to use `cumulus_pallet_parachain_system::RelaychainDataProvider` with palelt-vesting.
bkchr marked this conversation as resolved.
Show resolved Hide resolved

crates: [ ]
10 changes: 5 additions & 5 deletions substrate/frame/vesting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ pub mod pallet {
) -> DispatchResult {
let who = ensure_signed(origin)?;
if schedule1_index == schedule2_index {
return Ok(());
return Ok(())
};
let schedule1_index = schedule1_index as usize;
let schedule2_index = schedule2_index as usize;
Expand Down Expand Up @@ -522,7 +522,7 @@ impl<T: Config> Pallet<T> {
// Validate user inputs.
ensure!(schedule.locked() >= T::MinVestedTransfer::get(), Error::<T>::AmountLow);
if !schedule.is_valid() {
return Err(Error::<T>::InvalidScheduleParams.into());
return Err(Error::<T>::InvalidScheduleParams.into())
};
let target = T::Lookup::lookup(target)?;
let source = T::Lookup::lookup(source)?;
Expand Down Expand Up @@ -717,13 +717,13 @@ where
starting_block: BlockNumberFor<T>,
) -> DispatchResult {
if locked.is_zero() {
return Ok(());
return Ok(())
}

let vesting_schedule = VestingInfo::new(locked, per_block, starting_block);
// Check for `per_block` or `locked` of 0.
if !vesting_schedule.is_valid() {
return Err(Error::<T>::InvalidScheduleParams.into());
return Err(Error::<T>::InvalidScheduleParams.into())
};

let mut schedules = Self::vesting(who).unwrap_or_default();
Expand Down Expand Up @@ -751,7 +751,7 @@ where
) -> DispatchResult {
// Check for `per_block` or `locked` of 0.
if !VestingInfo::new(locked, per_block, starting_block).is_valid() {
return Err(Error::<T>::InvalidScheduleParams.into());
return Err(Error::<T>::InvalidScheduleParams.into())
}

ensure!(
Expand Down