From 944bf7c39fc8555fcfd4028a3a0de7e03d09bd56 Mon Sep 17 00:00:00 2001 From: jeffro256 Date: Mon, 11 Mar 2024 12:21:11 -0500 Subject: [PATCH] add mixability validation support --- src/seraphis_main/tx_validation_context.h | 7 +++++++ src/seraphis_main/txtype_base.cpp | 18 +++++++++++++----- src/seraphis_main/txtype_base.h | 2 ++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/seraphis_main/tx_validation_context.h b/src/seraphis_main/tx_validation_context.h index 39aa16a1bc..d0a4d5de4f 100644 --- a/src/seraphis_main/tx_validation_context.h +++ b/src/seraphis_main/tx_validation_context.h @@ -95,6 +95,13 @@ class TxValidationContext */ virtual void get_reference_set_proof_elements_v2(const std::vector &indices, rct::keyV &proof_elements_out) const = 0; + /** + * @brief gets the total number of on-chain, non-Seraphis enotes for a given amount in the validation context + * + * @param amount the output enote amount to get information for, with 0 meaning the RingCT dist + * @return std::uint64_t the current total number of on-chain enotes for the given amount + */ + virtual std::uint64_t get_cryptonote_global_ref_set_size(const std::uint64_t amount) const = 0; }; } //namespace sp diff --git a/src/seraphis_main/txtype_base.cpp b/src/seraphis_main/txtype_base.cpp index 405dac3eca..ffca106acc 100644 --- a/src/seraphis_main/txtype_base.cpp +++ b/src/seraphis_main/txtype_base.cpp @@ -63,16 +63,18 @@ static bool validate_txs_impl(const std::vector &txs, const TxV if (!validate_tx_version(*tx, tx_validation_context)) return false; - // Validate as many non-cryptographic static semantic rules against tx's nominal version as possible + // Validate as many non-cryptographic static semantic rules against tx's nominal version + // as possible if (!validate_tx_semantics(*tx)) return false; - // Validate non-cryptographic semantic rules for this tx which are dependent on the fork version (i.e. most - // Cryptonote/RingCT rules) + // Validate non-cryptographic semantic rules for this tx which are dependent on the fork + // version (i.e. most Cryptonote/RingCT rules) if (!validate_tx_semantics_fork_dependent(*tx, tx_validation_context)) return false; - // Validate that the key images do not exist in this validation context (and are otherwise valid) + // Validate that the key images do not exist in this validation context (and are + // otherwise valid) if (!validate_tx_key_images(*tx, tx_validation_context)) return false; @@ -80,7 +82,13 @@ static bool validate_txs_impl(const std::vector &txs, const TxV if (!validate_tx_amount_balance(*tx)) return false; - // Validate membership proofs, ring sigs, etc against live data (unless done in validate_txs_batchable) + // Validate that the transaction's ring sizes and signature types are allowed given the + // current size of the on-chain global output enote sets' sizes. + if (!validate_tx_mixability(*tx, tx_validation_context)) + return false; + + // Validate membership proofs, ring sigs, etc against live data (unless done in + // validate_txs_batchable()) if (!validate_tx_input_proofs(*tx, tx_validation_context)) return false; } diff --git a/src/seraphis_main/txtype_base.h b/src/seraphis_main/txtype_base.h index 06ad88a745..c33e27a7ff 100644 --- a/src/seraphis_main/txtype_base.h +++ b/src/seraphis_main/txtype_base.h @@ -76,6 +76,8 @@ bool validate_tx_key_images(const SpTxType &tx, const TxValidationContext &tx_va template bool validate_tx_amount_balance(const SpTxType &tx); template +bool validate_tx_mixability(const SpTxType &tx, const TxValidationContext &tx_validation_context); +template bool validate_tx_input_proofs(const SpTxType &tx, const TxValidationContext &tx_validation_context); template bool validate_txs_batchable(const std::vector &txs, const TxValidationContext &tx_validation_context);