re-factored code for mixins count verification(moved to core check, suggested by @sowle)

This commit is contained in:
cryptozoidberg 2024-01-15 19:38:53 +01:00
parent fb31c8862b
commit 6475571781
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
3 changed files with 9 additions and 25 deletions

View file

@ -5826,13 +5826,7 @@ bool blockchain_storage::validate_tx_for_hardfork_specific_terms(const transacti
{
return false;
}
uint64_t keys_count = get_hf4_inputs_key_offsets_count(tx);
if (keys_count != 0 && keys_count - 1 < CURRENCY_HF4_MANDATORY_DECOY_SET_SIZE)
return false;
}
return true;
}
//------------------------------------------------------------------

View file

@ -852,6 +852,15 @@ namespace currency
r = is_mixattr_applicable_for_fake_outs_counter(out_zc.mix_attr, key_offsets.size() - 1);
CHECK_AND_ASSERT_MES(r, false, "tx input ref #" << output_index << " violates mixin restrictions: mix_attr = " << static_cast<uint32_t>(out_zc.mix_attr) << ", key_offsets.size = " << key_offsets.size());
//after hf4 we're not allow unmixed outputs unless it's CURRENCY_TO_KEY_OUT_FORCED_NO_MIX
if (out_zc.mix_attr != CURRENCY_TO_KEY_OUT_FORCED_NO_MIX && key_offsets.size() - 1 < CURRENCY_HF4_MANDATORY_DECOY_SET_SIZE)
{
size_t verified_input_index = std::find(validated_tx.vin.begin(), validated_tx.vin.end(), verified_input) - validated_tx.vin.begin();
LOG_PRINT_RED_L0("handle_output failed for output #" << n << " in " << tx_id << " referenced by input #" << verified_input_index << " in tx " << get_transaction_hash(validated_tx) << ", mixins count: " << key_offsets.size() - 1);
return false;
}
TIME_MEASURE_START_PD(tx_check_inputs_loop_scan_outputkeys_loop_handle_output);
if (!vis.handle_output(tx_ptr->tx, validated_tx, out_zc, n))
{

View file

@ -3751,25 +3751,6 @@ namespace currency
return true;
}
//---------------------------------------------------------------
//if return 0 -> no txin_zc_input seen
uint64_t get_hf4_inputs_key_offsets_count(const transaction& tx)
{
uint64_t key_offsets_count = 0;
for (const auto& e : tx.vin)
{
if (e.type() != typeid(txin_zc_input))
continue;
if (boost::get<txin_zc_input>(e).key_offsets.size() > key_offsets_count)
{
key_offsets_count = boost::get<txin_zc_input>(e).key_offsets.size();
}
}
return key_offsets_count;
}
//---------------------------------------------------------------
bool check_native_coins_amount_burnt_in_outs(const transaction& tx, const uint64_t amount, uint64_t* p_amount_burnt /* = nullptr */)
{
if (tx.version <= TRANSACTION_VERSION_PRE_HF4)