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

Staking Miner #3141

Merged
merged 39 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
36502dc
Companion for Decouple Staking and Election - Part 3: Signed Phase
coriolinus Apr 1, 2021
1e509e9
Merge remote-tracking branch 'origin/master' into prgn-companion-for-…
coriolinus May 26, 2021
9638fcf
Merge remote-tracking branch 'origin/master' into prgn-companion-for-…
coriolinus May 27, 2021
59646c2
Merge branch 'prgn-companion-for-7910' of github.com:paritytech/polka…
kianenigma May 29, 2021
271d351
Template added
kianenigma May 29, 2021
7e21f24
Add stuff
kianenigma May 29, 2021
61cf070
First working version
kianenigma May 31, 2021
95b6ea0
revamp rpc stuff
kianenigma May 31, 2021
1709494
remove all the stale js stuff
kianenigma Jun 1, 2021
0c10c66
Major updates, closer to completion.
kianenigma Jun 3, 2021
a4aa730
removing my generic WIP for tidyness.
kianenigma Jun 3, 2021
72db361
add --at
kianenigma Jun 3, 2021
dc1a623
ass measure snapshot
kianenigma Jun 13, 2021
5fa5a3f
some new little debugging thigs
kianenigma Jun 17, 2021
138e8b9
pre-merge
kianenigma Jun 25, 2021
c3cfe94
Merge branch 'master' of github.com:paritytech/polkadot into kiz-stak…
kianenigma Jun 25, 2021
863ea3a
Master.into()
kianenigma Jun 28, 2021
3980e85
Fix
kianenigma Jun 28, 2021
d1ba0cb
revert dep update
kianenigma Jun 30, 2021
fe76cee
update to master
kianenigma Jun 30, 2021
3777a8a
revert all the toml shit
kianenigma Jun 30, 2021
64c22d9
Apply suggestions from code review
kianenigma Jun 30, 2021
bcd394d
cleanup
kianenigma Jun 30, 2021
e74218e
Fix more
kianenigma Jun 30, 2021
3ce287f
Fix era
kianenigma Jul 1, 2021
7dd7e64
Apply suggestions from code review
kianenigma Jul 1, 2021
ab87195
Few fixes
kianenigma Jul 1, 2021
c77bf51
Better reward scheme
kianenigma Jul 1, 2021
b25ee40
y
kianenigma Jul 1, 2021
10508ae
Update utils/staking-miner/src/main.rs
kianenigma Jul 1, 2021
f83ddb6
Update utils/staking-miner/src/dry_run.rs
kianenigma Jul 1, 2021
913e75a
Update utils/staking-miner/src/dry_run.rs
kianenigma Jul 1, 2021
89e0a38
Update utils/staking-miner/src/monitor.rs
kianenigma Jul 1, 2021
dcbe582
More chnages
kianenigma Jul 1, 2021
f10f00b
Merge branch 'kiz-staking-miner' of github.com:paritytech/polkadot in…
kianenigma Jul 1, 2021
df8725b
Fix
kianenigma Jul 1, 2021
1e4f6be
Master.into()
kianenigma Jul 1, 2021
01e92c4
Make it restart automatically.
kianenigma Jul 1, 2021
979cfcc
Final touches
kianenigma Jul 1, 2021
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
310 changes: 156 additions & 154 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ parameter_types! {
pub const UnsignedPhase: u32 = EPOCH_DURATION_IN_SLOTS / 4;

// signed config
pub const SignedMaxSubmissions: u32 = 0;
pub const SignedMaxSubmissions: u32 = 10;
pub const SignedRewardBase: Balance = 1 * DOLLARS;
pub const SignedDepositBase: Balance = 1 * DOLLARS;
pub const SignedDepositByte: Balance = 1 * CENTS;
Expand Down
5 changes: 4 additions & 1 deletion utils/staking-miner/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "staking-miner"
version = "0.9.0"
authors = ["parity"]
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

[dependencies]
Expand All @@ -18,13 +18,16 @@ serde = "1.0.0"
hex = "0.4.0"
lazy_static = "1.4.0"
paste = "1.0.5"
thiserror = "1.0.0"

remote-externalities = { git = "https://github.com/paritytech/substrate", branch = "kiz-staking-miner" }

sp-core = { git = "https://github.com/paritytech/substrate", branch = "kiz-staking-miner" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "kiz-staking-miner" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "kiz-staking-miner" }
sp-npos-elections = { git = "https://github.com/paritytech/substrate", branch = "kiz-staking-miner" }
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "kiz-staking-miner" }


