Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
38269b8
feat: initialize offline election prediction tool structure
karanvir12 Oct 10, 2025
531191f
chore:added prediction types
karanvir12 Oct 10, 2025
b9abed4
chore: add module for fetching and preprocessing election data
karanvir12 Oct 10, 2025
57a25c0
chore: add command-line interface for offline election prediction tool
karanvir12 Oct 10, 2025
4648815
chore: implement core prediction logic
karanvir12 Oct 10, 2025
342d700
chore: run election predictions and generate output files
karanvir12 Oct 10, 2025
7e16bce
test: add unit and integration tests for election prediction tool
karanvir12 Oct 10, 2025
f51f470
chore:code restructured
karanvir12 Oct 10, 2025
932e913
chore:added readme
karanvir12 Oct 10, 2025
4d370fd
fix:fixed snapshot fetching logic
pushkar1262 Oct 13, 2025
bc8c325
chore: Implemented suggested changes and improvements
pushkar1262 Nov 12, 2025
7f80138
fix(predict): custom file handling logic
pushkar1262 Nov 12, 2025
f60a578
chore:docker image updated
karanvir12 Nov 13, 2025
5a5b6f3
chore: apply minor codebase improvements and cleanup
pushkar1262 Nov 14, 2025
d5995ca
chore:docker file updated
karanvir12 Nov 19, 2025
16ad14b
Merge branch 'feat/offline-election-prediction-tool' of https://githu…
karanvir12 Nov 19, 2025
d13195d
chore:rust version updated
karanvir12 Nov 19, 2025
22a40eb
Merge branch 'paritytech:main' into feat/offline-election-prediction-…
Ipsa11 Nov 24, 2025
08ccbbc
chore:used mine_solution for prediction
pushkar1262 Nov 26, 2025
17275b7
fix:updated rust version
pushkar1262 Nov 26, 2025
945aeee
fix: predict.rs clippy workflow
pushkar1262 Nov 26, 2025
0a038aa
chore: added generate_changelog.sh file
pushkar1262 Nov 27, 2025
de6701f
fix: readme and get_chain_properties
pushkar1262 Dec 1, 2025
aaeb8f5
chore:docker file updated
karanvir12 Dec 1, 2025
cbf661d
fix(predict): used bags and voterlist for fetching staking data
pushkar1262 Dec 9, 2025
f34cbf0
fix: restored dockerfile and removed dockerignore
pushkar1262 Dec 11, 2025
7e626e1
Changed permissions of generate_changelog.sh
pushkar1262 Dec 11, 2025
ab9cdfd
feat: added cli options for do_reduce and block number
pushkar1262 Dec 15, 2025
55e1502
chore: updated README
pushkar1262 Dec 15, 2025
2202fd6
fix(predict): fixed voter data fetch and ordering
pushkar1262 Dec 23, 2025
fc798f6
chore: added number of nominators per validator and the individual no…
pushkar1262 Dec 24, 2025
6a957d6
refactor: fixed custom data file reading and some refactoring
pushkar1262 Jan 5, 2026
74bcabb
Merge branch 'main' into feat/offline-election-prediction-tool
Ipsa11 Jan 5, 2026
5a69b41
refactor: simplify backend initialization in Client
pushkar1262 Jan 5, 2026
a8c53fc
test(utils): add unit tests and misc cleanups
pushkar1262 Jan 13, 2026
c1a4756
Merge branch 'paritytech:main' into feat/offline-election-prediction-…
Ipsa11 Jan 14, 2026
b351c77
fix: fixed snapshot creation
pushkar1262 Jan 19, 2026
22ab2e4
Merge branch 'paritytech:main' into feat/offline-election-prediction-…
pushkar1262 Jan 21, 2026
a9a6670
fixed empty validator prediction
pushkar1262 Jan 21, 2026
c887d92
Merge branch 'main' into feat/offline-election-prediction-tool
pushkar1262 Jan 21, 2026
485db87
Added overrides option| removed custom-data option
pushkar1262 Jan 24, 2026
3b5a346
Added support for PhragMMS
pushkar1262 Jan 27, 2026
fb2333f
Merge branch 'main' into feat/offline-election-prediction-tool
pushkar1262 Jan 27, 2026
76ebc86
fix: address breaking changes from client.rs updates
pushkar1262 Jan 27, 2026
8415e40
improve logging hierarchy and used dynamic solver for kusama
pushkar1262 Jan 28, 2026
c3ba626
implemented separate clients for monitor and predict | some refactoring
pushkar1262 Jan 29, 2026
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
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Ignore build artifacts and large/generated data to keep the context slim.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove this file honestly - seems a bit out of scope for this PR

