monero-project / monero

Monero: the secure, private, untraceable cryptocurrency
https://getmonero.org
Other
9k stars 3.12k forks source link

Failed to parse transaction from blob #4833

Open alextrezvy opened 6 years ago

alextrezvy commented 6 years ago

The same issue as #4649, but on version 0.13.0.4 (Ubuntu, 64bit), which seems to be fixed. Is there a way to avoid of downloading of 60+GB DB?

moneromooo-monero commented 6 years ago

Bump logs (--log-level 2), see if you can see where it errors out. If you can't tell from the logs, add the following patch, which will dump the stack trace and the faulty transaction data in the logs:

diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp
index a51c2496b..04d90dc86 100644
--- a/src/cryptonote_basic/cryptonote_format_utils.cpp
+++ b/src/cryptonote_basic/cryptonote_format_utils.cpp
@@ -41,6 +41,7 @@ using namespace epee;
 #include "crypto/crypto.h"
 #include "crypto/hash.h"
 #include "ringct/rctSigs.h"
+#include "common/stack_trace.h"

 #undef MONERO_DEFAULT_LOG_CATEGORY
 #define MONERO_DEFAULT_LOG_CATEGORY "cn"
@@ -182,6 +183,11 @@ namespace cryptonote
     ss << tx_blob;
     binary_archive ba(ss);
     bool r = ::serialization::serialize(ba, tx);
+if (!r)
+{
+  MGINFO("Failed to parse tx from blob: " << epee::string_tools::buff_to_hex_nodelimer(tx_blob));
+  tools::log_stack_trace("");
+}
     CHECK_AND_ASSERT_MES(r, false, "Failed to parse transaction from blob");
     CHECK_AND_ASSERT_MES(expand_transaction_1(tx, false), false, "Failed to expand transaction data");
     tx.invalidate_hashes();
@@ -194,6 +200,11 @@ namespace cryptonote
     ss << tx_blob;
     binary_archive ba(ss);
     bool r = tx.serialize_base(ba);
+if (!r)
+{
+  MGINFO("Failed to parse tx base from blob: " << epee::string_tools::buff_to_hex_nodelimer(tx_blob));
+  tools::log_stack_trace("");
+}
     CHECK_AND_ASSERT_MES(r, false, "Failed to parse transaction from blob");
     CHECK_AND_ASSERT_MES(expand_transaction_1(tx, true), false, "Failed to expand transaction data");
     tx.invalidate_hashes();
alextrezvy commented 6 years ago

2018-11-09 18:46:45.795 7f4005796780 INFO blockchain.db.lmdb src/blockchain_db/lmdb/db_lmdb.cpp:4072 updating txs_pruned and txs_prunable tables... 2018-11-09 18:46:45.795 7f4005796780 INFO blockchain.db.lmdb src/blockchain_db/lmdb/db_lmdb.cpp:4100 updating txs tables: 2018-11-09 18:46:46.024 7f4005796780 ERROR cn src/cryptonote_basic/cryptonote_format_utils.cpp:185 Failed to parse transaction from blob 2018-11-09 18:46:46.024 7f4005796780 WARN blockchain.db.lmdb src/blockchain_db/lmdb/db_lmdb.cpp:75 Failed to parse tx from blob retrieved from the db

moneromooo-monero commented 6 years ago

OK that does look like corrupt db.

alextrezvy commented 6 years ago

What the reason made it corrupt? Previously it worked OK with 0.12.3.0. Hard disk has no errors.

iDunk5400 commented 6 years ago

Maybe you kept using v0.12.3.0 past block 1685554.

alextrezvy commented 6 years ago

Maybe you kept using v0.12.3.0 past block 1685554.

Maybe but how do I know when I must turn off the daemon? I'm not reading announcements 24/7. I suppose the software must stop running by itself before it makes a damage to the user's data. Now there is the case where I can't make a transaction before sync is finished. It might take a day or two. Is that a good motivation to run a node?

moneromooo-monero commented 5 years ago

Thankfully, there is a release at most a few days before the fork, so just looking every couple days should be enough. If you still fail to update and end up on the wrong chain, the current code will automatically get rid of the bad blocks once you update, and should then find the correct chain again.

Retia-Adolf commented 5 years ago

That sounds good. I have similar problem, it seems be caused by previous one error occurred in last year, now using current release v0.13.0.4-release but still can't resolve. Any idea? Thanks very much


**********************************************************************
You are now synchronized with the network. You may now start monero-wallet-cli.

