Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
e89dff9
First steps to stash/controller separation
gavofyork Feb 7, 2019
8e9c2d5
Merge remote-tracking branch 'origin/master' into gav-new-staking
gavofyork Feb 13, 2019
29d1b20
More drafting
gavofyork Feb 14, 2019
ac5d897
More drafting
gavofyork Feb 14, 2019
bfc089f
Finish draft.
gavofyork Feb 14, 2019
fe19f73
Optimisation
gavofyork Feb 14, 2019
24cedfb
Remove accidental commit
gavofyork Feb 14, 2019
0876c86
Make it build.
gavofyork Feb 15, 2019
c9f643f
Fix linked map for traits.
tomusdrw Feb 15, 2019
9190f7d
Fix Option<_> variant.
tomusdrw Feb 15, 2019
4b5274e
Merge branch 'master' into td-fixlinked
tomusdrw Feb 15, 2019
5354a2e
Improve naming a tad
tomusdrw Feb 15, 2019
00ba07e
Rebuild runtime
tomusdrw Feb 15, 2019
78bcf1a
Merge remote-tracking branch 'origin/master' into gav-new-staking2
gavofyork Feb 15, 2019
5ec3741
Merge remote-tracking branch 'origin/td-fixlinked' into gav-new-staking2
gavofyork Feb 15, 2019
ca18c79
Builds!
gavofyork Feb 15, 2019
a24dd8a
First test.
gavofyork Feb 15, 2019
15a3100
Bump RT version
gavofyork Feb 15, 2019
bd0a3de
Minor fix
gavofyork Feb 15, 2019
68f5405
Update Mock
shawntabrizi Feb 19, 2019
001a665
adds the correct reward testcase (+staking eras which was already ok)
kianenigma Feb 19, 2019
7042842
fixes the basic staking testcase to work properly (along with a small…
kianenigma Feb 20, 2019
75bf9d7
New logic to avoid controller transferring stash.
gavofyork Feb 20, 2019
f4ba1d6
Fix some build issues.
gavofyork Feb 20, 2019
a008ee1
Merge branch 'gav-new-staking' of github.com:paritytech/substrate int…
gavofyork Feb 20, 2019
27ad50e
adding some comments to tests
shawntabrizi Feb 20, 2019
93d0eb0
Merge branch 'gav-new-staking' of https://github.com/paritytech/subst…
shawntabrizi Feb 20, 2019
9f7ba25
Merge remote-tracking branch 'origin/master' into gav-new-staking
gavofyork Feb 20, 2019
b755466
Merge branch 'gav-new-staking' of github.com:paritytech/substrate int…
gavofyork Feb 20, 2019
50a212c
Fix impls.
gavofyork Feb 20, 2019
1eb43f7
adds a few more lines to explain the test case
kianenigma Feb 20, 2019
6eaddd1
Merge branch 'gav-new-staking' of github.com:paritytech/substrate int…
kianenigma Feb 20, 2019
e8661b2
More fixes.
gavofyork Feb 20, 2019
7284530
Merge branch 'gav-new-staking' of github.com:paritytech/substrate int…
kianenigma Feb 20, 2019
7e9d469
gets the basic test up and running again
kianenigma Feb 20, 2019
31bed92
Fix rest of build
gavofyork Feb 20, 2019
cadce5e
Merge branch 'gav-new-staking' of github.com:paritytech/substrate int…
gavofyork Feb 20, 2019
37adc08
Rebuild wasm
gavofyork Feb 20, 2019
039f4ea
Fix docs.
gavofyork Feb 20, 2019
4e67748
fix staking test with new chnages
kianenigma Feb 21, 2019
7fe7e01
updating some tests, pending questions
shawntabrizi Feb 21, 2019
a911ee9
Merge branch 'gav-new-staking' of https://github.com/paritytech/subst…
shawntabrizi Feb 21, 2019
514d5a6
More working tests
shawntabrizi Feb 21, 2019
1808869
adds double staking test
kianenigma Feb 21, 2019
2c4f738
Docs
gavofyork Feb 21, 2019
a163f87
Merge branch 'gav-new-staking' of github.com:paritytech/substrate int…
gavofyork Feb 21, 2019
1296562
Merge remote-tracking branch 'origin/master' into gav-new-staking
gavofyork Feb 22, 2019
200eea1
remove invalid slashing test
kianenigma Feb 23, 2019
15b9da0
Payee stuff.
gavofyork Feb 25, 2019
634ab7b
Merge branch 'gav-new-staking' of github.com:paritytech/substrate int…
gavofyork Feb 25, 2019
94a46d4
Fix build
gavofyork Feb 25, 2019
1a2ec9e
Docs
gavofyork Feb 25, 2019
dd7fba6
Fix test
gavofyork Feb 25, 2019
4b0e1e6
Fix a couple of tests
gavofyork Feb 25, 2019
61224f6
Layout plan for finishing tests before Pragmen
shawntabrizi Feb 25, 2019
e4ea05f
Merge branch 'gav-new-staking' of https://github.com/paritytech/subst…
shawntabrizi Feb 25, 2019
3b9917a
Add some working tests
shawntabrizi Feb 25, 2019
6f8f93d
re-build staking and reward tests
kianenigma Feb 25, 2019
4029139
Merge branch 'gav-new-staking' of github.com:paritytech/substrate int…
kianenigma Feb 25, 2019
cc8f195
Add more tests
shawntabrizi Feb 25, 2019
b0129a0
Merge branch 'gav-new-staking' of https://github.com/paritytech/subst…
shawntabrizi Feb 25, 2019
92c0621
fix offline grace test
shawntabrizi Feb 26, 2019
16a9239
Nominator should have payee checked for cleanup
shawntabrizi Feb 26, 2019
1064cfc
adds more nomination tets
kianenigma Feb 26, 2019
6865917
merged
kianenigma Feb 26, 2019
937c89c
adds validator prefs tests
kianenigma Feb 26, 2019
f606db2
Fix and clean up some TODOs
shawntabrizi Feb 27, 2019
6bf11f9
Fix a couple of issues
gavofyork Feb 27, 2019
9a02201
Fix tests
shawntabrizi Feb 27, 2019
be9f4f6
Merge branch 'gav-new-staking' of github.com:paritytech/substrate int…
kianenigma Feb 27, 2019
4ddaa42
noting warnings from tests
shawntabrizi Feb 28, 2019
54ee55b
final fix of local tests
kianenigma Feb 28, 2019
a53c3fd
Merge branch 'gav-new-staking' of https://github.com/paritytech/subst…
shawntabrizi Feb 28, 2019
93da8d8
Fix slot_stake bug
shawntabrizi Feb 28, 2019
4603cfe
Half baked test
shawntabrizi Feb 28, 2019
8bb2e43
fix a few gobal tests
kianenigma Feb 28, 2019
2f43287
Merge branch 'gav-new-staking' of github.com:paritytech/substrate int…
kianenigma Feb 28, 2019
a4ca045
Add logic to limit `unstake_threshold` set in storage
shawntabrizi Feb 28, 2019
ee54da0
Make sure to check before writing!
shawntabrizi Feb 28, 2019
51d25ed
Move a couple of comments
gavofyork Mar 1, 2019
231a02d
devops-parity updated wasm runtime blobs b58d9517 and merged in maste…
devops-parity Mar 1, 2019
68b5938
fix last broken slot_stake test
kianenigma Mar 1, 2019
3a74b73
Merge branch 'gav-new-staking' of github.com:paritytech/substrate int…
kianenigma Mar 1, 2019
ae1e1e5
Merge remote-tracking branch 'origin/master' into gav-new-staking
gavofyork Mar 1, 2019
da9cb52
Ignore broken test
gavofyork Mar 2, 2019
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
Binary file not shown.
4 changes: 2 additions & 2 deletions node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("node"),
impl_name: create_runtime_str!("substrate-node"),
authoring_version: 10,
spec_version: 29,
impl_version: 29,
spec_version: 35,
impl_version: 35,
apis: RUNTIME_API_VERSIONS,
};

Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions srml/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ impl<T: Trait> OnTimestampSet<T::Moment> for Module<T> {
/// A type for performing slashing based on aura reports.
pub struct StakingSlasher<T>(::rstd::marker::PhantomData<T>);

impl<T: staking::Trait + Trait> HandleReport for StakingSlasher<T> {
impl<T: session::Trait + Trait> HandleReport for StakingSlasher<T> {
fn handle_report(report: AuraReport) {
let validators = staking::Module::<T>::validators();
let validators = session::Module::<T>::validators();

report.punish(
validators.len(),
Expand Down
54 changes: 21 additions & 33 deletions srml/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,34 +268,6 @@ impl<T: Trait> Module<T> {
}
}

/// Adds up to `value` to the free balance of `who`. If `who` doesn't exist, it is created.
///
/// This is a sensitive function since it circumvents any fees associated with account
/// setup. Ensure it is only called by trusted code.
///
/// NOTE: This assumes that the total stake remains unchanged after this operation. If
/// you mean to actually mint value into existence, then use `reward` instead.
pub fn increase_free_balance_creating(who: &T::AccountId, value: T::Balance) -> UpdateBalanceOutcome {
Self::set_free_balance_creating(who, Self::free_balance(who) + value)
}

/// Substrates `value` from the free balance of `who`. If the whole amount cannot be
/// deducted, an error is returned.
///
/// NOTE: This assumes that the total stake remains unchanged after this operation. If
/// you mean to actually burn value out of existence, then use `slash` instead.
pub fn decrease_free_balance(
who: &T::AccountId,
value: T::Balance
) -> result::Result<UpdateBalanceOutcome, &'static str> {
T::EnsureAccountLiquid::ensure_account_liquid(who)?;
let b = Self::free_balance(who);
if b < value {
return Err("account has too few funds")
}
Ok(Self::set_free_balance(who, b - value))
}

/// Transfer some liquid free balance to another staker.
pub fn make_transfer(transactor: &T::AccountId, dest: &T::AccountId, value: T::Balance) -> Result {
let from_balance = Self::free_balance(transactor);
Expand All @@ -316,7 +288,7 @@ impl<T: Trait> Module<T> {
if would_create && value < Self::existential_deposit() {
return Err("value too low to create account");
}
T::EnsureAccountLiquid::ensure_account_liquid(transactor)?;
T::EnsureAccountLiquid::ensure_account_can_transfer(transactor)?;

// NOTE: total stake being stored in the same type means that this could never overflow
// but better to be safe than sorry.
Expand Down Expand Up @@ -398,17 +370,21 @@ where
}

fn can_reserve(who: &T::AccountId, value: Self::Balance) -> bool {
if T::EnsureAccountLiquid::ensure_account_liquid(who).is_ok() {
if T::EnsureAccountLiquid::ensure_account_can_transfer(who).is_ok() {
Self::free_balance(who) >= value
} else {
false
}
}

fn total_issuance() -> Self:: Balance {
fn total_issuance() -> Self::Balance {
Self::total_issuance()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this an infinite recursive call? or is there any mechanism to ensure this calls total_issuance generated by decl_storage?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not new, but it does look dodgy...

}

fn minimum_balance() -> Self::Balance {
Self::existential_deposit()
}

fn free_balance(who: &T::AccountId) -> Self::Balance {
Self::free_balance(who)
}
Expand Down Expand Up @@ -442,12 +418,24 @@ where
Self::set_free_balance_creating(who, Self::free_balance(who) + value)
}

fn decrease_free_balance(
who: &T::AccountId,
value: T::Balance
) -> result::Result<UpdateBalanceOutcome, &'static str> {
T::EnsureAccountLiquid::ensure_account_can_transfer(who)?;
let b = Self::free_balance(who);
if b < value {
return Err("account has too few funds")
}
Ok(Self::set_free_balance(who, b - value))
}

fn reserve(who: &T::AccountId, value: Self::Balance) -> result::Result<(), &'static str> {
let b = Self::free_balance(who);
if b < value {
return Err("not enough free funds")
}
T::EnsureAccountLiquid::ensure_account_liquid(who)?;
T::EnsureAccountLiquid::ensure_account_can_transfer(who)?;
Self::set_reserved_balance(who, Self::reserved_balance(who) + value);
Self::set_free_balance(who, b - value);
Ok(())
Expand Down Expand Up @@ -505,7 +493,7 @@ impl<T: Trait> TransferAsset<T::AccountId> for Module<T> {
}

fn remove_from(who: &T::AccountId, value: T::Balance) -> Result {
T::EnsureAccountLiquid::ensure_account_liquid(who)?;
T::EnsureAccountLiquid::ensure_account_can_transfer(who)?;
let b = Self::free_balance(who);
ensure!(b >= value, "account has too few funds");
Self::set_free_balance(who, b - value);
Expand Down
4 changes: 2 additions & 2 deletions srml/contract/COMPLEXITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ This function performs the following steps:

1. Querying source and destination balances from an overlay (see `get_balance`),
2. Querying `existential_deposit`.
3. Executing `ensure_account_liquid` hook.
3. Executing `ensure_account_can_transfer` hook.
4. Updating source and destination balance in the overlay (see `set_balance`).

**Note** that the complexity of executing `ensure_account_liquid` hook should be considered separately.
**Note** that the complexity of executing `ensure_account_can_transfer` hook should be considered separately.

In the course of the execution this function can perform up to 2 DB reads to `get_balance` of source and destination accounts. It can also induce up to 2 DB writes via `set_balance` if flushed to the storage.

Expand Down
2 changes: 1 addition & 1 deletion srml/contract/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ fn transfer<'a, T: Trait, V: Vm<T>, L: Loader<T>>(
if would_create && value < ctx.config.existential_deposit {
return Err("value too low to create account");
}
<T as balances::Trait>::EnsureAccountLiquid::ensure_account_liquid(transactor)?;
<T as balances::Trait>::EnsureAccountLiquid::ensure_account_can_transfer(transactor)?;

let new_to_balance = match to_balance.checked_add(&value) {
Some(b) => b,
Expand Down
2 changes: 1 addition & 1 deletion srml/democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ impl<T: Trait> OnFreeBalanceZero<T::AccountId> for Module<T> {
}

impl<T: Trait> EnsureAccountLiquid<T::AccountId> for Module<T> {
fn ensure_account_liquid(who: &T::AccountId) -> Result {
fn ensure_account_can_transfer(who: &T::AccountId) -> Result {
if Self::bondage(who) <= <system::Module<T>>::block_number() {
Ok(())
} else {
Expand Down
Loading