target/*
!target/release/
target/release/*
!target/release/polkadot-staking-miner
results
artifacts/tmp

# Git metadata and local configs.
.git
.gitignore
.github

# Editor / OS files.
*.swp
*.swo
*.log
*.tmp
.DS_Store
Thumbs.db

# Docker related.
Dockerfile.README.md
docker-compose*

22 changes: 15 additions & 7 deletions Cargo.lock

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

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ name = "polkadot-staking-miner"
version = "1.8.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2024"
rust-version = "1.85.0"
rust-version = "1.88.0"
license = "GPL-3.0"
repository = "https://github.com/paritytech/polkadot-staking-miner"
homepage = "https://www.parity.io/"
description = "A tool to submit NPoS election solutions for substrate based chains"
resolver = "2"

[dependencies]
codec = { package = "parity-scale-codec", version = "3.7.5" }
Expand Down Expand Up @@ -57,14 +56,17 @@ hyper-util = { version = "0.1.18", features = [
http-body-util = "0.1.0"
once_cell = "1.21"

ss58-registry = "1.9"

[dev-dependencies]
anyhow = "1"
assert_cmd = "2.1"
regex = "1"
tempfile = "3.8"

[features]
integration-tests = []

[package.metadata.docs.rs]
default-features = true
rustdoc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]
60 changes: 31 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
FROM docker.io/library/ubuntu:20.04
# Runtime image expecting a pre-built binary alongside the Docker build context.
FROM ubuntu:20.04

# metadata
ARG VCS_REF
ARG BUILD_DATE
# Metadata
ARG VCS_REF=unknown
ARG BUILD_DATE=unknown

LABEL io.parity.image.authors="[email protected]" \
io.parity.image.vendor="Parity Technologies" \
io.parity.image.title="polkadot-staking-miner" \
io.parity.image.description="Polkadot staking miner for substrate based chains" \
io.parity.image.source="https://github.com/paritytech/polkadot-staking-miner/blob/${VCS_REF}/Dockerfile" \
io.parity.image.revision="${VCS_REF}" \
io.parity.image.created="${BUILD_DATE}" \
io.parity.image.documentation="https://github.com/paritytech/polkadot/"

# show backtraces
ENV RUST_BACKTRACE 1

# install tools and dependencies
io.parity.image.vendor="Parity Technologies" \
Copy link
Contributor

Choose a reason for hiding this comment

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

All these indentation changes make it difficult to understand the actual modifications and the necessity for any adjustments here.

io.parity.image.title="polkadot-staking-miner" \
io.parity.image.description="Polkadot staking miner for substrate based chains" \
io.parity.image.source="https://github.com/paritytech/polkadot-staking-miner/blob/${VCS_REF}/Dockerfile" \
io.parity.image.revision="${VCS_REF}" \
io.parity.image.created="${BUILD_DATE}" \
io.parity.image.documentation="https://github.com/paritytech/polkadot/"

# Backtraces & useful defaults
ENV RUST_BACKTRACE=1 \
SEED="" \
URI="wss://rpc.polkadot.io" \
Copy link
Contributor

Choose a reason for hiding this comment

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

why? Also the tool won't event work vs this URI...

Copy link
Contributor

Choose a reason for hiding this comment

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

@Ipsa11 can you please review the comments in this file too from previous round?
I am actually not sure why we want to change the whole file at all

RUST_LOG="info"

# Install runtime dependencies (libssl1.1 still available on focal)
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
libssl1.1 \
ca-certificates && \
# apt cleanup
libssl1.1 \
ca-certificates && \
apt-get autoremove -y && \
apt-get clean && \
find /var/lib/apt/lists/ -type f -not -name lock -delete; \
find /var/lib/apt/lists/ -type f -not -name lock -delete && \
useradd -u 10000 -U -s /bin/sh miner

# add binary to docker image
# Copy the pre-built binary into the image
COPY ./polkadot-staking-miner /usr/local/bin

USER miner
# Create writable workspace and output directories
RUN mkdir -p /workspace/results /workspace/outputs && \
chmod 777 /workspace /workspace/results /workspace/outputs && \
/usr/local/bin/polkadot-staking-miner --version

ENV SEED=""
ENV URI="wss://rpc.polkadot.io"
ENV RUST_LOG="info"
WORKDIR /workspace

# check if the binary works in this container
RUN /usr/local/bin/polkadot-staking-miner --version

ENTRYPOINT [ "/usr/local/bin/polkadot-staking-miner" ]
ENTRYPOINT ["/usr/local/bin/polkadot-staking-miner"]
CMD ["--help"]
68 changes: 67 additions & 1 deletion Dockerfile.README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,70 @@

[GitHub](https://github.com/paritytech/polkadot-staking-miner)

Formerly known as `staking-miner-v2` historical images versions are available in the [hub.docker.com](https://hub.docker.com/r/paritytech/staking-miner-v2)
Formerly known as `staking-miner-v2` historical images versions are available in the [hub.docker.com](https://hub.docker.com/r/paritytech/staking-miner-v2)

## Using Pre-built Docker Image

### Pull the image from Docker Hub

```bash
docker pull polkadot-staking-miner
```

Or if using a specific registry:

```bash
docker pull <registry>/polkadot-staking-miner:<tag>
```

### Run prediction with custom file
Copy link
Contributor

Choose a reason for hiding this comment

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

This file is not specific for prediction only so if you extend examples to include predict, you should also do that for the other existing commands (monitor, info) imho.

Also - there is a #Docker section already in the main README.md, not sure if we benefit from these addictions here

Copy link
Contributor

Choose a reason for hiding this comment

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

@Ipsa11 can we review comments in this file from previous round? Not sure if we really need to change it at all imho in the scope of this PR


```bash
sudo docker run --rm \
-v "$(pwd):/workspace" \
polkadot-staking-miner \
--uri wss://westend-asset-hub-rpc.polkadot.io \
predict --custom-file custom.json --desired-validators 1
```

### Run basic prediction

```bash
docker run --rm \
-v "$(pwd):/workspace" \
polkadot-staking-miner \
--uri wss://westend-asset-hub-rpc.polkadot.io \
predict
```

## Building Locally

If you need to build the image locally:

```bash
docker build -t polkadot-staking-miner .
```



### Pull the image from Docker Hub


sudo docker pull paritytech/staking-miner-v2:latest

### for custom validators

sudo docker run --rm -v "$(pwd):/workspace" paritytech/staking-miner-v2:latest --uri wss://westend-asset-hub-rpc.polkadot.io predict --custom-file custom.json --desired-validators 1


### for basic prediction

sudo docker run --rm -v "$(pwd):/workspace" paritytech/staking-miner-v2:latest --uri wss://westend-asset-hub-rpc.polkadot.io predict

### monitor command

sudo docker run --rm -v "$(pwd):/workspace" paritytech/staking-miner-v2:latest --uri wss://westend-asset-hub-rpc.polkadot.io monitor --seed-or-path //Alice

### info commanda

sudo docker run --rm -v "$(pwd):/workspace" paritytech/staking-miner-v2:latest --uri wss://westend-asset-hub-rpc.polkadot.io info
Loading