carrot_impl: add consensus rule for unique output pubkeys in tx
Required by Carrot to mitigate burning bugs, described in section 4.3 of the Carrot spec: https://github.com/jeffro256/carrot/blob/master/carrot.md#43-transaction-model Also remove 0-out check in `check_output_types()`, which I added in and technically constitutes a retroactive network split. Co-authored-by: j-berman <justinberman@protonmail.com>
This commit is contained in:
@@ -1370,6 +1370,13 @@ bool Blockchain::prevalidate_miner_transaction(const block& b, uint64_t height,
|
||||
|
||||
CHECK_AND_ASSERT_MES(check_output_types(b.miner_tx, hf_version), false, "miner transaction has invalid output type(s) in block " << get_block_hash(b));
|
||||
|
||||
// from carrot or v18, require output pubkeys be sorted in strictly increasing lexicographical order
|
||||
const bool tx_is_carrot = !b.miner_tx.vout.empty() && b.miner_tx.vout.at(0).target.type() == typeid(txout_to_carrot_v1);
|
||||
const bool should_enforce_sorted_outputs = hf_version > HF_VERSION_CARROT || tx_is_carrot;
|
||||
if (should_enforce_sorted_outputs) {
|
||||
CHECK_AND_ASSERT_MES(are_transaction_output_pubkeys_sorted(b.miner_tx), false, "miner transaction outputs are not sorted in block " << get_block_hash(b));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
@@ -3691,6 +3698,16 @@ bool Blockchain::check_tx_type_and_version(const transaction& tx, tx_verificatio
|
||||
return false;
|
||||
}
|
||||
|
||||
// from carrot or v18, require output pubkeys be sorted in strictly increasing lexicographical order
|
||||
const bool tx_is_carrot = !tx.vout.empty() && tx.vout.at(0).target.type() == typeid(txout_to_carrot_v1);
|
||||
const bool should_enforce_sorted_outputs = hf_version > HF_VERSION_CARROT || tx_is_carrot;
|
||||
if (should_enforce_sorted_outputs) {
|
||||
if (!are_transaction_output_pubkeys_sorted(tx)) {
|
||||
tvc.m_invalid_output = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user