Refactor the balances module (#4649)

* Initially scoping out of the problem

* Remove need for exiry in balance locks.

* Remove expiry from locks.

* Remove supefluous balance test

* Amalgamate pieces of balance module

* Split out vesting

* Fix tests

* Fixes for vesting.

* Docs.

* Weight docs.

* Refactor things in terms of set_balances.

* Switch out ED to be free + reserved.

* Remove on_free_balance_zero and some docs.

* Build fixes

* Update frame/vesting/src/lib.rs

Co-Authored-By: Xiliang Chen <xlchen1291@gmail.com>

* Update frame/vesting/src/lib.rs

Co-Authored-By: Xiliang Chen <xlchen1291@gmail.com>

* Migration

* Remove superfluous code.

* Test fixes

* Fix some tests

* Fix repatriate reserve

* Fixes

* Add test for migration

* Final cleanups

* Fix

* Indentation.

* Undo unneeded referencing

* Bump runtime version

* Fixes

Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>
This commit is contained in:
Gavin Wood
2020-02-01 13:20:16 +00:00
committed by GitHub
parent b6e8fba179
commit d52d8692f9
46 changed files with 1748 additions and 1171 deletions
+6 -8
View File
@@ -30,7 +30,7 @@ use sp_runtime::{
};
use node_runtime::{
CheckedExtrinsic, Call, Runtime, Balances,
TransactionPayment, TransferFee, TransactionBaseFee, TransactionByteFee,
TransactionPayment, TransactionBaseFee, TransactionByteFee,
WeightFeeCoefficient, constants::currency::*,
};
use node_runtime::impls::LinearWeightToFee;
@@ -134,14 +134,14 @@ fn transaction_fee_is_correct_ultimate() {
// (this baed on assigning 0.1 CENT to the cheapest tx with `weight = 100`)
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, Storage {
top: map![
<pallet_balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
(100 * DOLLARS).encode()
<pallet_balances::Account<Runtime>>::hashed_key_for(alice()) => {
(100 * DOLLARS, 0 * DOLLARS, 0 * DOLLARS, 0 * DOLLARS).encode()
},
<pallet_balances::FreeBalance<Runtime>>::hashed_key_for(bob()) => {
(10 * DOLLARS).encode()
<pallet_balances::Account<Runtime>>::hashed_key_for(bob()) => {
(10 * DOLLARS, 0 * DOLLARS, 0 * DOLLARS, 0 * DOLLARS).encode()
},
<pallet_balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
(110 * DOLLARS).encode()
(110 * DOLLARS, 0 * DOLLARS, 0 * DOLLARS, 0 * DOLLARS).encode()
},
<pallet_indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
<frame_system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
@@ -193,9 +193,7 @@ fn transaction_fee_is_correct_ultimate() {
// we know that weight to fee multiplier is effect-less in block 1.
assert_eq!(weight_fee as Balance, MILLICENTS);
balance_alice -= weight_fee;
balance_alice -= tip;
balance_alice -= TransferFee::get();
assert_eq!(Balances::total_balance(&alice()), balance_alice);
});