MELON COIN: Testing Forked Ruby Blockchain Tutorial Code with Changes

Found some more Ruby blockchain example code. So, I forked this tutorial code after making some small, needed changes to work (for me):

After minor tweaks, it works OOTB (basically):

macos$ export MELON_ROOT=/path/to/project/root
macos$ cd "$MELON_ROOT"
macos$ ruby main.rb  mine
macos$ ruby main.rb  submit_random_transactions
I, [2022-05-25T20:30:31.692511 #25497]  INFO -- : Found correct nonce: 00000b469b3d469f9b6713abbb7f992cb1f218572007d03c4789555f74660be8
I, [2022-05-25T20:30:31.721434 #25497]  INFO -- : Block 147 successfuly mined with 1 transaction 🎉
I, [2022-05-25T20:30:31.759641 #25497]  INFO -- : Looking for higher blocks on the network
I, [2022-05-25T20:30:32.787370 #25497]  INFO -- : Found correct nonce: 0000044617aa0010f6718f11dd0d71ae233213874c032e8ea21d51ee2ee11a4d
I, [2022-05-25T20:30:32.790192 #25497]  INFO -- : Block 148 successfuly mined with 1 transaction 🎉
I, [2022-05-25T20:30:32.828424 #25497]  INFO -- : Looking for higher blocks on the network
I, [2022-05-25T20:30:33.320204 #25497]  INFO -- : Found correct nonce: 00000f5267ab497d3a685ac35e2bd264fce40c0526543663ab397978378494ad
I, [2022-05-25T20:30:33.322533 #25497]  INFO -- : Block 149 successfuly mined with 1 transaction 🎉
I, [2022-05-25T20:30:33.360682 #25497]  INFO -- : Looking for higher blocks on the network
I, [2022-05-25T20:30:42.808106 #25497]  INFO -- : Found correct nonce: 00000e658c99b8bde7ada882fb6ad1ae9758b2b889f5f7f8ba99d00eb3b5230b
I, [2022-05-25T20:30:42.813675 #25497]  INFO -- : Block 150 successfuly mined with 1 transaction 🎉
I, [2022-05-25T20:30:42.851590 #25497]  INFO -- : Looking for higher blocks on the network
I, [2022-05-25T20:30:43.857597 #25497]  INFO -- : Found correct nonce: 00000a798c03796ab9277dcbcd43d6b866d2117f198d758f062269572cc74c52
I, [2022-05-25T20:30:43.860200 #25497]  INFO -- : Block 151 successfuly mined with 1 transaction 🎉
I, [2022-05-25T20:30:43.897930 #25497]  INFO -- : Looking for higher blocks on the network
I, [2022-05-25T20:30:47.163460 #25497]  INFO -- : Found correct nonce: 0000037dc09d890379886ea5e68b59e0483ea1fe6b5f2eba68e4050d4ee283fa
I, [2022-05-25T20:30:47.165779 #25497]  INFO -- : Block 152 successfuly mined with 1 transaction 🎉
I, [2022-05-25T20:30:47.204857 #25497]  INFO -- : Looking for higher blocks on the network
I, [2022-05-25T20:30:49.222507 #25497]  INFO -- : Found correct nonce: 00000920d7f8be282e766dcd5f686db577f7e262213d9d402af85a42a9513c07
I, [2022-05-25T20:30:49.225448 #25497]  INFO -- : Block 153 successfuly mined with 1 transaction 🎉
I, [2022-05-25T20:30:49.263276 #25497]  INFO -- : Looking for higher blocks on the network
I, [2022-05-25T20:30:54.367050 #25497]  INFO -- : Found correct nonce: 0000072447a1cea5a26dafa1784f81e939488f382313c6059e9250a9a0c9a9a4
I, [2022-05-25T20:30:54.369868 #25497]  INFO -- : Block 154 successfuly mined with 1 transaction 🎉
I, [2022-05-25T20:30:54.408093 #25497]  INFO -- : Looking for higher blocks on the network

References:

See Also:

Testing Melon Coin....

Found that, for some reason not yet understood, the Melon mining process keeps creating new blocks when there are no transactions on the network.

Seems to me that the mining process should not create any new block when there are no transactions.

This seems to be a Melon bug which needs to be squashed.

I think it is a "mining reward" bug as the Melon mining code is issuing a mining reward even when there are no transactions to mine.

Let's call this the "Melon Lucky Miners Bug" :slight_smile:

Update;

  • Mining rewards appear to be broken. Need to confirm this, but it appears that mining reward transactions are provided on the same reward transactions, which creates an infinite loop of miners getting rewarded on their mining rewards and so block are infinitely added to the Melon blockchain for each active minor.

  • Updated the code, wrapping the classes in modules.

When I have time, I may debug and fix the "mining rewards" bug.