-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Delegated staking #246
Delegated staking #246
Conversation
| // Ok - all valid. | ||
|
|
||
| // update nominators_for | ||
| t.swap_remove(target_index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a question to refine my own understanding: isn't this will invalidate an index of the last nominator?
so for example, there are two calls:
unnominate(0, 0)unnominate(1, 1)
the second call will return an error Invalid target index because the first call invalidated the index of the nominator 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes - in that case, the second will be a no-op - they'll need to resubmit the tx. shit happens :)
substrate/runtime/staking/src/lib.rs
Outdated
| //let r = Self::voting_balance(n) * reward / total; // correct formula, but might overflow with large reard * total. | ||
| let quant = T::Balance::sa(1usize << 31); | ||
| let s = (Self::voting_balance(n) * quant / total) * rem / quant; // avoid overflow by using quant as a denominator. | ||
| let _ = Self::slash(n, s); // will never fail as nominator accounts must be created, but even if it did, it's just a missed reward. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait a minute, we are not talking about rewards here : D
| } | ||
|
|
||
| fn nominate(aux: &T::PublicAux, target: RawAddress<T::AccountId, T::AccountIndex>) -> Result { | ||
| let target = Self::lookup(target)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a validator. Can I nominate myself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any check that prevents this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not yet :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
|
Review continues in the rebased #262 |
* add debugging lines to author filter * some lines in author inherent * correct labels on debug lines * cargo fmt * silly typo * Separate inherent check into precheck and final check. * Revert de8951a (Remove relay block from author filter) * Bettter comment * Move dummy event handler to main module (not test module) * fix test harness * bump runtime version * Preapare embedded specs for network launch from instructions. https://purestake.atlassian.net/wiki/spaces/MOON/pages/1313013795/Generate+embedded+specs * prettier * Comment typos Co-authored-by: Amar Singh <[email protected]> * re-enable author filter debugging event * more logs * Make cargo.lock the way I want (cargo will mess it up though) * 20 block rounds * Hack to fix Apps * Fix the actual bug * re-disable debugging event for ci * change logs to trace level * whitespace * line length * one more spec version bump. Gonna try an upgrade. I think it'll work. * embedded specs * Add author filter call, and another spec version bump * Revert block per round change * one version bump will do Co-authored-by: Amar Singh <[email protected]>
* no message * update orderpair * no message
Subspace networking
) Signed-off-by: Gregory Hill <[email protected]>
Second part of #194 . Nothing special here, just added
nominateandunnominate, which roughly follow semantics ofstakeandunstake, except they nominate themselves to some other (potential) validator and share the reward.