I want to build near-full blocks in regtest.
I have written a script that does the job (on bitcoin core v24.0rc3), but it's too slow to be practical for my use case:
#!/usr/bin/env bash
BCLI="./bitcoin-cli -regtest"
DAEMON="./bitcoind -regtest"
Start from a clean node
$BCLI stop
sleep 2
rm -rf ~/.bitcoin/regtest
$DAEMON
sleep 2
set -eo pipefail
$BCLI -named createwallet wallet_name="miner" load_on_startup=false
mineraddress=$($BCLI getnewaddress)
$BCLI generatetoaddress 1000 $mineraddress
i=0
time while [ $i -lt 100 ]
do
newaddress=$($BCLI getnewaddress)
$BCLI sendtoaddress $newaddress 1
i=$((i+1))
done
$BCLI generatetoaddress 1 "$mineraddress"
There are a number of problems with this script:
- It's very slow, creating just ~10 transactions per second
- It's getting slower as more txs are created
- I have to generate lots of blocks (1000 instead of eg 101) to avoid hitting the limit of 25 chained mempool transactions, which further slows down the script.
- The above script creates just 100 txs for now just to measure its performance, but in reality I'd like to make ~7000 txs or more.
Can I improve this more than by just a constant factor?