Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions components/RPC-Connection.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect } from "react";
import { ApiPromise, WsProvider } from "@polkadot/api";
import { HumanReadable, BlocksToDays } from "./utilities/filters";
import { HumanReadable, Precise, BlocksToDays } from "./utilities/filters";

/*
This component connects to the Polkadot/Kusama APIs and renders the response data.
Expand Down Expand Up @@ -135,11 +135,14 @@ async function syncData(network, path, setReturnValue) {
function applyFilter(value, filter, network, setReturnValue) {
switch (filter) {
case "humanReadable":
HumanReadable(value, network, setReturnValue)
HumanReadable(value, network, setReturnValue);
break;
case "precise":
Precise(value, network, setReturnValue);
break;
case "blocksToDays":
BlocksToDays(value, setReturnValue);
break;
break;
default:
console.log("Ignoring unknown filter type");
return;
Expand Down
9 changes: 9 additions & 0 deletions components/utilities/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ module.exports = {
setReturnValue(value.toString());
},

Precise: function (value, network, setReturnValue) {
// String to number
value = parseFloat(value);
// Apply precision and append symbol without additional rounding
value = `${value / values[network].precision} ${values[network].symbol}`;
// Update value
setReturnValue(value);
},

BlocksToDays: function (value, setReturnValue) {
value = (value * 6) / 86400;
// Update value
Expand Down
35 changes: 18 additions & 17 deletions docs/learn/learn-staking-miner.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ discretion, as there is a risk of losing some funds.

:::

At the end of each era on Polkadot and Kusama, using [NPoS](learn-phragmen), a new set of validators
must be elected based on the nominator preferences. This is a computationally intensive process, hence
the usage of the term "mining" for computing the solution. The validators use
[off-chain workers](https://docs.substrate.io/reference/how-to-guides/offchain-workers/) to
compute the result and submit a transaction to propose the set of winners. This can also be delegated
to stand-alone programs, whose task is to mine the optimal solution. Staking miners compete with each other
to produce election solutions which consist of a validator set, stake distribution across that set, and a score
indicating how optimal the solution is. Staking miners run any given staking algorithms (as of now,
sequential Phragmén or PhragMMS, subject to change if improved algorithms are introduced) to produce results,
which are then sent as a transaction to the relay chain via a normal signed extrinsic. The transaction
requires a bond and a transaction fee. The best solution is rewarded, which the least covers the
transaction fee, and the bond is returned to the account. [The bond and the fee](learn-staking-miner#deposit-and-reward-mechanics) are lost if the solution
is invalid.

At the end of each era on Polkadot and Kusama, using [NPoS](learn-phragmen), a new set of validators
must be elected based on the nominator preferences. This is a computationally intensive process,
hence the usage of the term "mining" for computing the solution. The validators use
[off-chain workers](https://docs.substrate.io/reference/how-to-guides/offchain-workers/) to compute
the result and submit a transaction to propose the set of winners. This can also be delegated to
stand-alone programs, whose task is to mine the optimal solution. Staking miners compete with each
other to produce election solutions which consist of a validator set, stake distribution across that
set, and a score indicating how optimal the solution is. Staking miners run any given staking
algorithms (as of now, sequential Phragmén or PhragMMS, subject to change if improved algorithms are
introduced) to produce results, which are then sent as a transaction to the relay chain via a normal
signed extrinsic. The transaction requires a bond and a transaction fee. The best solution is
rewarded, which the least covers the transaction fee, and the bond is returned to the account.
[The bond and the fee](learn-staking-miner#deposit-and-reward-mechanics) are lost if the solution is
invalid.

Staking miner uses a pallet called `pallet_election_provider_multi_phase` and can only produce
solutions during the
Expand Down Expand Up @@ -139,9 +139,10 @@ Current deposit(`SignedDepositBase`) is
which is a fixed amount.

Current deposit per byte(`SignedDepositByte`) is
{{ polkadot: 0.0000097656 DOT :polkadot }}{{ kusama: 0.00000032551 KSM :kusama }} and the total is
variable depending on the size of the solution data. For example a solution weighing 200KB would
yield {{ polkadot: 200 x 0.0000097656 = **0.00195312 DOT**. :polkadot }}
{{ polkadot: <RPC network="polkadot" path="consts.electionProviderMultiPhase.signedDepositByte" defaultValue={97656} filter="precise"/> :polkadot }}
{{ kusama: <RPC network="kusama" path="consts.electionProviderMultiPhase.signedDepositByte" defaultValue={32551} filter="precise"/> :kusama }}
and the total is variable depending on the size of the solution data. For example, a solution
weighing 200KB would yield {{ polkadot: 200 x 0.0000097656 = **0.00195312 DOT**. :polkadot }}
{{ kusama: 200 x 0.00000032551 = **0.000065102 KSM**. :kusama }}

And the weight deposit(`SignedDepositWeight`) is currently set to `0` and has no effect.
Expand Down