8#include <chainparams.h>
11#include <test/util/setup_common.h>
13#include <boost/test/unit_test.hpp>
19BOOST_FIXTURE_TEST_SUITE(grasberg_tests, BasicTestingSetup)
136 MMIXLinearCongruentialGenerator lcg;
137 for (
int i = 0; i < 100000; i++) {
138 static constexpr int64_t
POW2_32 = int64_t(1) << 32;
140 const uint32_t n = lcg.next();
141 const double d = double(n) /
POW2_32;
144 const double expected = exp2(d) - 1;
146 BOOST_CHECK(fabs(computed - expected) < 0.0000000075);
151 const auto chainParams =
153 const auto ¶ms = chainParams->GetConsensus();
156 const int64_t expectedBlockTime =
157 nHeight * params.nPowTargetSpacing + chainParams->GenesisBlock().nTime;
161 block.
nTime = expectedBlockTime;
165 params.nPowTargetSpacing);
168 int64_t currentTarget = params.nPowTargetSpacing;
169 std::vector<int> downSteps = {
170 2910, 2916, 2921, 2925, 2931, 2935, 2941, 2945, 2950, 2955, 2961,
171 2965, 2970, 2976, 2980, 2986, 2991, 2995, 3001, 3007, 3011, 3016,
172 3022, 3027, 3033, 3037, 3043, 3048, 3054, 3059, 3064, 3069, 3076,
173 3080, 3086, 3091, 3097, 3103, 3107, 3114, 3119, 3124, 3131, 3135,
174 3142, 3147, 3153, 3158, 3165, 3170, 3175, 3182, 3187, 3194, 3199,
175 3205, 3210, 3217, 3223, 3228, 3235, 3241, 3246, 3253, 3259, 3265,
178 for (
int step : downSteps) {
180 for (
int i = 0; i < step; i++) {
190 for (
int i = 0; i < 10000; i++) {
197 block.
nTime = expectedBlockTime;
198 currentTarget = params.nPowTargetSpacing;
199 std::vector<int> upSteps = {
200 2906, 2901, 2896, 2892, 2887, 2882, 2877, 2873, 2867, 2864, 2858,
201 2854, 2849, 2844, 2840, 2835, 2831, 2826, 2822, 2816, 2813, 2808,
202 2803, 2799, 2794, 2790, 2786, 2781, 2776, 2772, 2768, 2764, 2759,
203 2754, 2751, 2746, 2741, 2738, 2733, 2729, 2724, 2721, 2716, 2711,
204 2708, 2704, 2699, 2695, 2691, 2687, 2682, 2679, 2674, 2671, 2666,
205 2662, 2658, 2655, 2650, 2646, 2642, 2638, 2634, 2630, 2626, 2622,
206 2619, 2614, 2611, 2606, 2603, 2599, 2594, 2592,
209 for (
int step : upSteps) {
210 for (
int i = 0; i < step; i++) {
220 for (
int i = 0; i < 10000; i++) {
230 block.
pprev = pindexPrev;
232 block.
nTime = pindexPrev->
nTime + nTimeInterval;
240 const auto chainParams =
242 const auto ¶ms = chainParams->GetConsensus();
244 std::vector<CBlockIndex> blocks(3000);
247 uint32_t powLimitBits = powLimit.
GetCompact();
249 uint32_t initialBits = currentPow.
GetCompact();
253 blocks[0].nHeight = 0;
254 blocks[0].nTime = 1269211443;
255 blocks[0].nBits = initialBits;
269 std::vector<uint32_t> diffs = {
270 0x1c10032b, 0x1c1004c1, 0x1c100658, 0x1c1007ef, 0x1c100986, 0x1c100b1d,
271 0x1c100cb4, 0x1c100e4b, 0x1c100fe3, 0x1c10117b, 0x1c101313, 0x1c1014ab,
272 0x1c101643, 0x1c1017db, 0x1c101974, 0x1c101b0d, 0x1c101ca6, 0x1c101e3f,
273 0x1c101fd8, 0x1c102171, 0x1c10230a, 0x1c1024a4, 0x1c10263e, 0x1c1027d8,
274 0x1c102972, 0x1c102b0c, 0x1c102ca6, 0x1c102e41, 0x1c102fdc, 0x1c103177,
275 0x1c103312, 0x1c1034ad, 0x1c103648, 0x1c1037e4, 0x1c103980, 0x1c103b1c,
276 0x1c103cb8, 0x1c103e54, 0x1c103ff0, 0x1c10418c, 0x1c104329, 0x1c1044c6,
277 0x1c104663, 0x1c104800, 0x1c10499d, 0x1c104b3a, 0x1c104cd8, 0x1c104e76,
278 0x1c105014, 0x1c1051b2, 0x1c105350, 0x1c1054ee, 0x1c10568d, 0x1c10582c,
279 0x1c1059cb, 0x1c105b6a, 0x1c105d09, 0x1c105ea8, 0x1c106048, 0x1c1061e8,
280 0x1c106388, 0x1c106528, 0x1c1066c8, 0x1c106868, 0x1c106a09, 0x1c106baa,
281 0x1c106d4b, 0x1c106eec, 0x1c10708d, 0x1c10722e, 0x1c1073cf, 0x1c107571,
282 0x1c107713, 0x1c1078b5, 0x1c107a57, 0x1c107bf9, 0x1c107d9b, 0x1c107f3e,
283 0x1c1080e1, 0x1c108284, 0x1c108427, 0x1c1085ca, 0x1c10876d, 0x1c108911,
284 0x1c108ab5, 0x1c108c59, 0x1c108dfd, 0x1c108fa1, 0x1c109145, 0x1c1092ea,
285 0x1c10948f, 0x1c109634, 0x1c1097d9, 0x1c10997e, 0x1c109b23, 0x1c109cc9,
286 0x1c109e6f, 0x1c10a015, 0x1c10a1bb, 0x1c10a361, 0x1c10a507, 0x1c10a6ae,
287 0x1c10a855, 0x1c10a9fc, 0x1c10aba3, 0x1c10ad4a, 0x1c10aef1, 0x1c10b099,
288 0x1c10b241, 0x1c10b3e9, 0x1c10b591, 0x1c10b739, 0x1c10b8e1, 0x1c10ba8a,
289 0x1c10bc33, 0x1c10bddc, 0x1c10bf85, 0x1c10c12e, 0x1c10c2d7, 0x1c10c480,
290 0x1c10c62a, 0x1c10c7d4, 0x1c10c97e, 0x1c10cb28, 0x1c10ccd2, 0x1c10ce7c,
291 0x1c10d027, 0x1c10d1d2, 0x1c10d37d, 0x1c10d528, 0x1c10d6d3, 0x1c10d87e,
292 0x1c10da2a, 0x1c10dbd6, 0x1c10dd82, 0x1c10df2e, 0x1c10e0da, 0x1c10e286,
293 0x1c10e433, 0x1c10e5e0, 0x1c10e78d, 0x1c10e93a, 0x1c10eae7, 0x1c10ec94,
294 0x1c10ee42, 0x1c10eff0, 0x1c10f19e, 0x1c10f34c, 0x1c10f4fa, 0x1c10f6a8,
295 0x1c10f857, 0x1c10fa06, 0x1c10fbb5, 0x1c10fd64, 0x1c10ff13, 0x1c1100c2,
296 0x1c110272, 0x1c110422, 0x1c1105d2, 0x1c110782, 0x1c110932, 0x1c110ae2,
297 0x1c110c93, 0x1c110e44, 0x1c110ff5, 0x1c1111a6, 0x1c111357, 0x1c111508,
298 0x1c1116ba, 0x1c11186c, 0x1c111a1e, 0x1c111bd0, 0x1c111d82, 0x1c111f34,
299 0x1c1120e7, 0x1c11229a, 0x1c11244d, 0x1c112600, 0x1c1127b3, 0x1c112967,
300 0x1c112b1b, 0x1c112ccf, 0x1c112e83, 0x1c113037, 0x1c1131eb, 0x1c1133a0,
301 0x1c113555, 0x1c11370a, 0x1c1138bf, 0x1c113a74, 0x1c113c29, 0x1c113ddf,
302 0x1c113f95, 0x1c11414b, 0x1c114301, 0x1c1144b7, 0x1c11466d, 0x1c114824,
303 0x1c1149db, 0x1c114b92, 0x1c114d49, 0x1c114f00, 0x1c1150b7, 0x1c11526f,
304 0x1c115427, 0x1c1155df, 0x1c115797, 0x1c11594f, 0x1c115b07, 0x1c115cc0,
305 0x1c115e79, 0x1c116032, 0x1c1161eb, 0x1c1163a4, 0x1c11655d, 0x1c116717,
306 0x1c1168d1, 0x1c116a8b, 0x1c116c45, 0x1c116dff, 0x1c116fb9, 0x1c117174,
307 0x1c11732f, 0x1c1174ea, 0x1c1176a5, 0x1c117860, 0x1c117a1c, 0x1c117bd8,
308 0x1c117d94, 0x1c117f50, 0x1c11810c, 0x1c1182c8, 0x1c118485, 0x1c118642,
309 0x1c1187ff, 0x1c1189bc, 0x1c118b79, 0x1c118d36, 0x1c118ef4, 0x1c1190b2,
310 0x1c119270, 0x1c11942e, 0x1c1195ec, 0x1c1197aa, 0x1c119969, 0x1c119b28,
311 0x1c119ce7, 0x1c119ea6, 0x1c11a065, 0x1c11a224, 0x1c11a3e4, 0x1c11a5a4,
312 0x1c11a764, 0x1c11a924, 0x1c11aae4, 0x1c11aca5, 0x1c11ae66, 0x1c11b027,
313 0x1c11b1e8, 0x1c11b3a9, 0x1c11b56a, 0x1c11b72c, 0x1c11b8ee, 0x1c11bab0,
314 0x1c11bc72, 0x1c11be34, 0x1c11bff6, 0x1c11c1b9, 0x1c11c37c, 0x1c11c53f,
315 0x1c11c702, 0x1c11c8c5, 0x1c11ca88, 0x1c11cc4c, 0x1c11ce10, 0x1c11cfd4,
316 0x1c11d198, 0x1c11d35c, 0x1c11d521, 0x1c11d6e6, 0x1c11d8ab, 0x1c11da70,
317 0x1c11dc35, 0x1c11ddfa, 0x1c11dfc0, 0x1c11e186, 0x1c11e34c, 0x1c11e512,
318 0x1c11e6d8, 0x1c11e89e, 0x1c11ea65, 0x1c11ec2c, 0x1c11edf3, 0x1c11efba,
319 0x1c11f181, 0x1c11f349, 0x1c11f511, 0x1c11f6d9, 0x1c11f8a1, 0x1c11fa69,
322 for (uint32_t expected : diffs) {
332 0x1c11eee4, 0x1c11e366, 0x1c11d7f0, 0x1c11cc81, 0x1c11c119, 0x1c11b5b9,
333 0x1c11aa60, 0x1c119f0e, 0x1c1193c3, 0x1c118880, 0x1c117d44, 0x1c11720f,
334 0x1c1166e1, 0x1c115bba, 0x1c11509a, 0x1c114582, 0x1c113a71, 0x1c112f67,
335 0x1c112464, 0x1c111968, 0x1c110e73, 0x1c110385, 0x1c10f89e, 0x1c10edbe,
336 0x1c10e2e5, 0x1c10d813, 0x1c10cd48, 0x1c10c284, 0x1c10b7c7, 0x1c10ad11,
337 0x1c10a261, 0x1c1097b8, 0x1c108d16, 0x1c10827b, 0x1c1077e7, 0x1c106d59,
338 0x1c1062d2, 0x1c105852, 0x1c104dd9, 0x1c104366, 0x1c1038fa, 0x1c102e95,
339 0x1c102436, 0x1c1019de, 0x1c100f8d, 0x1c100542, 0x1c0ffafe, 0x1c0ff0c0,
340 0x1c0fe689, 0x1c0fdc59, 0x1c0fd22f, 0x1c0fc80c, 0x1c0fbdef, 0x1c0fb3d9,
341 0x1c0fa9c9, 0x1c0f9fc0, 0x1c0f95bd, 0x1c0f8bc0, 0x1c0f81ca, 0x1c0f77da,
342 0x1c0f6df0, 0x1c0f640d, 0x1c0f5a30, 0x1c0f5059, 0x1c0f4689, 0x1c0f3cbf,
343 0x1c0f32fb, 0x1c0f293e, 0x1c0f1f87, 0x1c0f15d6, 0x1c0f0c2b, 0x1c0f0286,
344 0x1c0ef8e8, 0x1c0eef50, 0x1c0ee5be, 0x1c0edc32, 0x1c0ed2ac, 0x1c0ec92c,
345 0x1c0ebfb2, 0x1c0eb63e, 0x1c0eacd1, 0x1c0ea36a, 0x1c0e9a09, 0x1c0e90ae,
346 0x1c0e8759, 0x1c0e7e0a, 0x1c0e74c1, 0x1c0e6b7d, 0x1c0e623f, 0x1c0e5907,
347 0x1c0e4fd5, 0x1c0e46a9, 0x1c0e3d83, 0x1c0e3463, 0x1c0e2b49, 0x1c0e2235,
348 0x1c0e1926, 0x1c0e101d, 0x1c0e071a, 0x1c0dfe1d, 0x1c0df526, 0x1c0dec34,
349 0x1c0de348, 0x1c0dda62, 0x1c0dd181, 0x1c0dc8a6, 0x1c0dbfd1, 0x1c0db701,
350 0x1c0dae37, 0x1c0da573, 0x1c0d9cb4, 0x1c0d93fb, 0x1c0d8b47, 0x1c0d8299,
351 0x1c0d79f1, 0x1c0d714e, 0x1c0d68b1, 0x1c0d6019, 0x1c0d5787, 0x1c0d4efa,
352 0x1c0d4673, 0x1c0d3df1, 0x1c0d3575, 0x1c0d2cfe, 0x1c0d248c, 0x1c0d1c20,
353 0x1c0d13b9, 0x1c0d0b58, 0x1c0d02fc, 0x1c0cfaa5, 0x1c0cf254, 0x1c0cea08,
354 0x1c0ce1c1, 0x1c0cd980, 0x1c0cd144, 0x1c0cc90d, 0x1c0cc0dc, 0x1c0cb8b0,
355 0x1c0cb089, 0x1c0ca867, 0x1c0ca04a, 0x1c0c9833, 0x1c0c9021, 0x1c0c8814,
356 0x1c0c800c, 0x1c0c7809, 0x1c0c700b, 0x1c0c6813, 0x1c0c6020, 0x1c0c5832,
357 0x1c0c5049, 0x1c0c4865, 0x1c0c4086, 0x1c0c38ac, 0x1c0c30d7, 0x1c0c2907,
358 0x1c0c213c, 0x1c0c1976, 0x1c0c11b5, 0x1c0c09f9, 0x1c0c0242, 0x1c0bfa90,
359 0x1c0bf2e3, 0x1c0beb3b, 0x1c0be398, 0x1c0bdbfa, 0x1c0bd460, 0x1c0bcccb,
360 0x1c0bc53b, 0x1c0bbdb0, 0x1c0bb62a, 0x1c0baea9, 0x1c0ba72c, 0x1c0b9fb4,
361 0x1c0b9841, 0x1c0b90d3, 0x1c0b896a, 0x1c0b8205, 0x1c0b7aa5, 0x1c0b734a,
362 0x1c0b6bf3, 0x1c0b64a1, 0x1c0b5d54, 0x1c0b560c, 0x1c0b4ec8, 0x1c0b4789,
363 0x1c0b404f, 0x1c0b3919, 0x1c0b31e8, 0x1c0b2abb, 0x1c0b2393, 0x1c0b1c70,
364 0x1c0b1551, 0x1c0b0e37, 0x1c0b0721, 0x1c0b0010, 0x1c0af903, 0x1c0af1fb,
365 0x1c0aeaf7, 0x1c0ae3f8, 0x1c0adcfd, 0x1c0ad607, 0x1c0acf15, 0x1c0ac828,
366 0x1c0ac13f, 0x1c0aba5b, 0x1c0ab37b, 0x1c0aac9f, 0x1c0aa5c8, 0x1c0a9ef5,
367 0x1c0a9827, 0x1c0a915d, 0x1c0a8a97, 0x1c0a83d6, 0x1c0a7d19, 0x1c0a7660,
368 0x1c0a6fac, 0x1c0a68fc, 0x1c0a6250, 0x1c0a5ba8, 0x1c0a5505, 0x1c0a4e66,
369 0x1c0a47cb, 0x1c0a4134, 0x1c0a3aa2, 0x1c0a3414, 0x1c0a2d8a, 0x1c0a2704,
370 0x1c0a2082, 0x1c0a1a05, 0x1c0a138c, 0x1c0a0d17, 0x1c0a06a6, 0x1c0a0039,
371 0x1c09f9d0, 0x1c09f36b, 0x1c09ed0a, 0x1c09e6ae, 0x1c09e056, 0x1c09da02,
372 0x1c09d3b2, 0x1c09cd66, 0x1c09c71e, 0x1c09c0da, 0x1c09ba9a, 0x1c09b45e,
373 0x1c09ae26, 0x1c09a7f2, 0x1c09a1c2, 0x1c099b96, 0x1c09956e, 0x1c098f4a,
374 0x1c09892a, 0x1c09830d, 0x1c097cf4, 0x1c0976df, 0x1c0970ce, 0x1c096ac1,
375 0x1c0964b8, 0x1c095eb3, 0x1c0958b2, 0x1c0952b5, 0x1c094cbb, 0x1c0946c5,
376 0x1c0940d3, 0x1c093ae5, 0x1c0934fb, 0x1c092f14, 0x1c092931, 0x1c092352,
377 0x1c091d77, 0x1c09179f, 0x1c0911cb, 0x1c090bfb, 0x1c09062f, 0x1c090066,
378 0x1c08faa1, 0x1c08f4e0, 0x1c08ef22, 0x1c08e968, 0x1c08e3b2, 0x1c08de00,
379 0x1c08d851, 0x1c08d2a6, 0x1c08ccfe, 0x1c08c75a, 0x1c08c1ba, 0x1c08bc1d,
380 0x1c08b684, 0x1c08b0ee, 0x1c08ab5c, 0x1c08a5ce, 0x1c08a043, 0x1c089abc,
381 0x1c089538, 0x1c088fb8, 0x1c088a3b, 0x1c0884c2, 0x1c087f4c, 0x1c0879da,
384 for (uint32_t expected : diffs) {
394 0x1c08a0b5, 0x1c08c842, 0x1c08f084, 0x1c09197f, 0x1c094336, 0x1c096dac,
395 0x1c0998e4, 0x1c09c4e3, 0x1c09f1ab, 0x1c0a1f41, 0x1c0a4da8, 0x1c0a7ce3,
396 0x1c0aacf7, 0x1c0adde7, 0x1c0b0fb8, 0x1c0b426d, 0x1c0b760a, 0x1c0baa94,
397 0x1c0be00f, 0x1c0c167f, 0x1c0c4de9, 0x1c0c8651, 0x1c0cbfbb, 0x1c0cfa2c,
398 0x1c0d35a9, 0x1c0d7237, 0x1c0dafdb, 0x1c0dee99, 0x1c0e2e77, 0x1c0e6f7a,
399 0x1c0eb1a7, 0x1c0ef503, 0x1c0f3994, 0x1c0f7f5f, 0x1c0fc66a, 0x1c100ebb,
400 0x1c105857, 0x1c10a345, 0x1c10ef8a, 0x1c113d2d, 0x1c118c34, 0x1c11dca5,
401 0x1c122e87, 0x1c1281e0, 0x1c12d6b7, 0x1c132d13, 0x1c1384fb, 0x1c13de76,
402 0x1c14398b, 0x1c149642, 0x1c14f4a2, 0x1c1554b3, 0x1c15b67c, 0x1c161a05,
403 0x1c167f57, 0x1c16e679, 0x1c174f74, 0x1c17ba50, 0x1c182716, 0x1c1895cf,
404 0x1c190683, 0x1c19793c, 0x1c19ee03, 0x1c1a64e1, 0x1c1adde0, 0x1c1b590a,
405 0x1c1bd668, 0x1c1c5605, 0x1c1cd7eb, 0x1c1d5c25, 0x1c1de2bd, 0x1c1e6bbe,
406 0x1c1ef733, 0x1c1f8527, 0x1c2015a6, 0x1c20a8bb, 0x1c213e73, 0x1c21d6d9,
407 0x1c2271fa, 0x1c230fe2, 0x1c23b09e, 0x1c24543a, 0x1c24fac5, 0x1c25a44b,
408 0x1c2650da, 0x1c270080, 0x1c27b34b, 0x1c28694a, 0x1c29228b, 0x1c29df1e,
409 0x1c2a9f11, 0x1c2b6274, 0x1c2c2957, 0x1c2cf3ca, 0x1c2dc1dd, 0x1c2e93a0,
410 0x1c2f6925, 0x1c30427d, 0x1c311fb9, 0x1c3200eb, 0x1c32e626, 0x1c33cf7c,
411 0x1c34bcff, 0x1c35aec3, 0x1c36a4db, 0x1c379f5c, 0x1c389e59, 0x1c39a1e7,
412 0x1c3aaa1b, 0x1c3bb70a, 0x1c3cc8ca, 0x1c3ddf71, 0x1c3efb15, 0x1c401bcd,
413 0x1c4141b1, 0x1c426cd8, 0x1c439d5b, 0x1c44d352, 0x1c460ed6, 0x1c475000,
414 0x1c4896ea, 0x1c49e3af, 0x1c4b366a, 0x1c4c8f35, 0x1c4dee2d, 0x1c4f536e,
415 0x1c50bf15, 0x1c52313f, 0x1c53aa0a, 0x1c552994, 0x1c56affc, 0x1c583d62,
416 0x1c59d1e6, 0x1c5b6da8, 0x1c5d10ca, 0x1c5ebb6d, 0x1c606db4, 0x1c6227c2,
417 0x1c63e9bb, 0x1c65b3c2, 0x1c6785fd, 0x1c696091, 0x1c6b43a5, 0x1c6d2f60,
418 0x1c6f23e9, 0x1c712169, 0x1c732808, 0x1c7537f1, 0x1c77514e, 0x1c79744a,
419 0x1c7ba112, 0x1c7dd7d2, 0x1d008018, 0x1d008263, 0x1d0084b8, 0x1d008718,
420 0x1d008983, 0x1d008bf9, 0x1d008e7a, 0x1d009107, 0x1d00939f, 0x1d009643,
421 0x1d0098f3, 0x1d009bb0, 0x1d009e79, 0x1d00a14f, 0x1d00a432, 0x1d00a722,
422 0x1d00aa20, 0x1d00ad2b, 0x1d00b044, 0x1d00b36c, 0x1d00b6a2, 0x1d00b9e7,
423 0x1d00bd3b, 0x1d00c09e, 0x1d00c411, 0x1d00c793, 0x1d00cb25, 0x1d00cec8,
424 0x1d00d27b, 0x1d00d63f, 0x1d00da15, 0x1d00ddfc, 0x1d00e1f5, 0x1d00e600,
425 0x1d00ea1e, 0x1d00ee4f, 0x1d00f293, 0x1d00f6eb, 0x1d00fb56, 0x1d00ffd6,
426 0x1d00ffff, 0x1d00ffff, 0x1d00ffff, 0x1d00ffff, 0x1d00ffff, 0x1d00ffff,
427 0x1d00ffff, 0x1d00ffff,
430 for (uint32_t expected : diffs) {
443 0x1d00ff35, 0x1d00fe6b, 0x1d00fda2, 0x1d00fcda, 0x1d00fc12, 0x1d00fb4b,
444 0x1d00fa84, 0x1d00f9be, 0x1d00f8f9, 0x1d00f834, 0x1d00f770, 0x1d00f6ac,
445 0x1d00f5e9, 0x1d00f527, 0x1d00f465, 0x1d00f3a4, 0x1d00f2e3, 0x1d00f223,
446 0x1d00f164, 0x1d00f0a5, 0x1d00efe7, 0x1d00ef29, 0x1d00ee6c, 0x1d00edb0,
447 0x1d00ecf4, 0x1d00ec39, 0x1d00eb7e, 0x1d00eac4, 0x1d00ea0a, 0x1d00e951,
448 0x1d00e899, 0x1d00e7e1, 0x1d00e72a, 0x1d00e673, 0x1d00e5bd, 0x1d00e507,
449 0x1d00e452, 0x1d00e39d, 0x1d00e2e9, 0x1d00e236, 0x1d00e183, 0x1d00e0d1,
450 0x1d00e01f, 0x1d00df6e, 0x1d00debd, 0x1d00de0d, 0x1d00dd5d, 0x1d00dcae,
451 0x1d00dc00, 0x1d00db52, 0x1d00daa5, 0x1d00d9f8, 0x1d00d94c, 0x1d00d8a0,
452 0x1d00d7f5, 0x1d00d74a, 0x1d00d6a0, 0x1d00d5f6, 0x1d00d54d, 0x1d00d4a4,
453 0x1d00d3fc, 0x1d00d354, 0x1d00d2ad, 0x1d00d206, 0x1d00d160, 0x1d00d0ba,
454 0x1d00d015, 0x1d00cf70, 0x1d00cecc, 0x1d00ce28, 0x1d00cd85, 0x1d00cce2,
455 0x1d00cc40, 0x1d00cb9e, 0x1d00cafd, 0x1d00ca5c, 0x1d00c9bc, 0x1d00c91c,
456 0x1d00c87d, 0x1d00c7de, 0x1d00c740, 0x1d00c6a2, 0x1d00c605, 0x1d00c568,
457 0x1d00c4cc, 0x1d00c430, 0x1d00c395, 0x1d00c2fa, 0x1d00c260, 0x1d00c1c6,
458 0x1d00c12d, 0x1d00c094, 0x1d00bffc, 0x1d00bf64, 0x1d00becd, 0x1d00be36,
459 0x1d00bda0, 0x1d00bd0a, 0x1d00bc74, 0x1d00bbdf, 0x1d00bb4a, 0x1d00bab6,
460 0x1d00ba22, 0x1d00b98f, 0x1d00b8fc, 0x1d00b86a, 0x1d00b7d8, 0x1d00b747,
461 0x1d00b6b6, 0x1d00b625, 0x1d00b595, 0x1d00b505, 0x1d00b476, 0x1d00b3e7,
462 0x1d00b359, 0x1d00b2cb, 0x1d00b23e, 0x1d00b1b1, 0x1d00b124, 0x1d00b098,
463 0x1d00b00c, 0x1d00af81, 0x1d00aef6, 0x1d00ae6c, 0x1d00ade2, 0x1d00ad58,
464 0x1d00accf, 0x1d00ac46, 0x1d00abbe, 0x1d00ab36, 0x1d00aaaf, 0x1d00aa28,
465 0x1d00a9a1, 0x1d00a91b, 0x1d00a895, 0x1d00a810, 0x1d00a78b, 0x1d00a706,
466 0x1d00a682, 0x1d00a5fe, 0x1d00a57b, 0x1d00a4f8, 0x1d00a475, 0x1d00a3f3,
467 0x1d00a371, 0x1d00a2f0, 0x1d00a26f, 0x1d00a1ee, 0x1d00a16e, 0x1d00a0ee,
468 0x1d00a06f, 0x1d009ff0, 0x1d009f71, 0x1d009ef3, 0x1d009e75, 0x1d009df8,
469 0x1d009d7b, 0x1d009cfe, 0x1d009c82, 0x1d009c06, 0x1d009b8a, 0x1d009b0f,
470 0x1d009a94, 0x1d009a1a, 0x1d0099a0, 0x1d009926, 0x1d0098ad, 0x1d009834,
471 0x1d0097bc, 0x1d009744, 0x1d0096cc, 0x1d009655, 0x1d0095de, 0x1d009567,
472 0x1d0094f1, 0x1d00947b, 0x1d009405, 0x1d009390, 0x1d00931b, 0x1d0092a7,
473 0x1d009233, 0x1d0091bf, 0x1d00914c, 0x1d0090d9, 0x1d009066, 0x1d008ff4,
474 0x1d008f82, 0x1d008f10, 0x1d008e9f, 0x1d008e2e, 0x1d008dbd, 0x1d008d4d,
475 0x1d008cdd, 0x1d008c6d, 0x1d008bfe, 0x1d008b8f, 0x1d008b20, 0x1d008ab2,
476 0x1d008a44, 0x1d0089d6, 0x1d008969, 0x1d0088fc, 0x1d00888f, 0x1d008823,
477 0x1d0087b7, 0x1d00874b, 0x1d0086e0, 0x1d008675, 0x1d00860a, 0x1d0085a0,
478 0x1d008536, 0x1d0084cc, 0x1d008463, 0x1d0083fa, 0x1d008391, 0x1d008329,
479 0x1d0082c1, 0x1d008259, 0x1d0081f2, 0x1d00818b, 0x1d008124, 0x1d0080be,
480 0x1d008058, 0x1c7ff2cf, 0x1c7f8dee, 0x1c7f295d, 0x1c7ec51b, 0x1c7e6128,
481 0x1c7dfd84, 0x1c7d9a2e, 0x1c7d3727, 0x1c7cd46e, 0x1c7c7202, 0x1c7c0fe4,
482 0x1c7bae13, 0x1c7b4c90, 0x1c7aeb59, 0x1c7a8a6f, 0x1c7a29d1, 0x1c79c980,
483 0x1c79697b, 0x1c7909c1, 0x1c78aa53, 0x1c784b30, 0x1c77ec58, 0x1c778dcb,
484 0x1c772f88, 0x1c76d190, 0x1c7673e2, 0x1c76167e, 0x1c75b963, 0x1c755c92,
485 0x1c75000a, 0x1c74a3cb, 0x1c7447d4, 0x1c73ec26, 0x1c7390c0, 0x1c7335a2,
486 0x1c72dacc, 0x1c72803e, 0x1c7225f7, 0x1c71cbf7, 0x1c71723e, 0x1c7118cc,
487 0x1c70bfa1, 0x1c7066bc, 0x1c700e1d, 0x1c6fb5c4, 0x1c6f5db1, 0x1c6f05e3,
488 0x1c6eae5a, 0x1c6e5716, 0x1c6e0017, 0x1c6da95d, 0x1c6d52e7, 0x1c6cfcb5,
489 0x1c6ca6c7, 0x1c6c511d, 0x1c6bfbb6, 0x1c6ba693, 0x1c6b51b3, 0x1c6afd16,
490 0x1c6aa8bb, 0x1c6a54a3, 0x1c6a00cd, 0x1c69ad39, 0x1c6959e7, 0x1c6906d7,
491 0x1c68b408, 0x1c68617b, 0x1c680f2f, 0x1c67bd24, 0x1c676b59, 0x1c6719cf,
492 0x1c66c885, 0x1c66777b, 0x1c6626b1, 0x1c65d627, 0x1c6585dc, 0x1c6535d1,
495 for (uint32_t expected : diffs) {
505 0x1c64d713, 0x1c6478ae, 0x1c641aa1, 0x1c63bcec, 0x1c635f8f, 0x1c630289,
506 0x1c62a5da, 0x1c624982, 0x1c61ed81, 0x1c6191d6, 0x1c613681, 0x1c60db81,
507 0x1c6080d6, 0x1c602680, 0x1c5fcc7f, 0x1c5f72d2, 0x1c5f1979, 0x1c5ec073,
508 0x1c5e67c1, 0x1c5e0f62, 0x1c5db756, 0x1c5d5f9c, 0x1c5d0834, 0x1c5cb11e,
509 0x1c5c5a59, 0x1c5c03e6, 0x1c5badc4, 0x1c5b57f2, 0x1c5b0271, 0x1c5aad40,
510 0x1c5a585e, 0x1c5a03cc, 0x1c59af89, 0x1c595b95, 0x1c5907ef, 0x1c58b498,
511 0x1c58618f, 0x1c580ed3, 0x1c57bc65, 0x1c576a44, 0x1c571870, 0x1c56c6e9,
512 0x1c5675ae, 0x1c5624bf, 0x1c55d41c, 0x1c5583c4, 0x1c5533b7, 0x1c54e3f5,
513 0x1c54947e, 0x1c544551, 0x1c53f66e, 0x1c53a7d5, 0x1c535986, 0x1c530b80,
514 0x1c52bdc3, 0x1c52704f, 0x1c522323, 0x1c51d640, 0x1c5189a5, 0x1c513d51,
515 0x1c50f145, 0x1c50a580, 0x1c505a02, 0x1c500ecb, 0x1c4fc3da, 0x1c4f792f,
516 0x1c4f2eca, 0x1c4ee4ab, 0x1c4e9ad1, 0x1c4e513c, 0x1c4e07ec, 0x1c4dbee1,
517 0x1c4d761a, 0x1c4d2d97, 0x1c4ce558, 0x1c4c9d5d, 0x1c4c55a5, 0x1c4c0e30,
518 0x1c4bc6fe, 0x1c4b800f, 0x1c4b3962, 0x1c4af2f7, 0x1c4aacce, 0x1c4a66e7,
519 0x1c4a2141, 0x1c49dbdc, 0x1c4996b8, 0x1c4951d5, 0x1c490d33, 0x1c48c8d1,
520 0x1c4884af, 0x1c4840cd, 0x1c47fd2a, 0x1c47b9c7, 0x1c4776a3, 0x1c4733bd,
521 0x1c46f116, 0x1c46aead, 0x1c466c83, 0x1c462a97, 0x1c45e8e8, 0x1c45a777,
522 0x1c456643, 0x1c45254c, 0x1c44e492, 0x1c44a414, 0x1c4463d3, 0x1c4423ce,
523 0x1c43e405, 0x1c43a478, 0x1c436526, 0x1c43260f, 0x1c42e733, 0x1c42a892,
524 0x1c426a2c, 0x1c422c00, 0x1c41ee0f, 0x1c41b057, 0x1c4172d9, 0x1c413595,
525 0x1c40f88a, 0x1c40bbb8, 0x1c407f1f, 0x1c4042bf, 0x1c400697, 0x1c3fcaa8,
526 0x1c3f8ef1, 0x1c3f5372, 0x1c3f182a, 0x1c3edd1a, 0x1c3ea241, 0x1c3e679f,
527 0x1c3e2d34, 0x1c3df300, 0x1c3db902, 0x1c3d7f3b, 0x1c3d45aa, 0x1c3d0c4f,
528 0x1c3cd329, 0x1c3c9a39, 0x1c3c617e, 0x1c3c28f8, 0x1c3bf0a7, 0x1c3bb88b,
529 0x1c3b80a3, 0x1c3b48f0, 0x1c3b1171, 0x1c3ada26, 0x1c3aa30f, 0x1c3a6c2b,
530 0x1c3a357b, 0x1c39fefe, 0x1c39c8b4, 0x1c39929d, 0x1c395cb8, 0x1c392706,
531 0x1c38f186, 0x1c38bc38, 0x1c38871c, 0x1c385232, 0x1c381d79, 0x1c37e8f1,
532 0x1c37b49b, 0x1c378076, 0x1c374c81, 0x1c3718bd, 0x1c36e52a, 0x1c36b1c7,
533 0x1c367e94, 0x1c364b91, 0x1c3618be, 0x1c35e61a, 0x1c35b3a6, 0x1c358161,
534 0x1c354f4b, 0x1c351d64, 0x1c34ebab, 0x1c34ba21, 0x1c3488c5, 0x1c345798,
535 0x1c342699, 0x1c33f5c7, 0x1c33c523, 0x1c3394ad, 0x1c336464, 0x1c333448,
536 0x1c330459, 0x1c32d497, 0x1c32a502, 0x1c327599, 0x1c32465d, 0x1c32174d,
537 0x1c31e869, 0x1c31b9b1, 0x1c318b25, 0x1c315cc4, 0x1c312e8f, 0x1c310085,
538 0x1c30d2a6, 0x1c30a4f2, 0x1c307769, 0x1c304a0a, 0x1c301cd6, 0x1c2fefcc,
539 0x1c2fc2ec, 0x1c2f9636, 0x1c2f69aa, 0x1c2f3d48, 0x1c2f110f, 0x1c2ee500,
540 0x1c2eb91a, 0x1c2e8d5d, 0x1c2e61c9, 0x1c2e365e, 0x1c2e0b1b, 0x1c2de001,
541 0x1c2db50f, 0x1c2d8a46, 0x1c2d5fa5, 0x1c2d352b, 0x1c2d0ad9, 0x1c2ce0af,
542 0x1c2cb6ac, 0x1c2c8cd1, 0x1c2c631d, 0x1c2c3990, 0x1c2c102a, 0x1c2be6ea,
543 0x1c2bbdd1, 0x1c2b94df, 0x1c2b6c13, 0x1c2b436d, 0x1c2b1aed, 0x1c2af293,
544 0x1c2aca5f, 0x1c2aa250, 0x1c2a7a67, 0x1c2a52a3, 0x1c2a2b05, 0x1c2a038c,
545 0x1c29dc38, 0x1c29b508, 0x1c298dfd, 0x1c296717, 0x1c294055, 0x1c2919b7,
546 0x1c28f33d, 0x1c28cce7, 0x1c28a6b5, 0x1c2880a7, 0x1c285abd, 0x1c2834f6,
547 0x1c280f53, 0x1c27e9d3, 0x1c27c476, 0x1c279f3c, 0x1c277a25, 0x1c275530,
548 0x1c27305e, 0x1c270baf, 0x1c26e722, 0x1c26c2b7, 0x1c269e6e, 0x1c267a47,
549 0x1c265642, 0x1c26325f, 0x1c260e9d, 0x1c25eafd, 0x1c25c77e, 0x1c25a420,
550 0x1c2580e3, 0x1c255dc7, 0x1c253acc, 0x1c2517f2, 0x1c24f539, 0x1c24d2a0,
551 0x1c24b028, 0x1c248dd0, 0x1c246b98, 0x1c244980, 0x1c242788, 0x1c2405b0,
552 0x1c23e3f7, 0x1c23c25e, 0x1c23a0e4, 0x1c237f8a, 0x1c235e4f, 0x1c233d33,
553 0x1c231c36, 0x1c22fb58, 0x1c22da99, 0x1c22b9f8, 0x1c229976, 0x1c227912,
554 0x1c2258cd, 0x1c2238a6, 0x1c22189d, 0x1c21f8b2, 0x1c21d8e5, 0x1c21b936,
557 for (uint32_t expected : diffs) {
593 const auto chainParams =
595 const auto ¶ms = chainParams->GetConsensus();
597 std::vector<CBlockIndex> blocks(3000);
600 uint32_t powLimitBits = powLimit.
GetCompact();
602 uint32_t initialBits = currentPow.
GetCompact();
606 blocks[0].nHeight = 0;
607 blocks[0].nTime = 1269211443;
608 blocks[0].nBits = initialBits;
619 blkHeaderDummy.
nTime = blocks[0].nTime + 2 * params.nPowTargetSpacing;
625 blkHeaderDummy.
nTime++;
633 std::vector<uint32_t> diffs = {
634 0x1c100c81, 0x1c101ad2, 0x1c10292f, 0x1c103799, 0x1c104610,
635 0x1c105494, 0x1c106325, 0x1c1071c2, 0x1c10806d, 0x1c108f25,
640 for (uint32_t expected : diffs) {
642 &blocks[h - 1], 2 * params.nPowTargetSpacing + 1, powLimitBits);
656 0x1c109c17, 0x1c10aae8, 0x1c10b9c6, 0x1c10c8b1, 0x1c10d7a9,
657 0x1c10e6af, 0x1c10f5c2, 0x1c1104e2, 0x1c111410, 0x1c11234c,
661 for (uint32_t expected : diffs) {
663 &blocks[h - 1], 2 * params.nPowTargetSpacing + 1, powLimitBits);
670BOOST_AUTO_TEST_SUITE_END()
arith_uint256 UintToArith256(const uint256 &a)
arith_uint256 GetBlockProof(const CBlockIndex &block)
std::unique_ptr< const CChainParams > CreateChainParams(const ArgsManager &args, const std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
static const std::string TESTNET
static const std::string MAIN
BIP70 chain name strings (main, test or regtest)
The block chain is a tree shaped structure starting with the genesis block at the root,...
CBlockIndex * pprev
pointer to the index of the predecessor of this block
arith_uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
int nHeight
height of the entry in the chain. The genesis block has height 0
256-bit unsigned big integer.
uint32_t GetCompact(bool fNegative=false) const
static constexpr int64_t POW2_32
uint32_t GetNextGrasbergWorkRequired(const CBlockIndex *pindexPrev, const CBlockHeader *pblock, const CChainParams &chainParams)
Compute the next required proof of work using a relative target based ASERT algorithm.
static CBlockIndex GetBlockIndex(CBlockIndex *pindexPrev, int64_t nTimeInterval, uint32_t nBits)
BOOST_AUTO_TEST_CASE(exp2_test)
int64_t computeTargetBlockTime(const CBlockIndex *pindexPrev, const CChainParams &chainParams)
Compute the block time we are aiming for.
uint32_t deterministicExp2(const uint32_t n)
Computes exp2(n) = 2^32 * (2^(n/2^32) - 1)
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)