tests: update block_weight for 2021 scaling
the test was still performed with consensus rules from before that change
This commit is contained in:
parent
b6a029f222
commit
e0b3507c88
|
@ -141,7 +141,7 @@ static uint32_t lcg()
|
|||
|
||||
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)
|
||||
{
|
||||
|
@ -180,8 +180,8 @@ static void test(test_t t, uint64_t blocks)
|
|||
}
|
||||
uint64_t ltw = bc->get_next_long_term_block_weight(w);
|
||||
cryptonote::block b;
|
||||
b.major_version = 10;
|
||||
b.minor_version = 10;
|
||||
b.major_version = HF_VERSION_2021_SCALING;
|
||||
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(), {});
|
||||
|
||||
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
|
||||
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
|
||||
def get_median(vec):
|
||||
#temp = vec
|
||||
if len(vec) == 1:
|
||||
return vec[0]
|
||||
temp = sorted(vec)
|
||||
n = len(temp) // 2
|
||||
if len(temp) % 2 == 1:
|
||||
return temp[len(temp)//2]
|
||||
return temp[n]
|
||||
else:
|
||||
return int((temp[len(temp)//2]+temp[len(temp)//2-1])//2)
|
||||
return get_mid(temp[n-1], temp[n])
|
||||
|
||||
def LCG():
|
||||
global lcg_seed
|
||||
|
@ -46,7 +52,7 @@ def run(t, blocks):
|
|||
|
||||
# determine the effective weight
|
||||
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
|
||||
weights = weights[1:]
|
||||
|
@ -64,7 +70,7 @@ def run(t, blocks):
|
|||
else:
|
||||
sys.exit(1)
|
||||
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, BW %u, EMBW %u, LTBW %u" % (block, max_weight, embw, lt_weights[-1]))
|
||||
|
|
Loading…
Reference in New Issue