1
0
Fork 0
forked from lthn/blockchain

tx_pool: add post-HF4 txs are now being check for balance proof. Core test hard_fork_4_consolidated_txs changed accordingly

This commit is contained in:
sowle 2024-03-16 14:57:25 +01:00
parent 66cf29ccd3
commit 7f851205a0
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
3 changed files with 27 additions and 12 deletions

View file

@ -224,6 +224,14 @@ namespace currency
}
TIME_MEASURE_FINISH_PD(check_inputs_time);
TIME_MEASURE_START_PD(check_post_hf4_balance);
if (tx.version > TRANSACTION_VERSION_PRE_HF4)
{
r = check_tx_balance(tx, id);
CHECK_AND_ASSERT_MES_CUSTOM(r, false, { tvc.m_verification_failed = true; }, "post-HF4 tx: balance proof is invalid");
}
TIME_MEASURE_FINISH_PD(check_post_hf4_balance);
do_insert_transaction(tx, id, blob_size, kept_by_block, tx_fee, ch_inp_res ? max_used_block_id : null_hash, ch_inp_res ? max_used_block_height : 0);
TIME_MEASURE_FINISH_PD(tx_processing_time);
@ -240,9 +248,11 @@ namespace currency
<< "/" << m_performance_data.validate_alias_time.get_last_val()
<< "/" << m_performance_data.check_keyimages_ws_ms_time.get_last_val()
<< "/" << m_performance_data.check_inputs_time.get_last_val()
<< "/b"<< m_performance_data.check_post_hf4_balance.get_last_val()
<< "/" << m_performance_data.begin_tx_time.get_last_val()
<< "/" << m_performance_data.update_db_time.get_last_val()
<< "/" << m_performance_data.db_commit_time.get_last_val() << ")" );
<< "/" << m_performance_data.db_commit_time.get_last_val()
<< ")");
return true;
}

View file

@ -77,7 +77,8 @@ namespace currency
epee::math_helper::average<uint64_t, 5> check_inputs_time;
epee::math_helper::average<uint64_t, 5> begin_tx_time;
epee::math_helper::average<uint64_t, 5> update_db_time;
epee::math_helper::average<uint64_t, 5> db_commit_time;
epee::math_helper::average<uint64_t, 5> db_commit_time;
epee::math_helper::average<uint64_t, 1> check_post_hf4_balance;
};
typedef std::unordered_map<crypto::key_image, std::set<crypto::hash>> key_image_cache;

View file

@ -134,18 +134,22 @@ bool hard_fork_4_consolidated_txs::generate(std::vector<test_event_entry>& event
CHECK_AND_ASSERT_MES(dhc == destinations.size(), false, "unexpected derivation hints count: " << dhc);
// partially completed tx_1 shouldn't be accepted
if (m_post_hf4_zarcanum)
{
ADD_CUSTOM_EVENT(events, tx_1);
DO_CALLBACK(events, "mark_invalid_block");
MAKE_NEXT_BLOCK_TX1(events, blk_2a, blk_1r, miner_acc, tx_1);
}
else
{
// now we added a balance check to tx_memory_pool::add_tx() for post-HF4 txs, so the behaviour is the same -- partially completed consolidated tx won't be added to the pool -- sowle
// (subject to change in future)
//if (m_post_hf4_zarcanum)
//{
// ADD_CUSTOM_EVENT(events, tx_1);
// DO_CALLBACK(events, "mark_invalid_block");
// MAKE_NEXT_BLOCK_TX1(events, blk_2a, blk_1r, miner_acc, tx_1);
// DO_CALLBACK(events, "clear_tx_pool");
//}
//else
//{
DO_CALLBACK(events, "mark_invalid_tx");
ADD_CUSTOM_EVENT(events, tx_1);
}
DO_CALLBACK(events, "clear_tx_pool");
//}
}