Difference between revisions of "HowTo run PoP Miner"

From Veriblock Wiki
Jump to: navigation, search
Line 8: Line 8:
 
<pre>
 
<pre>
 
1. It is recommended for a single PoP Miner to at most PoP once per 10 minutes
 
1. It is recommended for a single PoP Miner to at most PoP once per 10 minutes
2. The automated PoP scheduler is temporarily disabled as a safety precaution
 
 
</pre>
 
</pre>
  

Revision as of 16:55, 18 September 2018

See: Main_Page, PoP_Miner_CommandLine, PoP_Transaction_LifeCycle, PoP_Miner_Rewards

Updates to PoP for High Noon

See: Mining_High_Noon#PoP_Miner_Update_for_High_Noon

1. It is recommended for a single PoP Miner to at most PoP once per 10 minutes

Overview

Proof-of-Proof (PoP) mining is what ultimately creates the payload to put in Bitcoin's OP_RETURN, and thereby allows an altchain to have Bitcoin-level security through VeriBlock. It is different than Proof-of-Work mining, which collects valid transactions into a block and adds that block to the blockchain.

Prerequisites

  • Send Bitcoins to your local PoP Miner's Bitcoin wallet
  • Run local NodeCore instance

Run the PoP Miner

Successful PoP Mining will look something like so:

Initially load everything:

PoP mine 1.png

Run the "mine" command:

PoP mine 2.png

Setup

Note: If you are having trouble running nodecore-pop on Linux, you may need to make nodecore-pop executable: chmod a+x nodecore-pop

Run a local instance of NodeCore

Unzip nodecore-pop-*.zip In the bin folder, if you're using Windows then run nodecore-pop.bat, if you're using Linux or macOS then run nodecore-pop

Wait a few seconds for the PoP Miner to start up. You should see something like:

===[ NodeCore Proof-of-Proof Miner v0.1.3 ]===

INFO: Connecting to NodeCore at 127.0.0.1:10501
WARN: PoP Miner: NOT READY (Could not connect to NodeCore)
WARN: PoP Miner: NOT READY (Bitcoin blockchain is not downloaded)
WARN: PoP Miner: NOT READY (Bitcoin service is not ready)
SUCCESS: Bitcoin blockchain finished downloading
INFO: Wallet loaded, current balance: 0.0 BTC
INFO: Send coins to: mit5BbeUcper58ozwbMJCxs9hWAZfRKcWk
SUCCESS: Bitcoin service is ready
SUCCESS: PoP Miner: READY
 >

Type "help" to see a list of all available commands:

 > help

Commands:
    getoperation <id>
    getpopendorsementinfo <address>
    help [command]
    listconfig
    listoperations
    mine
    quit
    resubmit <id>
    sendbitcointoaddress <address> <amount>
    setconfig <key> <value>
    showbitcoinaddress
    showbitcoinbalance

If you have zero balance, then open up a testnet wallet (or go to a BTC Testnet faucet) and send coins to the PoP BTC address (in this case "mit5BbeUcper58ozwbMJCxs9hWAZfRKcWk")

Get Bitcoin testnet coins from a faucet. Running PoP on VeriBlock testnet requires a small amount of testnet Bitcoin. You can find a list of popular Bitcoin testnet faucets here: https://en.bitcoin.it/wiki/Testnet#Faucets. Send Bitcoin from the faucet to the PoP BTC address (in this example: mit5BbeUcper58ozwbMJCxs9hWAZfRKcWk).

Before mining, you should be able to run showbitcoinbalance and see a positive balance

 > showbitcoinbalance
Bitcoin Balance: 0.049292 BTC

Mine

Simply run the "mine" command

 > mine
2018-04-18 12:29:22.215 [15dabd68] Mining operation is now: STARTED
2018-04-18 12:29:22.219 [15dabd68] Mining operation current action: Ready
2018-04-18 12:29:22.221 [15dabd68] Mining operation is now: RUNNING

*** COMMAND RESULT ***
* INFO: [V201] Mining operation started
* To view details, run command: getoperation 15dabd68
**********************

2018-04-18 12:29:22.226 [15dabd68] Mining operation current action: Getting PoP publication data
2018-04-18 12:29:22.239 [15dabd68] Received PoP mining instructions, publishing data: 00000001000000035D489E6E78F3C759BDDE71EEFB20D97A58A616B1187B6C2B666B827A2C53DCF3B766520B169C3AD22AC941C65AD77B46044AE83955448F00217C8C3562659235A15C85F155CA620C
2018-04-18 12:29:22.242 [15dabd68] Mining operation current action: Creating Bitcoin transaction containing PoP publication data
INFO: Received tx '9fb8d3f61826031749e89b6e0b940cf3a265a247691c4399ee5951d3945f15d4', new balance: '0.048938 BTC'
2018-04-18 12:29:23.937 [15dabd68] Signed Bitcoin transaction: 0100000001CFFE10EBBF7B9C30372DE738B845BFEDD533B13324ABC6E2AEFA1C79089A810E010000006A4730440220754348272F33F380D34A3E82D2005752AD6BE672EFD070AF830DD2A162D64FD00220279DFCF6849DD1712793A96B3EA0A03B0C206B58BD8B15D12DF55DE425B039CB012103086A1756BA928FE5644BE7ED595C37A72D4BD6E09A518CCA9A9A80165C351E9DFFFFFFFF0268AC4A00000000001976A914EACAE5B5B6643640FD906791F511694E0BA9AF3088AC0000000000000000536A4C5000000001000000035D489E6E78F3C759BDDE71EEFB20D97A58A616B1187B6C2B666B827A2C53DCF3B766520B169C3AD22AC941C65AD77B46044AE83955448F00217C8C3562659235A15C85F155CA620C00000000
2018-04-18 12:29:23.938 [15dabd68] Submitted Bitcoin transaction: 9fb8d3f61826031749e89b6e0b940cf3a265a247691c4399ee5951d3945f15d4
2018-04-18 12:29:23.940 [15dabd68] Mining operation current action: Waiting for transaction to be included in Bitcoin block
 >

This will show:

There can be multiple PoP Transactions at once, therefore each is given an in-session identifier, in this case "[15dabd68]". This is a temporary session ID. Ultimately the PoP Transaction will be on the VBK blockchain, and have a VBK Transaction ID.

View Status of Mining

While PoP Mining is very quick to start, it does take several confirmations on the BTC blockchain, and 500 confirmations on the VBK blockchain for payout. You can run getoperation on a session ID to see its current status:

 > getoperation 15dabd68

