Merge pull request #204 from j-berman/no-drop-dbl-spend

tx pool: don't drop cxns relaying key images spent in chain [beta]
This commit is contained in:
Justin Berman
2026-09-23 09:27:55 -07:00
committed by GitHub
2 changed files with 24 additions and 1 deletions
+3
View File
@@ -3520,7 +3520,10 @@ bool Blockchain::have_tx_keyimges_as_spent(const transaction &tx) const
{
CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key, in_to_key, true);
if(have_tx_keyimg_as_spent(in_to_key.k_image))
{
LOG_PRINT_L1("Key image already spent in blockchain: " << epee::string_tools::pod_to_hex(in_to_key.k_image));
return true;
}
}
return false;
}
+21 -1
View File
@@ -234,12 +234,32 @@ namespace cryptonote
return false;
}
if (!check_inputs_types_supported(tx))
{
// TODO: do more cheap semantics checks earlier. This is here so the have_tx_keyimges_as_spent below can only fail when expected.
MERROR("Unsupported input types for tx id= " << id);
tvc.m_verifivation_failed = true;
tvc.m_invalid_input = true;
return false;
}
if (version && version > HF_VERSION_FCMP_PLUS_PLUS)
{
// TODO: do more cheap semantics checks earlier. This is here to protect overloading have_tx_keyimges_as_spent with many DB reads.
if (tx.vin.empty() || tx.vin.size() > FCMP_PLUS_PLUS_MAX_INPUTS)
{
tvc.m_verifivation_failed = true;
tvc.m_invalid_input = true;
return false;
}
}
// if the transaction came from a block popped from the chain,
// don't check if we have its key images as spent.
// TODO: Investigate why not?
if(!kept_by_block)
{
if(have_tx_keyimges_as_spent(tx, id))
if(have_tx_keyimges_as_spent(tx, id) || m_blockchain.have_tx_keyimges_as_spent(tx))
{
mark_double_spend(tx);
LOG_PRINT_L1("Transaction with id= "<< id << " used already spent key images");