From bedf0285b057d9075fd0bcb3d1ea4a84964196aa Mon Sep 17 00:00:00 2001 From: sowle Date: Fri, 4 Nov 2022 21:17:27 +0100 Subject: [PATCH] blocks validation: prevalidate_miner_transaction() moved to go before heavy proof of work / proof of stake checks (@cryptozoidberg, please, take a look) --- src/currency_core/blockchain_storage.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 856fd357..3cadffea 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -5755,11 +5755,18 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt //check if PoS allowed in this height CHECK_AND_ASSERT_MES_CUSTOM(!(is_pos_bl && m_db_blocks.size() < m_core_runtime_config.pos_minimum_heigh), false, bvc.m_verification_failed = true, "PoS block not allowed on height " << m_db_blocks.size()); + if (!prevalidate_miner_transaction(bl, m_db_blocks.size(), is_pos_bl)) + { + LOG_PRINT_L0("Block with id: " << id << " @ " << height << " failed to pass miner tx prevalidation"); + bvc.m_verification_failed = true; + return false; + } + //check proof of work TIME_MEASURE_START_PD(target_calculating_time_2); wide_difficulty_type current_diffic = get_next_diff_conditional(is_pos_bl); CHECK_AND_ASSERT_MES_CUSTOM(current_diffic, false, bvc.m_verification_failed = true, "!!!!!!!!! difficulty overhead !!!!!!!!!"); - TIME_MEASURE_FINISH_PD(target_calculating_time_2); + TIME_MEASURE_FINISH_PD(target_calculating_time_2); TIME_MEASURE_START_PD(longhash_calculating_time_3); if (is_pos_bl) @@ -5783,16 +5790,10 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt return false; } } - TIME_MEASURE_FINISH_PD(longhash_calculating_time_3); + TIME_MEASURE_FINISH_PD(longhash_calculating_time_3); size_t aliases_count_befor_block = m_db_aliases.size(); - if (!prevalidate_miner_transaction(bl, m_db_blocks.size(), is_pos_bl)) - { - LOG_PRINT_L0("Block with id: " << id << " @ " << height << " failed to pass miner tx prevalidation"); - bvc.m_verification_failed = true; - return false; - } size_t cumulative_block_size = 0; size_t coinbase_blob_size = get_object_blobsize(bl.miner_tx);