PoP Mining Operation: 15dabd68
    Status: RUNNING
    Current Action: CONFIRM
    PoP Publication Data: 00000001000000035D489E6E78F3C759BDDE71EEFB20D97A58A616B1187B6C2B666B827A2C53DCF3B766520B169C3AD22AC941C65AD77B46044AE83955448F00217C8C3562659235A15C85F155CA620C
    Transaction: 0100000001CFFE10EBBF7B9C30372DE738B845BFEDD533B13324ABC6E2AEFA1C79089A810E010000006A4730440220754348272F33F380D34A3E82D2005752AD6BE672EFD070AF830DD2A162D64FD00220279DFCF6849DD1712793A96B3EA0A03B0C206B58BD8B15D12DF55DE425B039CB012103086A1756BA928FE5644BE7ED595C37A72D4BD6E09A518CCA9A9A80165C351E9DFFFFFFFF0268AC4A00000000001976A914EACAE5B5B6643640FD906791F511694E0BA9AF3088AC0000000000000000536A4C5000000001000000035D489E6E78F3C759BDDE71EEFB20D97A58A616B1187B6C2B666B827A2C53DCF3B766520B169C3AD22AC941C65AD77B46044AE83955448F00217C8C3562659235A15C85F155CA620C00000000
    Transaction ID: 9fb8d3f61826031749e89b6e0b940cf3a265a247691c4399ee5951d3945f15d4
    Block Header of Proof: 00000020D22D248064ECA9D9717DDF2C532CD3681E10B1F97462FC7A6101000000000000B3503C8DF213CC4AE02D0C96D5101DBFA85C0C7A950F1684D97DB9296F3A8C65AB80D75AFFFF001D6295F16F
    Context Headers:
        000000205D98FA5CE3BB7F40BDC6B74C3A3A0334EC29F4B7FB9850882A14CF9900000000FE7CB67E7E84491F9B2C9BDD08731343EBDE6E1B08E64E18265A70D55FB4F7DCF47BD75A9B03031A171C327000
    Merkle Path: 45:D4155F94D35159EE99431C6947A265A2F30C940B6E9BE84917032618F6D3B89F:D329F111C3FCE934C19827AEAB26C9DF22E1B21A219D2914429E7DB21A187DDD:0FB383E342468E76A9E16A27E3D1DA30268AC18F6A00B9032F5C6DD5B2D026A5:C53007F949B828F7A961BD353D1CD8C494F9EBB51816020D2AC27C27F597ADBA:B3D0436C782D545E4158CC5DD713184C3BE887CE18835561BFE34DAD3E33BE65:7605554A73E2A45ED8337A3778CE9CD66B5507EF32C7511C436DAC7BAAE2D0D9:B02952E115B2D21E1E437EF3AAD263A2323D922F10E60456BC97BE2E4227F415:3F6A1039A0C31A5A7E969F7286C476E94FBA511ED75B3D1A307E4430C23770FB:50C511B2D7C76006E4E6DD3C83CAF1C895A2943F1BFCBA4455A2BD106F97CAE8
    Alternate Blocks:
 >

PoP Mining Lifecycle

Current Actions

The WAIT and CONFIRM may take a while. Other steps should be fast.

Once the PoP Miner is done, there is nothing more for it to do, check HowTo_run_PoP_Miner#viewrecentrewards to see about rewards.

Action Duration Description
READY Operation has been initialized and is ready to start
PUBLICATION_DATA Getting the publication data from NodeCore
TRANSACTION Composing and submitting the Bitcoin transaction containing the PoP publication data
WAIT "a while" Waiting and listening for new Bitcoin blocks that include the transaction
PROOF Validating the merkle path of the transaction in the block
CONTEXT Accumulating Bitcoin block headers to provide enough context to NodeCore to maintain an unbroken SPV view of the Bitcoin blockchain
SUBMIT Submitting all required proofs of the Bitcoin transaction to NodeCore (NodeCore adds a PoP transaction to mempool)
CONFIRM maybe several hours Waiting and listening for new Bitcoin blocks and transaction to confirm 20 times. Handles resubmission of PoP transaction to NodeCore if the Bitcoin blockchain should fork and previous block is no longer in the main branch.
DONE Done with mining. Check HowTo_run_PoP_Miner#viewrecentrewards for upcoming rewards


Expect this kind of flow in the log:

Note the the PoP Id (2aaef35f) given to each step.

Expect this flow:
[2aaef35f] Mining operation current action: Waiting for transaction to be included in Bitcoin block
[2aaef35f] Transaction seen in block
[2aaef35f] Setting block header of proof
[2aaef35f] Found transaction in Bitcoin block with header: 
[2aaef35f] Mining operation current action: Proving transaction included in Bitcoin block
[2aaef35f] Found Merkle path to transaction: 
[2aaef35f] Mining operation current action: Building Bitcoin context
[2aaef35f] Added 3 context headers
...
[2aaef35f] Mining operation current action: Submitting completed PoP transaction
[2aaef35f] Submitted PoP transaction: B9BC44D4E77CD5EE1E6B05B8154453EB436CC516C1DC9B9D3E22208AA2E3BC2E
[2aaef35f] Mining operation current action: Confirming Bitcoin transaction
[2aaef35f] New block added, checking confidence
[2aaef35f] Mining operation current action: Done
[2aaef35f] Mining operation is now: COMPLETE

