Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Delegated staking#246

Closed
gavofyork wants to merge 30 commits intomasterfrom
gav-delegation
Closed

Delegated staking#246
gavofyork wants to merge 30 commits intomasterfrom
gav-delegation

Conversation

@gavofyork
Copy link
Copy Markdown
Member

@gavofyork gavofyork commented Jun 25, 2018

Second part of #194 . Nothing special here, just added nominate and unnominate, which roughly follow semantics of stake and unstake, except they nominate themselves to some other (potential) validator and share the reward.

  • Basic implementation
  • Proportional rewarding & slashing
  • Ratios should be cached until reward
  • Tests

@gavofyork gavofyork added the A3-in_progress Pull request is in progress. No review needed at this stage. label Jun 25, 2018
@gavofyork gavofyork added this to the PoC-2 (Co-finalisation) milestone Jun 25, 2018
@gavofyork gavofyork added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Jun 25, 2018
@gavofyork gavofyork removed this from the PoC-2 (Co-finalisation) milestone Jun 26, 2018
@gavofyork gavofyork requested review from pepyakin and rphmeier June 27, 2018 09:44
// Ok - all valid.

// update nominators_for
t.swap_remove(target_index);
Copy link
Copy Markdown
Contributor

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:

  1. unnominate(0, 0)
  2. unnominate(1, 1)

the second call will return an error Invalid target index because the first call invalidated the index of the nominator 1.

Copy link
Copy Markdown
Member Author

@gavofyork gavofyork Jun 28, 2018

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 :)

//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.
Copy link
Copy Markdown
Contributor

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)?;
Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

no...

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

not yet :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed.

@gavofyork gavofyork mentioned this pull request Jun 28, 2018
4 tasks
@gavofyork
Copy link
Copy Markdown
Member Author

Review continues in the rebased #262

@gavofyork gavofyork closed this Jun 28, 2018
@arkpar arkpar deleted the gav-delegation branch July 23, 2018 13:38
JoshOrndorff added a commit to moonbeam-foundation/substrate that referenced this pull request Apr 21, 2021
* 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 <asinghchrony@protonmail.com>

* 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 <asinghchrony@protonmail.com>
liuchengxu pushed a commit to chainx-org/substrate that referenced this pull request Aug 23, 2021
* no message

* update orderpair

* no message
liuchengxu pushed a commit to autonomys/substrate that referenced this pull request Jun 3, 2022
helin6 pushed a commit to boolnetwork/substrate that referenced this pull request Jul 25, 2023
)

Signed-off-by: Gregory Hill <gregorydhill@outlook.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

A0-please_review Pull request needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants