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 --- tests/core_tests/chaingen.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'tests/core_tests') diff --git a/tests/core_tests/chaingen.h b/tests/core_tests/chaingen.h index c0d31bb8a..b78640dc9 100644 --- a/tests/core_tests/chaingen.h +++ b/tests/core_tests/chaingen.h @@ -544,7 +544,7 @@ public: cryptonote::tx_verification_context tvc = AUTO_VAL_INIT(tvc); size_t pool_size = m_c.get_pool_transactions_count(); - m_c.handle_incoming_tx(t_serializable_object_to_blob(tx), tvc, m_txs_keeped_by_block, false, false); + m_c.handle_incoming_tx({t_serializable_object_to_blob(tx), crypto::null_hash}, tvc, m_txs_keeped_by_block, false, false); bool tx_added = pool_size + 1 == m_c.get_pool_transactions_count(); bool r = m_validator.check_tx_verification_context(tvc, tx_added, m_ev_index, tx); CHECK_AND_NO_ASSERT_MES(r, false, "tx verification context check failed"); @@ -555,12 +555,12 @@ public: { log_event("cryptonote::transaction"); - std::vector tx_blobs; + std::vector tx_blobs; std::vector tvcs; cryptonote::tx_verification_context tvc0 = AUTO_VAL_INIT(tvc0); for (const auto &tx: txs) { - tx_blobs.push_back(t_serializable_object_to_blob(tx)); + tx_blobs.push_back({t_serializable_object_to_blob(tx)}); tvcs.push_back(tvc0); } size_t pool_size = m_c.get_pool_transactions_count(); @@ -578,7 +578,11 @@ public: cryptonote::block_verification_context bvc = AUTO_VAL_INIT(bvc); cryptonote::blobdata bd = t_serializable_object_to_blob(b); std::vector pblocks; - if (m_c.prepare_handle_incoming_blocks(std::vector(1, {bd, {}}), pblocks)) + cryptonote::block_complete_entry bce; + bce.pruned = false; + bce.block = bd; + bce.txs = {}; + if (m_c.prepare_handle_incoming_blocks(std::vector(1, bce), pblocks)) { m_c.handle_incoming_block(bd, &b, bvc); m_c.cleanup_handle_incoming_blocks(); @@ -608,7 +612,11 @@ public: cryptonote::block_verification_context bvc = AUTO_VAL_INIT(bvc); std::vector pblocks; - if (m_c.prepare_handle_incoming_blocks(std::vector(1, {sr_block.data, {}}), pblocks)) + cryptonote::block_complete_entry bce; + bce.pruned = false; + bce.block = sr_block.data; + bce.txs = {}; + if (m_c.prepare_handle_incoming_blocks(std::vector(1, bce), pblocks)) { m_c.handle_incoming_block(sr_block.data, NULL, bvc); m_c.cleanup_handle_incoming_blocks(); -- cgit v1.2.3