Skip to content

Commit

Permalink
cryptonote_core: misc v17 consensus rules
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffro256 committed Jan 29, 2025
1 parent c6f2ccd commit 30674f1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/cryptonote_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@
#define HF_VERSION_BULLETPROOF_PLUS 15
#define HF_VERSION_VIEW_TAGS 15
#define HF_VERSION_2021_SCALING 15
#define HF_VERSION_FCMP 17
#define HF_VERSION_REJECT_UNLOCK_TIME 17
#define HF_VERSION_REJECT_LARGE_EXTRA 17
#define HF_VERSION_REJECT_UNMIXABLE_V1 17

#define PER_KB_FEE_QUANTIZATION_DECIMALS 8
#define CRYPTONOTE_SCALING_2021_FEE_ROUNDING_PLACES 2
Expand Down
21 changes: 19 additions & 2 deletions src/cryptonote_core/tx_verification_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ static bool ver_non_input_consensus_templated(TxForwardIt tx_begin, TxForwardIt
std::vector<const rct::rctSig*> rvv;
rvv.reserve(static_cast<size_t>(std::distance(tx_begin, tx_end)));

const size_t min_tx_version = hf_version >= HF_VERSION_REJECT_UNMIXABLE_V1 ? 2 : 1;
const size_t max_tx_version = hf_version < HF_VERSION_DYNAMIC_FEE ? 1 : 2;

const size_t tx_weight_limit = get_transaction_weight_limit(hf_version);
Expand All @@ -153,13 +154,29 @@ static bool ver_non_input_consensus_templated(TxForwardIt tx_begin, TxForwardIt
return false;
}

// Rule 2 & 3
if (tx.version == 0 || tx.version > max_tx_version)
// Rule 2, Rule 3, and Rule 10
if (tx.version < min_tx_version || tx.version > max_tx_version)
{
tvc.m_verifivation_failed = true;
return false;
}

// Rule 8
if (hf_version >= HF_VERSION_REJECT_UNLOCK_TIME && tx.unlock_time != 0)
{
tvc.m_verifivation_failed = true;
tvc.m_nonzero_unlock_time = true;
return false;
}

// Rule 9
if (hf_version >= HF_VERSION_REJECT_LARGE_EXTRA && tx.extra.size() > MAX_TX_EXTRA_SIZE)
{
tvc.m_verifivation_failed = true;
tvc.m_tx_extra_too_big = true;
return false;
}

// Rule 4
const size_t tx_weight = get_transaction_weight(tx, blob_size);
if (hf_version >= HF_VERSION_PER_BYTE_FEE && tx_weight > tx_weight_limit)
Expand Down
3 changes: 3 additions & 0 deletions src/cryptonote_core/tx_verification_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ struct pool_supplement
* 5. Passes core::check_tx_semantic()
* 6. Passes Blockchain::check_tx_outputs()
* 7. Passes ver_mixed_rct_semantics() [Uses batch RingCT verification when applicable]
* 8. Check unlock time is 0 from hardfork v17
* 9. Check extra size <= MAX_TX_EXTRA_SIZE from hardfork v17
* 10. Check all tx version >= 2 from hardfork v17, even unmixable sweeps
*
* For pool_supplement input:
* We assume the structure of the pool supplement is already correct: for each value entry, the
Expand Down

0 comments on commit 30674f1

Please sign in to comment.