aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2024-05-20 22:46:53 -0500
committerluigi1111 <luigi1111w@gmail.com>2024-05-20 22:46:53 -0500
commit172a191e3e2369e21d5fa9736a7701e08cd4bbf1 (patch)
tree76dbc4ca89c386c6eeaaa1506bc5a77d8cf03b83
parentMerge pull request #8396 (diff)
parenttests: update block_weight for 2021 scaling (diff)
downloadmonero-172a191e3e2369e21d5fa9736a7701e08cd4bbf1.tar.xz
Merge pull request #8488
e0b3507 tests: update block_weight for 2021 scaling (moneromooo-monero)
-rw-r--r--tests/block_weight/block_weight.cpp6
-rwxr-xr-xtests/block_weight/block_weight.py16
2 files changed, 14 insertions, 8 deletions
diff --git a/tests/block_weight/block_weight.cpp b/tests/block_weight/block_weight.cpp
index 4b00fc63f..676d56006 100644
--- a/tests/block_weight/block_weight.cpp
+++ b/tests/block_weight/block_weight.cpp
@@ -138,7 +138,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)
{
@@ -177,8 +177,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())
diff --git a/tests/block_weight/block_weight.py b/tests/block_weight/block_weight.py
index 5ec09896d..cfd0900fb 100755
--- a/tests/block_weight/block_weight.py
+++ b/tests/block_weight/block_weight.py
@@ -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]))