Can I mine 256MB blocks on my RPi4

2 663
Avatar for mtrycz
Written by
3 years ago (Last updated: 2 years ago)

中文

tl;dr

No. Not yet.

But I mined a 128MB block, which is cool.

Introduction

BCH is pushing the limits of technology. While hardware improves at its own pace (and the RPi4 with 8Gb is certainly a marvelous piece of tech) the awesome folks over at BCHN have been hard at work at improving the software.

As usual, if you don't know what Scalenet is about, check out Mr Toomim's great article, and do check out the other articles in this series: 1, 2, 4.

Methodology

As usual I used my beloved RPi4

  • BCH's Scalenet

  • RaspberryPi4 (8GB version, with a 64bit OS), with a nice passive cooling case (keeps temeprature below 60C and helps with throttling)

  • an 8GB Sd card I had lying around

  • A spare 256GB NVMe SSD attached through an USB3 adapter (I upgraded my laptop to 1TB, so I found a use for this one).

  • BCHN node software (release version 23.0.0 with no particular patches)

Total cost: ~20 tx fees on the BTC network. (as of time of writing - subject to change)

I have generated transactions on my laptop with txunami and BU, and waited for them to propagate to the RPi. Tried to run cpuminer on the RPi locally.

Results

If I tried to mine a 256MB block, the software would exhaust RAM and crash.

There are several steps to the process:

  • the mining software requests a block template from the node

  • the node assembles a valid template

  • the template is transferred between the two

  • the mining software uses the template to mine

  • if a valid hash is found, it is returned back to the node, and the block is propagated

The problem here is that with 256MB worth of transactions, the block template is big. In fact, it's so big, that the RPi is likely to exhaust memory during the transfer. For example a 130MB mempool with some 500k transactions will yield a template that's 370MB. The template takes 19 seconds to generate and 26 seconds to transfer. That's inefficient.

This is one of the reasons why BCHN implemented a new feature called getblocktemplatelight last year (more info). What is does is it generates a "light" template, which takes as much time as the other template, but it transfers only the minimum amount of data that the mining software requires. As a result, the "light" template takes the same 19 seconds to generate and the transfer time is negligible (milliseconds).

Unfortunately, there is no public mining software (yet) that makes use of getblocktemplatelight. This is likely to change in the future.

So, how far it will go?

Since 256MB blocks are too high, freetrader suggested to check if smaller blocks would work. So I took out my favourite RPi for a ride.

I proudly present you the first ~128MB block mined on a Raspberry Pi.

The mining software was a little clumsy at the start, but it managed in the end. After that it was just a matter of hitting a lucky hash with the RPi's admittedly low hashrate.

Conclusion

While it is not currently practically possible because of lack of implementation in mining software, I anticipate there is no hard barrier to mine 256MB blocks on my RPi4 when it will be available.

In the meantime, the block I mined is pretty heckin big: it contains almost twice the amount of transactions that BTC has in a day.

16
$ 26.67
$ 10.00 from @codevalley
$ 5.00 from @emergent_reasons
$ 5.00 from @btcfork
+ 6
Avatar for mtrycz
Written by
3 years ago (Last updated: 2 years ago)

Comments

Total cost: ~20 tx fees on the BTC network. (as of time of writing - subject to change)

I approve this unit of account.

$ 0.00
3 years ago