An open API service indexing awesome lists of open source software.

https://github.com/p2poolv2/p2poolv2

P2Poolv2 - Rebooting P2Pool for Bitcoin
https://github.com/p2poolv2/p2poolv2

bitcoin mining-pool p2p stratum

Last synced: about 2 months ago
JSON representation

P2Poolv2 - Rebooting P2Pool for Bitcoin

Awesome Lists containing this project

README

          

image:https://github.com/p2poolv2/p2poolv2/actions/workflows/rust.yml/badge.svg[Rust CI, link=https://github.com/p2poolv2/p2poolv2/actions/workflows/rust.yml]
image:https://codecov.io/gh/p2poolv2/p2poolv2/graph/badge.svg?token=Xeu4GFdASS[Codecov, link=https://codecov.io/gh/p2poolv2/p2poolv2]

== P2Poolv2

****
**Mission:** ##Replace pool operators with miners##
****

P2Poolv2 is a peer-to-peer Bitcoin mining pool where miners coordinate
directly and verify their rewards without centralized operators.

1. Share chain with uncles - all your work is accounted for.
2. Pay large miners in coinbase - non custodial solution for top N miners.
3. Support transactions - pay all miners with atomic swaps by market makers.
4. Market makers buy shares from smaller miners - earning virgin coins.

--
We chat on https://matrix.to/#/#p2poolv2:matrix.org[Matrix].

We use https://github.com/p2poolv2/p2poolv2/wiki[github wiki] for most design documents and tools for developers.

We are tracking progress using our https://github.com/orgs/p2poolv2/projects/1[Github project: Reboot P2Pool].

See detailed https://github.com/p2poolv2/p2poolv2/wiki/Developer-Setup-Notes[Developer Setup Notes] on the wiki.
--

== Running P2Poolv2

=== Setup Bitcoin Node

To run your local p2pool node you need to run a bitcoin node and then
a p2poolv2 node configured to talk to your bitcoind node to fetch
blocktemplates and submit blocks.

For signet we provide a `docker/bitcoin-signet.conf` that you can use
as your bitcoin.conf. We also provide a docker compose service that
will start signet bitcoind with enough blocks to start mining. If you
just want to run a signet network run bitcoin as

[,shell]
----
cd docker
docker compose up -d bitcoind
----

The important details you want from your bitcoin.conf are:

. rpcuser
. rpcpassword

Another important detail is to set your bitcoin config file to allow
for 500 coinbase outputs. This is required before we ship our atomic
swap based payout mechanism. With space to accomodate 500 miners, we
can start running P2Poolv2 with direct payments from coinbase.

For 500 P2WPKH outputs use `blockmaxweight` to 3930000.

[,config]
----
blockmaxweight=3930000
----

Finally, you need to mine 32 blocks before you can run p2poolv2 node
to talk to bitcoind. This is because BIP34 requires coinbase to
include height using varint format, which conflicts with how these
first 32 heights are encoded. The bitcoind docker service takes care
of this by bootstrapping the signet with first 32 blocks.

=== Install P2Poolv2

[,shell]
----
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/p2poolv2/p2poolv2/releases/latest/download/p2poolv2_node-installer.sh | sh
curl --proto '=https' --tlsv1.2 -LsSf -o config.toml https://github.com/p2poolv2/p2poolv2/releases/latest/download/config.sample.toml
----

The above will install `p2poolv2` and `p2poolv2_cli` in your PATH and download a `config.toml` for you to edit as required.

The location where the binaries are installed will be echoed by the installer.

[,shell]
----
p2poolv2 --help
p2poolv2_cli --help
----

=== Run P2Poolv2

. Edit the `config.toml` as required.
.. At the very least you need to provide the bitcoind rpc details under the `[bitcoinrpc]` section.
. Run P2Poolv2 `p2poolv2 config.toml`
. Point your miners to `:`

=== Enable Dashboard

P2Poolv2 includes a web dashboard for monitoring your node. The static
assets are distributed as a separate `dashboard.tar.gz` archive.

. Download and extract the dashboard assets:
+
[,shell]
----
curl --proto '=https' --tlsv1.2 -LsSf -o dashboard.tar.gz https://github.com/p2poolv2/p2poolv2/releases/latest/download/dashboard.tar.gz
tar xzf dashboard.tar.gz
----

. Set the `P2POOL_STATIC_DIR` environment variable to point to the extracted directory:
+
[,shell]
----
export P2POOL_STATIC_DIR=/path/to/static
----

. Access the dashboard at `http://:/dashboard`

If `P2POOL_STATIC_DIR` is not set, the dashboard is not available when
running from a release binary.

=== Setup Systemd Service

To setup as a systemd service, use the systemd service file provided
link:./p2poolv2@.service[p2poolv2@.service]. You can edit that service
file to require your bitcoind service, if you use one.

. Update the service file to point to where you installed your binaries. Use `which p2poolv2` to find where it is installed.
. Setup `p2poolv2` user/group.
. `/var/lib/p2poolv2`, `/var/log/p2poolv2`, `/etc/p2poolv2/` directories with permissions for p2poolv2 user.

The above service file can be used for different networks, like so:

[,shell]
----
sudo systemctl daemon-reload
sudo systemctl enable --now p2poolv2@testnet4
sudo systemctl enable --now p2poolv2@mainnet
----

=== Build From Source

==== MSRV and Edition

MSRV 1.88 with 2024 edition is required to build p2poolv2.

==== Build

. Install rust from link:https://rustup.rs/[rustup]
. Install link:https://github.com/casey/just?tab=readme-ov-file#installation[just]
. Build P2Poolv2
.. Get latest source `git clone git@github.com:p2poolv2/p2poolv2.git`
.. Build `just build-release`

==== Tests

To run CI tests locally run `just test`.

=== Docker Support

We also provide dockerfiles and a docker compose to run the node as a
docker service.

Our recommended way to run a node is using the provided installer and
using the systemd service.

If you still want to run a node using docker services, see
link:docker/README.adoc[docker/README.adoc] for details.

== API and CLI READMEs

Both the API and CLI crates provide detailed documentation on how to
use them in their individual crates.

link:p2poolv2_api/README.md[API Documentation]

link:p2poolv2_cli/README.md[CLI Documentation]