Provider CLI
Install
CARGO_NET_GIT_FETCH_WITH_CLI=true \
cargo install --git https://oak-node.net/cgit/powwow.git pw-miner-cli
Configure
-
Benchmark your provider.
Estimate the hashrate of your hardware by running a short PoW benchmark:
pw-miner-cli benchmark -vv
-
Create the config file.
Create a local
toml
file. Useprovider-config.toml
as a starting point and adjust it where necessary:curl -O https://lab.oak-node.net/powwow/doc/trunk/crates/pw-miner-cli/provider-config.toml
Set the
hashrate
to the average hashrate found in the benchmark above. -
Fine-tune the configuration
The automine config fields determine under which conditions the provider will start mining a Client Ask:
t_max_millis = 30_000 p_min = 0.75 hashrate = 400_000 baseline_price = 100
t_max_millis
sets the upper bound for how long you are willing to mine for any solution. If a Client Ask specifies a difficulty that, given your local hashrate, would need more time than this on average, that Ask will be ignored.p_min
is the minimum probability that you will find a solution for a specific Ask in a specific timeframe, given your current hashrate. If a Client Ask has a target difficulty and a timeframe where, given your hashrate, it's less likely thanp_min
to find a solution within the given timeframe, that Ask will not be automined.hashrate
is your local hashrate, as measured in the benchmark above. All CPU cores but one will be used during mining.baseline_price
is minimum amount of sats per second of mining you are willing to accept. A client's Ask will include the target difficulty, which will indicate how many attempts are required, on average, to find a solution. Divided by your hashrate, this will give the expected mining duration for that Ask. This expected mining duration multiplied by thebaseline_price
will set your price floor for that difficulty level. If the Ask offers an amount below this, it will not be automined.Fine-tune these parameters and use
pw-miner-cli config your-provider-config.toml
to see the resulting automine thresholds. Adjust the config and re-run the command until these thresholds are acceptable.
Run
To start listening for client requests and auto-mine them:
pw-miner-cli automine your-provider-config.toml
Example: Mine local event
You will need
openssl
to create a secret keynostril
to create Nostr eventspw-miner-cli
to mine PoW locally
// 1. Create a new event with Nostril
sk=$(openssl rand -hex 32)
content="Hello world"
initial_event=$(nostril --sec "${sk}" --content "${content}")
echo "Starting with event: ${initial_event}"
// 2. Mine
difficulty=15
reconstructed_event=$(pw-miner-cli mine -d "${difficulty}" "${initial_event}")
echo "Reconstructed event with PoW (unsigned): ${reconstructed_event}"
// 3. Sign the event with Nostril
created_at=$(echo "${reconstructed_event}" | jq '.created_at')
tags=$(echo "${reconstructed_event}" | jq -c '.tags')
nostril --sec "${sk}" --content "${content}" --tags "${tags}" --created-at "${created_at}"