1

Can anyone please tell me how to create a million blocks in regtest or testnet mode? Is there a way other than to start mining with the smallest difficulty?

2 Answers 2

5

Creating a private testnet and setting the difficulty very low is an easy way. You can start your testnet nodes passing the flag --fixed-difficulty N (where N is a very low number), so your mining node mines blocks near instantly.

There is also a new RPC command generateblocks, that can generate a bunch of blocks in regtest mode. It's currently not documented, but see the commit message. To use it, you would start monerod with the --regtest flag and the --fixed-difficulty flag (as detailed above). Then you can call the RPC interface passing the parameters: amount_of_blocks and wallet_address. For example:

curl -X POST http://127.0.0.1:18081/json_rpc -d
  '{"jsonrpc":"2.0","id":"0","method":"generateblocks","params":{
  "wallet_address":"44GBHzv...","amount_of_blocks":1000000}}' 
  -H 'Content-Type: application/json'
0

I've had some problems with mining on regtest. I was getting "status": "BUSY" whenever I wanted to /start_mining or generateblocks. In my case, the problem was that I was only running one node. It is hard to find any documentation or articles about Monero regtest, so I want to share my configuration.

First, run two monerod services.

First node:

./monerod \
    --regtest \
    --p2p-bind-ip 127.0.0.1 \
    --add-exclusive-node 127.0.0.1:28080 \
    --fixed-difficulty 1 \
    --rpc-bind-ip 0.0.0.0 \
    --confirm-external-bind

Second node:

./monerod \
    --regtest \
    --p2p-bind-ip 127.0.0.1 \
    --p2p-bind-port 28080 \
    --add-exclusive-node 127.0.0.1:18080 \
    --fixed-difficulty 1 \
    --rpc-bind-ip 0.0.0.0 \
    --rpc-bind-port 28081 \
    --zmq-rpc-bind-port 28082 \
    --confirm-external-bind

So basically you run first node with option --add-exclusive-node to restrict connection only to the second node. When starting second node, you point to the first one as its exclusive node. The rest of the config is just port settings.

After that you can also run a wallet:

./monero-wallet-rpc \
    --rpc-bind-port=18481 \
    --wallet-dir=/app/wallet \
    --rpc-login=rpcuser:rpcpassword \
    --rpc-bind-ip=0.0.0.0 \
    --confirm-external-bind 

Wallet does not have --regtest option, so you just run it as if it was using mainnet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.