Merge pull request #1902

7c033498 blockchain: lower the relay fee by 2% (moneromooo-monero)
266492e9 tx_pool: use new filling algorithm from v5 only (moneromooo-monero)
5b7c6ced wallet2: start using new fee priorities at v5, not 14 days laer (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2017-03-20 23:29:43 +02:00
commit 37eebd9dcf
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
3 changed files with 32 additions and 22 deletions

View file

@ -2860,7 +2860,7 @@ bool Blockchain::check_fee(size_t blob_size, uint64_t fee) const
needed_fee += (blob_size % 1024) ? 1 : 0; needed_fee += (blob_size % 1024) ? 1 : 0;
needed_fee *= fee_per_kb; needed_fee *= fee_per_kb;
if (fee < needed_fee) if (fee < needed_fee * 0.98) // keep a little buffer on acceptance
{ {
MERROR_VER("transaction fee is not enough: " << print_money(fee) << ", minimum fee: " << print_money(needed_fee)); MERROR_VER("transaction fee is not enough: " << print_money(fee) << ", minimum fee: " << print_money(needed_fee));
return false; return false;

View file

@ -614,7 +614,7 @@ namespace cryptonote
CRITICAL_REGION_LOCAL(m_transactions_lock); CRITICAL_REGION_LOCAL(m_transactions_lock);
uint64_t best_coinbase = 0; uint64_t best_coinbase = 0, coinbase;
total_size = 0; total_size = 0;
fee = 0; fee = 0;
@ -622,11 +622,9 @@ namespace cryptonote
get_block_reward(median_size, total_size, already_generated_coins, best_coinbase, version); get_block_reward(median_size, total_size, already_generated_coins, best_coinbase, version);
#if 1 size_t max_total_size_pre_v5 = (130 * median_size) / 100 - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE;
size_t max_total_size = (130 * median_size) / 100 - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE; size_t max_total_size_v5 = 2 * median_size - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE;
#else size_t max_total_size = version >= 5 ? max_total_size_v5 : max_total_size_pre_v5;
size_t max_total_size = 2 * median_size - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE;
#endif
std::unordered_set<crypto::key_image> k_images; std::unordered_set<crypto::key_image> k_images;
LOG_PRINT_L2("Filling block template, median size " << median_size << ", " << m_txs_by_fee_and_receive_time.size() << " txes in the pool"); LOG_PRINT_L2("Filling block template, median size " << median_size << ", " << m_txs_by_fee_and_receive_time.size() << " txes in the pool");
@ -644,21 +642,35 @@ namespace cryptonote
continue; continue;
} }
// If we're getting lower coinbase tx, // start using the optimal filling algorithm from v5
// stop including more tx if (version >= 5)
uint64_t block_reward;
if(!get_block_reward(median_size, total_size + tx_it->second.blob_size, already_generated_coins, block_reward, version))
{ {
LOG_PRINT_L2(" would exceed maximum block size"); // If we're getting lower coinbase tx,
sorted_it++; // stop including more tx
continue; uint64_t block_reward;
if(!get_block_reward(median_size, total_size + tx_it->second.blob_size, already_generated_coins, block_reward, version))
{
LOG_PRINT_L2(" would exceed maximum block size");
sorted_it++;
continue;
}
coinbase = block_reward + fee + tx_it->second.fee;
if (coinbase < template_accept_threshold(best_coinbase))
{
LOG_PRINT_L2(" would decrease coinbase to " << print_money(coinbase));
sorted_it++;
continue;
}
} }
uint64_t coinbase = block_reward + fee + tx_it->second.fee; else
if (coinbase < template_accept_threshold(best_coinbase))
{ {
LOG_PRINT_L2(" would decrease coinbase to " << print_money(coinbase)); // If we've exceeded the penalty free size,
sorted_it++; // stop including more tx
continue; if (total_size > median_size)
{
LOG_PRINT_L2(" would exceed median block size");
break;
}
} }
// Skip transactions that are not ready to be // Skip transactions that are not ready to be
@ -680,9 +692,7 @@ namespace cryptonote
bl.tx_hashes.push_back(tx_it->first); bl.tx_hashes.push_back(tx_it->first);
total_size += tx_it->second.blob_size; total_size += tx_it->second.blob_size;
fee += tx_it->second.fee; fee += tx_it->second.fee;
#if 0
best_coinbase = coinbase; best_coinbase = coinbase;
#endif
append_key_images(k_images, tx_it->second.tx); append_key_images(k_images, tx_it->second.tx);
sorted_it++; sorted_it++;
LOG_PRINT_L2(" added, new block size " << total_size << "/" << max_total_size << ", coinbase " << print_money(best_coinbase)); LOG_PRINT_L2(" added, new block size " << total_size << "/" << max_total_size << ", coinbase " << print_money(best_coinbase));

View file

@ -3379,7 +3379,7 @@ uint64_t wallet2::get_per_kb_fee()
int wallet2::get_fee_algorithm() int wallet2::get_fee_algorithm()
{ {
// changes at v3 and v5 // changes at v3 and v5
if (use_fork_rules(5, -720 * 14)) if (use_fork_rules(5, 0))
return 2; return 2;
if (use_fork_rules(3, -720 * 14)) if (use_fork_rules(3, -720 * 14))
return 1; return 1;