Use the "help" command to see the list of available commands.
**********************************************************************
2018-07-01 05:51:42.241 [P2P4]  INFO    global  src/blockchain_db/lmdb/db_lmdb.cpp:588  [batch] DB resize needed
2018-07-01 05:51:42.459 [P2P4]  INFO    global  src/blockchain_db/lmdb/db_lmdb.cpp:504  LMDB Mapsize increased.  Old: 66436MiB, New: 67460MiB
2018-07-01 05:51:42.459 [P2P4]  INFO    global  src/blockchain_db/lmdb/db_lmdb.cpp:588  [batch] DB resize needed
2018-07-01 05:51:42.459 [P2P4]  INFO    global  src/blockchain_db/lmdb/db_lmdb.cpp:504  LMDB Mapsize increased.  Old: 67460MiB, New: 68484MiB
2018-07-01 06:55:35.430 [P2P7]  WARN    net.dns src/common/dns_utils.cpp:508    WARNING: no two valid MoneroPulse DNS checkpoint records were received
2018-07-01 06:55:39.623 [P2P8]  INFO    global  src/cryptonote_protocol/cryptonote_protocol_handler.inl:310 [83.43.150.180:18080 OUT] Sync data returned a new top block candidate: 1606930 -> 1606932 [Your node is 2 blocks (0 days) behind] 
SYNCHRONIZATION started
2018-07-01 06:55:40.661 [P2P9]  INFO    global  src/cryptonote_protocol/cryptonote_protocol_handler.inl:1557    SYNCHRONIZED OK
2018-07-01 07:58:38.277 [P2P1]  WARN    net.dns src/common/dns_utils.cpp:508    WARNING: no two valid MoneroPulse DNS checkpoint records were received
2018-07-01 07:58:52.512 [P2P3]  INFO    global  src/cryptonote_protocol/cryptonote_protocol_handler.inl:310 [208.102.3.17:18080 OUT] Sync data returned a new top block candidate: 1606968 -> 1606969 [Your node is 1 blocks (0 days) behind] 
SYNCHRONIZATION started
2018-07-01 07:58:54.786 [P2P2]  INFO    global  src/cryptonote_protocol/cryptonote_protocol_handler.inl:1167    [208.102.3.17:18080 OUT]  Synced 1606969/1606969
2018-07-01 07:58:54.787 [P2P2]  INFO    global  src/cryptonote_protocol/cryptonote_protocol_handler.inl:1557    SYNCHRONIZED OK
2018-07-01 08:39:26.197 [P2P3]  INFO    global  src/cryptonote_protocol/cryptonote_protocol_handler.inl:1557    SYNCHRONIZED OK
2018-07-01 09:01:03.524 [P2P3]  WARN    net.dns src/common/dns_utils.cpp:508    WARNING: no two valid MoneroPulse DNS checkpoint records were received
2018-07-01 09:01:10.589 [P2P0]  INFO    global  src/cryptonote_protocol/cryptonote_protocol_handler.inl:310 [158.69.25.71:18080 OUT] Sync data returned a new top block candidate: 1607005 -> 1607006 [Your node is 1 blocks (0 days) behind] 
SYNCHRONIZATION started
2018-07-01 09:01:13.756 [P2P7]  INFO    global  src/cryptonote_protocol/cryptonote_protocol_handler.inl:1167    [159.69.35.201:18080 OUT]  Synced 1607006/1607006
2018-07-01 09:01:13.756 [P2P7]  INFO    global  src/cryptonote_protocol/cryptonote_protocol_handler.inl:1557    SYNCHRONIZED OK
2018-07-01 09:01:13.954 [P2P7]  INFO    global  src/cryptonote_protocol/cryptonote_protocol_handler.inl:1557    SYNCHRONIZED OK
2018-07-01 10:05:57.564 [P2P3]  WARN    net.dns src/common/dns_utils.cpp:508    WARNING: no two valid MoneroPulse DNS checkpoint records were received
2018-07-01 11:08:40.590 [P2P6]  WARN    net.dns src/common/dns_utils.cpp:508    WARNING: no two valid MoneroPulse DNS checkpoint records were received
2018-07-01 11:08:43.755 [P2P5]  INFO    global  src/cryptonote_protocol/cryptonote_protocol_handler.inl:310 [95.84.156.154:18080 OUT] Sync data returned a new top block candidate: 1607085 -> 1607086 [Your node is 1 blocks (0 days) behind] 
SYNCHRONIZATION started
2018-07-01 11:08:47.081 [P2P7]  INFO    global  src/cryptonote_protocol/cryptonote_protocol_handler.inl:1167    [81.107.114.253:18080 OUT]  Synced 1607086/1607086
2018-07-01 11:08:47.081 [P2P7]  INFO    global  src/cryptonote_protocol/cryptonote_protocol_handler.inl:1557    SYNCHRONIZED OK
2018-07-01 11:08:59.230 [P2P8]  INFO    global  src/cryptonote_protocol/cryptonote_protocol_handler.inl:1557    SYNCHRONIZED OK
2018-07-01 12:14:07.420 [P2P0]  WARN    net.dns src/common/dns_utils.cpp:508    WARNING: no two valid MoneroPulse DNS checkpoint records were received
2018-07-01 12:22:02.697 [P2P3]  INFO    global  src/cryptonote_core/blockchain.cpp:1475 ----- BLOCK ADDED AS ALTERNATIVE ON HEIGHT 1599986
id: <7e79c99dd378cd2e7830170a6b0928234f0a0f2b704599f5216ee6c29888efdf>
PoW:    <0d386fa4c7a4907d2166f9caa1d27eaaf3a5862fd655332fec930b0000000000>
difficulty: 47575247869
2018-07-01 13:20:45.031 [P2P2]  WARN    net.dns src/common/dns_utils.cpp:508    WARNING: no two valid MoneroPulse DNS checkpoint records were received
2018-07-01 13:34:30.606 11568   INFO    logging contrib/epee/src/mlog.cpp:185   New log categories: *:WARNING,net:FATAL,net.p2p:FATAL,net.cn:FATAL,global:INFO,verify:FATAL,stacktrace:INFO,logging:INFO,msgwriter:INFO
2018-07-01 13:34:30.628 11568   INFO    global  src/daemon/main.cpp:280 Monero 'Lithium Luna' (v0.12.0.0-master-release)
2018-07-01 13:34:30.629 11568   INFO    global  src/daemon/protocol.h:53    Initializing cryptonote protocol...
2018-07-01 13:34:30.629 11568   INFO    global  src/daemon/protocol.h:58    Cryptonote protocol initialized OK
2018-07-01 13:34:30.631 11568   INFO    global  src/daemon/p2p.h:63 Initializing p2p server...
2018-07-01 13:34:51.769 11568   INFO    global  src/daemon/p2p.h:68 p2p server initialized OK
2018-07-01 13:34:52.071 11568   INFO    global  src/daemon/rpc.h:63 Initializing core RPC server...
2018-07-01 13:34:52.072 11568   INFO    global  contrib/epee/include/net/http_server_impl_base.h:76 Binding on 127.0.0.1:18081
2018-07-01 13:34:52.072 11568   INFO    global  src/daemon/rpc.h:69 core RPC server initialized OK on port: 18081
2018-07-01 13:34:52.072 11568   INFO    global  src/daemon/core.h:86    Initializing core...
2018-07-01 13:34:52.075 11568   INFO    global  src/cryptonote_core/cryptonote_core.cpp:427 Loading blockchain from folder E:\Blockchain\Monero\lmdb ...
2018-07-01 13:34:52.811 11568   WARN    blockchain.db.lmdb  src/blockchain_db/lmdb/db_lmdb.cpp:75   Error attempting to retrieve a hard fork version at height 0 from the db: MDB_NOTFOUND: No matching key/data pair found
2018-07-01 13:56:10.697 11568   WARN    blockchain.db.lmdb  src/blockchain_db/lmdb/db_lmdb.cpp:75   Error attempting to retrieve a block from the db
2018-07-01 13:56:10.701 11568   FATAL   daemon  src/daemon/daemon.cpp:194   Uncaught exception! Error attempting to retrieve a block from the db
2018-07-01 13:56:10.702 11568   INFO    global  src/daemon/rpc.h:96 Deinitializing core RPC server...
2018-07-01 13:56:10.711 11568   INFO    global  src/daemon/p2p.h:90 Deinitializing p2p...
2018-07-01 13:56:11.859 11568   INFO    global  src/daemon/core.h:103   Deinitializing core...
2018-07-01 13:56:12.178 11568   INFO    global  src/daemon/protocol.h:75    Stopping cryptonote protocol...
2018-07-01 13:56:12.178 11568   INFO    global  src/daemon/protocol.h:79    Cryptonote protocol stopped successfully
2019-01-16 20:40:40.691 2136    INFO    global  src/daemon/main.cpp:287 Monero 'Beryllium Bullet' (v0.13.0.4-release)
2019-01-16 20:40:40.695 2136    INFO    global  src/daemon/protocol.h:53    Initializing cryptonote protocol...
2019-01-16 20:40:40.697 2136    INFO    global  src/daemon/protocol.h:58    Cryptonote protocol initialized OK
2019-01-16 20:40:40.697 2136    INFO    global  src/daemon/p2p.h:63 Initializing p2p server...
2019-01-16 20:41:01.757 2136    INFO    global  src/daemon/p2p.h:68 p2p server initialized OK
2019-01-16 20:41:01.762 2136    INFO    global  src/daemon/rpc.h:63 Initializing core RPC server...
2019-01-16 20:41:01.763 2136    INFO    global  contrib/epee/include/net/http_server_impl_base.h:76 Binding on 127.0.0.1:18081
2019-01-16 20:41:01.764 2136    INFO    global  src/daemon/rpc.h:69 core RPC server initialized OK on port: 18081
2019-01-16 20:41:01.764 2136    INFO    global  src/daemon/core.h:86    Initializing core...
2019-01-16 20:41:01.766 2136    INFO    global  src/cryptonote_core/cryptonote_core.cpp:447 Loading blockchain from folder C:\Users\Retia\Monero\lmdb ...
2019-01-16 20:41:01.810 2136    INFO    global  src/blockchain_db/lmdb/db_lmdb.cpp:4071 Migrating blockchain from DB version 1 to 2 - this may take a while:
2019-01-16 20:41:02.345 2136    ERROR   cn  src/cryptonote_basic/cryptonote_format_utils.cpp:185    Failed to parse transaction from blob
2019-01-16 20:41:02.346 2136    WARN    blockchain.db.lmdb  src/blockchain_db/lmdb/db_lmdb.cpp:75   Failed to parse tx from blob retrieved from the db
2019-01-16 20:41:02.346 2136    ERROR   cn  src/cryptonote_core/cryptonote_core.cpp:548 Error opening database: Failed to parse tx from blob retrieved from the db
2019-01-16 20:41:02.385 2136    INFO    global  src/daemon/rpc.h:96 Deinitializing core RPC server...
2019-01-16 20:41:02.387 2136    INFO    global  src/daemon/p2p.h:90 Deinitializing p2p...
2019-01-16 20:41:03.520 2136    INFO    global  src/daemon/core.h:103   Deinitializing core...
2019-01-16 20:41:03.566 2136    ERROR   daemon  src/daemon/core.h:108   Failed to deinitialize core...
2019-01-16 20:41:03.571 2136    INFO    global  src/daemon/protocol.h:75    Stopping cryptonote protocol...
2019-01-16 20:41:03.572 2136    INFO    global  src/daemon/protocol.h:79    Cryptonote protocol stopped successfully
moneromooo-monero commented 5 years ago

