mirror of
https://github.com/monero-project/monero.git
synced 2024-12-25 23:19:25 -05:00
Merge pull request #8488
e0b3507
tests: update block_weight for 2021 scaling (moneromooo-monero)
This commit is contained in:
commit
172a191e3e
@ -138,7 +138,7 @@ static uint32_t lcg()
|
|||||||
|
|
||||||
static void test(test_t t, uint64_t blocks)
|
static void test(test_t t, uint64_t blocks)
|
||||||
{
|
{
|
||||||
PREFIX(10);
|
PREFIX(HF_VERSION_2021_SCALING);
|
||||||
|
|
||||||
for (uint64_t h = 0; h < LONG_TERM_BLOCK_WEIGHT_WINDOW; ++h)
|
for (uint64_t h = 0; h < LONG_TERM_BLOCK_WEIGHT_WINDOW; ++h)
|
||||||
{
|
{
|
||||||
@ -177,8 +177,8 @@ static void test(test_t t, uint64_t blocks)
|
|||||||
}
|
}
|
||||||
uint64_t ltw = bc->get_next_long_term_block_weight(w);
|
uint64_t ltw = bc->get_next_long_term_block_weight(w);
|
||||||
cryptonote::block b;
|
cryptonote::block b;
|
||||||
b.major_version = 10;
|
b.major_version = HF_VERSION_2021_SCALING;
|
||||||
b.minor_version = 10;
|
b.minor_version = HF_VERSION_2021_SCALING;
|
||||||
bc->get_db().add_block(std::make_pair(std::move(b), ""), w, ltw, bc->get_db().height(), bc->get_db().height(), {});
|
bc->get_db().add_block(std::make_pair(std::move(b), ""), w, ltw, bc->get_db().height(), bc->get_db().height(), {});
|
||||||
|
|
||||||
if (!bc->update_next_cumulative_weight_limit())
|
if (!bc->update_next_cumulative_weight_limit())
|
||||||
|
@ -18,14 +18,20 @@ ltembw = MEDIAN_THRESHOLD
|
|||||||
weights = [MEDIAN_THRESHOLD]*MEDIAN_WINDOW_SMALL # weights of recent blocks (B), with index -1 most recent
|
weights = [MEDIAN_THRESHOLD]*MEDIAN_WINDOW_SMALL # weights of recent blocks (B), with index -1 most recent
|
||||||
lt_weights = [MEDIAN_THRESHOLD]*MEDIAN_WINDOW_BIG # long-term weights
|
lt_weights = [MEDIAN_THRESHOLD]*MEDIAN_WINDOW_BIG # long-term weights
|
||||||
|
|
||||||
|
# see contrib/epee/include/misc_language.h, get_mid
|
||||||
|
def get_mid(a, b):
|
||||||
|
return (a//2) + (b//2) + ((a - 2*(a//2)) + (b - 2*(b//2)))//2;
|
||||||
|
|
||||||
# Compute the median of a list
|
# Compute the median of a list
|
||||||
def get_median(vec):
|
def get_median(vec):
|
||||||
#temp = vec
|
if len(vec) == 1:
|
||||||
|
return vec[0]
|
||||||
temp = sorted(vec)
|
temp = sorted(vec)
|
||||||
|
n = len(temp) // 2
|
||||||
if len(temp) % 2 == 1:
|
if len(temp) % 2 == 1:
|
||||||
return temp[len(temp)//2]
|
return temp[n]
|
||||||
else:
|
else:
|
||||||
return int((temp[len(temp)//2]+temp[len(temp)//2-1])//2)
|
return get_mid(temp[n-1], temp[n])
|
||||||
|
|
||||||
def LCG():
|
def LCG():
|
||||||
global lcg_seed
|
global lcg_seed
|
||||||
@ -46,7 +52,7 @@ def run(t, blocks):
|
|||||||
|
|
||||||
# determine the effective weight
|
# determine the effective weight
|
||||||
stmedian = get_median(weights[-MEDIAN_WINDOW_SMALL:])
|
stmedian = get_median(weights[-MEDIAN_WINDOW_SMALL:])
|
||||||
embw = min(max(MEDIAN_THRESHOLD,stmedian),int(MULTIPLIER_BIG*ltembw))
|
embw = min(max(ltembw,stmedian),int(MULTIPLIER_BIG*ltembw))
|
||||||
|
|
||||||
# drop the lowest values
|
# drop the lowest values
|
||||||
weights = weights[1:]
|
weights = weights[1:]
|
||||||
@ -64,7 +70,7 @@ def run(t, blocks):
|
|||||||
else:
|
else:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
weights.append(max_weight)
|
weights.append(max_weight)
|
||||||
lt_weights.append(min(max_weight,int(ltembw + int(ltembw * 2 / 5))))
|
lt_weights.append(min(max(max_weight, ltembw * 10 // 17),int(ltembw + int(ltembw * 7 / 10))))
|
||||||
|
|
||||||
#print "H %u, r %u, BW %u, EMBW %u, LTBW %u, LTEMBW %u, ltmedian %u" % (block, r, max_weight, embw, lt_weights[-1], ltembw, ltmedian)
|
#print "H %u, r %u, BW %u, EMBW %u, LTBW %u, LTEMBW %u, ltmedian %u" % (block, r, max_weight, embw, lt_weights[-1], ltembw, ltmedian)
|
||||||
print("H %u, BW %u, EMBW %u, LTBW %u" % (block, max_weight, embw, lt_weights[-1]))
|
print("H %u, BW %u, EMBW %u, LTBW %u" % (block, max_weight, embw, lt_weights[-1]))
|
||||||
|
Loading…
Reference in New Issue
Block a user