diff --git a/src/DynexCNCore/Blockchain.cpp b/src/DynexCNCore/Blockchain.cpp index 6dd2d254..fc243953 100644 --- a/src/DynexCNCore/Blockchain.cpp +++ b/src/DynexCNCore/Blockchain.cpp @@ -454,17 +454,8 @@ bool Blockchain::have_tx_keyimg_as_spent(const Crypto::KeyImage &key_im) { } bool Blockchain::check_tx_inputs_keyimages_domain(const Crypto::KeyImage& keyImage) { - // scalar multiplication over I & R: - Crypto::KeyImage Ry = scalarmultKey(I, R); - // first validation: - if (!(scalarmultKey(I,R) == I)) { - logger(ERROR, BRIGHT_RED) << "Transaction uses key image not in the valid domain"; - return true; - } - // validate ((key image * curve order) == (identity element) - Crypto::KeyImage Rx = scalarmultKey(R, keyImage); - bool r = keyImage!=R; - return r; + if (getCurrentBlockchainHeight()>334581) return true; + return keyImage!=R; } bool Blockchain::checkIfSpent(const Crypto::KeyImage& keyImage, uint32_t blockIndex) { @@ -2094,23 +2085,8 @@ bool Blockchain::pushBlock(const Block& blockData, block_verification_context& b return true; } -bool Blockchain::newversiondate() { - const int day = 15; - const int month = 12; - const int year = 2023; - - if (daysFromNowToInputDate(day, month, year) < 0) - return true; - - return false; - } - bool Blockchain::check_non_privacy(const Transaction& tx) { - if (!newversiondate()) { - return true; - } - logger(DEBUGGING) << "DEBUG (Blockchain.cpp): check_non_privacy invoked for transaction " << getObjectHash(tx); DynexCN::TransactionPrefix transaction = *static_cast(&tx); @@ -2136,7 +2112,7 @@ bool Blockchain::check_non_privacy(const Transaction& tx) { } // enforce only non-privacy tx: - if (newversiondate() && (amount.empty() || to_address.empty())) { + if (amount.empty() || to_address.empty()) { { logger(ERROR) << "Transaction " << getObjectHash(tx) << " rejected: privacy transaction"; return false; diff --git a/src/DynexCNCore/Blockchain.h b/src/DynexCNCore/Blockchain.h index de66b816..c1030873 100644 --- a/src/DynexCNCore/Blockchain.h +++ b/src/DynexCNCore/Blockchain.h @@ -384,23 +384,6 @@ namespace DynexCN { const TransactionEntry& transactionByIndex(TransactionIndex index); // non-privacy functions: bool check_non_privacy(const Transaction& tx); - int daysFromNowToInputDate(int day, int month, int year) { - auto now = std::chrono::system_clock::now(); - time_t now_c = std::chrono::system_clock::to_time_t(now); - struct tm * timeGMT; - timeGMT = gmtime (&now_c); - struct tm inputDate = {0}; - inputDate.tm_year = year - 1900; - inputDate.tm_mon = month - 1; - inputDate.tm_mday = day; - time_t inputDate_c = mktime(&inputDate); - time_t timeGMT_c = mktime(timeGMT); - double diff_seconds = difftime(inputDate_c, timeGMT_c); - int diff_days = diff_seconds / (60 * 60 * 24); - return diff_days; - } - bool newversiondate(); - bool pushBlock(const Block& blockData, block_verification_context& bvc); bool pushBlock(const Block& blockData, const std::vector& transactions, block_verification_context& bvc); bool pushBlock(BlockEntry& block); diff --git a/src/DynexCNCore/Core.cpp b/src/DynexCNCore/Core.cpp index 3db42319..5ed849f9 100644 --- a/src/DynexCNCore/Core.cpp +++ b/src/DynexCNCore/Core.cpp @@ -1213,23 +1213,8 @@ bool core::getPaymentId(const Transaction& transaction, Crypto::Hash& paymentId) return getPaymentIdFromTransactionExtraNonce(extraNonce.nonce, paymentId); } -bool core::newversiondate() { - const int day = 15; - const int month = 12; - const int year = 2023; - - if (daysFromNowToInputDate(day, month, year) < 0) - return true; - - return false; -} - bool core::check_non_privacy(const Transaction& tx) { - if (!newversiondate()) { - return true; - } - logger(DEBUGGING) << "DEBUG (Core.cpp): check_non_privacy invoked for transaction " << getObjectHash(tx); DynexCN::TransactionPrefix transaction = *static_cast(&tx); @@ -1256,7 +1241,7 @@ bool core::check_non_privacy(const Transaction& tx) { } // enforce only non-privacy tx: - if (newversiondate() && (amount.empty() || to_address.empty())) { + if (amount.empty() || to_address.empty()) { { logger(ERROR) << "Transaction " << getObjectHash(tx) << " rejected: privacy transaction"; return false; diff --git a/src/DynexCNCore/Core.h b/src/DynexCNCore/Core.h index 957efc4b..90fe5ee3 100644 --- a/src/DynexCNCore/Core.h +++ b/src/DynexCNCore/Core.h @@ -130,25 +130,7 @@ namespace DynexCN { // non-privacy functions: bool check_non_privacy(const Transaction& tx); - int daysFromNowToInputDate(int day, int month, int year) { - auto now = std::chrono::system_clock::now(); - time_t now_c = std::chrono::system_clock::to_time_t(now); - struct tm * timeGMT; - timeGMT = gmtime (&now_c); - struct tm inputDate = {0}; - inputDate.tm_year = year - 1900; - inputDate.tm_mon = month - 1; - inputDate.tm_mday = day; - time_t inputDate_c = mktime(&inputDate); - time_t timeGMT_c = mktime(timeGMT); - double diff_seconds = difftime(inputDate_c, timeGMT_c); - int diff_days = diff_seconds / (60 * 60 * 24); - return diff_days; - } - bool newversiondate(); - - bool have_block(const Crypto::Hash& id) override; std::vector buildSparseChain() override; std::vector buildSparseChain(const Crypto::Hash& startBlockId) override; diff --git a/src/P2p/NetNode.cpp b/src/P2p/NetNode.cpp index 90b5b08e..4b281f99 100644 --- a/src/P2p/NetNode.cpp +++ b/src/P2p/NetNode.cpp @@ -87,22 +87,6 @@ size_t get_random_index_with_fixed_probability(size_t max_index) { return (x*x*x) / (max_index*max_index); //parabola \/ } -int daysFromNowToInputDate(int day, int month, int year) { - auto now = std::chrono::system_clock::now(); - time_t now_c = std::chrono::system_clock::to_time_t(now); - struct tm * timeGMT; - timeGMT = gmtime (&now_c); - struct tm inputDate = {0}; - inputDate.tm_year = year - 1900; - inputDate.tm_mon = month - 1; - inputDate.tm_mday = day; - time_t inputDate_c = mktime(&inputDate); - time_t timeGMT_c = mktime(timeGMT); - double diff_seconds = difftime(inputDate_c, timeGMT_c); - int diff_days = diff_seconds / (60 * 60 * 24); - return diff_days; -} - void addPortMapping(Logging::LoggerRef& logger, uint32_t port) { // Add UPnP port mapping logger(INFO) << "Attempting to add IGD port mapping."; @@ -255,16 +239,13 @@ namespace DynexCN m_payload_handler(payload_handler), m_allow_local_ip(false), m_hide_my_port(false), - m_network_id(BYTECOIN_NETWORK), - m_network_id_np(DYNEX_NETWORK), + m_network_id(DYNEX_NETWORK), logger(log, "node_server"), m_stopEvent(m_dispatcher), m_idleTimer(m_dispatcher), m_timedSyncTimer(m_dispatcher), m_timeoutTimer(m_dispatcher), m_stop(false), - // intervals - // m_peer_handshake_idle_maker_interval(DynexCN::P2P_DEFAULT_HANDSHAKE_INTERVAL), m_connections_maker_interval(1), m_peerlist_store_interval(60*30, false) { } @@ -287,20 +268,6 @@ namespace DynexCN int ret = 0; handled = true; - // enforce new version?: - if (m_network_id!=m_network_id_np && newversiondate()) { - m_network_id = m_network_id_np; - logger(INFO, BRIGHT_GREEN) << "Switched network to non-privacy " << m_network_id; - // drop this connection: - ctx.m_state = DynexCNConnectionContext::state_shutdown; - // drop all other connections: - forEachConnection([&](P2pConnectionContext& context) { - context.m_state = DynexCNConnectionContext::state_shutdown; - logger(INFO) << "Node connection to " << Common::ipAddressToString(context.m_remote_ip) << " dropped"; - }); - return 0; - } - if (cmd.isResponse && cmd.command == COMMAND_TIMED_SYNC::ID) { if (!handleTimedSyncResponse(cmd.buf, ctx)) { // invalid response, close connection @@ -579,17 +546,6 @@ namespace DynexCN //----------------------------------------------------------------------------------- - bool NodeServer::newversiondate() { - const int day = 15; - const int month = 12; - const int year = 2023; - - if (daysFromNowToInputDate(day, month, year) < 0) - return true; - - return false; - } - bool NodeServer::init(const NetNodeConfig& config) { if (!config.getTestnet()) { for (auto seed : DynexCN::SEED_NODES) { @@ -597,7 +553,6 @@ namespace DynexCN } } else { m_network_id.data[0] += 1; - m_network_id_np.data[0] += 1; } if (!handleConfig(config)) { @@ -627,14 +582,8 @@ namespace DynexCN m_last_stat_request_time = 0; #endif - // enforce new version?: - if (newversiondate() || config.getTestnet()) { - m_network_id = m_network_id_np; - } + logger(INFO) << "Network (non-privacy): " << m_network_id; - logger(INFO) << "Network: " << m_network_id; - logger(INFO) << "Network (non-privacy): " << m_network_id_np; - //try to bind logger(INFO) << "Binding on " << m_bind_ip << ":" << m_port; m_listeningPort = Common::fromString(m_port); @@ -755,11 +704,6 @@ namespace DynexCN //----------------------------------------------------------------------------------- bool NodeServer::handshake(DynexCN::LevinProtocol& proto, P2pConnectionContext& context, bool just_take_peerlist) { - // enforce new version? - if (m_network_id!=m_network_id_np && newversiondate()) { - m_network_id = m_network_id_np; - } - COMMAND_HANDSHAKE::request arg; COMMAND_HANDSHAKE::response rsp; get_local_node_data(arg.node_data); @@ -772,7 +716,7 @@ namespace DynexCN context.version = rsp.node_data.version; - if ((rsp.node_data.network_id != m_network_id) && (rsp.node_data.network_id != m_network_id_np)) { + if (rsp.node_data.network_id != m_network_id) { logger(Logging::DEBUGGING) << context << "COMMAND_HANDSHAKE Failed, wrong network! (" << rsp.node_data.network_id << "), closing connection."; return false; } @@ -1179,11 +1123,6 @@ namespace DynexCN bool NodeServer::get_local_node_data(basic_node_data& node_data) { - // enforce new version? - if (m_network_id!=m_network_id_np && newversiondate()) { - m_network_id = m_network_id_np; - } - node_data.version = P2PProtocolVersion::CURRENT; node_data.node_version = CN_PROJECT_VERSION; @@ -1373,11 +1312,6 @@ namespace DynexCN int NodeServer::handle_handshake(int command, COMMAND_HANDSHAKE::request& arg, COMMAND_HANDSHAKE::response& rsp, P2pConnectionContext& context) { - // enforce new version? - if (m_network_id!=m_network_id_np && newversiondate()) { - m_network_id = m_network_id_np; - } - context.version = arg.node_data.version; if (!is_remote_host_allowed(context.m_remote_ip)) { @@ -1386,7 +1320,7 @@ namespace DynexCN return 1; } - if ((arg.node_data.network_id != m_network_id) && (arg.node_data.network_id != m_network_id_np)) { + if (arg.node_data.network_id != m_network_id) { add_host_fail(context.m_remote_ip); logger(Logging::INFO) << context << "WRONG NETWORK AGENT CONNECTED! id=" << arg.node_data.network_id; context.m_state = DynexCNConnectionContext::state_shutdown; diff --git a/src/P2p/NetNode.h b/src/P2p/NetNode.h index 5d28c0b2..0d176780 100644 --- a/src/P2p/NetNode.h +++ b/src/P2p/NetNode.h @@ -301,7 +301,6 @@ namespace DynexCN std::list m_command_line_peers; uint64_t m_peer_livetime; boost::uuids::uuid m_network_id; - boost::uuids::uuid m_network_id_np; std::map m_blocked_hosts; std::map m_host_fails_score; diff --git a/src/P2p/P2pNetworks.h b/src/P2p/P2pNetworks.h index a21a860f..e303a6ef 100644 --- a/src/P2p/P2pNetworks.h +++ b/src/P2p/P2pNetworks.h @@ -39,6 +39,5 @@ namespace DynexCN { - const static boost::uuids::uuid BYTECOIN_NETWORK = { { 0xae, 0x3c, 0xff, 0xc2, 0x53, 0xea, 0xeb, 0x3f, 0x81, 0xf1, 0xde, 0x41, 0x9a, 0x55, 0xb0, 0xfd } }; const static boost::uuids::uuid DYNEX_NETWORK = { { 0x3c, 0xae, 0xb5, 0xc3, 0xf3, 0xee, 0xe0, 0x2f, 0xd2, 0xc3, 0xee, 0x1a, 0x3c, 0x4e, 0x0b, 0xfa } }; } diff --git a/src/P2p/P2pNodeConfig.cpp b/src/P2p/P2pNodeConfig.cpp index 014d9be1..e26fc65d 100644 --- a/src/P2p/P2pNodeConfig.cpp +++ b/src/P2p/P2pNodeConfig.cpp @@ -55,8 +55,7 @@ P2pNodeConfig::P2pNodeConfig() : handshakeTimeout(std::chrono::milliseconds(P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT)), connectInterval(P2P_DEFAULT_CONNECT_INTERVAL), connectTimeout(std::chrono::milliseconds(P2P_DEFAULT_CONNECTION_TIMEOUT)), - networkId(BYTECOIN_NETWORK), - networkId_np(DYNEX_NETWORK), + networkId(DYNEX_NETWORK), expectedOutgoingConnectionsCount(P2P_DEFAULT_CONNECTIONS_COUNT), whiteListConnectionsPercent(P2P_DEFAULT_WHITELIST_CONNECTIONS_PERCENT), peerListConnectRange(P2P_DEFAULT_CONNECT_RANGE), diff --git a/src/version.h.in b/src/version.h.in index 896c8db2..6f8b2a97 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -12,7 +12,7 @@ #define CN_VER_MAJOR 2 #define CN_VER_MINOR 2 #define CN_VER_REV 2 -#define CN_VER_BUILD 20231217 +#define CN_VER_BUILD 20231218 #define CN_VER_REMARK "#non-privacy" #define CN_PROJECT_VERSION STR(CN_VER_MAJOR) "." STR(CN_VER_MINOR) "." STR(CN_VER_REV) #define CN_PROJECT_VERSION_BUILD_NO STR(CN_VER_BUILD)