When and how to spam scalenet
Most of this article will be a step-by-step guide on how to generate spam on scalenet. But before we get to that, I would like to discuss the purpose of scalenet, and what kinds of behavior are appropriate and inappropriate on scalenet. When to spam There is a right way and a wrong way to use scalenet; a path of light, and a path of darkness. The purpose of this section is to describe the straight and narrow path of light, and the mysterious path of darkness. Scalenet is intended to be a public sandbox for testing performance-related aspects of Bitcoin Cash. It is intended to be a proving ground for new technologies, a place where people can try out weird and unexpected things and make a mess of the blockchain in an attempt to stress the limits of technology. It's the Wild West of blockchains. Here are some behaviors that are considered **acceptable** on scalenet: Testing your own software that you are running to see if you can break it Testing other people's software to see if you can break it Testing your hardware to see if you can break it Testing other people's hardware to see if you can break it Seeing how quickly you can generate spam because why not Leaving that spam around for other miners to clean up Screwing around and having fun Intentionally bloating the UTXO set to tens or hundreds of gigabytes Trying out worst-case scenarios and exploiting O(n^2) vulnerabilities Attempting 51% attack shenanigans Doing CPU mining Doing ASIC mining Forking scalenet to test new protocol upgrade code Forking scalenet because you were bored Forking scalenet because there is no spoon Using bitcoin-cli to generate a million transactions because the infinite scroll of TXIDs in terminal windows with a green font makes you feel like *The Matrix* Trying to trick your boss into thinking that you're being productive when you just want to have fun Scalenet is a pretty open an permissive environment. However, there are four important guidelines that everyone ought to follow in order to make sure that scalenet works well for everyone. The following behaviors are explicitly **discouraged** on scalenet: Asking for permission to use scalenet Not using scalenet because you don't want to disturb others Staying off of scalenet because you think you're not smart enough to participate Failing to learn because you were afraid to experiment The path of light leads to places we've already been. The path of darkness leads into the unknown. We must keep our project safe from monsters; and if we are to succeed at that, we must learn how to become monsters ourselves. Stare into the abyss and explore its depths until eventually the abyss stares back at you. How to spam Method 1: Using BCHN, bitcoin-cli, and bash Download BCHN. https://bitcoincashnode.org/en/download.html Unpack and/or install BCHN. For the rest of this guide, I will assume that you are running a Linux/Unix terminal from the folder containing your BCHN binaries. Run BCHN on scalenet: ./bitcoind -daemon -scalenet -blockmaxsize=256000000 -debug=bench Optionally, **in a separate terminal window**, watch the debug.log file: tail -f ~/.bitcoin/scalenet/debug.log Get money. You can either ask someone else (e.g. me) to give you some coins, or you can try mining a block or two with https://github.com/pooler/cpuminer. To do either, you'll first need to get a scalenet tBCH address: ./bitcoin-cli -scalenet getnewaddress should return something like`bchtest:qrfeyt384f6a29aw5uf4g5cteaumup99gqx8nmwu2j` Use that address to beg for coins, or try setting up the cpuminer to mine to that address. (I might add CPU mining instructions later.) You should now have money in your wallet. Verify that you're no longer poor: `./bitcoin-cli -scalenet getunconfirmedbalance` or `getbalance` should return something like `50.00000000` Wait until it confirms and shows up in `getbalance`, then store that amount into a BASH variable: bb=$(./bitcoin-cli -scalenet getbestblockhash) while [ $(./bitcoin-cli -scalenet getbestblockhash) == $bb ]; do sleep 1; done rootamt=$(./bitcoin-cli -scalenet getbalance) These lines of BASH will run the command encapsulated in the $(), and replace the $(...) text with the output of that command. That output then gets stored into the variables `bb` and `rootamt`. Check that it worked: `echo $rootamt` should show something like `50.00000000`. Now we're going to start generating UTXOs in a fan-out process. BCH is currently limited to 50 unconfirmed transactions in a chain. In order to make more than 50 transactions per block, you will need to be able to start with more than one UTXO in your wallet at the start of each block interval. We can do this with a fan-out process using the sendmany RPC call, which generates a single transaction with multiple specified outputs. Because we're sending money from our own wallet to our own wallet, if we make multiple transactions, there's a chance that the wallet might consume the UTXOs that the previous transaction created, so we're going to be careful to decrease the amount output in each transaction each round in order to discourage the wallet coin selection code from spending more than one input per transaction. Let's craft a transaction that sends 1/100th of our rootamt to 99 different addresses which we'll generate, with the remainder going to a change address that our wallet generates: outputcnt=100 outputamt=$(echo $rootamt | awk '{printf "%0.8f", $1 / $outputcnt}') echo $outputamt # make a json dictionary of {"address":"amount", ...} pairings outputs=$(for i in $(seq 1 99); do echo "\"$(./bitcoin-cli -scalenet getnewaddress)\":\"$outputamt\", " done) outputs=${outputs%??} # trim off the last comma and space outputs={$outputs} # Make outputs a valid json dictionary # Generate the sendmany transaction ./bitcoin-cli -scalenet sendmany "" "$outputs" Wait for that transaction to confirm, then we'll do another round to multiply our number of UTXOs by 100. To save time: bb=$(./bitcoin-cli -scalenet getbestblockhash); while [ $(./bitcoin-cli -scalenet getbestblockhash) == $bb ]; do sleep 1; done; echo Block found! outputcnt=$((outputcnt * 100)) outputamt=$(echo $rootamt $outputcnt | awk '{printf "%0.8f", $1 / $2}') echo $outputamt # make a json dictionary of {"address":"amount", ...} pairings outputs=$(for i in $(seq 1 99); do echo "\"$(./bitcoin-cli -scalenet getnewaddress)\":\"$outputamt\", " done) outputs=${outputs%??} # trim off the last comma and space outputs={$outputs} # Make outputs a valid json dictionary # Generate the sendmany transactions for i in $(seq 1 $((outputcnt/100 - 1))); do echo -n "$i " ./bitcoin-cli -scalenet sendmany "" "$outputs" done You should now have 10,000 UTXOs in your wallet. If you want more, you can repeat step 9 as many times as you want. But 10k should be enough for most mortals. You are now ready to start spamming. If you want to make 1000 transactions as quickly as you can, using a freshly generated address each time, and sending 546 satoshis (the dust limit) to each address, you can use the following command: for i in $(seq 1 1000); do echo -n "$i " ./bitcoin-cli -scalenet sendtoaddress "$(./bitcoin-cli -scalenet getnewaddress)" 0.00000546 "" "" false 2 done If you wish to improve performance you can try some of the following: Make sure your wallet.dat file (usually at `~/.bitcoin/scalenet/wallet.dat`) is stored on fast media like an SSD or a ramdisk. You can use the `./bitcoind -walletdir=<path> ...` command-line option to specify where you want the wallet to go. Keep in mind that if you use a ramdisk, you will lose your wallet and many of your coins when you reboot unless you copy your wallet back to permanent storage. An HDD or SD card will likely limit you to a generation rate of about 10 tx/sec; a SSD can get you up to around 100 tx/sec, and a RAM disk (`sudo mkdir /tmpfs; sudo mount -t tmpfs -size 4G /tmpfs`) can sometimes get you past that, especially if you: Use MR !830 and compile from source, if you know how. MR !830 with a RAM disk can usually sustain around 300 tx/sec on a decent x86 CPU. https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node/-/merge_requests/830 Reuse the same output address: address=$(./bitcoin-cli -scalenet getnewaddress) for i in $(seq 1 1000); do echo -n "$i " ./bitcoin-cli -scalenet sendtoaddress "$address" 0.00000546 "" "" false 2 done Use more computers, or run multiple nodes on the same computer to get access to multiple CPU cores. To see how your spamming is coming along, you can run `./bitcoin-cli -scalenet getmempoolinfo` or check https://sbch.loping.net/. If you've had enough, you can shut down scalenet with ./bitcoin-cli -scalenet stop ... Profit! Method 2: txVulcano txVulcano (from Flowee) might be able to work with scalenet, but I haven't tried it yet. https://flowee.org/docs/vulcano-tutorial/ Method 3: Txunami Andrew Stone of Bitcoin Unlimited has developed the Txunami tool for multithreaded spam generation. It does not save the output UTXOs, so any coins you use with Txunami will eventually be lost. https://www.bitcoinunlimited.info/blog/c004658e-7c6c-4ae1-96c6-47853aaa3f3d I have not used this tool, so I do not know how hard it would be to get it to work on scalenet. If anyone is able to get this to work, please write down how you did it. Scalenet is a fountain of chaos. May its waters remain forever turbulent.
8 comments
So what's the best thing about scalenet again? So people spam it for a good cause.
Scalenet is a BCH testnet with (currently) a 256 MB blocksize limit. It's intended as a place where people can test the performance limits of their software or hardware without needing to worry about annoying any users. Testing the software in stressful conditions helps developers learn what needs to be improved.
Awesome post, and I'm indeed very happy to see Scalenet happen. We got a [MR](https://gitlab.com/FloweeTheHub/thehub/-/merge_requests/18) last month and it is supported in `Flowee the Hub`. `Flowee TxVulcano` is likely a really fun way to generate transactions. It has its own wallet, which it saves, and is multi-threaded. Multi-threaded is useless if your full node isn't accepting them into the mempool the same, so it works in tandem with a `Flowee the Hub`. Using the latest master it was pretty darn fast. (about half a minute to fill up a 50MB block, IIRC) The only problem towards using it on scalenet is that the method of funding is currently to call 'generate'. Which won't work there. So a little update would be needed to make it accept a deposit address instead. More hardcoded numbers could be made configurable, for instance the code uses a spread-out strategy (more outputs than inputs) until a certain number of UTXOs is reached. To try and create a massive UTXO-DB this needs to be made configurable. Patches more than welcome, its code is probably a bit more messy than you'd expect, but at least its standalone and nobody will mind if stuff breaks.
Thanks, Justin Holmes! I think it's awesome that I have absolutely no idea who that is.
love your post is rich with info
this is over my head, but super cool project idea! I freaking love the crypto communities
First of all, what is scalenet?
Scalenet is a BCH testnet intended for stress-testing BCH software in high-throughput conditions.