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.

421 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", {2222,4265,5697,32633,36721,72831,50327,111577,24171,45144,43766,67438,41927,86592,74039,128773,8460,22914,99396,122026,14608,79760,64758,73405,42046,58543,77520,127669,55831,124202,71414,109700,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {4818,117221,38825,92215,31918,114994,57147,106021,8232,16693,62332,72580,31256,129953,65110,93949,9534,58986,59489,72696,17665,90516,116767,119104,21147,64277,31781,76296,56427,93037,80582,113269,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {5614,44224,102522,105050,17519,50940,32649,94197,8205,79117,19065,70720,10614,88835,42069,94112,20530,49182,34080,40764,39845,45233,84629,86508,27657,130080,114474,129432,35064,63917,64966,75230,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1701,117165,4865,23938,50061,51555,53067,86936,2477,98127,14700,100289,4715,64139,89096,115674,7685,81642,95067,98873,11318,35786,49564,103076,7736,10547,63170,111922,51003,114221,99683,113785,}},
{"0000000000000000000000000000000000000000000000000000000000000003", {3947,43955,28447,129162,72787,122714,106729,117723,22326,77730,26905,99816,70711,77360,98946,129374,18986,52553,98106,121249,58835,101976,83803,86641,23022,81374,82475,84822,47072,107456,62206,72571,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {3730,110690,42826,130448,27285,76891,56415,106750,12422,37100,74128,108884,64452,96485,72855,127929,12386,120058,45734,95843,36579,56839,38850,62273,28924,48880,75875,115290,60896,111831,100496,116722,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1306,37439,6526,15188,4379,32702,8926,9403,16314,83103,23149,122213,31513,102885,56459,106250,4675,9793,64110,112082,23116,37103,27854,29703,6251,74659,9417,54468,33067,125110,47680,84637,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {806,32401,9491,94186,10037,72100,16871,118914,28463,107446,43885,49398,77690,109894,100098,118179,19823,56115,28006,54250,25942,74907,60550,66280,26592,67544,37442,73278,46978,96898,123352,127104,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {1770,46912,60797,95779,26975,124444,29042,85745,4434,87053,21656,52717,35079,83850,57922,77856,3502,93635,39493,40191,15558,110618,38008,38896,9175,18885,53662,107866,72618,100149,85304,89637,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {1737,52120,85461,92444,48964,104820,116194,131022,6885,58564,58931,65458,18655,57380,75015,82895,29087,111943,51563,61836,58361,94347,76260,118015,30041,65374,104778,113730,37186,63675,77402,91562,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {4526,61877,41456,130668,9978,85549,93212,120567,18154,82527,66365,76225,70761,110109,107010,127120,7000,13075,41741,81233,83854,89753,91580,111342,8201,122666,45300,106423,16273,47906,105257,130163,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {7771,115438,33727,35173,21716,91174,35824,107726,22860,57296,45877,51459,86862,116325,89620,103957,27098,51502,46276,114429,47238,99506,103176,104611,27460,122902,62889,127035,48517,82914,84658,103424,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1106,112252,33939,123933,12004,106170,37531,111863,3380,127412,55850,88581,56957,107703,69065,94149,18622,31722,23398,68067,89067,113750,92229,114713,47944,64552,48148,126801,49070,68547,61152,78948,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {523,4197,116256,128867,5578,105428,29838,52125,11966,86351,70987,127584,53286,113632,81419,93375,19377,35523,79906,121631,64421,102879,71897,102067,66758,106654,72350,109992,69957,93639,104635,114614,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2305,6060,104076,125796,52784,57845,78376,113436,5934,104996,9946,104062,32914,90562,40968,91388,15760,59458,23283,37960,22779,59036,70342,129983,22966,121171,26290,66594,27333,58952,85396,128628,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {3154,37305,58118,77815,38752,80700,100109,115427,3378,80148,36263,77844,22494,40192,42745,45727,4239,77866,100345,124949,105929,113015,110867,119938,30537,126436,63882,77221,65019,98184,101008,115040,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2506,10638,78282,89504,20445,99824,54191,73291,16945,46797,20682,104874,41883,66863,82224,118336,18528,70300,81289,116085,41455,73057,97745,112101,22727,72716,32161,33951,85614,115053,99677,103758,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4059,70416,41396,108166,38024,98858,53930,55925,36441,108814,51157,63162,87055,112448,107531,119137,10777,29971,23108,37106,12747,82177,112808,113695,19647,26711,54732,70460,53706,127354,55997,113091,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4540,11362,35638,81993,12524,110860,21232,101258,4910,110852,119180,126837,24256,63254,41893,65879,5494,96815,79816,87116,35886,66406,85768,116818,43178,121660,79178,80141,55189,75848,62183,115793,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2112,50875,79344,100860,16947,72062,22925,80413,2714,44608,4648,130524,47696,120458,108668,124588,6928,99012,47866,80221,48916,119450,89656,124335,17169,27786,46030,115669,63869,112144,83431,120802,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {263,43835,68980,95068,7378,25914,110409,130432,32841,126212,59283,96467,42006,81184,54730,70533,8655,56279,98598,114623,11869,54441,41113,104099,27264,40491,28663,120993,69587,119221,110573,130807,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {861,109746,10911,28557,3853,117067,83589,118834,42039,56264,59153,120767,94642,127260,99637,123726,4459,75522,64560,111742,70203,113557,119427,126526,29861,70153,52719,75884,108251,129158,112482,119219,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {6449,14779,28899,49838,20784,38828,82207,88578,8413,85546,58916,82514,55127,113306,118779,125135,32936,68550,96688,128925,43966,129487,62967,116076,55166,119049,128334,130470,76130,81263,85123,102630,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {295,98148,32192,48300,33243,49778,107699,110059,6190,10230,68985,128578,50969,129957,81425,90178,1448,88103,96927,128592,30893,87638,71202,88213,26762,90448,84440,95044,66439,99953,78628,88671,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2174,33977,6590,33701,47425,64904,99829,127216,8019,131064,92171,114364,32220,98155,93277,118736,8666,48284,12891,103443,17365,98809,33380,56456,45691,70735,78875,83243,61687,79658,81558,125093,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2006,45073,42206,73618,16488,39189,89136,124070,6183,16391,71908,83591,15596,33567,48641,61347,7919,58586,68646,100672,15220,35682,35683,82383,9758,17273,77543,91656,44334,81492,53914,74192,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1770,90257,51169,78463,8638,130515,60254,129300,33580,126990,97703,125697,57892,75051,67676,126509,23460,127701,43164,128258,30402,119491,66982,91109,27525,34120,50122,76303,51308,108055,112739,121011,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {3048,118281,105251,125482,30105,114570,55904,90131,12895,29868,104920,124419,70692,81171,105835,117319,9618,83714,71033,91468,110947,120632,124394,130054,37141,42998,53186,100366,51516,124030,79319,107425,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1161,9398,55510,110645,1530,30361,6171,42411,8877,116569,14222,60257,68070,93002,68399,77017,3298,118306,53711,116479,25935,119320,71686,78600,6097,28577,64306,81268,33127,109910,81424,129499,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {455,80076,71972,129281,7462,24067,7564,117871,19848,88837,124629,129405,54809,87190,66136,90015,10899,64583,63450,75877,22952,26204,43478,98963,51908,126680,115865,118364,69760,116015,119333,125620,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1146,63415,10488,21678,28215,84412,69425,105071,2709,66096,6666,94775,4818,48111,26786,109327,24366,84821,34694,123168,48106,94416,89201,122382,46679,74485,77341,102298,104795,107522,112476,128382,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {200,2560,13626,41541,35433,40264,76052,124966,19006,72683,23661,38194,62058,110925,71446,81453,5918,18742,88531,88620,27689,95707,85976,127434,28511,56593,60859,79786,33881,52787,67480,77264,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {8743,88640,82999,127676,50806,65868,105626,122262,27162,93474,82785,105945,36015,44522,67443,96804,13222,16684,105152,116418,25448,40897,45658,53442,20869,28032,83976,89730,61793,124893,74699,127848,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {3812,102317,38474,74771,8570,90514,51460,81439,15130,35702,71232,106726,43668,118618,110724,125065,8584,23951,23778,97866,58415,111076,77241,94702,8961,85755,43898,130702,10598,29640,43672,52346,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1089,114927,15817,74537,5670,62369,52468,104336,2085,10986,74128,77446,21401,85800,94512,115376,10156,52290,27129,95527,69966,102468,86210,91742,12403,84072,17266,113115,12662,95598,15296,75885,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {18,93539,77220,83108,37441,64155,47100,53277,14757,119036,84591,108450,74650,110626,87913,103915,5133,109798,41394,67980,26835,72950,69926,117546,16936,28752,28351,70048,26058,86910,55039,57609,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {4322,50750,29546,30732,6198,16468,64891,82168,11171,11863,29669,103075,11780,66370,89169,130493,6044,31980,45921,92684,46964,73616,51589,125087,21543,91681,41626,74003,23695,83638,36106,39597,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1769,119565,15443,97005,79027,91986,89329,117509,5563,43502,7352,69973,70732,83751,76410,86820,15592,77088,31957,37420,50322,68776,69966,95762,45208,119362,52387,95760,62300,112815,82996,102799,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {9067,68915,68359,116304,47117,120744,63885,96398,14925,20519,90357,113734,20432,44032,25876,34172,10994,55944,103048,128073,24807,79494,37983,107632,39152,90259,62926,72067,48718,90181,64396,96592,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1743,49746,23636,57935,24056,73428,119179,124602,36751,78782,47602,123806,60493,83005,91495,115609,8830,78467,16703,53808,23712,94569,34175,45842,27777,103110,67152,71453,51692,102954,64391,103397,}},
{"0000000000000000000000000000000000000000000000000000000000000003", {6832,69983,15205,50719,13421,109177,87377,121408,7637,106066,59686,127806,60405,62936,66181,130063,31654,101645,63207,108207,61559,126047,111795,116858,31667,92598,70032,88526,50195,52784,87405,130251,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {983,12640,46381,126079,26370,88135,32855,87087,15686,23600,33817,35383,49559,113471,61344,68233,6847,130114,87306,101324,16253,28724,42675,73398,7158,50375,112553,124617,16138,122702,46044,92882,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1165,72675,28717,84039,3431,129211,34467,94325,13487,50687,22731,36353,15090,106146,26691,96609,21248,64425,78316,106484,47249,62290,76002,89117,51207,83602,51236,56530,64964,84003,65602,91027,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2805,124202,97503,126419,33518,111736,70483,101911,11755,109623,54630,58754,12711,24852,21518,23171,2894,101150,89775,116781,16686,48745,102657,110134,5520,21110,47927,119327,6571,78801,50932,75994,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1475,33850,20510,68795,15128,95363,40616,82859,31807,60077,33215,115283,34267,100297,40785,93814,2756,45613,16894,90166,67305,124808,96822,114222,30450,31029,57290,78176,35782,89622,41314,105175,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1208,98097,27956,67934,12197,110963,52971,110837,14365,120568,90094,110431,61949,97514,111711,115952,3912,109193,34971,93238,78325,100833,117951,128338,7947,68482,88654,96351,67234,121310,91133,98556,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {702,98005,4814,130948,15185,115777,59819,110125,11205,20941,33931,119611,33348,51246,89280,108530,3347,99425,48231,73234,15944,96633,79040,121900,18208,118894,63977,98135,23673,107101,91896,100390,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {11674,45842,13567,97253,16044,25394,37636,99305,12220,113323,66904,106917,82841,128796,96947,106846,24897,46074,40878,119297,32741,97858,76203,92240,26849,41371,41406,70836,46281,129768,49513,85165,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1987,25637,15038,47140,11078,103734,98551,111031,8733,18232,80020,94107,69288,120743,87180,114304,6618,94387,11729,40843,61869,68274,62537,111322,21418,31240,25695,118667,25648,46195,27151,94325,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {571,110715,4129,10511,19453,87551,67800,85519,38065,76851,94169,102823,54058,122251,79501,116683,8374,107341,111156,117733,24497,74260,51065,96044,31627,107972,59921,91872,31809,128794,76149,83067,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3101,48432,4846,31160,10152,25747,10807,99497,17458,64017,57513,92320,75418,89535,102524,120753,3880,55801,45893,81756,11706,112008,18794,62516,11027,124234,22925,116101,22796,115575,44317,103076,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {250,106103,64203,79970,51412,99738,58634,58849,27994,76619,73233,83507,71639,76377,75565,110529,21163,61199,29408,95648,51105,77313,79813,103774,26509,46772,28393,74999,44970,46765,107087,127685,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {730,107813,12207,118888,9255,83815,53276,78014,24601,121100,62732,128992,69318,126665,106671,112403,2759,85997,111124,126826,58898,84762,66738,94031,10636,97134,59027,79993,31588,112594,34342,95727,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {3071,29059,23167,102191,40292,85784,54469,68914,3239,28377,23256,31897,18700,67079,92016,97668,10484,46689,96241,119182,43689,72690,103598,125474,26398,48369,34933,100998,34732,60952,51072,64236,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {5321,41985,28308,113908,46665,73325,60833,83265,9045,51084,29804,70680,12312,37475,22446,22878,13095,60741,92855,98147,51958,85072,93222,117422,14860,39976,24659,84156,62962,116468,72908,128668,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {234,80588,109840,123829,65231,94019,87230,99248,14833,20452,27135,98291,44627,48118,84980,90287,3974,118408,44595,90784,58361,84612,69611,99459,6588,20637,53103,127339,21078,96409,70781,121699,}},
{"0000000000000000000000000000000000000000000000000000000000000003", {1735,61860,71402,76466,4894,123773,8590,72257,35500,61556,59878,79634,55144,82524,93232,114913,16456,94432,112958,118239,19710,128792,26617,68206,21080,105729,41956,102126,72835,92366,82236,101689,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {198,20063,21732,105619,13644,82468,96317,97613,8193,96574,39017,66408,56743,119537,75151,122050,17249,120281,25447,83679,42377,53886,91098,129348,37910,110600,75044,122083,94910,107114,100030,106591,}},
{"0000000000000000000000000000000000000000000000000000000000000003", {1842,43376,104996,118250,53700,58695,61945,80361,19412,22870,21365,48249,73641,120344,77321,117634,23020,66784,63143,120982,71303,75446,86193,106155,24483,54047,72559,81330,33028,110362,33504,106558,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {622,104008,66712,73067,5158,30898,41370,63608,4283,53598,94804,113218,5294,62807,48056,106440,9268,23090,21330,65094,14489,109447,69335,87296,16584,74934,33708,70913,81759,84821,108238,117704,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {8221,25121,51472,107813,13640,24979,40735,92879,16716,118982,29012,37005,65508,67998,85673,128652,11909,32465,67475,130562,116310,126497,120884,126150,12079,130936,73670,109768,27563,130967,120571,125505,}},
{"0000000000000000000000000000000000000000000000000000000000000003", {3934,120785,73462,122302,9609,75184,18507,78208,12053,57822,67526,122738,74837,101548,86629,129190,11232,92982,34849,72501,53205,82536,65458,112648,13321,28123,32621,96713,34259,104873,48081,75099,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {951,20364,60260,126840,30693,41945,37677,128736,25256,99555,41966,67793,36276,121044,104134,128482,2061,31751,54448,89717,61094,68116,109599,123599,18062,84980,90173,125573,39093,63465,50998,109587,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {9900,27946,96431,109647,35372,98152,96507,112571,52549,85628,52666,98154,62373,119709,70376,88758,17596,91168,64039,111310,44521,98578,45661,83362,28904,103234,112829,114005,77027,89081,80639,111804,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2321,92553,77651,101020,60534,64060,114359,117135,31849,101775,108168,120633,43550,73163,59900,85421,6448,85388,24856,130792,25908,63525,35146,80348,10359,56417,28149,61928,31484,118568,100970,121174,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3978,79112,76999,100333,20580,87224,99203,128620,8364,20323,99120,122474,15163,86556,93911,110728,20456,124840,46844,75753,45640,119747,63872,88895,46877,99564,104328,106283,49303,100079,49490,109616,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {441,121765,15425,61395,42323,86925,80210,102186,6174,26969,20376,43425,47659,71281,67474,82322,6752,76878,115067,115974,83692,130183,102597,123050,11278,59549,110414,113703,14988,68898,15498,41455,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1797,114194,43193,72119,14607,112822,71329,123985,26977,112383,76896,118947,48256,85231,102164,104454,1982,12892,45777,59275,93715,94805,98971,125723,10856,107114,39493,62384,18016,85816,26133,115590,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {404,33879,81960,96633,16541,74641,86241,92233,18178,123712,101185,129346,21855,114539,38920,107927,2934,114009,44282,49772,58946,61947,68448,69454,16315,73840,75933,88215,28401,111913,49743,70258,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {3028,82960,76376,101717,34987,101887,102534,119842,29796,107026,117025,130496,57704,121796,64223,95593,7904,22712,53757,114848,89305,126661,118020,126960,35293,78251,41421,50470,40441,57296,43862,84284,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {7716,115768,39992,113646,19820,38233,20712,78622,11454,32697,19260,34503,50289,108342,59458,111753,20485,73975,86624,89194,29405,91934,45722,115723,39010,110395,120593,126435,54281,113076,105513,118817,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {9529,75105,44779,110891,22498,23906,106671,123670,22058,125572,82047,86896,76473,97989,92655,119337,12076,71338,22208,116633,34830,35581,43742,104845,14070,15594,31327,42810,72600,94931,86125,111136,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {3298,20537,75443,83210,9935,84074,29041,95153,11098,28982,11595,128172,19381,118630,26129,52946,14470,40639,67310,92193,36814,67611,90666,102470,20559,62525,58928,84092,23788,112136,24561,78635,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {128,54442,23611,30432,79852,126923,100295,125046,9966,97886,45173,71932,17568,28073,95837,100327,9553,91803,30014,120080,60433,65883,110650,113607,12796,60655,31106,78305,18544,73399,68291,70395,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2180,13998,13371,34179,11774,117580,53055,109834,14264,113031,28004,117000,17721,77428,42788,129553,2950,9940,26828,63990,23485,79473,27455,69359,18294,55445,46911,79337,95386,126353,95728,125973,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {8316,111049,41619,46076,14399,26060,104028,104378,13055,67487,43409,107256,22379,44392,29822,55963,11953,64649,32225,33943,20931,34446,33938,118180,43821,82578,61116,109696,50721,51567,67808,85520,}},
{"0000000000000000000000000000000000000000000000000000000000000004", {1475,125623,100398,128564,7637,122320,34822,108170,10809,67829,23779,47268,58593,111568,78652,81633,12150,32344,54291,125974,43384,75473,49062,103582,30293,67070,47353,97398,37593,97270,107006,110306,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4745,60524,56843,63140,6839,107825,47428,58041,13546,104859,43167,61340,28339,30779,64665,111202,5346,75344,39759,84156,69846,111995,90219,124206,7187,60925,38735,56285,48574,83267,71886,101724,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {455,66606,74792,90926,14631,85662,33038,82115,19826,122960,60827,88770,39543,100098,107985,121079,1369,18938,16797,88212,1711,59755,90611,115233,14458,42595,29190,62989,56426,77099,71426,89112,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2745,121267,11986,105122,36089,48394,74834,111658,18379,78011,23784,68743,98422,108241,112116,123026,19785,46347,32101,97132,28591,72474,106996,117443,34155,118300,37749,129761,56083,81447,59626,90190,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4538,121920,74637,109789,71876,75543,74878,94444,17015,106577,96457,100226,17466,89387,46459,49716,16548,103903,18124,51897,36595,85874,113228,116663,44774,101201,49619,107584,64364,94128,104960,111553,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3456,45225,25481,52338,49306,85693,74992,101558,21652,97899,62378,102995,27147,101547,86549,127119,5488,128540,18244,109319,69979,79417,101002,102354,9678,57412,13360,57418,47910,73819,78577,80714,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1462,96914,46867,115589,47701,130984,95434,121095,26769,30425,43274,108126,28675,74122,60796,82556,15589,113407,73673,90724,26653,94580,76492,93798,23174,58078,62070,102008,83560,91929,106022,125091,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2724,87642,41447,49635,62449,66682,74446,107557,47252,90427,65403,100724,63216,113545,120247,125339,6408,101759,40991,45800,19740,73300,67986,102636,22705,84303,51376,81344,82516,88165,108785,128777,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1565,78750,114006,126441,36061,60723,45497,47679,7405,49007,50277,103209,12114,69157,19421,29286,9090,121924,20153,28177,21570,56008,66808,87912,14890,83980,15242,19092,66249,82982,101712,108982,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {38,4472,46339,118716,22951,52867,76177,81445,40737,120290,51290,110456,74880,127533,123481,128845,12152,58277,42311,125772,13249,93185,104092,117598,20617,91072,26025,124492,33469,95212,42503,80439,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {4200,60929,36062,51490,4487,49765,39081,58430,13012,88309,17054,103153,19171,68571,83189,103847,6272,26527,8921,91786,35619,121327,46560,86243,11679,117541,77762,103232,45795,48433,72695,75973,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {269,123318,27657,64344,505,84045,76662,102732,15846,117982,113239,119132,16920,61680,23526,74073,1162,18296,38836,77127,34340,73481,80244,82377,6924,28307,42393,48964,32953,59937,42112,51628,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {19913,68092,25574,69127,84450,128678,117440,128930,32763,76336,84012,104083,51605,105394,52688,123645,21692,101741,51127,128802,93197,101244,94558,99175,23774,108909,43636,57059,36347,111277,124120,129317,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {202,107341,30454,67063,21800,46364,39040,64750,1481,92707,110889,123866,26119,129820,40014,78461,25606,39920,26076,96895,59208,117439,86038,108055,35448,35511,49777,106270,45294,63997,84426,91205,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {6728,55694,72552,82347,19109,110624,113117,117946,15574,84222,16988,111499,87023,89248,108664,109123,7697,82803,54917,75205,56041,106768,81639,120157,11501,34045,48901,107566,34560,92202,36666,83636,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2978,80213,45624,69807,92573,101411,105751,112296,5103,76264,5985,85056,28984,71792,32624,124783,5148,42475,45356,120232,70036,120053,88291,111000,25595,107048,28604,68288,56840,126215,65697,107347,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {102,41236,10412,125395,57378,70685,90050,98367,19945,34600,49881,94892,22167,69025,95288,124147,20827,129981,26528,125014,79101,91225,91018,107352,26110,37499,93518,115357,38101,81504,63652,80063,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1090,80663,32602,117959,67540,95912,114335,124530,2871,91787,46588,55658,14678,48191,85620,111364,3978,64431,61898,120053,5794,89650,57358,78836,34515,119544,52312,105709,53905,84267,87187,107207,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3567,108726,61603,106031,4664,73222,24537,34661,5899,87080,7486,109416,48381,103052,62740,115550,4800,69926,97139,99875,10932,48321,97549,113544,6185,27728,21116,97765,16935,30405,67263,117630,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {3515,45801,29845,101797,39861,106336,80654,99014,8721,130786,45645,130342,17103,20765,31635,122854,4691,80200,42505,67935,27282,33207,93340,113785,17809,29772,77231,100338,27981,28224,30535,85986,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4109,96817,66150,92842,41253,54542,48879,130451,6099,28368,49284,114512,11525,42665,23812,95221,17777,83888,23844,74345,31379,130652,34949,39406,31505,125985,59997,93337,45170,95483,59015,99625,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {186,78236,22156,76788,84679,95809,85122,89543,52552,55421,85357,120558,84374,93011,96103,121730,20106,124535,75921,76173,30370,60471,37863,128853,31285,48435,74660,120620,83134,91183,93412,124398,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2213,24525,87504,110477,13555,108818,53867,66698,3676,118042,102112,104575,25494,48411,94197,95689,10101,30216,72327,79603,91939,92733,110661,114830,12269,123923,51405,105266,78056,106442,83381,98522,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {472,108240,12671,35911,93294,100150,107743,113795,28030,107619,73882,106036,60882,119628,71385,84404,3335,121782,17032,38199,32007,104160,42313,88433,8082,29510,54953,87024,10806,75588,109112,129256,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1532,18734,2134,97139,14354,25980,68166,68956,26520,121060,44818,56717,46923,117164,77564,120189,8666,22784,22434,50680,9645,36597,11001,67915,29017,39638,62311,101748,53227,111592,54101,100232,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2108,76513,19058,64686,21773,102713,30959,127293,26208,44307,48619,124824,46281,117607,76763,123526,9920,30019,106999,124725,49589,127683,79750,106793,23788,41442,40888,115231,29339,108079,75704,114088,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {447,24891,108406,127741,13974,79393,38505,107967,6426,100981,8357,126057,19059,70525,48680,78503,10968,14964,26165,130501,21506,72473,69831,95032,11133,63448,50969,77868,15697,111027,54580,119107,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3452,90659,52661,117232,4931,118564,16147,41673,13196,61720,84171,101576,16709,35729,117785,120927,12696,48016,42046,121191,41337,102832,76725,94026,43983,126213,47867,126644,65082,95545,80272,103624,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {121,40209,96515,110628,93529,102683,94066,117286,2386,90155,77749,121352,18884,53513,71425,77097,14718,47164,106350,107018,15778,27856,55874,126398,29684,123106,67037,126415,30695,59004,118830,123155,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1903,115726,10082,86987,18063,27952,124532,128098,2401,129013,66400,102778,4350,112380,8189,103806,4766,48029,10347,104668,33812,100519,40889,54865,23299,107532,54310,115236,36331,119384,42381,57438,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2265,65556,50529,87812,54441,117771,79522,91978,21735,38739,43440,122737,49656,80104,111816,121932,3947,80966,13177,63462,15147,82384,42338,56460,3952,97374,120609,129087,33340,96025,52456,113868,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2672,15110,21366,32653,45142,106847,55383,99801,6541,129990,56064,95437,19009,50619,42695,91664,8415,45156,36583,58009,22631,112430,48896,90062,15585,45963,26179,44378,18454,54748,55441,55483,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {975,103172,3589,97639,12512,29025,52812,128755,27526,89196,39433,99838,56671,129118,78842,88081,3008,21665,17020,74242,13649,112061,23333,44261,30203,76484,56126,85907,52839,121362,57122,66343,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {4341,61910,37045,94903,26029,77749,40966,68158,10020,108963,15600,85072,31888,108725,59565,101047,13300,111502,47791,93035,14930,64697,65049,98601,17732,65805,51099,51483,74985,97359,83639,117142,}},
};
// 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;
// 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)
{
// Simple block creation, nothing special yet:
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
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);
// Hash state
crypto_generichash_blake2b_state eh_state;
EhInitialiseState(96, 5, 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;
EhBasicSolve(96, 5, curr_state, solns);
bool ret;
for (auto soln : solns) {
EhIsValidSolution(96, 5, curr_state, soln, ret);
assert(ret);
pblock->nSolution = soln;
CValidationState state;
if (ProcessNewBlock(state, NULL, pblock, true, NULL) && state.IsValid()) {
goto foundit;
}
//std::cout << state.GetRejectReason() << std::endl;
}
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();
// Need to recreate the template each round because of mining slow start
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 = 50000LL;
for (unsigned int i = 0; i < 1001; ++i)
{
tx.vout[0].nValue -= 10;
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 = 50000LL;
for (unsigned int i = 0; i < 128; ++i)
{
tx.vout[0].nValue -= 350;
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 = 39000LL;
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 = 49000LL;
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 = 49000LL;
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 -= 10000;
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 = 49000LL;
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 = 49000LL;
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 = 79000LL;
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()