Create a directory for this workshop where you'll put Bitcoin Core, SRI and configuration files.
E.g. mkdir sv2-workshop
Download Bitcoin Core v30 or later:
- https://bitcoincore.org/download
- for macOS you need the
.tar.gzdownload, not the.zip - Windows is not supported yet.
- try torrent if download is slow
No need to replace your existing node, just extract it into the workshop directory.
Sanity check:
./bitcoin-30.0/bin/bitcoin --versionBefore you run the node, create a bitcoin.conf and put it in the workshop dir:
chain=signet
[signet]
# OP_PUSHDATA1 32 sha256(sjors)
signetchallenge=4c200a7dd26236968bacb6401df5fff23e5863ad6c4949c44ac5e943f23311638994
# Allow connection from sv2-tp (Template Provider)
ipcbind=unix
# Initial peer
connect=91.98.71.169
# Fee estimation doesn't work due to empty blocks
fallbackfee=0.0001Start the node:
./bitcoin-30.0/bin/bitcoin -m node -datadir=$PWDYou should see at least 100 blocks scroll by in the log.
Open a new terminal tab to connect to your node via RPC:
./bitcoin-30.0/bin/bitcoin rpc -datadir=$PWD getblockchaininfoDepending on Wi-Fi restrictions, you may be able to connect to your neighbors:
./bitcoin-30.0/bin/bitcoin rpc -datadir=$PWD addnode 192.168.x.x onetry
./bitcoin-30.0/bin/bitcoin rpc -datadir=$PWD getpeerinfoOtherwise, any block you mine will reach your neighbors via the cloud peer.
Finally, let's create a wallet and generate an address to receive our plentiful coinbase bounty!
./bitcoin-30.0/bin/bitcoin rpc -datadir=$PWD createwallet Miner
./bitcoin-30.0/bin/bitcoin rpc -datadir=$PWD getnewaddress Pool bech32mAdd wallet=Miner to your bitcoin.conf so it's automatically loaded in the future.
Download sv2-tp or build it from source:
- https://github.com/stratum-mining/sv2-tp/releases
- extract into the workshop directory
Open a new terminal tab and sanity check it:
./sv2-tp-1.0.3/bin/sv2-tp --versionCreate an sv2-tp.conf and put it in the workshop dir:
chain=signet
[signet]
debug=sv2
loglevel=sv2:trace
# Create a new template every N seconds
sv2interval=10
# But only if fees rise by at least 1 sat
sv2feedelta=1Start the Template Provider:
./sv2-tp-1.0.3/bin/sv2-tp -datadir=$PWDYou should see the following log entry:
[sv2:info] Template Provider listening on 127.0.0.1:38336
In a new terminal tab, clone the repo:
git clone https://github.com/stratum-mining/sv2-apps.gitFirst copy the example config file:
cp sv2-apps/pool-apps/pool/config-examples/pool-config-local-tp-example.toml pool.tomlEdit the config file:
- under
coinbase_reward_scriptchange the address to the one you generated above pool_signature: pick a cool nametp_address: change the port to38336
Now let's start your pool:
cd sv2-apps/pool-apps/pool
cargo run -- -c ~/sv2-workshop/pool.tomlThe first time, it has to download a bunch of crates.
It should then connect to your template provider. You should see NewTemplate
and SetNewPrevHash in both the pool and template provider logs.
SRI comes with a Stratum v2 native CPU miner. It's not very efficient, but it should find a block within a few seconds on most laptops.
In yet another new tab:
cd sv2-apps/miner-apps/mining-device
cargo run --release -- --address-pool 127.0.0.1:34254It won't output any logs, but in the pool tab you'll see 💰 Block Found!!! 💰.
For each block, you'll see a SubmitSolution entry in the Template Provider logs.
On the node side, you'll see UpdateTip, which could be your block or it could be
another block. But you'll also see [Miner] AddToWallet with your new wealth!
If you brought a BitAxe, you can mine much faster than with a CPU. But it doesn't speak Stratum v2, so you'll first need to run a translator. Your laptop firewall and Wi-Fi network restrictions may also get in the way, but let's try...
Time for another terminal tab.
First you'll need another config file:
cp sv2-apps/miner-apps/translator/config-examples/tproxy-config-local-pool-example.toml translator.tomlAdjust min_individual_miner_hashrate for the BitAxe hash rate; it doesn't have to
be accurate, though. E.g., make it 1 TH/s: 1_000_000_000_000.0
cd sv2-apps/miner-apps/translator
cargo run -- -c ~/sv2-workshop/translator.tomlYou should see Translator Proxy: listening on 0.0.0.0:34255
Find your local IP address, e.g., ifconfig | grep 192
Log in to your BitAxe and change the pool address to 192.168.x.x:34255.
If it works, the translator and pool logs will go berserk. Once you find a few blocks, please turn it off again so we don't raise the difficulty.
If it doesn't work, check the logs. Restart the device and refresh your browser tab to see logs from the beginning.
Note: if you're on public Wi-Fi, anyone can edit your BitAxe settings and steal your precious Sjorsnet coins. When you get back home, recheck the settings!
Try to connect to your neighbor's pool and mine on it. Note that you may get rugged,
since Stratum v2 does not specify how pools should distribute their coins. Maybe
if you ask nicely, they'll use the send RPC to send your rewards (after coinbase
maturity).
Without any transactions on the network, this is kind of pointless.
But the approach is:
- the pool runs a Job Declarator Server (
pool-apps/jd-server, needs RPC access to your node) - the miner runs a Job Declarator Client (
miner-apps/jd-client)
Note that, although you get to decide which transactions go into the block, you still don't get to control who gets the coinbase reward. That goes to the pool, which then needs to distribute it.