Ah, it looks like it's trying to convert before popping, this is annoying. What you'd do in this case is revert to using the monerod you were using originally, then run: monero-blockchain-import --pop-blocks 61086 Then, with some luck, you'll be at height 1546000. If you're still above, pop some more blocks. If you're below, it's fine. Then update to current monerod again, and it should hopefully sync. If not, your db was probably corrupt to start with.

Retia-Adolf commented 5 years ago

@moneromooo-monero emmm... not try yet, I found I forgot to mention that it had converted for a while at a few days ago, my first using of this release.

2019-01-10 14:25:10.897 10384   INFO    logging contrib/epee/src/mlog.cpp:277   New log categories: *:WARNING,net:FATAL,net.http:FATAL,net.p2p:FATAL,net.cn:FATAL,global:INFO,verify:FATAL,stacktrace:INFO,logging:INFO,msgwriter:INFO
2019-01-10 14:25:10.899 10384   INFO    global  src/daemon/main.cpp:287 Monero 'Beryllium Bullet' (v0.13.0.4-release)
2019-01-10 14:25:10.901 10384   INFO    global  src/daemon/protocol.h:53    Initializing cryptonote protocol...
2019-01-10 14:25:10.901 10384   INFO    global  src/daemon/protocol.h:58    Cryptonote protocol initialized OK
2019-01-10 14:25:10.902 10384   INFO    global  src/daemon/p2p.h:63 Initializing p2p server...
2019-01-10 14:25:31.938 10384   INFO    global  src/daemon/p2p.h:68 p2p server initialized OK
2019-01-10 14:25:31.939 10384   INFO    global  src/daemon/rpc.h:63 Initializing core RPC server...
2019-01-10 14:25:31.940 10384   INFO    global  contrib/epee/include/net/http_server_impl_base.h:76 Binding on 127.0.0.1:18081
2019-01-10 14:25:31.941 10384   INFO    global  src/daemon/rpc.h:69 core RPC server initialized OK on port: 18081
2019-01-10 14:25:31.941 10384   INFO    global  src/daemon/core.h:86    Initializing core...
2019-01-10 14:25:31.942 10384   INFO    global  src/cryptonote_core/cryptonote_core.cpp:447 Loading blockchain from folder C:\Users\Retia\Monero\lmdb ...
2019-01-10 14:25:31.981 10384   INFO    global  src/blockchain_db/lmdb/db_lmdb.cpp:4071 Migrating blockchain from DB version 1 to 2 - this may take a while:
2019-01-10 14:55:27.000 10384   ERROR   cn  src/cryptonote_basic/cryptonote_format_utils.cpp:185    Failed to parse transaction from blob
2019-01-10 14:55:27.003 10384   WARN    blockchain.db.lmdb  src/blockchain_db/lmdb/db_lmdb.cpp:75   Failed to parse tx from blob retrieved from the db
2019-01-10 14:55:27.022 10384   ERROR   cn  src/cryptonote_core/cryptonote_core.cpp:548 Error opening database: Failed to parse tx from blob retrieved from the db
Retia-Adolf commented 5 years ago

