From 8330e772f1ed680a54833d25c4d17d09a99ab8d6 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Mon, 16 Sep 2019 12:18:34 +0000 Subject: monerod can now sync from pruned blocks If the peer (whether pruned or not itself) supports sending pruned blocks to syncing nodes, the pruned version will be sent along with the hash of the pruned data and the block weight. The original tx hashes can be reconstructed from the pruned txes and theur prunable data hash. Those hashes and the block weights are hashes and checked against the set of precompiled hashes, ensuring the data we received is the original data. It is currently not possible to use this system when not using the set of precompiled hashes, since block weights can not otherwise be checked for validity. This is off by default for now, and is enabled by --sync-pruned-blocks --- src/blockchain_utilities/blockchain_import.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/blockchain_utilities/blockchain_import.cpp') diff --git a/src/blockchain_utilities/blockchain_import.cpp b/src/blockchain_utilities/blockchain_import.cpp index cb9154f29..bc7489a0d 100644 --- a/src/blockchain_utilities/blockchain_import.cpp +++ b/src/blockchain_utilities/blockchain_import.cpp @@ -191,7 +191,7 @@ int check_flush(cryptonote::core &core, std::vector &block } hashes.push_back(cryptonote::get_block_hash(block)); } - core.prevalidate_block_hashes(core.get_blockchain_storage().get_db().height(), hashes); + core.prevalidate_block_hashes(core.get_blockchain_storage().get_db().height(), hashes, {}); std::vector pblocks; if (!core.prepare_handle_incoming_blocks(blocks, pblocks)) @@ -217,7 +217,7 @@ int check_flush(cryptonote::core &core, std::vector &block if(tvc.m_verifivation_failed) { MERROR("transaction verification failed, tx_id = " - << epee::string_tools::pod_to_hex(get_blob_hash(tx_blob))); + << epee::string_tools::pod_to_hex(get_blob_hash(tx_blob.blob))); core.cleanup_handle_incoming_blocks(); return 1; } @@ -468,13 +468,17 @@ int import_from_file(cryptonote::core& core, const std::string& import_file_path { cryptonote::blobdata block; cryptonote::block_to_blob(bp.block, block); - std::vector txs; + std::vector txs; for (const auto &tx: bp.txs) { - txs.push_back(cryptonote::blobdata()); - cryptonote::tx_to_blob(tx, txs.back()); + txs.push_back({cryptonote::blobdata(), crypto::null_hash}); + cryptonote::tx_to_blob(tx, txs.back().blob); } - blocks.push_back({block, txs}); + block_complete_entry bce; + bce.pruned = false; + bce.block = std::move(block); + bce.txs = std::move(txs); + blocks.push_back(bce); int ret = check_flush(core, blocks, false); if (ret) { -- cgit v1.2.3