tari: Merge mining proxy sometimes create wrong XMR blocks

Describe the bug I get this error from monerod v0.18.3.4 via merge mining proxy: {"error":{"code":-7,"message":"Block not accepted"},"id":"0","jsonrpc":"2.0"}

What I see in ~/.bitmonero/bitmonero.log monerod (with --log-level=1):

2025-05-08 15:57:17.959 [RPC0]  ERROR   verify  src/cryptonote_core/blockchain.cpp:1436 coinbase transaction spend too much money (0.662061490373). Block reward is 0.662060531140(0.599971351140+0.062089180000), cumulative_block_weight 302073
2025-05-08 15:57:17.959 [RPC0]  ERROR   verify  src/cryptonote_core/blockchain.cpp:4430 Block with id: <022fc65d598a2c02af684d90a543211cdbbae60fbedd931b099f0623d1443394> has incorrect miner transaction

Here is merge mining block data being submitted:

1010d1a8f3c006b8a185e055dcd04828319d00a3dd9cb3f93da82b8cdafc0cf8d647bbb425547ae39a020002cffbcf0101ff93fbcf0101c5c1c2afa213037a948d998e4dd333e1e09d32304b9ea66a8867a677208ef3b1b033bfc457aeeadd57032100763e24f14419a0cb8c2ea9b4c17b4de1b3930526bb15f79fe4f1f428fe29d81b01ff8f6433b767f5d37e98d7f450a16100106036de3e3ca10239eb52899ce39df80211000001fac3b55d00000000000000000000008501cfb41b4e4dbbb1ff7df36fb282fb7b9056499ddb83987799f02e01ad843c21aea88434c49f00cce517b44f1196d6a09edaaaf71367a57c74a609eeb03c823037516cb1b26fcb3823bf0da8c5b8e47ede57f03f906112811fafdf1373b980052eca73ec002a2c97dbaf235956b27fbbbc294475852077e53de8a0f32e96d04becb47e16d7e68da11f039d989282c3cbf2ca72e3b928187c0a8c7a630b430c532a6e49e785480dce853132cae1c146d5b13fd88e0792a29865cde2e31cbd41b1a7d039cbd60875460300ed05bbb6abff104b10fbf43428b4c838a5cc2ff48c87597840f3ec7f5e10f721f49e5dee584ee2c76bccf981cacf0e34351d1a57377b5315c086e0b48983da8ded96104ca511b0eec95d69150ae40b99dc2a19138a74cfd1dd4c1926f13914eb71ec47dcf27730fac4cd216829d16184301e5fc1ddbbdb04cab39b5ebf83bddbb04bc6f7c61d63d22551d47d56d24e3400e5b196493eb713b77dc791726087c2fd04b749a7e4c68995c64c8d52d29a24df0e0852d54950ce29af5bbabcc048fd9709cd3df6fdf8ba8138cdcda4a3c5f90a8d13698892fe760d5ed5c567704d151d0ca7599dd577a3f6ce0a8169455c34cd2af8e524a87c481ac43629faa3af0dbf9784bb7f88eb236e7e1a30fd12a73d4441aaf5c2d321191fef6e644a3cb7fdcf17ce8f5f3edd9d27449814e68ab76e92495ce2968bc7a7f5e46e8c6915c308be831e93b889f3773db5fbc037c37d42f04b8e71b7a84106d84ff42c64b58f24c4263a4bb577a82dc3f5d74f5bdf8cb42129aa76accaf0f68b101fe993e14f725c1bead2cd1418f65feae818e02b9b1ee1b89f450861a5fdac2bcded236e335bfb8c07e53ebfd3e45beb8cd22c9eb48a14ee6c38d9761c28585f87dbff43d308983475d644984b9ed4148ddbc622f6d522e7cc2e58f4928cb0f03063ea016c017148424537365cca3d62e8ed4d65183b310d2563faa0bd698761c49032f772e8b260304316380232d53f844721642a1490dc8dc36d8a8a9288ddba20fc0469daf3cb4e9ce97c9f6eb4deed49536f4a52f7b4d02f4ca92bf9e29beec7de8c3b99e38146774516d64138895ff96b1b31351fa9ed25f4efe56b6b23513340d69e9208ed193cf9dfeb680c4c50296db9195527b67a6dcd021eb7dee28c35462b8fe157744d335c2ef8696a85e75db5d8634727813e2d86e6bca9f7afbdfcd469b3ee9b3403fba9f4ff0be009f50e71abbd8f6e2ef190c5bb5e6561c6c7d66abbcd4c0e17368d1415794cfe3e305f6767740f8c80714fc36dde65a465665759f945278ffa5989197d5b0e56c47733154287672d9746722791386eadc71c58cc73211d7fc29313236ddb4dbcfb3817c5ac028e2c410139111888fa49c0642ff00f34625f9e9f9b4e7bf07a5fc4fa63bd02500da1b1d42912bb12c5da2d96578d831ab804530184527ad400bb687c41082563c0fcb8f0a27fadd7afef42310c38e52df4769836282d94d55cb550577837be9f6381d7458f240d3fd6d13a60b1edde94cdb166b0be7d2aa15cf70e7579df2b175d81f589f731d1972ba043954756b83fc8a5eb5e5a4717a2260456e20c4e5eb4beeb2623d3f2a70f003c0118c5b5e97450a4473d9cf2dc61103af84b2af186ba8648648b4156cc05f4da1f74638c6c8ddc9509de07af0ca77bc654964fa0934af802a11afb62f3b5281c44078e20056f53ca815f1e71f0bff12fad5f4c2f9617c3e04012c77142895f5e4c42196ce95703a81a0cf5a0c734be8b89e265a0dacc8182ea47e0ca153934a5e1f2b77cedf3f648933d88aef5aebdda4d7efe15fe9a17f95a1a2a30f329fd689a3b65973a1ed3f2ffb304076055dd42fa8c09d8d1dc8ecf486fac9e77d41ad5e5d9f7356a0db741475e0e81c2fb9c0ac669a8ae2d5b251007eb1f360ff49034f5f05c663f629c9b20b79bb61c9a3e126b9f2847f3883055041588b108918aaced9b35103d2e125fca119865ea158a486cbcc49ccee782a3f761d4e1dd14bf2c362d9d1249475ea9d5d632a82fe0c53f68124757680cbd4e40e5c001459fbd825b7592dd38b027f063b84e396eb628e0f43076f2c41ed3670eb5f47ad26c59bc952609d2196401c320ca5cd312c66ffd610f8e832b54d1e52fbe8f33d6e1f5eff3d2f6c6cebf78b13f8ee09751ae9974800597a3023daf4a2f643aa26d591b6a665cfd37ff538f9cf86e57bcce596c205a8eb7525c233b55648819fcf9074fd4ae505a1c436d9c5d1b3cbd88dca8da593bad981e43c64db105858241bd08acd8ab21dd61903fab7e317d1b7c5ce3a6fb7aecc8b2dcd10892288dedc4aea927c2fdc8f5948b0ec1fbc6402e25094067d99f0210307f5d1dac95fee465540d587d1d47c33dda8c737697c1c50ed1d64d1496774339e6e516d6f147584bceff19a78d2839f9c792f46bc1766d1e2f7444200a81e7aa7786fcbbab00843477f8320b09e4227d06fb5a4c79d67ec396f368293a557a495b3d7cf7add9d24e416339b694b0499144da03accaa68dffbb11e7bf5ea19d8283624f93046f5d557dd9518376b28966cfdd60d0afa170d41500ea53f720cc11112b388346b9060cc45ac9edff8a9f7d0d6ed840c5d1fc587ef5ba89f04f04347bfd6ba82ccac64a2c50d52b7eead67ac64733f5c24f1546c53e74346207e0679903cd091156fd8e53c5eb2df002913af09e82be76ec7dfad8b4d2983e5ad3ac613746fb4df95f615288f7e8a5b38da529d28896ead4e07121d199bf006ad9490508f79395889fe1264301d3b203858ef6ba9fa2ab04714a64a17f3c18133be06f3535f79833b02e063832955ef7b08ffdba669849ebde6ef16599db91579c0385a276a721e420f3563f349f56f31d775d825ea23c699e4050bb0f9dae35f0dac4eb5c8774a748834dad4398920ada079ec7d41e2294f8a1cb4dfdd0608f749bdc785b7bc376daae68bf5192358819ffd8cf336493b273655c01266e06c2d1978cd3bdb4cd43f18c153264a58e47e3d98a580422361678d7c84374444d08df6c8496ef1e8a9da9409b0b85392231068237835961cb6766efd995c0d7b825223d97ddd7ae7508abf8ebe39d451ee49b1e33046670f4a5f83a8e5db477bac39e9bde1cef5ffc659ea4540b39ae98ef22039bdb7efdf70576b8413332ed61bbd14a98593178121e6e8fc908981d731587df815f957bd4825a0c265b299bfe5b332edbcedb1ef44d0fa9bb00ae6bdeb7a2bddb465622a90d8e008b2e1ebde0494b1c4fe952a54c7a7b7d7b2f51d09dbf6d8497948b64bc00aa4170ccdb1a601b18f9b5595ab38489dccd16589150a4e58caa90dab09d659ac0b7e6dfe277281aa4f9be79c21c04da420c49fa356861e14f397cd970bf3bb5d89965412683ede58eab6e14ad5aa2a38a07c2bdb0bbf79bb39596a14593b1755267b73066c47ec6724eb28659d93f26d059f0355fa51873778c224b12ff38226820598733226868fe22eb37e47fa5332366117b7288c6d363adf7c03aa44674f1a6b13efd9c12e26f744b4be740f8c08f0bcc1e66d1f9e987d503023f24522ebdfebd51cf01a87ea540051fceb36dcee5eef3cde5a332859b01a34a2b67b721968a6a3f9696c9be77a2ce8df0112bd4321e548a72a755143c9cf1c42263c2dddf40b85179d741b7d5ff56fc9d23fb0c4b3981632d22e06c7181309c5616c581de236ab31087d7d91c7ed7a4f87cad981c32603266e92f3152ff5f5eba150ba6a7704a0eeec4467d5322d0e5816c61fc8cd8e895737a8d9642d4af6c18509625c5161f0f70ed3d803f095c2fcb4423c055aedd3f1c47af4d69db9ad484eb806ef1cf97b91b72f9273542e536505ab94b3ea5ec9257a512a12c5a1a1b6846d05ed7eb39a0f569359567c3b0b8d72d40ca9eb49999abad44f1833864c7aadb57a2b6a0765651151f0fbfb0f3e5d5aac7f5c6d86e21f254fc9f005f6c455705bc8bb710c59f17517dce8849fe4a7fed98732b88ad09d5d24f31b31545c0ff6168ae063c01740ee78593bb22ae5994dc6bf4991cdefeded76edb8af979b024e018021df83fcdc0acbad384441423149259d3a2b0c92bc177f7ee8503161cbe7a3fd26ffaefd1dbccf1af7c7bd322481cc46da486278d394fb5215e7978e432ebe44dea6334946eb69d0b704db24d1182bcfbcc93b88986d94dd7b3761d9b5a4eb2f09146d734a93b17b46bd08090b7cd5cb45d4a8527c9c9e35d3d458ec7c97551fe9c73e9c47be668af12acc5465497d4571d4944f167db38774e71c9e9615302043ae3c636d802e70de36f0a5a7db8e26d5dfe1c5dc768c730e2a20c6ecd99d9dc719f9f2e51df6e2a85f85e709cffaa027bc0cbdc5f3b5290c2fe02e2dcda4195fa31d77e59fd46f37841fc437f8b7f797c572d87e8d0555d06ec95a0a4595e02eac4487de2e0ddeb24798b2bbf4f3501d46e8990aecbdfab3c03a75eb7c9384d5be3ad65858bfe81332dc49a42fb67005f581d8307043c04ef45c1746bec95a022c04083f68b14fb8275f68419a1ecb45822099e34fdd6cc05c7b7db5c4706538fbf47c004832d5b9f46e3fd2c1250b36e74fb1bccac251f438552ff3341b9c62093c656f989e09f75369464d948b1f3c5b61f6fca08c073e66d280bd4ecfe1c0f252222323bc21d5d2b860dc1d308a81fbf34395ca8375b656f16f9101c7645d6a54c109ff56b63d77d0f207cf8ad068837aadfabc28803509815017d093cbbdfe8f82c4c54bef43a6b798b0955874b0e99802708ce3e33acde009f39879dec6fd3ac880c7a040a3cbf68e36d89c6991b12aafd9a36c399c9179543b94fad3889605c986e2b5e527a9c548e3bd70c91a273b71411685bd165896c59bc8887e3904c4fea5d622c09047e517de8d6021707f18d175978588ad10649cb5b27c5efb001224227d0b9a8a74064beacdc3fb93613c251b5a3d0c3dcbeb72d7f0f43f1984292cdb77007aea5e2c3217f5166c37876eda968bed637024ff643e029c134a16266fd1021636c0664d4b90155485378d6a3554fad8c1448fd05e5625271d87a2375f4b5fb10b3dd44f9c0db0d15e12688e5992375570e657198e472dbcef5c99763879a1355e8364b454b5b0bfb38171d16cf1ec19cd89ba7426290ffd2c65bd2afce0e45dda553bcda4c114b359c3e89c013853b5ec0615ebf3b4b524c3b4dcf365234e92e14db04f2b6b9b7865fae5d457be3ec8a4b761440d3fbc8bb4b5d0028dc282f853b6a88524783895b80225e4067a76c7ea268793fd5e85d41674c21a8cb7f862773c224afde065830f397b54766f2c8006d18bb6b8f312a470dccee023c5c61aef4b6724c7ccece393744d18c1eb7f549fc73105a2cb1c6683b88c8d0cace38e87cadc1a576d880ff95304764ed04a0c666fd58d092d3eecfd433716e71ad1a7a1073a5a372d23a40181e6ebcc84340a5fc6b4a956e95146cbb6979506d2fb6da87cb06a9838307b01d1f5b6bf9fb61de3ff3cc345a00ed37f44a304ef777fddf8acaff9ce005e9fcf81fc6574ef47aefce0411e19791c1ba22af2c7afbcc35f1117d41348dcefb8e97da5b441b77ab82a693c351379c83d3ca16984298068874e8915de86c7fc0e11baf0ff5973c6bd1c40d13e01daa90eb7f6edbb1e0306378149cc6c2f560053eb68de2240b36c38bc0bc3dce77a933f496b7a589b9d5a385c7841527ed2973ce161bedb409142fae9ca834bc3c85349462e90596ba905ac22790950f1a4218c9859bc5edd4f5d19e050c90d4906abae9f5e9dfe9edc3ab866d9d8c1a97c7b38ff87ccb2cec24c25a20106430c846078ba6a9627fcf0e5956c27944ba637d8569e02a0a923ad39641d3772b64e83340a926e1eb1da489413e33488b85d8eeaefbd250f7bb6839a988a1f7dcbd70c4c2f6b2a407db43f58073a1131d493792ff62c71bba7dca7803f2307f65c6be41761ed58388fd06bca0b267795bf2d76299dd54634d5b50

