mirror of
https://github.com/monero-project/monero.git
synced 2024-12-23 03:59:33 +00:00
Merge pull request #5414
e9fac29a
unit_tests/long_term_block_weight: some tweaks that seem to make more sense (stoffu)467f4c7e
tests/block_weight: use integer division when computing median (stoffu)815d08dc
tests/block_weight: remove unused MULTIPLIER_SMALL (stoffu)661f1fb8
blockchain: remove unused calc of short_term_constraint (stoffu)
This commit is contained in:
commit
0d2aaac15b
3 changed files with 11 additions and 12 deletions
|
@ -3986,7 +3986,6 @@ bool Blockchain::update_next_cumulative_weight_limit(uint64_t *long_term_effecti
|
||||||
new_weights[0] = long_term_block_weight;
|
new_weights[0] = long_term_block_weight;
|
||||||
long_term_median = epee::misc_utils::median(new_weights);
|
long_term_median = epee::misc_utils::median(new_weights);
|
||||||
m_long_term_effective_median_block_weight = std::max<uint64_t>(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5, long_term_median);
|
m_long_term_effective_median_block_weight = std::max<uint64_t>(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5, long_term_median);
|
||||||
short_term_constraint = m_long_term_effective_median_block_weight + m_long_term_effective_median_block_weight * 2 / 5;
|
|
||||||
|
|
||||||
weights.clear();
|
weights.clear();
|
||||||
get_last_n_blocks_weights(weights, CRYPTONOTE_REWARD_BLOCKS_WINDOW);
|
get_last_n_blocks_weights(weights, CRYPTONOTE_REWARD_BLOCKS_WINDOW);
|
||||||
|
|
|
@ -9,7 +9,6 @@ import math
|
||||||
|
|
||||||
MEDIAN_WINDOW_SMALL = 100 # number of recent blocks for median computation
|
MEDIAN_WINDOW_SMALL = 100 # number of recent blocks for median computation
|
||||||
MEDIAN_WINDOW_BIG = 5000
|
MEDIAN_WINDOW_BIG = 5000
|
||||||
MULTIPLIER_SMALL = 1.4 # multipliers for determining weights
|
|
||||||
MULTIPLIER_BIG = 50.0
|
MULTIPLIER_BIG = 50.0
|
||||||
MEDIAN_THRESHOLD = 300*1000 # initial value for median (scaled kB -> B)
|
MEDIAN_THRESHOLD = 300*1000 # initial value for median (scaled kB -> B)
|
||||||
lcg_seed = 0
|
lcg_seed = 0
|
||||||
|
@ -24,9 +23,9 @@ def get_median(vec):
|
||||||
#temp = vec
|
#temp = vec
|
||||||
temp = sorted(vec)
|
temp = sorted(vec)
|
||||||
if len(temp) % 2 == 1:
|
if len(temp) % 2 == 1:
|
||||||
return temp[len(temp)/2]
|
return temp[len(temp)//2]
|
||||||
else:
|
else:
|
||||||
return int((temp[len(temp)/2]+temp[len(temp)/2-1])/2)
|
return int((temp[len(temp)//2]+temp[len(temp)//2-1])//2)
|
||||||
|
|
||||||
def LCG():
|
def LCG():
|
||||||
global lcg_seed
|
global lcg_seed
|
||||||
|
|
|
@ -198,9 +198,10 @@ TEST(long_term_block_weight, multi_pop)
|
||||||
const uint64_t effective_median = bc->get_current_cumulative_block_weight_median();
|
const uint64_t effective_median = bc->get_current_cumulative_block_weight_median();
|
||||||
const uint64_t effective_limit = bc->get_current_cumulative_block_weight_limit();
|
const uint64_t effective_limit = bc->get_current_cumulative_block_weight_limit();
|
||||||
|
|
||||||
for (uint64_t h = 0; h < 4; ++h)
|
const uint64_t num_pop = 4;
|
||||||
|
for (uint64_t h = 0; h < num_pop; ++h)
|
||||||
{
|
{
|
||||||
size_t w = h < TEST_LONG_TERM_BLOCK_WEIGHT_WINDOW ? CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5 : bc->get_current_cumulative_block_weight_limit();
|
size_t w = bc->get_current_cumulative_block_weight_limit();
|
||||||
uint64_t ltw = bc->get_next_long_term_block_weight(w);
|
uint64_t ltw = bc->get_next_long_term_block_weight(w);
|
||||||
bc->get_db().add_block(std::make_pair(cryptonote::block(), ""), w, ltw, h, h, {});
|
bc->get_db().add_block(std::make_pair(cryptonote::block(), ""), w, ltw, h, h, {});
|
||||||
ASSERT_TRUE(bc->update_next_cumulative_weight_limit());
|
ASSERT_TRUE(bc->update_next_cumulative_weight_limit());
|
||||||
|
@ -208,10 +209,8 @@ TEST(long_term_block_weight, multi_pop)
|
||||||
|
|
||||||
cryptonote::block b;
|
cryptonote::block b;
|
||||||
std::vector<cryptonote::transaction> txs;
|
std::vector<cryptonote::transaction> txs;
|
||||||
bc->get_db().pop_block(b, txs);
|
for (uint64_t h = 0; h < num_pop; ++h)
|
||||||
bc->get_db().pop_block(b, txs);
|
bc->get_db().pop_block(b, txs);
|
||||||
bc->get_db().pop_block(b, txs);
|
|
||||||
bc->get_db().pop_block(b, txs);
|
|
||||||
ASSERT_TRUE(bc->update_next_cumulative_weight_limit());
|
ASSERT_TRUE(bc->update_next_cumulative_weight_limit());
|
||||||
|
|
||||||
ASSERT_EQ(effective_median, bc->get_current_cumulative_block_weight_median());
|
ASSERT_EQ(effective_median, bc->get_current_cumulative_block_weight_median());
|
||||||
|
@ -294,9 +293,11 @@ TEST(long_term_block_weight, pop_invariant_random)
|
||||||
{
|
{
|
||||||
PREFIX(10);
|
PREFIX(10);
|
||||||
|
|
||||||
for (uint64_t h = 1; h < TEST_LONG_TERM_BLOCK_WEIGHT_WINDOW - 10; ++h)
|
for (uint64_t h = 1; h < 2 * TEST_LONG_TERM_BLOCK_WEIGHT_WINDOW - 10; ++h)
|
||||||
{
|
{
|
||||||
size_t w = bc->get_db().height() < TEST_LONG_TERM_BLOCK_WEIGHT_WINDOW ? CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5 : bc->get_current_cumulative_block_weight_limit();
|
lcg_seed = bc->get_db().height();
|
||||||
|
uint32_t r = lcg();
|
||||||
|
size_t w = bc->get_db().height() < TEST_LONG_TERM_BLOCK_WEIGHT_WINDOW ? CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5 : (r % bc->get_current_cumulative_block_weight_limit());
|
||||||
uint64_t ltw = bc->get_next_long_term_block_weight(w);
|
uint64_t ltw = bc->get_next_long_term_block_weight(w);
|
||||||
bc->get_db().add_block(std::make_pair(cryptonote::block(), ""), w, ltw, h, h, {});
|
bc->get_db().add_block(std::make_pair(cryptonote::block(), ""), w, ltw, h, h, {});
|
||||||
ASSERT_TRUE(bc->update_next_cumulative_weight_limit());
|
ASSERT_TRUE(bc->update_next_cumulative_weight_limit());
|
||||||
|
|
Loading…
Reference in a new issue