mirror of
https://github.com/monero-project/monero.git
synced 2024-12-13 20:06:32 +02:00
core: from v12, require consistent ring size for mixable txes
We're supposed to have a fixed ring size now Already checked by MLSAG verification, but here seems more intuitive
This commit is contained in:
parent
26072f1393
commit
555dc7c394
@ -151,6 +151,7 @@
|
||||
#define HF_VERSION_LONG_TERM_BLOCK_WEIGHT 10
|
||||
#define HF_VERSION_MIN_2_OUTPUTS 12
|
||||
#define HF_VERSION_MIN_V2_COINBASE_TX 12
|
||||
#define HF_VERSION_SAME_MIXIN 12
|
||||
|
||||
#define PER_KB_FEE_QUANTIZATION_DECIMALS 8
|
||||
|
||||
|
@ -2860,7 +2860,8 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
|
||||
if (hf_version >= 2)
|
||||
{
|
||||
size_t n_unmixable = 0, n_mixable = 0;
|
||||
size_t mixin = std::numeric_limits<size_t>::max();
|
||||
size_t min_actual_mixin = std::numeric_limits<size_t>::max();
|
||||
size_t max_actual_mixin = 0;
|
||||
const size_t min_mixin = hf_version >= HF_VERSION_MIN_MIXIN_10 ? 10 : hf_version >= HF_VERSION_MIN_MIXIN_6 ? 6 : hf_version >= HF_VERSION_MIN_MIXIN_4 ? 4 : 2;
|
||||
for (const auto& txin : tx.vin)
|
||||
{
|
||||
@ -2885,29 +2886,43 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
|
||||
else
|
||||
++n_mixable;
|
||||
}
|
||||
if (in_to_key.key_offsets.size() - 1 < mixin)
|
||||
mixin = in_to_key.key_offsets.size() - 1;
|
||||
size_t ring_mixin = in_to_key.key_offsets.size() - 1;
|
||||
if (ring_mixin < min_actual_mixin)
|
||||
min_actual_mixin = ring_mixin;
|
||||
if (ring_mixin > max_actual_mixin)
|
||||
max_actual_mixin = ring_mixin;
|
||||
}
|
||||
}
|
||||
MDEBUG("Mixin: " << min_actual_mixin << "-" << max_actual_mixin);
|
||||
|
||||
if (hf_version >= HF_VERSION_SAME_MIXIN)
|
||||
{
|
||||
if (min_actual_mixin != max_actual_mixin)
|
||||
{
|
||||
MERROR_VER("Tx " << get_transaction_hash(tx) << " has varying ring size (" << (min_actual_mixin + 1) << "-" << (max_actual_mixin + 1) << "), it should be constant");
|
||||
tvc.m_low_mixin = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (((hf_version == HF_VERSION_MIN_MIXIN_10 || hf_version == HF_VERSION_MIN_MIXIN_10+1) && mixin != 10) || (hf_version >= HF_VERSION_MIN_MIXIN_10+2 && mixin > 10))
|
||||
if (((hf_version == HF_VERSION_MIN_MIXIN_10 || hf_version == HF_VERSION_MIN_MIXIN_10+1) && min_actual_mixin != 10) || (hf_version >= HF_VERSION_MIN_MIXIN_10+2 && min_actual_mixin > 10))
|
||||
{
|
||||
MERROR_VER("Tx " << get_transaction_hash(tx) << " has invalid ring size (" << (mixin + 1) << "), it should be 11");
|
||||
MERROR_VER("Tx " << get_transaction_hash(tx) << " has invalid ring size (" << (min_actual_mixin + 1) << "), it should be 11");
|
||||
tvc.m_low_mixin = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mixin < min_mixin)
|
||||
if (min_actual_mixin < min_mixin)
|
||||
{
|
||||
if (n_unmixable == 0)
|
||||
{
|
||||
MERROR_VER("Tx " << get_transaction_hash(tx) << " has too low ring size (" << (mixin + 1) << "), and no unmixable inputs");
|
||||
MERROR_VER("Tx " << get_transaction_hash(tx) << " has too low ring size (" << (min_actual_mixin + 1) << "), and no unmixable inputs");
|
||||
tvc.m_low_mixin = true;
|
||||
return false;
|
||||
}
|
||||
if (n_mixable > 1)
|
||||
{
|
||||
MERROR_VER("Tx " << get_transaction_hash(tx) << " has too low ring size (" << (mixin + 1) << "), and more than one mixable input with unmixable inputs");
|
||||
MERROR_VER("Tx " << get_transaction_hash(tx) << " has too low ring size (" << (min_actual_mixin + 1) << "), and more than one mixable input with unmixable inputs");
|
||||
tvc.m_low_mixin = true;
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user