Here are more example of this same issue for other blocks:

ERROR   verify  src/cryptonote_core/blockchain.cpp:1436 coinbase transaction spend too much money (0.634277661573). Block reward is 0.634277167140(0.599992267140+0.034284900000), cumulative_block_weight 301077
ERROR   verify  src/cryptonote_core/blockchain.cpp:1436 coinbase transaction spend too much money (0.648853395493). Block reward is 0.648852232793(0.599958032793+0.048894200000), cumulative_block_weight 302509

To Reproduce Do merge mining using minotari_merge_mining_proxy and monitor XMR block submission errors.

Expected behavior No failed monerod block submissions.

Desktop (please complete the following information):

  • Ubuntu 24.04

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 26 (13 by maintainers)

Most upvoted comments

Change it to 166, not 161.

Thanks a lot. It worked, i can produce valid blocks now. But now, it’s not a good way (make empty block) to do the merge mining, do we have a good approach to that? Can we just construct blob without merge mining proxy? Also i found that the minotari_merge_mining_proxy has a memory leak…

The following fix in monerod fixes it without producing empty blocks:

diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index fb65b2b50..246b58a07 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -1686,7 +1686,8 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block,
   size_t max_outs = hf_version >= 4 ? 1 : 11;
   bool r = construct_miner_tx(height, median_weight, already_generated_coins, txs_weight, fee, miner_address, b.miner_tx, ex_nonce, max_outs, hf_version);
   CHECK_AND_ASSERT_MES(r, false, "Failed to construct miner tx, first chance");
