Skip to content

Commit f4d08d6

Browse files
committed
FCMP++ <> Carrot, BP+ <> Legacy & enforce min tx version
1 parent 7ca251c commit f4d08d6

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/cryptonote_basic/cryptonote_format_utils.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,17 @@ namespace cryptonote
10091009
<< "expected matching variant types in transaction id=" << get_transaction_hash(tx));
10101010
}
10111011
}
1012+
1013+
// during v17, require non-coinbase carrot txs use FCMP++ and legacy use BP+
1014+
if (hf_version == HF_VERSION_CARROT && !cryptonote::is_coinbase(tx) && tx.vout.size())
1015+
{
1016+
const auto &o = tx.vout.front();
1017+
CHECK_AND_ASSERT_MES(
1018+
(o.target.type() == typeid(txout_to_carrot_v1) && tx.rct_signatures.type == rct::RCTTypeFcmpPlusPlus) ||
1019+
(o.target.type() == typeid(txout_to_tagged_key) && tx.rct_signatures.type == rct::RCTTypeBulletproofPlus),
1020+
false, "mismatched output type to tx proof type in transaction id=" << get_transaction_hash(tx));
1021+
}
1022+
10121023
return true;
10131024
}
10141025
//---------------------------------------------------------------

src/cryptonote_core/tx_verification_utils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ static bool ver_non_input_consensus_templated(TxForwardIt tx_begin, TxForwardIt
227227
std::vector<const rct::rctSig*> rvv;
228228
rvv.reserve(static_cast<size_t>(std::distance(tx_begin, tx_end)));
229229

230+
const size_t min_tx_version = hf_version <= HF_VERSION_FCMP_PLUS_PLUS ? 1 : 2;
230231
const size_t max_tx_version = hf_version < HF_VERSION_DYNAMIC_FEE ? 1 : 2;
231232

232233
const size_t tx_weight_limit = get_transaction_weight_limit(hf_version);
@@ -245,7 +246,7 @@ static bool ver_non_input_consensus_templated(TxForwardIt tx_begin, TxForwardIt
245246
}
246247

247248
// Rule 2 & 3
248-
if (tx.version == 0 || tx.version > max_tx_version)
249+
if (tx.version < min_tx_version || tx.version > max_tx_version)
249250
{
250251
tvc.m_verifivation_failed = true;
251252
return false;

src/cryptonote_core/tx_verification_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ bool batch_ver_fcmp_pp_consensus
128128
*
129129
* List of checks that we do for each transaction:
130130
* 1. Check tx blob size < get_max_tx_size()
131-
* 2. Check tx version != 0
131+
* 2. Check tx version is greater than minimum for given hard fork version
132132
* 3. Check tx version is less than maximum for given hard fork version
133133
* 4. Check tx weight < get_transaction_weight_limit()
134134
* 5. Passes core::check_tx_semantic()

0 commit comments

Comments
 (0)