1
0
Fork 0
forked from lthn/blockchain

Merge branch 'develop' into autodoc

This commit is contained in:
cryptozoidberg 2024-03-28 19:28:33 +01:00
commit 31abc2d1bd
No known key found for this signature in database
GPG key ID: 2E10CC61CAC8F36D
4 changed files with 22 additions and 27 deletions

View file

@ -174,15 +174,13 @@ bool wallet2::set_core_proxy(const std::shared_ptr<i_core_proxy>& proxy)
return true;
}
//----------------------------------------------------------------------------------------------------
void wallet2::set_pos_utxo_count_limits_for_defragmentation_tx(uint64_t min_outs, uint64_t max_outs)
void wallet2::set_defragmentation_tx_settings(bool enabled, uint64_t min_outs, uint64_t max_outs, uint64_t max_allowed_amount, size_t decoys_count)
{
m_min_utxo_count_for_defragmentation_tx = min_outs;
m_max_utxo_count_for_defragmentation_tx = max_outs;
}
//----------------------------------------------------------------------------------------------------
void wallet2::set_pos_decoys_count_for_defragmentation_tx(size_t decoys_count)
{
m_decoys_count_for_defragmentation_tx = decoys_count;
m_defragmentation_tx_enabled = enabled;
m_min_utxo_count_for_defragmentation_tx = min_outs;
m_max_utxo_count_for_defragmentation_tx = max_outs;
m_max_allowed_output_amount_for_defragmentation_tx = max_allowed_amount;
m_decoys_count_for_defragmentation_tx = decoys_count;
}
//----------------------------------------------------------------------------------------------------
std::shared_ptr<i_core_proxy> wallet2::get_core_proxy()
@ -406,7 +404,7 @@ void wallet2::process_ado_in_new_transaction(const currency::asset_descriptor_op
<< ENDL << "Ticker: " << asset_context.ticker
<< ENDL << "Total Max Supply: " << print_asset_money(asset_context.total_max_supply, asset_context.decimal_point)
<< ENDL << "Current Supply: " << print_asset_money(asset_context.current_supply, asset_context.decimal_point)
<< ENDL << "Decimal Point: " << asset_context.decimal_point;
<< ENDL << "Decimal Point: " << (int)asset_context.decimal_point;
add_rollback_event(ptc.height, asset_register_event{ asset_id });
@ -443,7 +441,7 @@ void wallet2::process_ado_in_new_transaction(const currency::asset_descriptor_op
<< ENDL << "Ticker: " << ado.descriptor.ticker
<< ENDL << "Total Max Supply: " << print_asset_money(ado.descriptor.total_max_supply, ado.descriptor.decimal_point)
<< ENDL << "Current Supply: " << print_asset_money(ado.descriptor.current_supply, ado.descriptor.decimal_point)
<< ENDL << "Decimal Point: " << ado.descriptor.decimal_point;
<< ENDL << "Decimal Point: " << (int)ado.descriptor.decimal_point;
add_rollback_event(ptc.height, asset_register_event{ asset_id });
@ -474,7 +472,7 @@ void wallet2::process_ado_in_new_transaction(const currency::asset_descriptor_op
<< ENDL << "Ticker: " << ado.descriptor.ticker
<< ENDL << "Total Max Supply: " << print_asset_money(ado.descriptor.total_max_supply, ado.descriptor.decimal_point)
<< ENDL << "Current Supply: " << print_asset_money(ado.descriptor.current_supply, ado.descriptor.decimal_point)
<< ENDL << "Decimal Point: " << ado.descriptor.decimal_point;
<< ENDL << "Decimal Point: " << (int)ado.descriptor.decimal_point;
add_rollback_event(ptc.height, asset_register_event{ asset_id });
WLT_LOG_MAGENTA(ss.str(), LOG_LEVEL_0);
@ -6306,6 +6304,12 @@ void wallet2::select_decoys(currency::COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS
{
out_entry entry = extract_random_from_container(amount_entry.outs);
//
if (entry.global_amount_index == own_g_index)
{
continue;
}
//skip auditable
if ((entry.flags & (RANDOM_OUTPUTS_FOR_AMOUNTS_FLAGS_NOT_ALLOWED)))
{
@ -6316,11 +6320,7 @@ void wallet2::select_decoys(currency::COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS
coinbases.push_back(entry);
continue;
}
//
if (entry.global_amount_index == own_g_index)
{
continue;
}
local_outs.push_back(entry);
}

View file

@ -402,8 +402,7 @@ namespace tools
bool daemon_get_asset_info(const crypto::public_key& asset_id, currency::asset_descriptor_base& adb);
bool set_core_proxy(const std::shared_ptr<i_core_proxy>& proxy);
void set_pos_utxo_count_limits_for_defragmentation_tx(uint64_t min_outs, uint64_t max_outs); // don't create UTXO defrag. tx if there are less than 'min_outs' outs; don't put more than 'max_outs' outs
void set_pos_decoys_count_for_defragmentation_tx(size_t decoys_count);
void set_defragmentation_tx_settings(bool enabled, uint64_t min_outs, uint64_t max_outs, uint64_t max_allowed_amount = CURRENCY_BLOCK_REWARD, size_t decoys_count = SIZE_MAX);
void set_pos_required_decoys_count(size_t v) { m_required_decoys_count = v; }
void set_minimum_height(uint64_t h);
std::shared_ptr<i_core_proxy> get_core_proxy();

View file

@ -1085,7 +1085,7 @@ bool pos_minting_tx_packing::c1(currency::core& c, size_t ev_index, const std::v
m_alice_start_amount + CURRENCY_BLOCK_REWARD * m_pos_mint_packing_size // unlocked
), false, "");
alice_wlt->set_pos_utxo_count_limits_for_defragmentation_tx(m_pos_mint_packing_size + 1, m_pos_mint_packing_size + 1); // +1 because previous implementation () had an error with this limit
alice_wlt->set_defragmentation_tx_settings(true, m_pos_mint_packing_size + 1, m_pos_mint_packing_size + 1); // +1 because previous implementation () had an error with this limit
// no coinbase tx outputs should be packed
r = alice_wlt->try_mint_pos();

View file

@ -3440,8 +3440,7 @@ bool packing_outputs_on_pos_minting_wallet::c1(currency::core& c, size_t ev_inde
// 1. Try to defragment the same UTXO that is used for staking
// (Bob has two: one UTXO is for staking, other is being defragmented)
bob_wlt->set_pos_utxo_count_limits_for_defragmentation_tx(1, 10);
bob_wlt->set_pos_decoys_count_for_defragmentation_tx(0);
bob_wlt->set_defragmentation_tx_settings(true, 1, 10, CURRENCY_BLOCK_REWARD, 0);
bob_wlt->try_mint_pos();
CHECK_AND_ASSERT_MES(c.get_current_blockchain_size() == CURRENCY_MINED_MONEY_UNLOCK_WINDOW * 2 + 3, false, "Incorrect blockchain height:" << c.get_current_blockchain_size());
@ -3453,8 +3452,7 @@ bool packing_outputs_on_pos_minting_wallet::c1(currency::core& c, size_t ev_inde
// 2. Try to mine a PoS block and defragment some of UTXO
alice_wlt->set_pos_utxo_count_limits_for_defragmentation_tx(2, 2);
alice_wlt->set_pos_decoys_count_for_defragmentation_tx(0);
alice_wlt->set_defragmentation_tx_settings(true, 2, 2, CURRENCY_BLOCK_REWARD, 0);
alice_wlt->try_mint_pos();
CHECK_AND_ASSERT_MES(c.get_current_blockchain_size() == CURRENCY_MINED_MONEY_UNLOCK_WINDOW * 2 + 4, false, "Incorrect blockchain height:" << c.get_current_blockchain_size());
@ -3467,8 +3465,7 @@ bool packing_outputs_on_pos_minting_wallet::c1(currency::core& c, size_t ev_inde
// 3. Try to mine a PoS block and defragment with huge decoy set. Make sure block is mined successfully without a defragmentation tx
// Alice has one UTXO
alice_wlt->set_pos_utxo_count_limits_for_defragmentation_tx(1, 1);
alice_wlt->set_pos_decoys_count_for_defragmentation_tx(80);
alice_wlt->set_defragmentation_tx_settings(true, 1, 1, CURRENCY_BLOCK_REWARD, 80);
alice_wlt->try_mint_pos();
CHECK_AND_ASSERT_MES(c.get_current_blockchain_size() == CURRENCY_MINED_MONEY_UNLOCK_WINDOW * 2 + 5, false, "Incorrect blockchain height:" << c.get_current_blockchain_size());
@ -3480,8 +3477,7 @@ bool packing_outputs_on_pos_minting_wallet::c1(currency::core& c, size_t ev_inde
// 4. Finally mine a PoS and defragment the last one unlocked UTXO
alice_wlt->set_pos_utxo_count_limits_for_defragmentation_tx(1, 1);
alice_wlt->set_pos_decoys_count_for_defragmentation_tx(0);
alice_wlt->set_defragmentation_tx_settings(true, 1, 1, CURRENCY_BLOCK_REWARD, 0);
alice_wlt->try_mint_pos();
CHECK_AND_ASSERT_MES(c.get_current_blockchain_size() == CURRENCY_MINED_MONEY_UNLOCK_WINDOW * 2 + 6, false, "Incorrect blockchain height:" << c.get_current_blockchain_size());