-  size_t cumulative_weight = txs_weight + get_transaction_weight(b.miner_tx);
+#define get_transaction_weight35(miner_tx) (get_transaction_weight(miner_tx) + 35)
+  size_t cumulative_weight = txs_weight + get_transaction_weight35(b.miner_tx);
 #if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
   MDEBUG("Creating block template: miner tx weight " << get_transaction_weight(b.miner_tx) <<
       ", cumulative weight " << cumulative_weight);
@@ -1696,7 +1697,7 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block,
     r = construct_miner_tx(height, median_weight, already_generated_coins, cumulative_weight, fee, miner_address, b.miner_tx, ex_nonce, max_outs, hf_version);
 
     CHECK_AND_ASSERT_MES(r, false, "Failed to construct miner tx, second chance");
-    size_t coinbase_weight = get_transaction_weight(b.miner_tx);
+    size_t coinbase_weight = get_transaction_weight35(b.miner_tx);
     if (coinbase_weight > cumulative_weight - txs_weight)
     {
       cumulative_weight = txs_weight + coinbase_weight;
@@ -1717,11 +1718,11 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block,
 #endif
       b.miner_tx.extra.insert(b.miner_tx.extra.end(), delta, 0);
       //here  could be 1 byte difference, because of extra field counter is varint, and it can become from 1-byte len to 2-bytes len.
-      if (cumulative_weight != txs_weight + get_transaction_weight(b.miner_tx))
+      if (cumulative_weight != txs_weight + get_transaction_weight35(b.miner_tx))
       {
-        CHECK_AND_ASSERT_MES(cumulative_weight + 1 == txs_weight + get_transaction_weight(b.miner_tx), false, "unexpected case: cumulative_weight=" << cumulative_weight << " + 1 is not equal txs_cumulative_weight=" << txs_weight << " + get_transaction_weight(b.miner_tx)=" << get_transaction_weight(b.miner_tx));
+        CHECK_AND_ASSERT_MES(cumulative_weight + 1 == txs_weight + get_transaction_weight35(b.miner_tx), false, "unexpected case: cumulative_weight=" << cumulative_weight << " + 1 is not equal txs_cumulative_weight=" << txs_weight << " + get_transaction_weight(b.miner_tx)=" << get_transaction_weight(b.miner_tx));
         b.miner_tx.extra.resize(b.miner_tx.extra.size() - 1);
-        if (cumulative_weight != txs_weight + get_transaction_weight(b.miner_tx))
+        if (cumulative_weight != txs_weight + get_transaction_weight35(b.miner_tx))
         {
           //fuck, not lucky, -1 makes varint-counter size smaller, in that case we continue to grow with cumulative_weight
           MDEBUG("Miner tx creation has no luck with delta_extra size = " << delta << " and " << delta - 1);
@@ -1731,7 +1732,7 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block,
         MDEBUG("Setting extra for block: " << b.miner_tx.extra.size() << ", try_count=" << try_count);
       }
     }
-    CHECK_AND_ASSERT_MES(cumulative_weight == txs_weight + get_transaction_weight(b.miner_tx), false, "unexpected case: cumulative_weight=" << cumulative_weight << " is not equal txs_cumulative_weight=" << txs_weight << " + get_transaction_weight(b.miner_tx)=" << get_transaction_weight(b.miner_tx));
+    CHECK_AND_ASSERT_MES(cumulative_weight == txs_weight + get_transaction_weight35(b.miner_tx), false, "unexpected case: cumulative_weight=" << cumulative_weight << " is not equal txs_cumulative_weight=" << txs_weight << " + get_transaction_weight(b.miner_tx)=" << get_transaction_weight(b.miner_tx));
 #if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
     MDEBUG("Creating block template: miner tx weight " << coinbase_weight <<
         ", cumulative weight " << cumulative_weight << " is now good");

Change it to 166, not 161.

This code adds 35 weight only to coinbase transaction. Other transaction weights are added in the other place.

maybe the same issue here: https://github.com/tari-project/tari/issues/7068 It looks like forcing non-tx block template would solve the issue (just a hint for bug fixing)