From bf9195db5867853a1d93b71e5aab578f49edfefe Mon Sep 17 00:00:00 2001 From: sowle Date: Thu, 7 Jan 2021 19:40:55 +0300 Subject: [PATCH] validate_alt_block_input fixed rare bug for cases g3-g5 when an output is spent in the next block --- src/currency_core/blockchain_storage.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 2acbbb8a..8eb50220 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -6047,9 +6047,8 @@ bool blockchain_storage::validate_alt_block_input(const transaction& input_tx, s if (abg_it != alt_chain.back()->second.gindex_lookup_table.end()) { amount_touched_altchain = true; - //Notice: since transactions is not allowed to refer to each other in one block, then we can consider that index in - //tx input would be always less then top for previous block, so just take it - global_outs_for_amount = abg_it->second; + // local gindex lookup table contains last used gindex, so we can't get total number of outs + // just skip setting global_outs_for_amount } else { @@ -6074,7 +6073,7 @@ bool blockchain_storage::validate_alt_block_input(const transaction& input_tx, s if (off.type() == typeid(uint64_t)) { uint64_t offset_gindex = boost::get(off); - CHECK_AND_ASSERT_MES(offset_gindex < global_outs_for_amount, false, + CHECK_AND_ASSERT_MES(amount_touched_altchain || (offset_gindex < global_outs_for_amount), false, "invalid global output index " << offset_gindex << " for amount=" << input.amount << ", max is " << global_outs_for_amount << ", referred to by offset #" << pk_n <<