Reference

ncpop.properties Reference

These properties can be set in the ncpop.properties file (in bin folder, located next to nodecore-pop.bat). If this file does not exist, then you can create it.

These can also be seen from running the "listconfig" command, and set with the "setconfig" command.

Config Key Default Value Comment
bitcoin.network testnet
bitcoin.fee.max 80000
bitcoin.fee.perbyte 200
nodecore.rpc.host 127.0.0.1
nodecore.rpc.port 10501
nodecore.rpc.ssl false
nodecore.rpc.password
nodecore.rpc.cert.chain.path

Sample ncpop.properties (if the file doesn't exist, you can create it)

#NodeCore PoP Miner Configuration
#
#Default configuration values are below. Uncomment to override.
#
#bitcoin.fee.max=80000
#bitcoin.fee.perbyte=200
#bitcoin.network=testnet
#nodecore.rpc.host=127.0.0.1
#nodecore.rpc.port=10501
#nodecore.rpc.ssl=false
#pop.action.timeout=90
#
#Cron expressions can be built using an online tool, such as http://www.cronmaker.com/
#Below is an example that runs a mine operation at :00 and :30 of every hour
#
#pop.cron.schedule=0 0/30 * * * ?
#

PoP Application Status Codes

Status of the PoP Miner

Status Description
STARTED
RUNNING Will most often see this state
COMPLETE
FAILED


PoP Files

These are files within the \bin folder:

  • bitcoinj.nodecore-pop.log - log file for BitcoinJ
  • bitcoin-pop-testnet.spvchain
  • bitcoin-pop-testnet.wallet --> Bitcoin testnet wallet, this contains your tBTC!
  • ncpop.properties
  • nodecore-pop --> start PoP Miner on linux
  • nodecore-pop.bat --> start PoP Miner on windows
  • veriblock.nodecore-pop.log --> log file for PoP. If you have errors with PoP mining, keep this file for troubleshooting

FAQ

How can I see my PoP rewards?

See: PoP_Miner_Rewards

Do I need to run a full Bitcoin node?

No. The PoP Miner uses the BitcoinJ library and embeds a bitcoin wallet, such that one does NOT need to run a full node to do PoP Mining.

Does the Bitcoin I send to my PoP Wallet need to be confirmed?

No. If the Bitcoin transaction with the deposit ends up being reverted, then the PoP transaction that depends on it just fails.

This also has the benefit of allowing PoP Mining immediately after a BTC deposit, without waiting for several confirmations.

How do I set the BTC transaction fee?

For "what should the BTC fee be", check: PoP_Miner_Rewards#What_should_the_tBTC_Tx_fee_be.3F. This section explains how to set the fee.

Either set it in the ncpop.properties file:

bitcoin.fee.max=800000
bitcoin.fee.perbyte=2000

Or set it via the 'setconfig' command:

setconfig bitcoin.fee.perbyte 2000
setconfig bitcoin.fee.max 800000

Note: Make sure to also set 'bitcoin.fee.max'. That is a safety cap in case many BTC transactions were involved. An average transaction may be around 300 bytes, so normally bitcoin.fee.max = 300 x bitcoin.fee.perbyte.

You can see the current fee by running the 'listconfig' command (HowTo_run_PoP_Miner#listconfig)

How to set up a cron schedule for mining

Properties file is:

pop.cron.schedule=0 0/30 * * * ?

Checkout http://www.cronmaker.com/ for help building the expression

Can I run multiple PoP Miners?

For most people you should not need to. Whereas a PoW Miner (either GPU or CPU) is limited by Hardware and processing power and electricity - i.e. run 10 PoW miners for 10x more likely chance of getting a reward - a PoP miner is limited by BTC for the transaction fee.

It will be easier for someone to manage a single instance of the PoP miner, but mine more frequently by constantly feeding it BTC for the TX fees.

BUT... if you do want to run multiple instances:

  • Option A: You'll need to put them in separate folders on the machine and use different BitcoinJ wallets. Do not run the multiple instances of the same executable with the same wallet. Each copy will have it's own set of files: HowTo_run_PoP_Miner#PoP_Files
  • Option B: You can also run multiple instances on different machines, all pointed to the same remote NodeCore instance by setting the ncpop.properties 'nodecore.rpc.host=<remote_IP_Here>' (also see [[1]] to set up NodeCore to accept connections from the remote PoP miner)

Can I import a previous BTC wallet?

Yes, just copy bin\bitcoin-pop-testnet.wallet.

This will carry over the BTC balance.

Troubleshooting

"PoP Miner not ready" warning

Warning Solution
PoP wallet does not contain sufficient funds Send Bitcoins to your PoP BTC wallet address. Run commands showbitcoinbalance (it should be greater than zero), and sendbitcointoaddress.
Could not connect to NodeCore Ensure an instance of NodeCore is running, and you could connect to it from the NC_CLI and run getinfo
Bitcoin blockchain is not downloaded Ensure the ncpop.properties file has a line for bitcoin.network=testnet, and wait for the blockchain to download. There should be a message like "Blockchain downloading: 95%".
Bitcoin service is not ready Check the other warnings. There should be a message like "SUCCESS: Bitcoin service is ready".

I do not have any bitcoin

For testnet, use a faucet to get test bitcoin. You can find a list of popular Bitcoin testnet faucets here: https://en.bitcoin.it/wiki/Testnet#Faucets.

Mining operation action took longer than expected. Operation can be resubmitted.

If you get an error, then try running the resubmit command: PoP_Miner_CommandLine#resubmit

ERROR: Mining operation action took longer than expected. Operation can be resubmitted.

PoP Transaction must complete within a certain period of time to remain relevant, and hence it times out. For example, if there's an abnormally high amount of context headers, that may cause a timeout.

Why does the BTC address change each time I run the showAddress command?

Bitcoin addresses are just a representation of the public key from a public/private key pair. We generate new key pairs every time you run the `showAddress` command. The PoP Miner manages these addresses for you, so you don't have to worry about them. As a privacy best practice, it's best to always use a new address (key pair) every time you receive a payment. The reason the PoP miner (or any Bitcoin wallet) generates a new address each time you receive a payment is for privacy reasons only, because if you use the same address for many transactions, the peers you traded with will be able to identify which other transactions you were involved in, and your identity will be easier to tie to the address. [Credit: A sentence or two for this answer may come from an unknown tech source]


Failed to get PoP publication data from NodeCore

This kind of error implies that NodeCore is not ready.

Try to connect to the NC instance with the NC_CLI and run getinfo:

Failed to get PoP publication data from NodeCore: Status{code=DEADLINE_EXCEEDED, description=deadline exceeded after 14999412514ns, cause=null}

Can you run NC_CLI getinfo?

  • Yes --> Then try to repeat the PoP miner operation.
  • No --> Troubleshoot NodeCore HowTo_run_NodeCore

Command Line Reference

clear

exit

getoperation

getoperation <id>

getpopendorsementinfo

help

listconfig

listoperations

mine

mine [blockNumber]

quit

resetwallet

NOT IMPLEMENTED YET, will be added in the future

Resets the Bitcoin wallet, marking it for resync.

   INFO: (2018-08-31 07:58:27) [V200] Success
         Wallet reset. Delete *.spvchain and restart.

resubmit

resubmit <id>

setconfig

setconfig <key> <value>

showbitcoinaddress

showbitcoinbalance

showmineraddress

viewrecentrewards

Rewards are awarded at a known block. Prior to that block, this will try to guess the amount:

{endorsed_block: 89612, projected_reward: 0.03168883, paid_in_block: 90112}

After that block it can tell the exact reward:

{endorsed_block: 89612, reward: 0.03168976, paid_in_block: 90112}

withdrawbitcointoaddress

withdrawbitcointoaddress <address> <amount>