frame-system = { git = "https://github.com/paritytech/substrate", branch = "kiz-staking-miner" }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "kiz-staking-miner" }
Expand Down
5 changes: 0 additions & 5 deletions utils/staking-miner/js/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions utils/staking-miner/js/nodemon.json

This file was deleted.

30 changes: 0 additions & 30 deletions utils/staking-miner/js/package.json

This file was deleted.

69 changes: 0 additions & 69 deletions utils/staking-miner/js/src/index.ts

This file was deleted.

14 changes: 0 additions & 14 deletions utils/staking-miner/js/tsconfig.json

This file was deleted.

28 changes: 20 additions & 8 deletions utils/staking-miner/src/dry_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ use crate::{prelude::*, Signer, SharedConfig, WsClient, Error, rpc_helpers::*, p
use codec::Encode;

/// Forcefully create the snapshot. This can be used to compute the election at anytime.
fn force_create_snapshot<T: EPM::Config>(ext: &mut Ext) {
fn force_create_snapshot<T: EPM::Config>(ext: &mut Ext) -> Result<(), Error> {
ext.execute_with(|| {
if <EPM::Snapshot<T>>::exists() {
log::info!(target: LOG_TARGET, "snapshot already exists.");
} else {
log::info!(target: LOG_TARGET, "creating a fake snapshot now.");
}
<EPM::Pallet<T>>::create_snapshot().unwrap();
});
let _ = <EPM::Pallet<T>>::create_snapshot()?;
Ok(())
})
}

macro_rules! dry_run_cmd_for { ($runtime:tt) => { paste::paste! {
macro_rules! dry_run_cmd_for { ($runtime:ident) => { paste::paste! {
/// Execute the dry-run command.
pub(crate) async fn [<dry_run_cmd_ $runtime>](
kianenigma marked this conversation as resolved.
Show resolved Hide resolved
client: WsClient,
Expand All @@ -40,11 +41,22 @@ macro_rules! dry_run_cmd_for { ($runtime:tt) => { paste::paste! {
) -> Result<(), Error> {
use $crate::[<$runtime _runtime_exports>]::*;
let hash = rpc::<<Block as BlockT>::Hash>(&client, "chain_getFinalizedHead", params!{}).await.expect("chain_getFinalizedHead infallible; qed.");
let mut ext = crate::create_election_ext::<Runtime, Block>(shared.uri.clone(), hash, true).await;
force_create_snapshot::<Runtime>(&mut ext);
let (raw_solution, witness) = crate::mine_unchecked::<Runtime>(&mut ext);
let mut ext = crate::create_election_ext::<Runtime, Block>(shared.uri.clone(), hash, true).await?;
force_create_snapshot::<Runtime>(&mut ext)?;
let (raw_solution, witness) = crate::mine_unchecked::<Runtime>(&mut ext)?;
log::info!(target: LOG_TARGET, "mined solution with {:?}", &raw_solution.score);
let extrinsic = ext.execute_with(|| create_uxt(raw_solution, witness, signer.clone()));

let nonce = crate::get_account_info::<Runtime>(&client, &signer.account, Some(hash))
.await?
.map(|i| i.nonce)
.expect("signer account is checked to exist upon startup; it can only die if it \
transfers funds out of it, or get slashed. If it does not exist at this point, \
it is likely due to a bug, or the signer got slashed. Terminating."
);
let tip = 0 as Balance;
let era = sp_runtime::generic::Era::Immortal;
let extrinsic = ext.execute_with(|| create_uxt(raw_solution, witness, signer.clone(), nonce, tip, era));

let bytes = sp_core::Bytes(extrinsic.encode().to_vec());
let outcome = rpc_decode::<sp_runtime::ApplyExtrinsicResult>(&client, "system_dryRun", params!{ bytes }).await?;
log::info!(target: LOG_TARGET, "dry-run outcome is {:?}", outcome);
Expand Down
Loading