diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 357fac0cb..ddada45bf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -89,7 +89,7 @@ add_subdirectory(ringct) add_subdirectory(checkpoints) add_subdirectory(cryptonote_basic) add_subdirectory(cryptonote_core) -add_subdirectory(fcmp) +add_subdirectory(fcmp_pp) add_subdirectory(lmdb) add_subdirectory(multisig) add_subdirectory(net) diff --git a/src/blockchain_db/blockchain_db.cpp b/src/blockchain_db/blockchain_db.cpp index 2a3e307ee..4779f680d 100644 --- a/src/blockchain_db/blockchain_db.cpp +++ b/src/blockchain_db/blockchain_db.cpp @@ -314,7 +314,7 @@ uint64_t BlockchainDB::add_block( const std::pair& blck // When adding a block, we also need to add all the leaf tuples included in // the block to a table keeping track of locked leaf tuples. Once those leaf // tuples unlock, we use them to grow the tree. - std::multimap leaf_tuples_by_unlock_block; + std::multimap leaf_tuples_by_unlock_block; // Get miner tx's leaf tuples CHECK_AND_ASSERT_THROW_MES(m_curve_trees != nullptr, "curve trees must be set"); diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h index 41fbc1e23..af6807141 100644 --- a/src/blockchain_db/blockchain_db.h +++ b/src/blockchain_db/blockchain_db.h @@ -42,7 +42,7 @@ #include "cryptonote_basic/difficulty.h" #include "cryptonote_basic/hardfork.h" #include "cryptonote_protocol/enums.h" -#include "fcmp/curve_trees.h" +#include "fcmp_pp/curve_trees.h" /** \file * Cryptonote Blockchain Database Interface @@ -418,7 +418,7 @@ private: , const uint64_t& coins_generated , uint64_t num_rct_outs , const crypto::hash& blk_hash - , const std::multimap& leaf_tuples_by_unlock_block + , const std::multimap& leaf_tuples_by_unlock_block ) = 0; /** @@ -592,7 +592,7 @@ protected: HardFork* m_hardfork; - std::shared_ptr m_curve_trees; + std::shared_ptr m_curve_trees; public: @@ -1783,7 +1783,7 @@ public: virtual bool for_all_alt_blocks(std::function f, bool include_blob = false) const = 0; // TODO: description and make private - virtual void grow_tree(std::vector &&new_leaves) = 0; + virtual void grow_tree(std::vector &&new_leaves) = 0; virtual void trim_tree(const uint64_t trim_n_leaf_tuples) = 0; diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index e5808a29c..0642c7d78 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -798,7 +798,7 @@ estim: } void BlockchainLMDB::add_block(const block& blk, size_t block_weight, uint64_t long_term_block_weight, const difficulty_type& cumulative_difficulty, const uint64_t& coins_generated, - uint64_t num_rct_outs, const crypto::hash& blk_hash, const std::multimap &leaf_tuples_by_unlock_block) + uint64_t num_rct_outs, const crypto::hash& blk_hash, const std::multimap &leaf_tuples_by_unlock_block) { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1344,7 +1344,7 @@ void BlockchainLMDB::remove_spent_key(const crypto::key_image& k_image) } } -void BlockchainLMDB::grow_tree(std::vector &&new_leaves) +void BlockchainLMDB::grow_tree(std::vector &&new_leaves) { LOG_PRINT_L3("BlockchainLMDB::" << __func__); if (new_leaves.empty()) @@ -1403,7 +1403,7 @@ void BlockchainLMDB::grow_tree(std::vector throw0(DB_ERROR(("Growing odd c2 layer, expected even layer idx for c1: " + std::to_string(layer_idx)).c_str())); - this->grow_layer(m_curve_trees->m_c2, + this->grow_layer(m_curve_trees->m_c2, c2_extensions, c2_idx, layer_idx); @@ -1416,7 +1416,7 @@ void BlockchainLMDB::grow_tree(std::vector throw0(DB_ERROR(("Growing even c1 layer, expected odd layer idx for c2: " + std::to_string(layer_idx)).c_str())); - this->grow_layer(m_curve_trees->m_c1, + this->grow_layer(m_curve_trees->m_c1, c1_extensions, c1_idx, layer_idx); @@ -1430,7 +1430,7 @@ void BlockchainLMDB::grow_tree(std::vector template void BlockchainLMDB::grow_layer(const std::unique_ptr &curve, - const std::vector> &layer_extensions, + const std::vector> &layer_extensions, const uint64_t ext_idx, const uint64_t layer_idx) { @@ -1596,7 +1596,7 @@ void BlockchainLMDB::trim_tree(const uint64_t trim_n_leaf_tuples) template void BlockchainLMDB::trim_layer(const std::unique_ptr &curve, - const fcmp::curve_trees::LayerReduction &layer_reduction, + const fcmp_pp::curve_trees::LayerReduction &layer_reduction, const uint64_t layer_idx) { LOG_PRINT_L3("BlockchainLMDB::" << __func__); @@ -1718,7 +1718,7 @@ std::array BlockchainLMDB::get_tree_root() const return root; } -fcmp::curve_trees::CurveTreesV1::LastHashes BlockchainLMDB::get_tree_last_hashes() const +fcmp_pp::curve_trees::CurveTreesV1::LastHashes BlockchainLMDB::get_tree_last_hashes() const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1726,7 +1726,7 @@ fcmp::curve_trees::CurveTreesV1::LastHashes BlockchainLMDB::get_tree_last_hashes TXN_PREFIX_RDONLY(); RCURSOR(layers) - fcmp::curve_trees::CurveTreesV1::LastHashes last_hashes; + fcmp_pp::curve_trees::CurveTreesV1::LastHashes last_hashes; auto &c1_last_hashes = last_hashes.c1_last_hashes; auto &c2_last_hashes = last_hashes.c2_last_hashes; @@ -1772,8 +1772,8 @@ fcmp::curve_trees::CurveTreesV1::LastHashes BlockchainLMDB::get_tree_last_hashes return last_hashes; } -fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim BlockchainLMDB::get_last_chunk_children_to_trim( - const std::vector &trim_instructions) const +fcmp_pp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim BlockchainLMDB::get_last_chunk_children_to_trim( + const std::vector &trim_instructions) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1783,7 +1783,7 @@ fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim BlockchainLMDB::get_las TXN_PREFIX_RDONLY(); RCURSOR(layers) - fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim last_chunk_children_to_trim; + fcmp_pp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim last_chunk_children_to_trim; auto &c1_last_children_out = last_chunk_children_to_trim.c1_children; auto &c2_last_children_out = last_chunk_children_to_trim.c2_children; @@ -1793,17 +1793,17 @@ fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim BlockchainLMDB::get_las CHECK_AND_ASSERT_THROW_MES(!trim_instructions.empty(), "no instructions"); const auto &trim_leaf_layer_instructions = trim_instructions[0]; - std::vector leaves_to_trim; + std::vector leaves_to_trim; if (trim_leaf_layer_instructions.end_trim_idx > trim_leaf_layer_instructions.start_trim_idx) { leaves_to_trim.reserve(trim_leaf_layer_instructions.end_trim_idx - trim_leaf_layer_instructions.start_trim_idx); uint64_t idx = trim_leaf_layer_instructions.start_trim_idx; - CHECK_AND_ASSERT_THROW_MES(idx % fcmp::curve_trees::CurveTreesV1::LEAF_TUPLE_SIZE == 0, + CHECK_AND_ASSERT_THROW_MES(idx % fcmp_pp::curve_trees::CurveTreesV1::LEAF_TUPLE_SIZE == 0, "expected divisble by leaf tuple size"); - const uint64_t leaf_tuple_idx = idx / fcmp::curve_trees::CurveTreesV1::LEAF_TUPLE_SIZE; + const uint64_t leaf_tuple_idx = idx / fcmp_pp::curve_trees::CurveTreesV1::LEAF_TUPLE_SIZE; MDB_val_copy k(leaf_tuple_idx); MDB_cursor_op leaf_op = MDB_SET; @@ -1817,7 +1817,7 @@ fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim BlockchainLMDB::get_las if (result != MDB_SUCCESS) throw0(DB_ERROR(lmdb_error("Failed to get leaf: ", result).c_str())); - const auto preprocessed_leaf_tuple = *(fcmp::curve_trees::PreprocessedLeafTuple *)v.mv_data; + const auto preprocessed_leaf_tuple = *(fcmp_pp::curve_trees::PreprocessedLeafTuple *)v.mv_data; // TODO: parallelize calls to this function auto leaf = m_curve_trees->leaf_tuple(preprocessed_leaf_tuple); @@ -1826,7 +1826,7 @@ fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim BlockchainLMDB::get_las leaves_to_trim.emplace_back(std::move(leaf.I_x)); leaves_to_trim.emplace_back(std::move(leaf.C_x)); - idx += fcmp::curve_trees::CurveTreesV1::LEAF_TUPLE_SIZE; + idx += fcmp_pp::curve_trees::CurveTreesV1::LEAF_TUPLE_SIZE; } while (idx < trim_leaf_layer_instructions.end_trim_idx); } @@ -1841,8 +1841,8 @@ fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim BlockchainLMDB::get_las { const auto &trim_layer_instructions = trim_instructions[i]; - std::vector c1_children; - std::vector c2_children; + std::vector c1_children; + std::vector c2_children; if (trim_layer_instructions.end_trim_idx > trim_layer_instructions.start_trim_idx) { @@ -1895,8 +1895,8 @@ fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim BlockchainLMDB::get_las return last_chunk_children_to_trim; } -fcmp::curve_trees::CurveTreesV1::LastHashes BlockchainLMDB::get_last_hashes_to_trim( - const std::vector &trim_instructions) const +fcmp_pp::curve_trees::CurveTreesV1::LastHashes BlockchainLMDB::get_last_hashes_to_trim( + const std::vector &trim_instructions) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -1904,7 +1904,7 @@ fcmp::curve_trees::CurveTreesV1::LastHashes BlockchainLMDB::get_last_hashes_to_t TXN_PREFIX_RDONLY(); RCURSOR(layers) - fcmp::curve_trees::CurveTreesV1::LastHashes last_hashes_out; + fcmp_pp::curve_trees::CurveTreesV1::LastHashes last_hashes_out; // Traverse the tree layer-by-layer starting at the layer closest to leaf layer uint64_t layer_idx = 0; @@ -1975,7 +1975,7 @@ bool BlockchainLMDB::audit_tree(const uint64_t expected_n_leaf_tuples) const while (1) { // Get next leaf chunk - std::vector leaf_tuples_chunk; + std::vector leaf_tuples_chunk; leaf_tuples_chunk.reserve(m_curve_trees->m_c2_width); // Iterate until chunk is full or we get to the end of all leaves @@ -1989,7 +1989,7 @@ bool BlockchainLMDB::audit_tree(const uint64_t expected_n_leaf_tuples) const if (result != MDB_SUCCESS) throw0(DB_ERROR(lmdb_error("Failed to add leaf: ", result).c_str())); - const auto preprocessed_leaf_tuple = *(fcmp::curve_trees::PreprocessedLeafTuple *)v.mv_data; + const auto preprocessed_leaf_tuple = *(fcmp_pp::curve_trees::PreprocessedLeafTuple *)v.mv_data; auto leaf = m_curve_trees->leaf_tuple(preprocessed_leaf_tuple); leaf_tuples_chunk.emplace_back(std::move(leaf)); @@ -2022,13 +2022,13 @@ bool BlockchainLMDB::audit_tree(const uint64_t expected_n_leaf_tuples) const // Get the expected leaf chunk hash const auto leaves = m_curve_trees->flatten_leaves(std::move(leaf_tuples_chunk)); - const fcmp::curve_trees::Selene::Chunk chunk{leaves.data(), leaves.size()}; + const fcmp_pp::curve_trees::Selene::Chunk chunk{leaves.data(), leaves.size()}; // Hash the chunk of leaves for (uint64_t i = 0; i < leaves.size(); ++i) MDEBUG("Hashing " << m_curve_trees->m_c2->to_string(leaves[i])); - const fcmp::curve_trees::Selene::Point chunk_hash = fcmp::curve_trees::get_new_parent(m_curve_trees->m_c2, chunk); + const auto chunk_hash = fcmp_pp::curve_trees::get_new_parent(m_curve_trees->m_c2, chunk); MDEBUG("chunk_hash " << m_curve_trees->m_c2->to_string(chunk_hash) << " , hash init point: " << m_curve_trees->m_c2->to_string(m_curve_trees->m_c2->hash_init_point()) << " (" << leaves.size() << " leaves)"); @@ -2173,7 +2173,7 @@ bool BlockchainLMDB::audit_layer(const std::unique_ptr &c_child, for (uint64_t i = 0; i < child_scalars.size(); ++i) MDEBUG("Hashing " << c_parent->to_string(child_scalars[i])); - const auto chunk_hash = fcmp::curve_trees::get_new_parent(c_parent, chunk); + const auto chunk_hash = fcmp_pp::curve_trees::get_new_parent(c_parent, chunk); MDEBUG("chunk_hash " << c_parent->to_string(chunk_hash) << " , hash init point: " << c_parent->to_string(c_parent->hash_init_point()) << " (" << child_scalars.size() << " children)"); @@ -2194,7 +2194,7 @@ bool BlockchainLMDB::audit_layer(const std::unique_ptr &c_child, chunk_width); } -std::vector BlockchainLMDB::get_leaf_tuples_at_unlock_block_id( +std::vector BlockchainLMDB::get_leaf_tuples_at_unlock_block_id( uint64_t block_id) { LOG_PRINT_L3("BlockchainLMDB::" << __func__); @@ -2207,7 +2207,7 @@ std::vector BlockchainLMDB::get_leaf_tuples MDB_val v_tuple; // Get all the locked outputs at the provided block id - std::vector leaf_tuples; + std::vector leaf_tuples; MDB_cursor_op op = MDB_SET; while (1) @@ -2223,8 +2223,8 @@ std::vector BlockchainLMDB::get_leaf_tuples if (blk_id != block_id) throw0(DB_ERROR(("Blk id " + std::to_string(blk_id) + " not the expected" + std::to_string(block_id)).c_str())); - const auto range_begin = ((const fcmp::curve_trees::LeafTupleContext*)v_tuple.mv_data); - const auto range_end = range_begin + v_tuple.mv_size / sizeof(fcmp::curve_trees::LeafTupleContext); + const auto range_begin = ((const fcmp_pp::curve_trees::LeafTupleContext*)v_tuple.mv_data); + const auto range_end = range_begin + v_tuple.mv_size / sizeof(fcmp_pp::curve_trees::LeafTupleContext); auto it = range_begin; @@ -2279,7 +2279,7 @@ BlockchainLMDB::~BlockchainLMDB() BlockchainLMDB::close(); } -BlockchainLMDB::BlockchainLMDB(bool batch_transactions, std::shared_ptr curve_trees): BlockchainDB() +BlockchainLMDB::BlockchainLMDB(bool batch_transactions, std::shared_ptr curve_trees): BlockchainDB() { LOG_PRINT_L3("BlockchainLMDB::" << __func__); // initialize folder to something "safe" just in case @@ -6836,7 +6836,7 @@ void BlockchainLMDB::migrate_5_6() } // Convert the output into a leaf tuple context - fcmp::curve_trees::LeafTupleContext tuple_context; + fcmp_pp::curve_trees::LeafTupleContext tuple_context; try { tuple_context = m_curve_trees->output_to_leaf_context( diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h index 2098cdc4f..30167f1a0 100644 --- a/src/blockchain_db/lmdb/db_lmdb.h +++ b/src/blockchain_db/lmdb/db_lmdb.h @@ -30,7 +30,7 @@ #include "blockchain_db/blockchain_db.h" #include "cryptonote_basic/blobdatatype.h" // for type blobdata -#include "fcmp/curve_trees.h" +#include "fcmp_pp/curve_trees.h" #include "ringct/rctTypes.h" #include @@ -194,7 +194,7 @@ struct mdb_txn_safe class BlockchainLMDB : public BlockchainDB { public: - BlockchainLMDB(bool batch_transactions=true, std::shared_ptr curve_trees = fcmp::curve_trees::curve_trees_v1()); + BlockchainLMDB(bool batch_transactions=true, std::shared_ptr curve_trees = fcmp_pp::curve_trees::curve_trees_v1()); ~BlockchainLMDB(); virtual void open(const std::string& filename, const int mdb_flags=0); @@ -368,7 +368,7 @@ public: static int compare_string(const MDB_val *a, const MDB_val *b); // make private - virtual void grow_tree(std::vector &&new_leaves); + virtual void grow_tree(std::vector &&new_leaves); virtual void trim_tree(const uint64_t trim_n_leaf_tuples); @@ -388,7 +388,7 @@ private: , const uint64_t& coins_generated , uint64_t num_rct_outs , const crypto::hash& block_hash - , const std::multimap& leaf_tuples_by_unlock_block + , const std::multimap& leaf_tuples_by_unlock_block ); virtual void remove_block(); @@ -420,26 +420,26 @@ private: template void grow_layer(const std::unique_ptr &curve, - const std::vector> &layer_extensions, + const std::vector> &layer_extensions, const uint64_t c_idx, const uint64_t layer_idx); template void trim_layer(const std::unique_ptr &curve, - const fcmp::curve_trees::LayerReduction &layer_reduction, + const fcmp_pp::curve_trees::LayerReduction &layer_reduction, const uint64_t layer_idx); virtual uint64_t get_num_leaf_tuples() const; virtual std::array get_tree_root() const; - fcmp::curve_trees::CurveTreesV1::LastHashes get_tree_last_hashes() const; + fcmp_pp::curve_trees::CurveTreesV1::LastHashes get_tree_last_hashes() const; - fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim get_last_chunk_children_to_trim( - const std::vector &trim_instructions) const; + fcmp_pp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim get_last_chunk_children_to_trim( + const std::vector &trim_instructions) const; - fcmp::curve_trees::CurveTreesV1::LastHashes get_last_hashes_to_trim( - const std::vector &trim_instructions) const; + fcmp_pp::curve_trees::CurveTreesV1::LastHashes get_last_hashes_to_trim( + const std::vector &trim_instructions) const; template bool audit_layer(const std::unique_ptr &c_child, @@ -449,7 +449,7 @@ private: const uint64_t child_chunk_idx, const uint64_t chunk_width) const; - std::vector get_leaf_tuples_at_unlock_block_id(uint64_t block_id); + std::vector get_leaf_tuples_at_unlock_block_id(uint64_t block_id); void del_locked_leaf_tuples_at_block_id(uint64_t block_id); diff --git a/src/blockchain_db/testdb.h b/src/blockchain_db/testdb.h index 33635a04b..81317b6a2 100644 --- a/src/blockchain_db/testdb.h +++ b/src/blockchain_db/testdb.h @@ -116,7 +116,7 @@ public: virtual void add_tx_amount_output_indices(const uint64_t tx_index, const std::vector& amount_output_indices) override {} virtual void add_spent_key(const crypto::key_image& k_image) override {} virtual void remove_spent_key(const crypto::key_image& k_image) override {} - virtual void grow_tree(std::vector &&new_leaves) override {}; + virtual void grow_tree(std::vector &&new_leaves) override {}; virtual void trim_tree(const uint64_t trim_n_leaf_tuples) override {}; virtual bool audit_tree(const uint64_t expected_n_leaf_tuples) const override { return false; }; virtual std::array get_tree_root() const override { return {}; }; @@ -149,7 +149,7 @@ public: , const uint64_t& coins_generated , uint64_t num_rct_outs , const crypto::hash& blk_hash - , const std::multimap& leaf_tuples_by_unlock_block + , const std::multimap& leaf_tuples_by_unlock_block ) override { } virtual cryptonote::block get_block_from_height(const uint64_t& height) const override { return cryptonote::block(); } virtual void set_hard_fork_version(uint64_t height, uint8_t version) override {} diff --git a/src/blockchain_utilities/CMakeLists.txt b/src/blockchain_utilities/CMakeLists.txt index a41cd1e53..d6257ef99 100644 --- a/src/blockchain_utilities/CMakeLists.txt +++ b/src/blockchain_utilities/CMakeLists.txt @@ -141,6 +141,7 @@ target_link_libraries(blockchain_import PRIVATE cryptonote_core blockchain_db + fcmp_pp version epee ${Boost_FILESYSTEM_LIBRARY} diff --git a/src/fcmp/CMakeLists.txt b/src/fcmp_pp/CMakeLists.txt similarity index 94% rename from src/fcmp/CMakeLists.txt rename to src/fcmp_pp/CMakeLists.txt index 8f37e9b74..33d428f82 100644 --- a/src/fcmp/CMakeLists.txt +++ b/src/fcmp_pp/CMakeLists.txt @@ -32,11 +32,11 @@ set(fcmp_pp_sources monero_find_all_headers(fcmp_pp_headers "${CMAKE_CURRENT_SOURCE_DIR}") -add_subdirectory(fcmp_rust) +add_subdirectory(fcmp_pp_rust) monero_add_library_with_deps( NAME fcmp_pp - DEPENDS fcmp_rust + DEPENDS fcmp_pp_rust SOURCES ${fcmp_pp_sources} ${fcmp_pp_headers}) @@ -54,6 +54,6 @@ target_link_libraries(fcmp_pp epee ringct PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/fcmp_rust/libfcmp_rust.a + ${CMAKE_CURRENT_BINARY_DIR}/fcmp_pp_rust/libfcmp_pp_rust.a ${EXTRA_LIBRARIES} ${EXTRA_RUST_LIBRARIES}) diff --git a/src/fcmp/curve_trees.cpp b/src/fcmp_pp/curve_trees.cpp similarity index 99% rename from src/fcmp/curve_trees.cpp rename to src/fcmp_pp/curve_trees.cpp index b2e8b3ebc..50f354a9e 100644 --- a/src/fcmp/curve_trees.cpp +++ b/src/fcmp_pp/curve_trees.cpp @@ -31,7 +31,7 @@ #include "ringct/rctOps.h" -namespace fcmp +namespace fcmp_pp { namespace curve_trees { @@ -549,7 +549,7 @@ static TrimLayerInstructions get_trim_layer_instructions( } //---------------------------------------------------------------------------------------------------------------------- template -static typename fcmp::curve_trees::LayerReduction get_next_layer_reduction( +static typename fcmp_pp::curve_trees::LayerReduction get_next_layer_reduction( const std::unique_ptr &c_child, const std::unique_ptr &c_parent, const TrimLayerInstructions &trim_layer_instructions, @@ -1028,4 +1028,4 @@ GrowLayerInstructions CurveTrees::set_next_layer_extension( //---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------- } //namespace curve_trees -} //namespace fcmp +} //namespace fcmp_pp diff --git a/src/fcmp/curve_trees.h b/src/fcmp_pp/curve_trees.h similarity index 99% rename from src/fcmp/curve_trees.h rename to src/fcmp_pp/curve_trees.h index e70d51277..3ca9e332a 100644 --- a/src/fcmp/curve_trees.h +++ b/src/fcmp_pp/curve_trees.h @@ -38,7 +38,7 @@ #include -namespace fcmp +namespace fcmp_pp { namespace curve_trees { @@ -309,4 +309,4 @@ std::shared_ptr curve_trees_v1( //---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------- } //namespace curve_trees -} //namespace fcmp +} //namespace fcmp_pp diff --git a/src/fcmp/fcmp_rust/.gitignore b/src/fcmp_pp/fcmp_pp_rust/.gitignore similarity index 100% rename from src/fcmp/fcmp_rust/.gitignore rename to src/fcmp_pp/fcmp_pp_rust/.gitignore diff --git a/src/fcmp/fcmp_rust/CMakeLists.txt b/src/fcmp_pp/fcmp_pp_rust/CMakeLists.txt similarity index 95% rename from src/fcmp/fcmp_rust/CMakeLists.txt rename to src/fcmp_pp/fcmp_pp_rust/CMakeLists.txt index 457f44740..646fc6981 100644 --- a/src/fcmp/fcmp_rust/CMakeLists.txt +++ b/src/fcmp_pp/fcmp_pp_rust/CMakeLists.txt @@ -93,9 +93,9 @@ else () set(TARGET_DIR "release") endif () -set(FCMP_PP_RUST_HEADER_DIR "${MONERO_GENERATED_HEADERS_DIR}/fcmp_rust") +set(FCMP_PP_RUST_HEADER_DIR "${MONERO_GENERATED_HEADERS_DIR}/fcmp_pp_rust") set(FCMP_PP_RUST_HEADER "${FCMP_PP_RUST_HEADER_DIR}/fcmp++.h") -set(FCMP_PP_RUST_LIB "${CMAKE_CURRENT_BINARY_DIR}/libfcmp_rust.a") +set(FCMP_PP_RUST_LIB "${CMAKE_CURRENT_BINARY_DIR}/libfcmp_pp_rust.a") # Removing OUTPUT files makes sure custom command runs every time file(REMOVE_RECURSE "${FCMP_PP_RUST_HEADER_DIR}") @@ -109,10 +109,10 @@ add_custom_command( OUTPUT ${FCMP_PP_RUST_LIB} COMMAND CARGO_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR} ${CARGO_CMD} COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/fcmp++.h ${FCMP_PP_RUST_HEADER} - COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/${RUST_TARGET}/${TARGET_DIR}/libfcmp_rust.a ${FCMP_PP_RUST_LIB} + COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/${RUST_TARGET}/${TARGET_DIR}/libfcmp_pp_rust.a ${FCMP_PP_RUST_LIB} COMMAND echo "Finished copying fcmp++ rust targets" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} VERBATIM ) -add_custom_target(fcmp_rust DEPENDS ${FCMP_PP_RUST_LIB}) +add_custom_target(fcmp_pp_rust DEPENDS ${FCMP_PP_RUST_LIB}) diff --git a/src/fcmp/fcmp_rust/Cargo.lock b/src/fcmp_pp/fcmp_pp_rust/Cargo.lock similarity index 99% rename from src/fcmp/fcmp_rust/Cargo.lock rename to src/fcmp_pp/fcmp_pp_rust/Cargo.lock index 196a2a39d..742b6570e 100644 --- a/src/fcmp/fcmp_rust/Cargo.lock +++ b/src/fcmp_pp/fcmp_pp_rust/Cargo.lock @@ -239,7 +239,7 @@ dependencies = [ ] [[package]] -name = "fcmp_rust" +name = "fcmp_pp_rust" version = "0.0.0" dependencies = [ "ciphersuite", diff --git a/src/fcmp/fcmp_rust/Cargo.toml b/src/fcmp_pp/fcmp_pp_rust/Cargo.toml similarity index 95% rename from src/fcmp/fcmp_rust/Cargo.toml rename to src/fcmp_pp/fcmp_pp_rust/Cargo.toml index 21573b824..65a487a0c 100644 --- a/src/fcmp/fcmp_rust/Cargo.toml +++ b/src/fcmp_pp/fcmp_pp_rust/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "fcmp_rust" +name = "fcmp_pp_rust" version = "0.0.0" edition = "2021" [lib] -name = "fcmp_rust" +name = "fcmp_pp_rust" crate-type = ["staticlib"] [dependencies] diff --git a/src/fcmp/fcmp_rust/fcmp++.h b/src/fcmp_pp/fcmp_pp_rust/fcmp++.h similarity index 100% rename from src/fcmp/fcmp_rust/fcmp++.h rename to src/fcmp_pp/fcmp_pp_rust/fcmp++.h diff --git a/src/fcmp/fcmp_rust/src/lib.rs b/src/fcmp_pp/fcmp_pp_rust/src/lib.rs similarity index 100% rename from src/fcmp/fcmp_rust/src/lib.rs rename to src/fcmp_pp/fcmp_pp_rust/src/lib.rs diff --git a/src/fcmp/proof.h b/src/fcmp_pp/proof.h similarity index 94% rename from src/fcmp/proof.h rename to src/fcmp_pp/proof.h index 63e7cfa10..f01cdb267 100644 --- a/src/fcmp/proof.h +++ b/src/fcmp_pp/proof.h @@ -30,16 +30,16 @@ #include -namespace fcmp +namespace fcmp_pp { // Byte buffer containing the fcmp++ proof using FcmpPpProof = std::vector; -static inline std::size_t fcmp_pp_len(const std::size_t n_inputs) +static inline std::size_t proof_len(const std::size_t n_inputs) { // TODO: implement return n_inputs * 4; }; -}//namespace fcmp +}//namespace fcmp_pp diff --git a/src/fcmp/tower_cycle.cpp b/src/fcmp_pp/tower_cycle.cpp similarity index 99% rename from src/fcmp/tower_cycle.cpp rename to src/fcmp_pp/tower_cycle.cpp index bb2e207e8..9cb35af1f 100644 --- a/src/fcmp/tower_cycle.cpp +++ b/src/fcmp_pp/tower_cycle.cpp @@ -29,7 +29,7 @@ #include "string_tools.h" #include "tower_cycle.h" -namespace fcmp +namespace fcmp_pp { namespace tower_cycle { @@ -280,4 +280,4 @@ template void extend_scalars_from_cycle_points(const std::unique //---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------- } //namespace tower_cycle -} //namespace fcmp +} //namespace fcmp_pp diff --git a/src/fcmp/tower_cycle.h b/src/fcmp_pp/tower_cycle.h similarity index 99% rename from src/fcmp/tower_cycle.h rename to src/fcmp_pp/tower_cycle.h index e7b9fb701..8ab69f902 100644 --- a/src/fcmp/tower_cycle.h +++ b/src/fcmp_pp/tower_cycle.h @@ -29,12 +29,12 @@ #pragma once #include "crypto/crypto.h" -#include "fcmp_rust/fcmp++.h" +#include "fcmp_pp_rust/fcmp++.h" #include "ringct/rctTypes.h" #include -namespace fcmp +namespace fcmp_pp { namespace tower_cycle { @@ -188,4 +188,4 @@ void extend_scalars_from_cycle_points(const std::unique_ptr &curve, //---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------- }//namespace tower_cycle -}//namespace fcmp +}//namespace fcmp_pp diff --git a/src/ringct/rctTypes.h b/src/ringct/rctTypes.h index 45d52f950..d00902512 100644 --- a/src/ringct/rctTypes.h +++ b/src/ringct/rctTypes.h @@ -45,7 +45,7 @@ extern "C" { } #include "crypto/generic-ops.h" #include "crypto/crypto.h" -#include "fcmp/proof.h" +#include "fcmp_pp/proof.h" #include "hex.h" #include "span.h" #include "memwipe.h" @@ -426,7 +426,7 @@ namespace rct { std::vector MGs; // simple rct has N, full has 1 std::vector CLSAGs; keyV pseudoOuts; //C - for simple rct - fcmp::FcmpPpProof fcmp_pp; + fcmp_pp::FcmpPpProof fcmp_pp; // when changing this function, update cryptonote::get_pruned_transaction_weight template class Archive> @@ -503,7 +503,7 @@ namespace rct { { ar.tag("fcmp_pp"); ar.begin_object(); - const std::size_t proof_len = fcmp::fcmp_pp_len(inputs); + const std::size_t proof_len = fcmp_pp::proof_len(inputs); if (!typename Archive::is_saving()) fcmp_pp.resize(proof_len); if (fcmp_pp.size() != proof_len) diff --git a/tests/block_weight/block_weight.cpp b/tests/block_weight/block_weight.cpp index 81caa945d..dfcc4580c 100644 --- a/tests/block_weight/block_weight.cpp +++ b/tests/block_weight/block_weight.cpp @@ -32,7 +32,7 @@ #include #include "cryptonote_core/cryptonote_core.h" #include "blockchain_db/testdb.h" -#include "fcmp/curve_trees.h" +#include "fcmp_pp/curve_trees.h" #define LONG_TERM_BLOCK_WEIGHT_WINDOW 5000 @@ -65,7 +65,7 @@ public: , const uint64_t& coins_generated , uint64_t num_rct_outs , const crypto::hash& blk_hash - , const std::multimap& leaf_tuples_by_unlock_block + , const std::multimap& leaf_tuples_by_unlock_block ) override { blocks.push_back({block_weight, long_term_block_weight}); } diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp index 376cdcc6a..dfab14252 100644 --- a/tests/core_tests/chaingen.cpp +++ b/tests/core_tests/chaingen.cpp @@ -88,7 +88,7 @@ namespace , const uint64_t& coins_generated , uint64_t num_rct_outs , const crypto::hash& blk_hash - , const std::multimap& leaf_tuples_by_unlock_block + , const std::multimap& leaf_tuples_by_unlock_block ) override { blocks.push_back({blk, blk_hash}); diff --git a/tests/unit_tests/curve_trees.cpp b/tests/unit_tests/curve_trees.cpp index c2e9e40cf..650c75bcb 100644 --- a/tests/unit_tests/curve_trees.cpp +++ b/tests/unit_tests/curve_trees.cpp @@ -62,7 +62,7 @@ static bool validate_layer(const std::unique_ptr &curve, for (std::size_t i = 0; i < chunk_size; ++i) MDEBUG("Hashing " << curve->to_string(chunk_start[i])); - const typename C::Point chunk_hash = fcmp::curve_trees::get_new_parent(curve, chunk); + const typename C::Point chunk_hash = fcmp_pp::curve_trees::get_new_parent(curve, chunk); MDEBUG("chunk_start_idx: " << chunk_start_idx << " , chunk_size: " << chunk_size << " , chunk_hash: " << curve->to_string(chunk_hash)); @@ -193,7 +193,7 @@ void CurveTreesGlobalTree::extend_tree(const CurveTreesV1::TreeExtension &tree_e if (use_c2) { CHECK_AND_ASSERT_THROW_MES(c2_idx < c2_extensions.size(), "unexpected c2 layer extension"); - const fcmp::curve_trees::LayerExtension &c2_ext = c2_extensions[c2_idx]; + const fcmp_pp::curve_trees::LayerExtension &c2_ext = c2_extensions[c2_idx]; CHECK_AND_ASSERT_THROW_MES(!c2_ext.hashes.empty(), "empty c2 layer extension"); @@ -226,7 +226,7 @@ void CurveTreesGlobalTree::extend_tree(const CurveTreesV1::TreeExtension &tree_e else { CHECK_AND_ASSERT_THROW_MES(c1_idx < c1_extensions.size(), "unexpected c1 layer extension"); - const fcmp::curve_trees::LayerExtension &c1_ext = c1_extensions[c1_idx]; + const fcmp_pp::curve_trees::LayerExtension &c1_ext = c1_extensions[c1_idx]; CHECK_AND_ASSERT_THROW_MES(!c1_ext.hashes.empty(), "empty c1 layer extension"); @@ -338,7 +338,7 @@ void CurveTreesGlobalTree::reduce_tree(const CurveTreesV1::TreeReduction &tree_r //---------------------------------------------------------------------------------------------------------------------- // TODO: template CurveTreesV1::LastChunkChildrenToTrim CurveTreesGlobalTree::get_all_last_chunk_children_to_trim( - const std::vector &trim_instructions) + const std::vector &trim_instructions) { CurveTreesV1::LastChunkChildrenToTrim all_children_to_trim; @@ -424,7 +424,7 @@ CurveTreesV1::LastChunkChildrenToTrim CurveTreesGlobalTree::get_all_last_chunk_c } //---------------------------------------------------------------------------------------------------------------------- CurveTreesV1::LastHashes CurveTreesGlobalTree::get_last_hashes_to_trim( - const std::vector &trim_instructions) const + const std::vector &trim_instructions) const { CurveTreesV1::LastHashes last_hashes; CHECK_AND_ASSERT_THROW_MES(!trim_instructions.empty(), "no instructions"); @@ -532,7 +532,7 @@ bool CurveTreesGlobalTree::audit_tree(const std::size_t expected_n_leaf_tuples) CHECK_AND_ASSERT_MES(!children.empty(), false, "no children at c1_idx " + std::to_string(c1_idx)); std::vector child_scalars; - fcmp::tower_cycle::extend_scalars_from_cycle_points(m_curve_trees.m_c1, + fcmp_pp::tower_cycle::extend_scalars_from_cycle_points(m_curve_trees.m_c1, children, child_scalars); @@ -559,7 +559,7 @@ bool CurveTreesGlobalTree::audit_tree(const std::size_t expected_n_leaf_tuples) CHECK_AND_ASSERT_MES(!children.empty(), false, "no children at c2_idx " + std::to_string(c2_idx)); std::vector child_scalars; - fcmp::tower_cycle::extend_scalars_from_cycle_points(m_curve_trees.m_c2, + fcmp_pp::tower_cycle::extend_scalars_from_cycle_points(m_curve_trees.m_c2, children, child_scalars); @@ -660,7 +660,7 @@ void CurveTreesGlobalTree::log_tree_extension(const CurveTreesV1::TreeExtension { CHECK_AND_ASSERT_THROW_MES(c2_idx < c2_extensions.size(), "unexpected c2 layer"); - const fcmp::curve_trees::LayerExtension &c2_layer = c2_extensions[c2_idx]; + const fcmp_pp::curve_trees::LayerExtension &c2_layer = c2_extensions[c2_idx]; MDEBUG("Selene tree extension start idx: " << c2_layer.start_idx); for (std::size_t j = 0; j < c2_layer.hashes.size(); ++j) @@ -673,7 +673,7 @@ void CurveTreesGlobalTree::log_tree_extension(const CurveTreesV1::TreeExtension { CHECK_AND_ASSERT_THROW_MES(c1_idx < c1_extensions.size(), "unexpected c1 layer"); - const fcmp::curve_trees::LayerExtension &c1_layer = c1_extensions[c1_idx]; + const fcmp_pp::curve_trees::LayerExtension &c1_layer = c1_extensions[c1_idx]; MDEBUG("Helios tree extension start idx: " << c1_layer.start_idx); for (std::size_t j = 0; j < c1_layer.hashes.size(); ++j) @@ -743,11 +743,11 @@ void CurveTreesGlobalTree::log_tree() //---------------------------------------------------------------------------------------------------------------------- // Test helpers //---------------------------------------------------------------------------------------------------------------------- -static const std::vector generate_random_leaves(const CurveTreesV1 &curve_trees, +static const std::vector generate_random_leaves(const CurveTreesV1 &curve_trees, const std::size_t old_n_leaf_tuples, const std::size_t new_n_leaf_tuples) { - std::vector tuples; + std::vector tuples; tuples.reserve(new_n_leaf_tuples); for (std::size_t i = 0; i < new_n_leaf_tuples; ++i) @@ -777,7 +777,7 @@ static const Selene::Scalar generate_random_selene_scalar() rct::key S_x; CHECK_AND_ASSERT_THROW_MES(rct::point_to_wei_x(rct::pk2rct(S), S_x), "failed to convert to wei x"); - return fcmp::tower_cycle::selene_scalar_from_bytes(S_x); + return fcmp_pp::tower_cycle::selene_scalar_from_bytes(S_x); } //---------------------------------------------------------------------------------------------------------------------- static bool grow_tree(CurveTreesV1 &curve_trees, @@ -941,7 +941,7 @@ TEST(curve_trees, grow_tree) LOG_PRINT_L1("Test grow tree with helios chunk width " << helios_chunk_width << ", selene chunk width " << selene_chunk_width); - const auto curve_trees = fcmp::curve_trees::curve_trees_v1(helios_chunk_width, selene_chunk_width); + const auto curve_trees = fcmp_pp::curve_trees::curve_trees_v1(helios_chunk_width, selene_chunk_width); // Constant for how deep we want the tree static const std::size_t TEST_N_LAYERS = 4; @@ -984,7 +984,7 @@ TEST(curve_trees, trim_tree) LOG_PRINT_L1("Test trim tree with helios chunk width " << helios_chunk_width << ", selene chunk width " << selene_chunk_width); - const auto curve_trees = fcmp::curve_trees::curve_trees_v1(helios_chunk_width, selene_chunk_width); + const auto curve_trees = fcmp_pp::curve_trees::curve_trees_v1(helios_chunk_width, selene_chunk_width); // Constant for how deep we want the tree static const std::size_t TEST_N_LAYERS = 4; @@ -1028,7 +1028,7 @@ TEST(curve_trees, trim_tree) // Make sure the result of hash_trim is the same as the equivalent hash_grow excluding the trimmed children TEST(curve_trees, hash_trim) { - const auto curve_trees = fcmp::curve_trees::curve_trees_v1(); + const auto curve_trees = fcmp_pp::curve_trees::curve_trees_v1(); // 1. Trim 1 { @@ -1183,7 +1183,7 @@ TEST(curve_trees, hash_trim) //---------------------------------------------------------------------------------------------------------------------- TEST(curve_trees, hash_grow) { - const auto curve_trees = fcmp::curve_trees::curve_trees_v1(); + const auto curve_trees = fcmp_pp::curve_trees::curve_trees_v1(); // Start by hashing: {selene_scalar_0, selene_scalar_1} // Then grow 1: {selene_scalar_0, selene_scalar_1, selene_scalar_2} diff --git a/tests/unit_tests/curve_trees.h b/tests/unit_tests/curve_trees.h index b0a0f173c..2cdf07ae3 100644 --- a/tests/unit_tests/curve_trees.h +++ b/tests/unit_tests/curve_trees.h @@ -28,12 +28,12 @@ #pragma once -#include "fcmp/curve_trees.h" -#include "fcmp/tower_cycle.h" +#include "fcmp_pp/curve_trees.h" +#include "fcmp_pp/tower_cycle.h" -using Helios = fcmp::curve_trees::Helios; -using Selene = fcmp::curve_trees::Selene; -using CurveTreesV1 = fcmp::curve_trees::CurveTreesV1; +using Helios = fcmp_pp::curve_trees::Helios; +using Selene = fcmp_pp::curve_trees::Selene; +using CurveTreesV1 = fcmp_pp::curve_trees::CurveTreesV1; // Helper class to read/write a global tree in memory. It's only used in testing because normally the tree isn't kept // in memory (it's stored in the db) @@ -85,10 +85,10 @@ public: // - This function is useful to collect all tree data necessary to perform the actual trim operation // - This function can return elems from each last chunk that will need to be trimmed CurveTreesV1::LastHashes get_last_hashes_to_trim( - const std::vector &trim_instructions) const; + const std::vector &trim_instructions) const; CurveTreesV1::LastChunkChildrenToTrim get_all_last_chunk_children_to_trim( - const std::vector &trim_instructions); + const std::vector &trim_instructions); private: CurveTreesV1 &m_curve_trees; diff --git a/tests/unit_tests/hardfork.cpp b/tests/unit_tests/hardfork.cpp index fc58c7cfb..dcc0d4d93 100644 --- a/tests/unit_tests/hardfork.cpp +++ b/tests/unit_tests/hardfork.cpp @@ -35,7 +35,7 @@ #include "cryptonote_basic/cryptonote_format_utils.h" #include "cryptonote_basic/hardfork.h" #include "blockchain_db/testdb.h" -#include "fcmp/curve_trees.h" +#include "fcmp_pp/curve_trees.h" using namespace cryptonote; @@ -55,7 +55,7 @@ public: , const uint64_t& coins_generated , uint64_t num_rct_outs , const crypto::hash& blk_hash - , const std::multimap& leaf_tuples_by_unlock_block + , const std::multimap& leaf_tuples_by_unlock_block ) override { blocks.push_back(blk); } diff --git a/tests/unit_tests/long_term_block_weight.cpp b/tests/unit_tests/long_term_block_weight.cpp index 92862372d..a77e431ea 100644 --- a/tests/unit_tests/long_term_block_weight.cpp +++ b/tests/unit_tests/long_term_block_weight.cpp @@ -58,7 +58,7 @@ public: , const uint64_t& coins_generated , uint64_t num_rct_outs , const crypto::hash& blk_hash - , const std::multimap& leaf_tuples_by_unlock_block + , const std::multimap& leaf_tuples_by_unlock_block ) override { blocks.push_back({block_weight, long_term_block_weight}); } diff --git a/tests/unit_tests/serialization.cpp b/tests/unit_tests/serialization.cpp index 92825e42b..66fc4177b 100644 --- a/tests/unit_tests/serialization.cpp +++ b/tests/unit_tests/serialization.cpp @@ -1370,8 +1370,8 @@ TEST(Serialization, tx_fcmp_pp) tx.rct_signatures.referenceBlock = referenceBlock; // 1 fcmp++ proof - fcmp::FcmpPpProof fcmp_pp; - const std::size_t proof_len = fcmp::fcmp_pp_len(n_inputs); + fcmp_pp::FcmpPpProof fcmp_pp; + const std::size_t proof_len = fcmp_pp::proof_len(n_inputs); fcmp_pp.reserve(proof_len); for (std::size_t i = 0; i < proof_len; ++i) fcmp_pp.push_back(i); @@ -1400,7 +1400,7 @@ TEST(Serialization, tx_fcmp_pp) string blob; // Extend fcmp++ proof - ASSERT_TRUE(tx.rct_signatures.p.fcmp_pp.size() == fcmp::fcmp_pp_len(n_inputs)); + ASSERT_TRUE(tx.rct_signatures.p.fcmp_pp.size() == fcmp_pp::proof_len(n_inputs)); tx.rct_signatures.p.fcmp_pp.push_back(0x01); ASSERT_FALSE(serialization::dump_binary(tx, blob)); @@ -1411,7 +1411,7 @@ TEST(Serialization, tx_fcmp_pp) transaction tx = make_dummy_fcmp_pp_tx(); // Shorten the fcmp++ proof - ASSERT_TRUE(tx.rct_signatures.p.fcmp_pp.size() == fcmp::fcmp_pp_len(n_inputs)); + ASSERT_TRUE(tx.rct_signatures.p.fcmp_pp.size() == fcmp_pp::proof_len(n_inputs)); ASSERT_TRUE(tx.rct_signatures.p.fcmp_pp.size() > 1); tx.rct_signatures.p.fcmp_pp.pop_back(); diff --git a/tests/unit_tests/unit_tests_utils.h b/tests/unit_tests/unit_tests_utils.h index 1f153fa6b..11bdfcf74 100644 --- a/tests/unit_tests/unit_tests_utils.h +++ b/tests/unit_tests/unit_tests_utils.h @@ -34,7 +34,7 @@ #include "blockchain_db/blockchain_db.h" #include "blockchain_db/lmdb/db_lmdb.h" -#include "fcmp/curve_trees.h" +#include "fcmp_pp/curve_trees.h" #include "misc_log_ex.h" #include @@ -84,7 +84,7 @@ namespace unit_test remove_files(); } - void init_new_db(std::shared_ptr curve_trees) + void init_new_db(std::shared_ptr curve_trees) { CHECK_AND_ASSERT_THROW_MES(this->m_db == nullptr, "expected nullptr m_db"); this->m_db = new cryptonote::BlockchainLMDB(true/*batch_transactions*/, curve_trees);