Skip to content

Commit

Permalink
Remove vesting from testnets (#1214)
Browse files Browse the repository at this point in the history
  • Loading branch information
AurevoirXavier authored Jul 21, 2023
1 parent c4ef814 commit 0a1b13d
Show file tree
Hide file tree
Showing 24 changed files with 3 additions and 653 deletions.
3 changes: 0 additions & 3 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions node/src/chain_spec/pangolin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ pub fn genesis_config() -> ChainSpec {
)],
..Default::default()
},
vesting: Default::default(),

// Consensus stuff.
darwinia_staking: DarwiniaStakingConfig {
Expand Down Expand Up @@ -294,7 +293,6 @@ fn testnet_genesis(
)],
..Default::default()
},
vesting: Default::default(),

// Consensus stuff.
darwinia_staking: DarwiniaStakingConfig {
Expand Down
2 changes: 0 additions & 2 deletions node/src/chain_spec/pangoro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ pub fn genesis_config() -> ChainSpec {
)],
..Default::default()
},
vesting: Default::default(),

// Consensus stuff.
darwinia_staking: DarwiniaStakingConfig {
Expand Down Expand Up @@ -294,7 +293,6 @@ fn testnet_genesis(
)],
..Default::default()
},
vesting: Default::default(),

// Consensus stuff.
darwinia_staking: DarwiniaStakingConfig {
Expand Down
2 changes: 0 additions & 2 deletions pallet/account-migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ frame-system = { workspace = true }
pallet-assets = { workspace = true }
pallet-balances = { workspace = true }
pallet-identity = { workspace = true }
pallet-vesting = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
Expand Down Expand Up @@ -54,7 +53,6 @@ std = [
"pallet-assets/std",
"pallet-balances/std",
"pallet-identity/std",
"pallet-vesting/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
Expand Down
7 changes: 0 additions & 7 deletions pallet/account-migration/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ mod benchmarks {
extra: Default::default(),
},
);
<Vestings<T>>::insert(
from,
vec![
VestingInfo::new(1, Default::default(), Default::default());
<T as pallet_vesting::Config>::MAX_VESTING_SCHEDULES as usize
],
);
<Identities<T>>::insert(
from,
Registration {
Expand Down
27 changes: 1 addition & 26 deletions pallet/account-migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,12 @@ use dc_primitives::{AccountId as AccountId20, AssetId, Balance, BlockNumber, Ind
use frame_support::{
migration,
pallet_prelude::*,
traits::{Currency, ExistenceRequirement::AllowDeath, LockableCurrency, WithdrawReasons},
traits::{Currency, ExistenceRequirement::AllowDeath},
StorageHasher,
};
use frame_system::{pallet_prelude::*, AccountInfo, RawOrigin};
use pallet_balances::AccountData;
use pallet_identity::{Judgement, Registration};
use pallet_vesting::VestingInfo;
use sp_core::{
ed25519::{Public as Ep, Signature as Es},
sr25519::{Public as Sp, Signature as Ss},
Expand Down Expand Up @@ -111,7 +110,6 @@ pub mod pallet {
Lookup = IdentityLookup<AccountId20>,
> + pallet_assets::Config<Balance = Balance, AssetId = AssetId>
+ pallet_balances::Config<Balance = Balance>
+ pallet_vesting::Config<Currency = pallet_balances::Pallet<Self>>
+ pallet_identity::Config<Currency = pallet_balances::Pallet<Self>>
+ darwinia_deposit::Config
+ darwinia_staking::Config
Expand Down Expand Up @@ -160,15 +158,6 @@ pub mod pallet {
#[pallet::getter(fn kton_account_of)]
pub type KtonAccounts<T: Config> = StorageMap<_, Blake2_128Concat, AccountId32, AssetAccount>;

/// [`pallet_vesting::Vesting`] data.
///
/// <https://github.dev/paritytech/substrate/blob/19162e43be45817b44c7d48e50d03f074f60fbf4/frame/vesting/src/lib.rs#L188>
#[pallet::storage]
#[pallet::unbounded]
#[pallet::getter(fn vesting_of)]
pub type Vestings<T: Config> =
StorageMap<_, Blake2_128Concat, AccountId32, Vec<VestingInfo<Balance, BlockNumber>>>;

/// [`darwinia_deposit::Deposits`] data.
#[pallet::storage]
#[pallet::unbounded]
Expand Down Expand Up @@ -448,20 +437,6 @@ pub mod pallet {
);
}
}
if let Some(v) = <Vestings<T>>::take(from) {
let locked = v.iter().map(|v| v.locked()).sum();

<pallet_vesting::Vesting<T>>::insert(
to,
BoundedVec::try_from(v).map_err(|_| <Error<T>>::ExceedMaxVestings)?,
);

// https://github.dev/paritytech/substrate/blob/19162e43be45817b44c7d48e50d03f074f60fbf4/frame/vesting/src/lib.rs#L248
let reasons = WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE;

// https://github.dev/paritytech/substrate/blob/19162e43be45817b44c7d48e50d03f074f60fbf4/frame/vesting/src/lib.rs#L86
<pallet_balances::Pallet<T>>::set_lock(*b"vesting ", to, locked, reasons);
}
if let Some(mut i) = <Identities<T>>::take(from) {
i.deposit = 0;
i.judgements.iter_mut().for_each(|(_, j)| {
Expand Down
11 changes: 0 additions & 11 deletions pallet/account-migration/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,6 @@ frame_support::parameter_types! {
frame_support::traits::WithdrawReasons::TRANSFER | frame_support::traits::WithdrawReasons::RESERVE
);
}
impl pallet_vesting::Config for Runtime {
type BlockNumberToBalance = sp_runtime::traits::ConvertInto;
type Currency = Balances;
type MinVestedTransfer = ();
type RuntimeEvent = RuntimeEvent;
type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons;
type WeightInfo = ();

const MAX_VESTING_SCHEDULES: u32 = 1;
}

impl darwinia_deposit::Config for Runtime {
type Kton = Dummy;
Expand Down Expand Up @@ -226,7 +216,6 @@ frame_support::construct_runtime! {
Timestamp: pallet_timestamp,
Balances: pallet_balances,
Assets: pallet_assets,
Vesting: pallet_vesting,
Deposit: darwinia_deposit,
Staking: darwinia_staking,
Identity: pallet_identity,
Expand Down
34 changes: 0 additions & 34 deletions runtime/common/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,6 @@ macro_rules! impl_account_migration_tests {
Destroying,
}

// This struct is private in `pallet-vesting`.
#[derive(Encode)]
struct VestingInfo {
locked: u128,
per_block: u128,
starting_block: u32,
}

fn alice() -> (Pair, AccountId32) {
let pair = Keyring::Alice.pair();
let public_key = AccountId32::new(pair.public().0);
Expand Down Expand Up @@ -281,32 +273,6 @@ macro_rules! impl_account_migration_tests {
});
}

#[test]
fn vesting_should_work() {
let (from, from_pk) = alice();
let to = H160::from_low_u64_be(255).into();

ExtBuilder::default().build().execute_with(|| {
preset_state_of(&from);

migration::put_storage_value(
b"AccountMigration",
b"Vestings",
&Blake2_128Concat::hash(from_pk.as_ref()),
vec![
VestingInfo { locked: 100, per_block: 5, starting_block: 0 },
VestingInfo { locked: 100, per_block: 5, starting_block: 0 },
],
);
assert!(Vesting::vesting(to).is_none());
assert!(Balances::locks(to).is_empty());

assert_ok!(migrate(from, to));
assert_eq!(Vesting::vesting(to).unwrap().len(), 2);
assert_eq!(Balances::locks(to).len(), 1);
});
}

#[test]
fn staking_should_work() {
let (from, from_pk) = alice();
Expand Down
4 changes: 0 additions & 4 deletions runtime/pangolin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ pallet-transaction-payment = { workspace = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true }
pallet-treasury = { workspace = true }
pallet-utility = { workspace = true }
pallet-vesting = { workspace = true }
sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-consensus-aura = { workspace = true }
Expand Down Expand Up @@ -237,7 +236,6 @@ std = [
"pallet-transaction-payment/std",
"pallet-treasury/std",
"pallet-utility/std",
"pallet-vesting/std",
"sp-api/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
Expand Down Expand Up @@ -329,7 +327,6 @@ runtime-benchmarks = [
"pallet-tips/runtime-benchmarks",
"pallet-treasury/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-vesting/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
# substrate optional
"frame-benchmarking/runtime-benchmarks",
Expand Down Expand Up @@ -395,7 +392,6 @@ try-runtime = [
"pallet-transaction-payment/try-runtime",
"pallet-treasury/try-runtime",
"pallet-utility/try-runtime",
"pallet-vesting/try-runtime",
"sp-runtime/try-runtime",
# substrate optional
"frame-try-runtime/try-runtime",
Expand Down
3 changes: 1 addition & 2 deletions runtime/pangolin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ frame_support::construct_runtime! {
Balances: pallet_balances = 5,
TransactionPayment: pallet_transaction_payment = 6,
Assets: pallet_assets = 7,
Vesting: pallet_vesting = 8,
// Vesting: pallet_vesting = 8,
Deposit: darwinia_deposit = 9,
AccountMigration: darwinia_account_migration = 10,

Expand Down Expand Up @@ -211,7 +211,6 @@ frame_benchmarking::define_benchmarks! {
[pallet_tips, Tips]
[pallet_treasury, Treasury]
[pallet_utility, Utility]
[pallet_vesting, Vesting]
[pallet_session, SessionBench::<Runtime>]
[pallet_timestamp, Timestamp]
}
Expand Down
2 changes: 0 additions & 2 deletions runtime/pangolin/src/pallets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ mod transaction_payment;
mod assets;
pub use assets::*;

mod vesting;

mod deposit;
#[cfg(feature = "runtime-benchmarks")]
pub use deposit::*;
Expand Down
1 change: 0 additions & 1 deletion runtime/pangolin/src/pallets/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ impl DispatchValidateT<AccountId, RuntimeCall> for DarwiniaDispatchValidator {
if matches!(
call,
RuntimeCall::Assets(..)
| RuntimeCall::Vesting(..)
| RuntimeCall::Ethereum(..)
| RuntimeCall::EVM(..)
| RuntimeCall::MessageTransact(..)
Expand Down
1 change: 0 additions & 1 deletion runtime/pangolin/src/pallets/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ impl frame_support::traits::InstanceFilter<RuntimeCall> for ProxyType {
c,
RuntimeCall::Balances(..)
| RuntimeCall::Assets(..)
| RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. })
| RuntimeCall::Deposit(..)
| RuntimeCall::DarwiniaStaking(..)
// Might contains transfer {
Expand Down
40 changes: 0 additions & 40 deletions runtime/pangolin/src/pallets/vesting.rs

This file was deleted.

1 change: 0 additions & 1 deletion runtime/pangolin/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ pub mod pallet_timestamp;
pub mod pallet_tips;
pub mod pallet_treasury;
pub mod pallet_utility;
pub mod pallet_vesting;
Loading

0 comments on commit 0a1b13d

Please sign in to comment.