From addd26cd474694d8ad3608128d2f7a94b03ed07d Mon Sep 17 00:00:00 2001 From: Some Random Crypto Guy Date: Fri, 16 Aug 2024 14:01:11 +0100 Subject: [PATCH] Fixes include: - setting DEFAULT_STACK_TRACE=OFF for all release builds (prevents boost weak_ptr crash on some Linux systems) - setting RPC-SSL to disabled by default (fixes "no connection to daemon" error) - updated BlockchainLMDB::get_circulating_supply() to report staked coins as something other than BURNT - bumped to v0.4.5 --- CMakeLists.txt | 4 ++-- src/blockchain_db/blockchain_db.h | 4 ++-- src/blockchain_db/lmdb/db_lmdb.cpp | 25 +++++++++++++++++-------- src/blockchain_db/lmdb/db_lmdb.h | 4 ++-- src/cryptonote_core/blockchain.cpp | 19 +++++++++++++------ src/cryptonote_core/blockchain.h | 2 +- src/rpc/rpc_args.cpp | 2 +- src/version.cpp.in | 2 +- 8 files changed, 39 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7336153..668636b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -538,7 +538,7 @@ elseif (DEPENDS AND NOT LINUX) set(DEFAULT_STACK_TRACE OFF) set(LIBUNWIND_LIBRARIES "") elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT MINGW) - set(DEFAULT_STACK_TRACE ON) + set(DEFAULT_STACK_TRACE OFF) set(STACK_TRACE_LIB "easylogging++") # for diag output only set(LIBUNWIND_LIBRARIES "") elseif (ARM) @@ -547,7 +547,7 @@ elseif (ARM) else() find_package(Libunwind) if(LIBUNWIND_FOUND) - set(DEFAULT_STACK_TRACE ON) + set(DEFAULT_STACK_TRACE OFF) set(STACK_TRACE_LIB "libunwind") # for diag output only else() set(DEFAULT_STACK_TRACE OFF) diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h index 2d54195..2054778 100644 --- a/src/blockchain_db/blockchain_db.h +++ b/src/blockchain_db/blockchain_db.h @@ -1915,8 +1915,8 @@ public: */ virtual uint64_t get_database_size() const = 0; - virtual int get_yield_block_info(const uint64_t height, yield_block_info& ybi) = 0; - virtual int get_yield_tx_info(const uint64_t height, std::vector& yti_container) = 0; + virtual int get_yield_block_info(const uint64_t height, yield_block_info& ybi) const = 0; + virtual int get_yield_tx_info(const uint64_t height, std::vector& yti_container) const = 0; /** diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index c416175..4d8f827 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -800,7 +800,7 @@ estim: return threshold_size; } -int BlockchainLMDB::get_yield_block_info(const uint64_t height, yield_block_info& ybi) +int BlockchainLMDB::get_yield_block_info(const uint64_t height, yield_block_info& ybi) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -825,11 +825,13 @@ int BlockchainLMDB::get_yield_block_info(const uint64_t height, yield_block_info yield_block_info *p = (yield_block_info*)v.mv_data; ybi = *p; + TXN_POSTFIX_RDONLY(); + // Return success to caller return ret; } -int BlockchainLMDB::get_yield_tx_info(const uint64_t height, std::vector& yti_container) +int BlockchainLMDB::get_yield_tx_info(const uint64_t height, std::vector& yti_container) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); check_open(); @@ -858,6 +860,8 @@ int BlockchainLMDB::get_yield_tx_info(const uint64_t height, std::vector BlockchainLMDB::get_circulating_supply() const uint64_t m_coinbase = get_block_already_generated_coins(m_height-1); LOG_PRINT_L3("BlockchainLMDB::" << __func__ << " - mined supply for SAL = " << m_coinbase); - // SRCG: For V1, we can simply return this number, because there is no other source of coins - //circulating_supply["SAL"] = m_coinbase; - //return circulating_supply; + uint64_t staked_coins = 0; + yield_block_info ybi; + int result = get_yield_block_info(m_height-1, ybi); + if (result) + throw0(DB_ERROR(lmdb_error("Failed to get YBI when querying supply: ", result).c_str())); + staked_coins = ybi.locked_coins_tally; check_open(); @@ -3480,8 +3487,6 @@ std::map BlockchainLMDB::get_circulating_supply() const MDB_val k; MDB_val v; - int result = 0; - MDB_cursor_op op = MDB_FIRST; while (1) { @@ -3513,7 +3518,11 @@ std::map BlockchainLMDB::get_circulating_supply() const if (circulating_supply.empty()) { circulating_supply["SAL"] = m_coinbase; } - circulating_supply["BURN"] = m_coinbase - circulating_supply["SAL"]; + + // Adjust the supply to account for the staked coins + circulating_supply["STAKE"] = staked_coins; + + circulating_supply["BURN"] = m_coinbase - circulating_supply["SAL"] - circulating_supply["STAKE"]; return circulating_supply; } diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h index 77ec44d..e0686ac 100644 --- a/src/blockchain_db/lmdb/db_lmdb.h +++ b/src/blockchain_db/lmdb/db_lmdb.h @@ -459,8 +459,8 @@ private: //void migrate_0_1(); void cleanup_batch(); - virtual int get_yield_block_info(const uint64_t height, yield_block_info& ybi); - virtual int get_yield_tx_info(const uint64_t height, std::vector& yti_container); + virtual int get_yield_block_info(const uint64_t height, yield_block_info& ybi) const; + virtual int get_yield_tx_info(const uint64_t height, std::vector& yti_container) const; private: MDB_env* m_env; diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index ea36cdf..0e3fdac 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1478,7 +1478,7 @@ bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_bl } //------------------------------------------------------------------ // SRCG -bool Blockchain::validate_protocol_transaction(const block& b, uint64_t height, std::vector>& txs, const std::map& circ_supply, uint8_t hf_version) +bool Blockchain::validate_protocol_transaction(const block& b, uint64_t height, std::vector>& txs, uint8_t hf_version) { LOG_PRINT_L3("Blockchain::" << __func__); CHECK_AND_ASSERT_MES(b.tx_hashes.size() == txs.size(), false, "Invalid number of TXs / hashes supplied"); @@ -1488,6 +1488,17 @@ bool Blockchain::validate_protocol_transaction(const block& b, uint64_t height, CHECK_AND_ASSERT_MES(b.protocol_tx.vout.size() == 0, false, "void protocol transaction in the block has outputs"); return true; } + + if (!b.protocol_tx.vout.size()) { + // No money is minted, nothing to verify - bail out + return true; + } + + // Get the circulating supply so we can verify + std::map circ_supply; + if (hf_version >= HF_VERSION_ENABLE_CONVERT) { + circ_supply = get_db().get_circulating_supply(); + } // Build a map of outputs from the protocol_tx std::map> outputs; @@ -4900,12 +4911,8 @@ leave: } TIME_MEASURE_FINISH(vmt); - TIME_MEASURE_START(gcs); - std::map circ_supply = get_db().get_circulating_supply(); - TIME_MEASURE_FINISH(gcs); - TIME_MEASURE_START(vpt); - if(!validate_protocol_transaction(bl, blockchain_height, txs, circ_supply, m_hardfork->get_current_version())) + if(!validate_protocol_transaction(bl, blockchain_height, txs, m_hardfork->get_current_version())) { MERROR_VER("Block with id: " << id << " has incorrect protocol transaction"); bvc.m_verifivation_failed = true; diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h index 2407139..d0aa7c6 100644 --- a/src/cryptonote_core/blockchain.h +++ b/src/cryptonote_core/blockchain.h @@ -1521,7 +1521,7 @@ namespace cryptonote * * @return false if anything is found wrong with the protocol transaction, otherwise true */ - bool validate_protocol_transaction(const block& b, uint64_t height, std::vector>& txs, const std::map& circ_supply, uint8_t hf_version); + bool validate_protocol_transaction(const block& b, uint64_t height, std::vector>& txs, uint8_t hf_version); /** * @brief reverts the blockchain to its previous state following a failed switch diff --git a/src/rpc/rpc_args.cpp b/src/rpc/rpc_args.cpp index 74f0879..1a347b9 100644 --- a/src/rpc/rpc_args.cpp +++ b/src/rpc/rpc_args.cpp @@ -98,7 +98,7 @@ namespace cryptonote , rpc_login({"rpc-login", rpc_args::tr("Specify username[:password] required for RPC server"), "", true}) , confirm_external_bind({"confirm-external-bind", rpc_args::tr("Confirm rpc-bind-ip value is NOT a loopback (local) IP")}) , rpc_access_control_origins({"rpc-access-control-origins", rpc_args::tr("Specify a comma separated list of origins to allow cross origin resource sharing"), ""}) - , rpc_ssl({"rpc-ssl", rpc_args::tr("Enable SSL on RPC connections: enabled|disabled|autodetect"), "autodetect"}) + , rpc_ssl({"rpc-ssl", rpc_args::tr("Enable SSL on RPC connections: enabled|disabled|autodetect"), "disabled"}) , rpc_ssl_private_key({"rpc-ssl-private-key", rpc_args::tr("Path to a PEM format private key"), ""}) , rpc_ssl_certificate({"rpc-ssl-certificate", rpc_args::tr("Path to a PEM format certificate"), ""}) , rpc_ssl_ca_certificates({"rpc-ssl-ca-certificates", rpc_args::tr("Path to file containing concatenated PEM format certificate(s) to replace system CA(s)."), ""}) diff --git a/src/version.cpp.in b/src/version.cpp.in index c08aec9..4df9a23 100644 --- a/src/version.cpp.in +++ b/src/version.cpp.in @@ -1,5 +1,5 @@ #define DEF_SALVIUM_VERSION_TAG "@VERSIONTAG@" -#define DEF_SALVIUM_VERSION "0.4.4-beta2" +#define DEF_SALVIUM_VERSION "0.4.5" #define DEF_MONERO_VERSION_TAG "release" #define DEF_MONERO_VERSION "0.18.3.3" #define DEF_MONERO_RELEASE_NAME "Zero"