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

Commit

Permalink
staking miner: spawn separate task for each block (#4716)
Browse files Browse the repository at this point in the history
* staking miner: use config for emergency solution

Fixes #4678

* bump jsonrpsee

* run `monitor_cmd_for` until the connection is closed

* new tokio task for submit_and_watch xt

* re-use header subscription

* update jsonrpsee + simplify code

* revert polkadot runtime changes

* fix grumbles

* Update utils/staking-miner/src/monitor.rs

* grumbles: fix logs + nits
  • Loading branch information
niklasad1 authored Feb 7, 2022
1 parent c81bd36 commit 666f317
Show file tree
Hide file tree
Showing 6 changed files with 232 additions and 97 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions utils/staking-miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

[dependencies]
clap = { version = "3.0", features = ["derive", "env"] }
codec = { package = "parity-scale-codec", version = "2.0.0" }
tokio = { version = "1.15", features = ["macros"] }
log = "0.4.11"
env_logger = "0.9.0"
clap = { version = "3.0", features = ["derive", "env"] }
jsonrpsee = { version = "0.4.1", default-features = false, features = ["ws-client"] }
serde_json = "1.0"
serde = "1.0.132"
jsonrpsee = { version = "0.8", features = ["ws-client"] }
log = "0.4.11"
paste = "1.0.6"
serde = "1.0.132"
serde_json = "1.0"
thiserror = "1.0.30"
tokio = { version = "1.15", features = ["macros", "rt-multi-thread", "sync"] }

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

Expand Down
7 changes: 7 additions & 0 deletions utils/staking-miner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,10 @@ docker run --rm -it \
-e URI=wss://your-node:9944 \
staking-miner dry-run
```

### Test locally

1. Modify `EPOCH_DURATION_IN_SLOTS` and `SessionsPerEra` to force an election
more often than once per day.
2. $ polkadot --chain polkadot-dev --tmp --alice --execution Native -lruntime=debug --offchain-worker=Always --ws-port 9999
3. $ staking-miner --uri ws://localhost:9999 --seed //Alice monitor phrag-mms
4 changes: 2 additions & 2 deletions utils/staking-miner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ macro_rules! any_runtime_unit {
#[derive(frame_support::DebugNoBound, thiserror::Error)]
enum Error<T: EPM::Config> {
Io(#[from] std::io::Error),
JsonRpsee(#[from] jsonrpsee::types::Error),
JsonRpsee(#[from] jsonrpsee::core::Error),
RpcHelperError(#[from] rpc_helpers::RpcHelperError),
Codec(#[from] codec::Error),
Crypto(sp_core::crypto::SecretStringError),
Expand Down Expand Up @@ -602,7 +602,7 @@ async fn main() {

let outcome = any_runtime! {
match command.clone() {
Command::Monitor(c) => monitor_cmd(&client, shared, c, signer_account).await
Command::Monitor(c) => monitor_cmd(client, shared, c, signer_account).await
.map_err(|e| {
log::error!(target: LOG_TARGET, "Monitor error: {:?}", e);
}),
Expand Down
Loading

0 comments on commit 666f317

Please sign in to comment.