Hush Full Node software. We were censored from Github, this is where all development happens now. https://hush.is
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

416 lines
40 KiB

// Copyright (c) 2011-2014 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "arith_uint256.h"
#include "consensus/validation.h"
#include "main.h"
#include "miner.h"
#include "pubkey.h"
#include "uint256.h"
#include "util.h"
#include "crypto/equihash.h"
#include "test/test_bitcoin.h"
#include <boost/test/unit_test.hpp>
BOOST_FIXTURE_TEST_SUITE(miner_tests, TestingSetup)
#define NUM_EQUIHASH_SOLUTIONS 32
static
struct {
const char *nonce_hex;
uint32_t vSolutions[NUM_EQUIHASH_SOLUTIONS];
} blockinfo[] = {
{"0000000000000000000000000000000000000000000000000000000000000001", {187,76993,40977,102791,20135,21950,25386,35096,10891,74755,22546,105268,50515,118565,125060,127451,17045,69410,53809,119937,35356,115865,100848,106004,47327,85897,92734,131007,51962,64071,95207,106604}},
{"0000000000000000000000000000000000000000000000000000000000000000", {6114,45875,93365,109347,85385,86771,102972,119313,10868,44740,38680,130916,54721,92791,79419,116006,24014,107390,47609,125808,52484,102571,104798,120840,67949,99024,79539,79757,78555,111141,111114,111248}},
{"0000000000000000000000000000000000000000000000000000000000000002", {184,21800,22466,96728,71530,129292,112385,114842,4548,34355,52096,76968,25108,27158,103316,111645,14433,124390,80962,119412,46159,71937,99247,130008,15312,32471,19673,117551,25249,58891,118022,124388}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2039,110329,37265,54052,6484,70372,65899,107380,9323,99320,36022,36270,22327,94983,23074,85336,11167,113840,75287,86333,21971,86803,29137,40960,41652,59663,54853,117798,58220,70913,58798,101257}},
{"0000000000000000000000000000000000000000000000000000000000000000", {361,49078,36044,56395,30867,77313,119849,119894,6719,72703,45925,128171,47873,55425,101655,123874,1485,125183,54136,63264,11288,121451,98826,125397,3427,124759,69753,110152,47454,99914,53232,82916}},
{"0000000000000000000000000000000000000000000000000000000000000000", {519,18820,26785,101932,2762,56222,41407,58328,1788,12716,36758,64368,25152,86798,52010,112505,2666,14667,30671,121537,3483,53618,64493,89621,26754,47632,85241,101490,30518,36880,106868,110795}},
{"0000000000000000000000000000000000000000000000000000000000000000", {635,99683,52684,74186,28758,119239,53891,103535,1877,27639,7807,109829,13049,126554,60358,106466,4684,42764,32471,74921,84259,89890,96077,100828,14712,61236,28563,113553,90933,96637,123553,129003}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1765,8369,41055,45261,28648,106816,101551,108866,15933,86192,47218,50589,42634,93760,44465,130779,3639,107149,34298,118782,93320,112318,116517,121207,6931,103006,23083,49823,13643,26782,33856,79846}},
{"0000000000000000000000000000000000000000000000000000000000000002", {1219,42469,28844,124051,35499,89565,63338,74524,3080,64017,6594,109370,23333,45764,52892,117441,35527,95498,79363,95190,107053,120414,110715,120429,40192,63589,68073,83834,83104,110882,103128,116993}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1107,1908,22555,116763,14932,105552,121086,130688,10505,98040,73981,81409,41441,91433,80046,118134,6982,109710,69963,125674,29068,68913,63619,115291,7131,21585,75789,109235,18980,25074,39528,100124}},
{"0000000000000000000000000000000000000000000000000000000000000002", {6536,45897,68514,125641,14094,105992,16103,121669,13647,93501,87131,101863,21257,78439,85204,111352,7039,28607,106796,113449,24248,59756,72219,115749,10687,90215,24838,106770,21938,37239,35650,88023}},
{"0000000000000000000000000000000000000000000000000000000000000000", {47,16497,23115,106144,19180,103398,38646,46616,596,70799,43480,64539,17466,36992,117740,128767,14252,95134,126571,129889,34654,60631,65625,120956,32612,47315,39153,109615,39737,109766,84663,129759}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3351,46140,79872,117896,17414,106008,40311,127549,8193,66946,92978,98906,71416,93543,79586,112627,12775,94378,45621,87504,39788,93878,82426,97579,18592,19003,80654,82128,34818,109542,63473,101405}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3600,95632,22811,46261,20828,86734,48801,70129,24517,49491,125561,128748,52351,82004,71739,105200,15963,41895,75180,92821,34726,84303,47349,58698,16666,58201,71573,115972,19788,56414,29655,42412}},
{"0000000000000000000000000000000000000000000000000000000000000000", {992,61817,18826,114730,2949,31521,28661,95343,45661,128036,56229,104262,56599,58786,60864,92892,16643,49856,27502,84824,44515,63588,81004,115069,21239,81648,44989,89549,58360,74784,85134,128311}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1097,112414,79087,97004,14812,33613,18567,35736,5141,40849,5557,29943,39417,57426,88933,124090,18643,80444,72217,105286,46587,91729,77071,80455,50126,84055,97541,108574,51475,54069,103547,129044}},
{"0000000000000000000000000000000000000000000000000000000000000000", {483,18545,73790,103171,16108,121875,24941,89710,4867,70280,20439,127550,21060,60306,36917,72419,6570,24821,43964,85152,60119,127937,120668,129979,22427,81722,31747,118238,26786,60374,61264,98223}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1985,52978,93280,112413,16860,75088,27225,119413,8514,30080,77727,96205,20597,50863,75358,127974,13024,70998,76666,113099,15610,108858,35553,96576,51126,108603,86511,93995,58158,74697,75777,108668}},
{"0000000000000000000000000000000000000000000000000000000000000002", {990,120065,5132,37976,13709,88942,26162,79411,30465,112548,80122,84151,84268,85058,118673,128671,17855,77883,38353,100850,29902,94158,88364,121554,30267,66686,36535,104237,49868,99119,52284,103559}},
{"0000000000000000000000000000000000000000000000000000000000000002", {30,71083,89127,128008,108656,114488,122295,126802,23860,52459,89370,92103,37533,72960,56631,77247,198,53786,36079,91660,15253,46654,29497,64143,32982,97570,49921,61672,37659,49926,91545,96536}},
{"0000000000000000000000000000000000000000000000000000000000000000", {9125,34203,91722,121842,31100,75896,43764,70736,13794,82032,18036,74182,77486,91316,107044,115899,9132,41974,61832,130515,28657,90798,111121,126465,49824,75912,125451,130373,72273,104357,104673,128729}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4889,78455,7785,124570,43667,69583,79549,107533,29335,39317,109478,110213,35650,41721,36685,97120,8416,84137,43266,75387,26589,121463,28297,77973,31187,101489,61443,128674,39849,79684,47217,82809}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3970,61803,17147,85215,21615,76510,25047,129773,13210,126622,23448,97288,27059,83222,108992,121097,15583,106067,48206,71396,21395,37866,118938,120563,24090,44506,26185,35289,26676,61579,48057,122770}},
{"0000000000000000000000000000000000000000000000000000000000000002", {768,119749,27515,103930,35727,121168,117188,118388,10104,51160,87417,124524,32234,74253,33666,95089,2950,128205,58456,74862,22777,109304,94167,114083,7084,79138,50770,130201,26271,123710,129306,130754}},
{"0000000000000000000000000000000000000000000000000000000000000000", {10,104292,62611,107340,52533,102377,65141,107884,17267,81606,91897,116981,34716,117480,45092,77049,19090,75267,48534,95568,34288,85933,88624,119670,22680,87293,100255,120401,43549,100024,110621,118573}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1180,54359,23777,124960,29031,53988,47177,85582,18206,47613,20882,130701,19462,69836,23319,58297,1330,41157,55443,76494,67088,87512,71431,106076,18350,67174,22153,131053,56153,112286,99884,130530}},
{"0000000000000000000000000000000000000000000000000000000000000001", {8002,51020,47401,101708,13155,96983,65775,103159,11325,125338,35176,44580,18573,66623,20962,124977,30097,58919,42977,113092,48324,112252,81766,114974,31479,50551,47746,121209,53497,86450,99254,121726}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2732,30038,60920,84255,10566,39325,73877,130382,37775,67570,39646,66396,44541,123622,102721,107893,4553,39137,31202,111997,8004,45011,22086,82716,13567,77096,15755,71392,39619,57823,119456,124933}},
{"0000000000000000000000000000000000000000000000000000000000000002", {6392,62099,72763,121639,23982,126255,45789,104209,12025,40742,91850,111181,16390,67036,107011,116740,27705,74476,85645,90953,59919,71418,74868,95539,47455,92857,100022,112763,58378,95492,78901,127518}},
{"0000000000000000000000000000000000000000000000000000000000000000", {5421,69956,9055,49438,22160,85872,30261,96813,17801,22419,19155,45994,86377,100441,123155,123474,8213,56219,85408,91055,63582,87962,83910,126378,42403,106111,64747,129824,65866,126389,68224,98759}},
{"0000000000000000000000000000000000000000000000000000000000000001", {293,19732,106566,113908,15897,116097,53208,105649,17841,35358,79437,120904,25528,106333,55697,129229,1111,99840,15590,25682,4700,67249,15585,53412,21230,116348,34468,78887,50442,94029,82409,126078}},
{"0000000000000000000000000000000000000000000000000000000000000000", {478,51062,14729,48777,39602,77768,61943,105765,25325,126182,28038,100222,48980,82229,57418,57899,3131,75516,54801,97072,10212,44341,88882,130779,35923,57487,36907,83873,48022,95812,86753,113329}},
{"0000000000000000000000000000000000000000000000000000000000000001", {6,96899,94241,113441,3870,41129,51224,58722,5944,92310,44335,62560,28844,126498,53553,85564,19292,95952,41569,104134,56889,114507,75309,97406,22577,76811,28807,38040,23134,101063,34892,69784}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3580,53771,86016,115575,43436,54428,56947,91434,18695,58999,31246,90039,46950,82288,71612,80716,17328,45067,47344,125947,25795,34553,41923,118936,35751,50817,67782,103375,43974,72655,87457,93047}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1131,69609,21330,120011,19409,86406,47162,67322,20491,102933,55395,85399,22287,43303,47198,47467,3180,53349,29475,43385,15404,124457,35117,111880,8656,76391,95815,111931,55612,61397,91104,101877}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1302,109860,25689,104941,24911,25337,57094,117620,13829,129451,80714,104408,76283,76716,92402,114285,6532,127641,71303,125888,31402,40777,62793,96248,7304,104567,105103,113835,22978,26683,67233,118683}},
{"0000000000000000000000000000000000000000000000000000000000000000", {348,25552,79948,114751,31895,106154,54683,62300,13152,74877,84146,122596,13514,58627,26454,28701,2044,81789,49497,122423,28144,55154,88711,129426,5880,95785,65786,65798,23182,103934,46986,121602}},
{"0000000000000000000000000000000000000000000000000000000000000000", {337,5435,7292,42171,68065,106088,76628,93313,49136,104261,49890,63405,76819,77642,83664,100343,1026,36487,25749,120454,32054,50170,48095,72617,4225,11782,8031,83241,9097,39819,35098,39613}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1642,44644,19952,24946,46755,47575,60399,112864,5752,56195,41644,124388,10161,125578,39394,99307,5723,18437,17167,127991,16972,79158,73209,130644,23621,82892,72172,78852,88427,99430,105446,121198}},
{"0000000000000000000000000000000000000000000000000000000000000001", {3657,97320,6456,84613,57850,89159,81208,127858,17025,29054,28621,107499,32964,72614,35415,97919,4847,26496,85538,107763,13702,126140,16200,126731,22077,93744,69324,129411,28035,53994,68633,122458}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2727,126553,92483,98010,25925,66216,40286,93206,19133,83385,62853,77088,23385,109497,48566,116661,5685,11150,47919,62398,21294,51895,23598,94629,28685,57516,48102,62985,30202,120146,65803,79757}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2255,40017,82746,115765,25925,122194,36545,78020,19316,37837,65899,119563,49328,54261,51393,128307,24106,100480,69358,89308,78154,96605,91638,127631,40206,61727,50210,87501,64962,87943,69869,103397}},
{"0000000000000000000000000000000000000000000000000000000000000000", {83,113895,20382,92204,12768,115624,22854,64026,26721,66888,28036,61918,38967,39140,45464,84043,22044,114237,95651,112635,42029,121683,57389,104880,40769,44571,54340,102219,47311,129914,99507,99872}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4173,46907,31483,107903,12494,113736,38059,42439,10182,52017,56585,68667,12675,73398,117681,119607,10040,71759,32340,115982,56826,80397,92192,129235,21363,58105,36523,61771,31275,40410,80051,117390}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2078,93897,9643,56302,5639,71958,108514,126953,8798,112029,80680,97958,65460,76914,99477,121712,4233,79618,25712,29643,36517,84226,61044,127743,43843,62119,72228,80954,69085,110216,92212,94574}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1379,3159,11813,105746,12431,105115,25494,90517,38009,51914,97595,127279,71647,98597,106695,129647,20660,62733,34168,42145,64001,84621,76917,81888,33855,90584,37974,67667,39276,75451,107994,126462}},
{"0000000000000000000000000000000000000000000000000000000000000002", {4,18904,50494,84634,6101,130765,33562,125940,214,6834,72750,89199,2108,30716,2542,69930,13106,38605,56865,124636,38956,102165,61705,116133,18451,29311,65802,85812,47101,126396,61794,103110}},
{"0000000000000000000000000000000000000000000000000000000000000002", {3537,85557,41131,114366,7069,84712,47272,48166,15370,126666,78392,97409,80046,119428,92104,97948,7597,103286,79872,115060,24221,97772,24613,41111,44015,107358,80657,115887,44538,66870,51215,104248}},
{"0000000000000000000000000000000000000000000000000000000000000000", {200,69611,1008,71080,32226,78399,54621,130954,38491,45194,73392,97675,46179,73935,80145,96607,26082,34224,101232,115364,27612,68416,40445,60380,44933,86985,96596,103322,54658,121127,101727,111929}},
{"0000000000000000000000000000000000000000000000000000000000000000", {9428,131060,12357,19150,26154,102307,84911,96048,12584,35319,76255,111896,55197,102394,63345,100750,11670,42094,97986,116558,46650,95958,98165,111819,20183,119390,22391,37596,23529,74117,23692,66809}},
{"0000000000000000000000000000000000000000000000000000000000000000", {5737,26502,37023,59338,30895,129511,99395,127461,16397,35973,51508,120993,49870,68087,68481,107865,17807,88519,21456,108047,22506,54757,53306,86638,24725,31428,35988,41117,46424,82496,91134,119130}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1784,56809,6088,110305,9210,66060,92802,122764,9809,62357,64859,125073,39305,77024,66710,74730,4458,43108,43771,118147,5926,11813,61186,74013,29351,122380,93324,115367,63715,65959,89046,125360}},
{"0000000000000000000000000000000000000000000000000000000000000001", {6245,49627,85219,117426,15541,79203,50360,69728,39667,101715,54964,63846,64633,72098,103071,107852,8700,96935,35760,111595,39043,99926,79863,122892,17567,61843,48677,96477,41274,117374,102704,128225}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1211,30046,57584,85189,47771,96045,89139,119958,13035,48797,31226,49165,33052,49680,99187,120786,1700,32291,60888,62355,15237,50573,31624,120804,3502,121790,53050,122647,26280,80967,26386,40754}},
{"0000000000000000000000000000000000000000000000000000000000000002", {632,117763,102235,130267,13607,41148,83752,87039,24862,130511,26545,84502,47559,130048,124272,128212,938,83518,12653,57071,78658,111731,97132,102507,13865,85875,17280,37886,16032,116436,51637,74845}},
{"0000000000000000000000000000000000000000000000000000000000000002", {1902,35610,75019,119475,22190,74116,38709,126602,29584,119286,69089,118892,35093,125906,43892,64158,14410,118938,64031,98818,19497,58785,48143,80285,46361,115298,49380,72550,65673,96524,65853,70131}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3412,106976,52821,102602,5264,125954,81293,114473,4431,15965,74394,129969,82601,86888,91466,122673,17846,30876,24101,51813,51413,98271,67656,129287,22643,67111,63793,84597,56528,60259,87173,122157}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1646,99888,116759,119773,48974,74438,86235,102437,12155,74305,57390,59619,33626,56783,50776,57650,3970,17087,64960,74806,71540,93023,120791,127773,6690,108120,74211,88366,91364,114993,111133,112671}},
{"0000000000000000000000000000000000000000000000000000000000000000", {107,55842,779,12422,62759,100196,111855,115924,43683,62602,90749,114293,55059,109052,75013,123832,6518,103417,88719,95153,24836,45834,34380,109255,8902,130943,9198,29064,63717,94750,84754,107907}},
{"0000000000000000000000000000000000000000000000000000000000000000", {6133,31306,58079,99333,60039,71050,74701,78688,19233,72385,75304,125707,78788,86272,95973,129469,7956,73683,36379,50301,22779,106188,107441,128404,65396,112057,74767,123350,72728,80297,99521,127714}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3187,31120,51976,69423,93349,125371,102201,104465,17207,122269,24470,92752,26789,113789,28920,32027,5408,18914,62896,81531,25900,113150,30361,54187,21537,130398,103933,109792,25523,102864,38954,107053}},
{"0000000000000000000000000000000000000000000000000000000000000001", {137,99632,109305,111541,33786,122309,79253,82012,11831,78492,79485,118856,39558,83584,45130,129803,2598,59549,32586,74859,20134,64384,41281,82353,10426,102837,59492,89786,28112,84183,56145,72436}},
{"0000000000000000000000000000000000000000000000000000000000000000", {753,4094,22442,57549,931,2706,71281,123853,13597,26743,68707,101928,16572,32580,21543,88986,5581,19525,40220,117835,29553,61257,108715,123107,37755,125266,74361,94054,38312,98045,74159,108758}},
{"0000000000000000000000000000000000000000000000000000000000000002", {270,53263,5282,53064,15080,100864,32203,98548,11712,69213,28328,64994,71842,119248,94693,105846,24474,127101,85572,95669,46770,50945,105414,127203,58194,120151,68062,116292,65479,123615,66733,119075}},
{"0000000000000000000000000000000000000000000000000000000000000000", {747,97760,13399,130856,85651,97126,106971,110505,3603,103536,7108,10404,35280,128771,65612,111634,2852,33628,69081,86396,20649,110832,49161,109895,7224,122865,41207,128469,44234,107477,77772,116989}},
{"0000000000000000000000000000000000000000000000000000000000000000", {9051,37227,49663,96294,67492,76384,91756,106339,10148,61276,50866,129134,30206,48703,35413,61105,10156,44099,22484,88642,53713,94047,62563,85469,51569,130637,65764,81680,52601,80129,56248,111714}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1749,15723,31447,106773,36046,81912,75728,120824,3698,78303,55229,104391,22865,117177,56279,59028,9469,87913,25013,68095,61932,77594,102787,115527,9911,17208,38046,124460,41346,75563,80122,111848}},
{"0000000000000000000000000000000000000000000000000000000000000001", {521,90685,35076,99432,35068,124005,54188,79459,23235,103525,63165,71467,40880,74043,52546,76551,1513,99630,21309,86507,22342,113805,28971,109108,12701,55648,92458,123878,53116,85968,124277,125617}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3623,123715,43492,118101,36800,41788,80614,103784,30710,80867,39635,113006,33668,53082,42535,79939,17320,104250,42313,73879,44716,105513,58153,62360,18024,109352,82019,91761,43838,94083,115532,126045}},
{"0000000000000000000000000000000000000000000000000000000000000003", {486,81370,81085,100485,52008,99619,56782,60768,26067,130153,75399,129422,34930,113115,43274,129279,6237,64252,62642,110571,45127,108431,53470,71935,15362,127794,37431,74694,46672,104769,88276,104046}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1568,22550,21786,89457,81873,119236,97458,115893,33342,92331,82815,104756,37734,65698,39266,116289,5799,24680,90665,127796,15585,98180,23593,57551,6928,57812,36933,47624,19578,55496,34269,90997}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2763,89076,58717,95255,26847,73704,70267,96392,38823,104306,97967,100626,39085,65524,40967,51798,6830,15108,64071,101016,9484,60906,55229,86843,28617,90956,41921,54272,45031,74109,101883,112120}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3984,127336,69342,117958,18834,25252,40634,100460,42479,78160,82122,124328,49469,56372,89393,92014,5586,87903,107710,122937,9546,125428,104438,112237,35482,42066,87414,105714,44503,54094,58749,75411}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3407,97582,77287,82635,6337,20506,49441,106096,31508,117606,95022,121663,47299,53597,50568,101413,10206,74065,109574,121909,29548,67817,55803,82077,50294,52279,56443,71217,55138,62404,80788,128512}},
{"0000000000000000000000000000000000000000000000000000000000000000", {8964,74059,96733,113839,58808,67554,86861,125809,17809,126529,18633,19118,55275,76600,97037,100006,9933,23795,36733,60661,25974,104197,43489,127536,10279,87212,57201,129084,40861,106520,71742,77825}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2115,120922,66477,84670,14502,80199,23703,39996,5485,88607,39332,111274,18623,41464,73720,88749,13346,53738,30843,49584,32196,88096,90659,116612,16742,67377,31613,72351,23372,67267,33615,130243}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1462,59714,106947,128526,7901,12814,61078,66265,21455,124907,31882,129363,42071,113499,96206,129375,1475,7727,67070,130397,58396,98556,85274,125397,15855,31632,76727,121015,32366,71237,34842,69231}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1290,49541,11616,35519,9091,68151,72548,100822,15018,116542,48932,130966,23066,46871,30498,126749,14441,119137,41768,98146,53661,127507,70119,81483,36101,40479,41270,55937,59507,110974,117411,125487}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1196,85986,40098,48999,20297,116177,75833,128678,6035,65003,31676,38878,23562,62796,37594,68648,7082,62536,72047,88972,24134,115541,28658,128930,13402,24919,41111,47096,66905,76470,74461,99985}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1468,79849,69451,108162,13558,57818,121440,130039,7889,16529,58352,88213,21878,34679,123672,126625,4379,57519,39691,121536,52428,126838,71747,128326,19134,91616,25966,110254,61932,87669,89273,128548}},
{"0000000000000000000000000000000000000000000000000000000000000001", {53,43778,13680,123655,104042,130246,110535,118361,27091,114939,84179,124949,33156,39774,46803,99398,19921,105368,47526,80403,71146,89632,80310,91358,37528,126325,57251,82862,60072,85162,92890,119803}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1849,39205,37279,70529,9013,76618,62566,118755,20906,109766,30375,64413,40482,125592,61278,66799,2753,55049,50706,125274,16347,83184,67709,126974,7571,130681,76254,129471,46155,67364,75023,106747}},
{"0000000000000000000000000000000000000000000000000000000000000000", {381,95667,29178,112117,50775,72951,107882,113857,4342,38697,54156,94619,17499,104556,80251,92875,40777,58172,72627,86277,51179,66916,78169,93366,45869,79846,114008,118364,113496,119265,120863,126461}},
{"0000000000000000000000000000000000000000000000000000000000000000", {944,8501,69533,104904,6599,119616,20528,67710,12711,85781,19608,81182,67126,114249,68825,82467,3761,4001,5936,106028,7511,105464,89893,129225,22740,33524,73711,81358,90613,107235,91912,116254}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1827,12978,6333,33704,9962,49230,69820,114749,5010,36113,57008,101559,54216,54380,79278,93779,4618,22121,40582,47565,17157,125712,32636,46232,16461,97027,23498,57479,34236,100279,48627,49224}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2747,45014,36807,129006,25738,73230,30316,125189,29106,109555,37937,111724,72272,76168,75995,76719,12236,108873,69968,112354,54800,64746,114034,114796,17112,99358,80678,120094,32652,51600,111121,123573}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1746,58177,29591,64615,56695,102426,60216,124288,16869,58517,36151,44150,71818,130041,80161,85844,6377,75346,30198,116573,38780,123598,47993,62849,15635,129072,18289,78489,51788,86778,54721,102447}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1505,124792,71228,123473,7856,108392,16368,75133,23017,61558,64279,79362,33527,78182,87105,123102,12277,65879,14806,25317,94797,108194,97382,126625,31793,94419,49922,62827,39206,121475,52667,76778}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2186,36879,60267,118197,73085,100658,73393,76471,7285,69353,10414,30130,14288,72590,15569,81984,9788,107046,29481,92965,30228,77233,56376,79437,54068,54654,103424,125801,66430,80866,72907,89752}},
{"0000000000000000000000000000000000000000000000000000000000000002", {1043,91153,11358,90365,19272,117942,53813,121723,6610,126068,73989,128465,41152,110496,58463,89910,5067,39458,20564,108458,47480,98869,74081,124936,14038,30155,50612,80533,19020,108507,31973,42339}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2339,62823,28318,43329,8316,71085,97583,111421,14026,60728,25722,76345,85022,89315,104275,107991,2417,130977,46026,111930,23212,114045,24771,54591,23902,82430,54900,95876,57985,80195,65298,90496}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2543,101030,92350,96085,49879,106797,58195,63176,25194,121741,91651,100715,31218,104993,117467,122712,6168,65167,10464,113308,40324,87141,96299,126264,11994,65431,44634,81498,22421,55036,54976,102185}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4509,49998,66505,75663,13474,49680,29636,42265,23206,71697,28977,85947,30025,43828,30796,77817,4663,73761,68358,84141,65256,92524,94152,113774,6579,96763,63936,69954,69931,122843,87219,91804}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1437,41053,25884,32676,34895,86738,89123,112596,2869,59116,17934,98775,17591,92117,55593,61975,10053,10612,25816,82213,30301,46099,77931,92486,17910,68610,25514,87339,19859,104009,96688,97896}},
{"0000000000000000000000000000000000000000000000000000000000000002", {58,64150,9214,122618,4950,74667,29428,96409,2522,96626,63755,73849,26842,49745,86851,101415,7311,74505,73472,127836,9939,77724,20705,126618,27843,89645,126600,131002,43823,57303,64343,69854}},
{"0000000000000000000000000000000000000000000000000000000000000000", {10011,85215,39119,111614,19032,74127,22587,40242,13660,108342,38422,43437,48941,81907,82117,103039,35175,130684,74949,91134,86288,99928,86729,96199,53180,116743,55744,92052,68074,103978,100313,124650}},
{"0000000000000000000000000000000000000000000000000000000000000001", {3132,130830,77288,78668,32945,84395,88763,98834,35037,86814,51291,52115,82447,95269,99972,111639,6049,8998,52778,58058,12681,77917,62748,110931,9034,56367,11879,83961,13912,74259,96404,125810}},
{"0000000000000000000000000000000000000000000000000000000000000002", {6587,111679,14213,54005,14966,112333,56423,104212,13100,129793,15495,78947,59414,111432,85083,125529,13254,54250,63174,80872,63770,74428,71876,93141,16180,94534,24924,69875,58931,110119,120529,123470}},
{"0000000000000000000000000000000000000000000000000000000000000000", {5975,28978,9566,61953,80079,109816,83336,130247,8539,59996,23108,24408,71489,128045,77295,120570,10614,129418,41413,49760,30618,112622,49621,109184,13455,99848,32438,46190,26719,117115,27565,103748}},
{"0000000000000000000000000000000000000000000000000000000000000000", {240,24486,86634,115411,11247,13761,107845,112595,18089,63870,55386,72646,61142,94133,115701,123711,9824,128130,26890,112163,38606,118838,62915,113341,29985,74526,61074,94415,52870,69054,68568,127204}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1891,39781,12154,15084,49276,99546,100073,115771,38621,62156,40301,48181,50540,51175,68666,96884,7149,117684,64291,113579,21713,122337,95481,127896,29712,47714,77225,116196,78548,106038,90880,123619}},
{"0000000000000000000000000000000000000000000000000000000000000002", {682,125337,60526,70437,22399,119957,94318,122504,25279,85570,42897,68955,47164,72324,47990,76314,2267,49969,8632,124435,55852,75449,78151,113496,4436,17175,41266,56046,67014,83836,93756,125121}},
{"0000000000000000000000000000000000000000000000000000000000000003", {2063,112667,70220,130926,78568,80024,119828,120071,47215,117923,59702,69954,49261,58923,94532,121604,23448,89696,45754,112424,45876,88694,80387,87626,30626,101690,86459,97829,53509,97163,112425,126170}},
{"0000000000000000000000000000000000000000000000000000000000000000", {585,129540,82582,103945,13704,119340,73307,76360,1286,56998,15490,100622,22703,47394,125390,127633,3572,91943,87239,100402,20071,47264,67878,118175,19170,21182,23033,125766,30705,38558,31686,129265}},
{"0000000000000000000000000000000000000000000000000000000000000002", {404,57517,14585,118425,6915,110787,10611,29446,4889,64472,85191,114379,12299,34895,65815,85073,7390,46581,14916,73911,40960,83545,89481,101199,18284,83440,38417,130650,23571,82551,55940,120349}},
{"0000000000000000000000000000000000000000000000000000000000000001", {5160,91031,41493,117909,29209,127975,114964,120727,16912,90361,65208,116048,57058,87669,70015,107007,5970,102898,44274,122827,34757,67112,116598,116776,10761,125378,64602,76859,25551,66274,76712,109949}},
{"0000000000000000000000000000000000000000000000000000000000000000", {6555,91784,44271,57382,34213,113475,34328,119803,12291,28213,14813,128727,37983,41775,47623,130929,7935,95305,11856,93016,47068,122035,78303,111051,25516,87726,36165,101754,43009,88573,120251,129099}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4495,90680,85745,119305,19606,55482,50466,108234,21153,63230,33476,39101,80717,111025,101335,110064,12087,114180,89319,124698,37497,115882,60226,122890,24015,129158,42862,108225,44607,90172,68979,100698}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1017,85163,80130,106167,7203,65290,13171,26823,2996,77441,37275,122349,14110,46617,20350,108050,5319,38657,102910,128462,9549,45743,73919,123720,9368,76718,72248,76067,38047,53158,101708,114377}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4128,120697,80252,105536,26321,77754,31234,128466,17595,109649,60513,128306,36151,96931,75395,95356,20337,107080,33932,62693,27108,57399,29825,85510,22612,111322,45546,112054,44474,106586,71478,93490}}
};
// NOTE: These tests rely on CreateNewBlock doing its own self-validation!
BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
{
CScript scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
CBlockTemplate *pblocktemplate;
CMutableTransaction tx,tx2;
CScript script;
uint256 hash;
LOCK(cs_main);
fCheckpointsEnabled = false;
// Simple block creation, nothing special yet:
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
// We can't make transactions until we have inputs
// Therefore, load 100 blocks :)
std::vector<CTransaction*>txFirst;
for (unsigned int i = 0; i < sizeof(blockinfo)/sizeof(*blockinfo); ++i)
{
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
pblock->nVersion = 1;
pblock->nTime = chainActive.Tip()->GetMedianTimePast()+1;
CMutableTransaction txCoinbase(pblock->vtx[0]);
txCoinbase.vin[0].scriptSig = CScript();
txCoinbase.vin[0].scriptSig.push_back((unsigned char) 0);
txCoinbase.vin[0].scriptSig.push_back(chainActive.Height());
txCoinbase.vout[0].scriptPubKey = CScript();
pblock->vtx[0] = CTransaction(txCoinbase);
if (txFirst.size() < 2)
txFirst.push_back(new CTransaction(pblock->vtx[0]));
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
pblock->nNonce = uint256S(blockinfo[i].nonce_hex);
pblock->nSolution = std::vector<uint32_t>(blockinfo[i].vSolutions,
blockinfo[i].vSolutions + NUM_EQUIHASH_SOLUTIONS);
/*
{
arith_uint256 try_nonce(0);
Equihash eh {96, 5};
// Hash state
crypto_generichash_blake2b_state eh_state;
eh.InitialiseState(eh_state);
// I = the block header minus nonce and solution.
CEquihashInput I{*pblock};
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss << I;
// H(I||...
crypto_generichash_blake2b_update(&eh_state, (unsigned char*)&ss[0], ss.size());
while (true) {
pblock->nNonce = ArithToUint256(try_nonce);
// H(I||V||...
crypto_generichash_blake2b_state curr_state;
curr_state = eh_state;
crypto_generichash_blake2b_update(&curr_state,
pblock->nNonce.begin(),
pblock->nNonce.size());
// (x_1, x_2, ...) = A(I, V, n, k)
std::set<std::vector<unsigned int>> solns = eh.BasicSolve(curr_state);
for (auto soln : solns) {
assert(eh.IsValidSolution(curr_state, soln));
pblock->nSolution = soln;
CValidationState state;
if (ProcessNewBlock(state, NULL, pblock, true, NULL) && state.IsValid()) {
goto foundit;
}
}
try_nonce += 1;
}
foundit:
std::cout << "{\"" << pblock->nNonce.GetHex() << "\", {";
BOOST_FOREACH(auto num, pblock->nSolution) {
std::cout << num << ",";
}
std::cout << "}}," << std::endl;
}
*/
CValidationState state;
BOOST_CHECK(ProcessNewBlock(state, NULL, pblock, true, NULL));
BOOST_CHECK_MESSAGE(state.IsValid(), state.GetRejectReason());
pblock->hashPrevBlock = pblock->GetHash();
}
delete pblocktemplate;
// Just to make sure we can still make simple blocks
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
// block sigops > limit: 1000 CHECKMULTISIG + 1
tx.vin.resize(1);
// NOTE: OP_NOP is used to force 20 SigOps for the CHECKMULTISIG
tx.vin[0].scriptSig = CScript() << OP_0 << OP_0 << OP_0 << OP_NOP << OP_CHECKMULTISIG << OP_1;
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
tx.vin[0].prevout.n = 0;
tx.vout.resize(1);
tx.vout[0].nValue = 5000000000LL;
for (unsigned int i = 0; i < 1001; ++i)
{
tx.vout[0].nValue -= 1000000;
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
tx.vin[0].prevout.hash = hash;
}
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
mempool.clear();
// block size > limit
tx.vin[0].scriptSig = CScript();
// 18 * (520char + DROP) + OP_1 = 9433 bytes
std::vector<unsigned char> vchData(520);
for (unsigned int i = 0; i < 18; ++i)
tx.vin[0].scriptSig << vchData << OP_DROP;
tx.vin[0].scriptSig << OP_1;
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
tx.vout[0].nValue = 5000000000LL;
for (unsigned int i = 0; i < 128; ++i)
{
tx.vout[0].nValue -= 10000000;
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
tx.vin[0].prevout.hash = hash;
}
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
mempool.clear();
// orphan in mempool
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
mempool.clear();
// child with higher priority than parent
tx.vin[0].scriptSig = CScript() << OP_1;
tx.vin[0].prevout.hash = txFirst[1]->GetHash();
tx.vout[0].nValue = 4900000000LL;
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
tx.vin[0].prevout.hash = hash;
tx.vin.resize(2);
tx.vin[1].scriptSig = CScript() << OP_1;
tx.vin[1].prevout.hash = txFirst[0]->GetHash();
tx.vin[1].prevout.n = 0;
tx.vout[0].nValue = 5900000000LL;
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
mempool.clear();
// coinbase in mempool
tx.vin.resize(1);
tx.vin[0].prevout.SetNull();
tx.vin[0].scriptSig = CScript() << OP_0 << OP_1;
tx.vout[0].nValue = 0;
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
mempool.clear();
// invalid (pre-p2sh) txn in mempool
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
tx.vin[0].prevout.n = 0;
tx.vin[0].scriptSig = CScript() << OP_1;
tx.vout[0].nValue = 4900000000LL;
script = CScript() << OP_0;
tx.vout[0].scriptPubKey = GetScriptForDestination(CScriptID(script));
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
tx.vin[0].prevout.hash = hash;
tx.vin[0].scriptSig = CScript() << (std::vector<unsigned char>)script;
tx.vout[0].nValue -= 1000000;
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
mempool.clear();
// double spend txn pair in mempool
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
tx.vin[0].scriptSig = CScript() << OP_1;
tx.vout[0].nValue = 4900000000LL;
tx.vout[0].scriptPubKey = CScript() << OP_1;
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
tx.vout[0].scriptPubKey = CScript() << OP_2;
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
mempool.clear();
// subsidy changing
int nHeight = chainActive.Height();
chainActive.Tip()->nHeight = 209999;
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
chainActive.Tip()->nHeight = 210000;
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
delete pblocktemplate;
chainActive.Tip()->nHeight = nHeight;
// non-final txs in mempool
SetMockTime(chainActive.Tip()->GetMedianTimePast()+1);
// height locked
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
tx.vin[0].scriptSig = CScript() << OP_1;
tx.vin[0].nSequence = 0;
tx.vout[0].nValue = 4900000000LL;
tx.vout[0].scriptPubKey = CScript() << OP_1;
tx.nLockTime = chainActive.Tip()->nHeight+1;
hash = tx.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
BOOST_CHECK(!CheckFinalTx(tx, LOCKTIME_MEDIAN_TIME_PAST));
// time locked
tx2.vin.resize(1);
tx2.vin[0].prevout.hash = txFirst[1]->GetHash();
tx2.vin[0].prevout.n = 0;
tx2.vin[0].scriptSig = CScript() << OP_1;
tx2.vin[0].nSequence = 0;
tx2.vout.resize(1);
tx2.vout[0].nValue = 4900000000LL;
tx2.vout[0].scriptPubKey = CScript() << OP_1;
tx2.nLockTime = chainActive.Tip()->GetMedianTimePast()+1;
hash = tx2.GetHash();
mempool.addUnchecked(hash, CTxMemPoolEntry(tx2, 11, GetTime(), 111.0, 11));
BOOST_CHECK(!CheckFinalTx(tx2, LOCKTIME_MEDIAN_TIME_PAST));
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
// Neither tx should have make it into the template.
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 1);
delete pblocktemplate;
// However if we advance height and time by one, both will.
chainActive.Tip()->nHeight++;
SetMockTime(chainActive.Tip()->GetMedianTimePast()+2);
// FIXME: we should *actually* create a new block so the following test
// works; CheckFinalTx() isn't fooled by monkey-patching nHeight.
//BOOST_CHECK(CheckFinalTx(tx));
//BOOST_CHECK(CheckFinalTx(tx2));
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 2);
delete pblocktemplate;
chainActive.Tip()->nHeight--;
SetMockTime(0);
mempool.clear();
BOOST_FOREACH(CTransaction *tx, txFirst)
delete tx;
fCheckpointsEnabled = true;
}
BOOST_AUTO_TEST_SUITE_END()