@moneromooo-monero Forgot this again for a long time. emmm... what should I do next? ( I know that's enough for me to re-download it many times, but just ask for curious (:з)∠))

~\..\..\..\0.12.0.0  .\monero-blockchain-import --data-dir E:\monero --pop-blocks 61086
2019-08-15 18:06:24.689 13528   INFO    bcutil  src/blockchain_utilities/blockchain_import.cpp:688
        Starting...
2019-08-15 18:06:24.689 13528   INFO    bcutil  src/blockchain_utilities/blockchain_import.cpp:723
        database: lmdb
2019-08-15 18:06:24.689 13528   INFO    bcutil  src/blockchain_utilities/blockchain_import.cpp:724
        database flags: 0
2019-08-15 18:06:24.689 13528   INFO    bcutil  src/blockchain_utilities/blockchain_import.cpp:725
        verify:  true
2019-08-15 18:06:24.689 13528   INFO    bcutil  src/blockchain_utilities/blockchain_import.cpp:729
        batch:   true  batch size: 5000
2019-08-15 18:06:24.689 13528   INFO    bcutil  src/blockchain_utilities/blockchain_import.cpp:735
        resume:  true
2019-08-15 18:06:24.689 13528   INFO    bcutil  src/blockchain_utilities/blockchain_import.cpp:736
        nettype: mainnet
2019-08-15 18:06:24.689 13528   INFO    bcutil  src/blockchain_utilities/blockchain_import.cpp:738
        bootstrap file path: E:\monero\export\blockchain.raw
2019-08-15 18:06:24.689 13528   INFO    bcutil  src/blockchain_utilities/blockchain_import.cpp:739
        database path:       E:\monero
2019-08-15 18:06:24.704 13528   INFO    global  src/cryptonote_core/cryptonote_core.cpp:427     Loading blockchain from folder E:\monero\lmdb ...
2019-08-15 18:06:24.704 13528   WARN    blockchain.db.lmdb      src/blockchain_db/lmdb/db_lmdb.cpp:1181
        LMDB memory map needs to be resized, doing that now.
2019-08-15 18:06:24.704 13528   INFO    global  src/blockchain_db/lmdb/db_lmdb.cpp:504  LMDB Mapsize increased.  Old: 68484MiB, New: 69508MiB
2019-08-15 18:06:24.736 13528   WARN    blockchain.db.lmdb      src/blockchain_db/lmdb/db_lmdb.cpp:75
        Error attempting to retrieve a hard fork version at height 0 from the db: MDB_NOTFOUND: No matching key/data pair found
2019-08-15 18:06:24.736 13528   INFO    global  src/blockchain_db/lmdb/db_lmdb.cpp:588  [batch] DB resize needed
2019-08-15 18:06:24.736 13528   INFO    global  src/blockchain_db/lmdb/db_lmdb.cpp:504  LMDB Mapsize increased.  Old: 69508MiB, New: 70532MiB
2019-08-15 18:20:28.881 13528   WARN    blockchain.db.lmdb      src/blockchain_db/lmdb/db_lmdb.cpp:75
        Error attempting to retrieve a block from the db
Error loading blockchain db: Error attempting to retrieve a block from the db -- shutting down now
moneromooo-monero commented 5 years ago

At this point your db is likely corrupt. Whether it got corrupted by the upgrade process I can't tell.