forked from lthn/blockchain
(cherry picked) 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:
parent
7d3e3ae358
commit
806eb326d1
3 changed files with 47 additions and 14 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -89,6 +89,10 @@ bool hard_fork_4_consolidated_txs::generate(std::vector<test_event_entry>& event
|
|||
ADD_CUSTOM_EVENT(events, tx_0b);
|
||||
MAKE_NEXT_BLOCK_TX_LIST(events, blk_1, blk_0r, miner_acc, std::list<transaction>({tx_0a, tx_0b}));
|
||||
|
||||
size_t dhc = count_type_in_variant_container<tx_derivation_hint>(tx_0b.extra);
|
||||
CHECK_AND_ASSERT_MES(dhc == tx_0b.vout.size(), false, "unexpected derivation hints count: " << dhc);
|
||||
|
||||
|
||||
REWIND_BLOCKS_N_WITH_TIME(events, blk_1r, blk_1, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
|
||||
|
||||
// check Alice's balance
|
||||
|
|
@ -100,7 +104,7 @@ bool hard_fork_4_consolidated_txs::generate(std::vector<test_event_entry>& event
|
|||
CHECK_AND_ASSERT_MES(check_balance_via_wallet(*alice_wlt.get(), "alice", alice_amount, 0, alice_amount, 0, 0), false, "");
|
||||
|
||||
uint64_t miner_amount = MK_TEST_COINS(60);
|
||||
uint64_t bob_amount = miner_amount + alice_amount - TX_DEFAULT_FEE;
|
||||
m_bob_amount = miner_amount + alice_amount - TX_DEFAULT_FEE;
|
||||
|
||||
// Consolidated tx (TX_FLAG_SIGNATURE_MODE_SEPARATE).
|
||||
|
||||
|
|
@ -119,17 +123,33 @@ bool hard_fork_4_consolidated_txs::generate(std::vector<test_event_entry>& event
|
|||
std::vector<tx_destination_entry> destinations;
|
||||
if (miner_change != 0)
|
||||
destinations.push_back(tx_destination_entry(miner_change, miner_acc.get_public_address()));
|
||||
destinations.push_back(tx_destination_entry(bob_amount, bob_acc.get_public_address()));
|
||||
destinations.push_back(tx_destination_entry(m_bob_amount, bob_acc.get_public_address()));
|
||||
|
||||
add_flags_to_all_destination_entries(tx_destination_entry_flags::tdef_explicit_native_asset_id, destinations);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_extra, empty_attachment, tx_1, get_tx_version_from_events(events), one_time_secret_key,
|
||||
0, 0, 0, true, TX_FLAG_SIGNATURE_MODE_SEPARATE, TX_DEFAULT_FEE, gen_context);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
dhc = count_type_in_variant_container<tx_derivation_hint>(tx_1.extra);
|
||||
CHECK_AND_ASSERT_MES(dhc == destinations.size(), false, "unexpected derivation hints count: " << dhc);
|
||||
|
||||
// partially completed tx_1 shouldn't be accepted
|
||||
//DO_CALLBACK(events, "mark_invalid_tx");
|
||||
ADD_CUSTOM_EVENT(events, tx_1);
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_2a, blk_1r, miner_acc, tx_1);
|
||||
|
||||
// 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);
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -147,23 +167,25 @@ bool hard_fork_4_consolidated_txs::generate(std::vector<test_event_entry>& event
|
|||
0, 0, 0, true, TX_FLAG_SIGNATURE_MODE_SEPARATE, 0 /* note zero fee here */, gen_context);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
|
||||
size_t dhc_2 = count_type_in_variant_container<tx_derivation_hint>(tx_1.extra);
|
||||
CHECK_AND_ASSERT_MES(dhc_2 == dhc, false, "unexpected derivation hints count: " << dhc_2);
|
||||
|
||||
ADD_CUSTOM_EVENT(events, tx_1);
|
||||
}
|
||||
MAKE_NEXT_BLOCK_TX1(events, blk_2, blk_1r, miner_acc, tx_1);
|
||||
|
||||
//std::shared_ptr<tools::wallet2> bob_wlt;
|
||||
//r = generator.init_test_wallet(bob_acc, get_block_hash(blk_0), bob_wlt);
|
||||
//CHECK_AND_ASSERT_MES(r, false, "init_test_wallet failed");
|
||||
//r = generator.refresh_test_wallet(events, bob_wlt.get(), get_block_hash(blk_2), 2 * CURRENCY_MINED_MONEY_UNLOCK_WINDOW + 2);
|
||||
//CHECK_AND_ASSERT_MES(r, false, "refresh_test_wallet failed");
|
||||
//CHECK_AND_ASSERT_MES(check_balance_via_wallet(*bob_wlt.get(), "Bob", bob_amount, 0, 0, 0, 0), false, "");
|
||||
|
||||
DO_CALLBACK(events, "c1");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hard_fork_4_consolidated_txs::c1(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events)
|
||||
{
|
||||
std::shared_ptr<tools::wallet2> bob_wlt = init_playtime_test_wallet(events, c, BOB_ACC_IDX);
|
||||
bob_wlt->refresh();
|
||||
|
||||
CHECK_AND_ASSERT_MES(check_balance_via_wallet(*bob_wlt.get(), "Bob", m_bob_amount, 0, 0, 0, 0), false, "");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue