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.

420 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[] = {
{"0000000000000000000000000000000000000000000000000000000000000000", {1193,68340,5805,59781,21573,101819,84494,100389,26152,101895,56614,69824,68505,127156,108332,117134,6101,86601,32223,55671,34644,46254,59054,118572,18968,124250,121832,125993,41000,49585,59793,105979,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {951,84997,49786,60053,12094,43048,83063,124928,1452,7997,58278,73769,4983,53167,39342,82656,13109,33678,60093,111937,60525,89308,90766,108757,22437,121760,40980,110590,22757,49523,31625,82733,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {4399,104285,25912,119683,63611,115195,101142,114723,6370,62432,75125,125462,17176,130435,37321,96253,16328,29754,52212,120333,54044,82860,63348,94180,21925,41672,68743,76362,47862,54804,92142,98555,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2285,54465,48817,105281,10335,36137,87114,127022,18043,77407,70323,82185,38482,81833,41146,93481,11592,123985,25540,128286,49378,67003,83596,94091,18585,106443,42849,56172,43791,82755,96732,101870,}},
{"0000000000000000000000000000000000000000000000000000000000000003", {453,123519,14319,97557,61520,127956,111967,129428,6575,125590,42158,85101,26717,73037,85271,127993,614,11229,30718,101043,21205,91206,99137,103900,4030,49049,59374,104461,21656,127124,61917,124006,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {909,104608,10097,80586,18684,116050,45970,119876,2753,45785,61441,93588,29303,129805,99212,110899,4058,59055,108690,118771,17246,32029,27885,93922,4115,74287,37651,98917,11080,94042,46560,57246,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {368,61762,81613,109844,5707,28474,15122,60311,17354,73143,73199,114365,23686,65484,95250,106417,3140,97029,6646,34497,20874,68384,56714,97310,24743,72241,36759,115726,82975,112556,117857,129546,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1307,19213,9523,71852,40333,126825,55675,85763,1458,115924,42237,81430,28236,99717,46576,67646,2558,74406,87445,112220,21505,49598,32033,76698,4727,58935,14982,93480,9706,107784,98800,106751,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2490,14987,9626,107816,39094,130902,43150,101385,18675,115829,63930,72519,30526,103628,30552,121031,9862,63792,80351,106779,14441,101996,76265,126531,27596,121410,42804,58889,75300,81494,86861,130418,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {4762,95176,75796,89310,6298,26026,34272,98650,17989,102253,35669,75103,36554,101621,63552,125033,5177,89457,13653,112349,12060,36913,59005,62573,44422,75768,93271,125000,64067,111402,98669,119761,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {10454,67451,71879,124545,16164,40504,59213,78098,10908,26685,53096,104644,13153,23363,93470,121463,10658,110039,28174,89262,12095,59514,86455,105763,14247,43788,44598,106932,34509,126066,122507,129750,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {929,104227,46239,52576,13125,104888,26633,89995,6750,80059,99983,107079,18924,23839,51888,112098,2213,9821,25943,100564,28490,84656,28636,62192,9983,36079,19152,43210,29465,86194,59703,64407,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1540,56929,73299,98953,28081,56404,55913,63444,18350,37331,34504,54542,70055,75356,104057,108720,1546,130800,11191,97633,53334,96695,81719,86171,4160,5519,42514,98145,64533,83081,92846,111576,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {370,113631,27773,29208,23447,100376,32506,56907,42243,98148,104641,107192,44795,102891,61589,94336,2074,94475,62539,118392,3057,53957,51614,89600,45863,56862,50789,102134,82590,96334,99294,120664,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {5277,59674,45884,59015,16320,113745,62532,78882,7878,100230,67824,81267,17542,81571,60141,64007,6865,29061,8011,26826,30731,112604,41377,45762,18799,120782,22676,90558,19095,34165,76085,77629,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2436,122524,63941,88723,21821,64616,38193,61605,19805,68099,103904,114426,47943,86478,73873,76862,5221,14764,58144,61176,7804,32413,73132,75633,18297,46435,72385,114028,59980,81248,97423,102567,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {71,85986,24576,71554,51438,124293,53232,58938,22307,36972,82081,104384,45107,61995,49375,95152,5618,79329,66319,113612,29548,102819,81240,119828,6360,95708,34066,108557,7279,125331,66337,121654,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {181,125604,19288,70901,11930,69219,83800,120369,54181,117409,119020,123867,92877,126214,116763,121982,4743,87719,56289,130021,33098,116166,61076,117462,19714,41842,54924,104530,55397,74391,59800,69432,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {4647,121230,30281,105784,55229,68678,103620,106229,9146,39618,15127,19834,30280,79424,76857,82367,11573,78718,86589,106508,30760,104974,77685,86374,26925,122911,64725,69172,49263,91846,83116,83913,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {934,84484,98804,107779,27791,80836,46181,127141,1102,41711,18826,31852,9530,25783,57463,80857,13565,35466,24086,35314,18193,92000,114981,116723,18392,68407,25534,117318,55536,83249,56474,81854,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {111,123193,37110,92665,34618,69223,92080,119639,1838,68869,8447,59269,59959,115453,71172,73025,6646,97463,83791,120408,71692,121700,73995,84631,14725,48249,103443,129331,58778,106135,68669,95587,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {459,49263,63938,101531,32220,70305,61414,85864,15475,78448,34238,80264,52891,124874,55594,67696,6582,22449,96357,116855,33464,75216,58802,70872,21995,57094,27259,119176,23382,90436,71459,77197,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {257,65325,75263,80551,30423,83310,49665,122857,4491,97576,12794,16963,6833,56486,31891,127807,8582,72557,33236,116531,14523,82763,72622,103589,10765,51051,51199,63619,56930,112694,90543,130732,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2140,21241,57248,76335,16999,59349,61166,75625,6711,120824,23620,78002,21813,84836,45828,110088,6370,32220,7538,125138,37435,70626,74503,129591,36436,91147,39301,94207,58379,81724,66312,82725,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {5542,48855,9261,94491,29165,29544,69914,122786,8965,29241,54006,61177,28121,73961,58668,62402,7053,127467,8973,98466,69682,112212,98826,120578,52727,68259,78563,85974,61184,86264,69918,108992,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {281,47133,56199,72919,3792,108888,3855,116539,6654,59097,81394,128457,85589,119701,90846,115354,3092,23469,56324,103713,10663,10941,16329,75438,21320,80348,77277,97679,24071,128513,30931,80144,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1373,11576,46207,115407,33499,61261,111748,114143,6142,93867,39039,115842,25806,102439,115783,130495,10049,97043,44465,45930,60871,100519,63479,94417,15919,32958,48491,78779,73179,81624,73723,108100,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {5787,85082,8256,117350,21600,86285,86911,95542,24742,96440,24976,97559,66779,98914,101048,110636,11368,62265,23907,26284,13643,65347,40785,70020,13716,47854,21461,39753,50923,112568,73066,123144,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {865,41077,21910,107517,20834,83091,75686,114775,31065,79450,54773,112235,62914,91958,93886,129768,1267,68064,16887,34329,34577,126107,88911,89275,11431,76576,36812,43199,54105,103104,98328,126498,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {8313,60066,25159,41521,9901,75053,67181,102691,54231,62134,92172,97888,64286,101376,84455,109590,14214,130607,20297,113832,29536,89036,52158,120368,16147,41359,37959,122756,20537,28408,84175,89314,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2352,75046,78686,113598,21081,121310,70500,101035,3634,21217,23481,112156,30716,116824,41569,82082,4018,99471,100962,126925,41357,104218,57209,121888,22399,123652,102752,115306,26608,30634,28884,71504,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {547,93847,10235,18611,16965,129793,27702,121739,1536,117104,6808,48414,22335,66846,98837,120403,3320,39059,34301,124875,31478,45466,63922,77846,4174,17468,55452,111916,84512,124580,85565,114278,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {604,56022,50945,87744,1992,24846,33241,97259,9874,115968,75513,128324,21011,77110,66071,130969,14960,94394,108913,128375,67794,78639,106843,115238,19439,84994,81268,98401,39596,84893,53536,71487,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {196,39402,63753,128618,51850,53454,69336,87785,8130,42277,81496,93522,9767,45508,52689,83614,9117,93050,35209,97904,19436,125069,49697,119063,19469,53780,31384,89045,52265,63899,75086,93685,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {902,83015,11750,59813,7705,105354,118121,129040,26350,69302,65467,82730,58735,73945,70191,98020,10111,10308,83145,93411,24795,69433,60088,91028,13694,81094,17495,104746,19490,36252,53232,63330,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {7099,124648,38017,79590,86757,112693,103964,107096,27846,59965,31511,88472,28222,54332,90975,122600,19672,64817,64785,122447,51119,96682,53338,120408,80990,106784,96655,123332,100224,102631,101996,116355,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {138,91040,31718,83313,96656,99254,110266,111882,5870,37712,83597,108360,25785,43972,48815,54136,8926,45554,59700,124308,38326,110195,49884,121320,14187,14421,86532,98376,23481,115445,32081,74429,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {14533,31259,58833,61876,34430,105194,55673,87494,22919,122529,116980,122215,43089,59445,53672,86910,31746,76693,122017,127893,33924,74010,82520,113809,45928,123413,100249,127812,80026,112579,83063,118036,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1544,102416,43972,71060,71009,106841,113931,116112,18830,50191,19652,46599,19119,127280,51162,69343,11909,128558,21386,84969,35430,60920,42869,57204,25471,125680,88934,117970,53417,72331,67387,116689,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {61,3977,14422,71864,996,89538,77970,127651,14623,43194,15549,76562,87817,110102,91804,94587,3839,70920,54294,91571,22759,90594,43746,106410,27301,100997,35286,73667,57071,97127,92363,112883,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2744,130958,55396,67778,10885,118201,82654,108250,26337,126390,102127,124282,27342,35838,61179,68124,9868,81588,11943,66839,29348,69429,88791,99905,15642,87096,87766,108006,24724,85708,38255,106526,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1013,73539,36787,73848,79726,93679,88249,109242,1220,62904,15836,92116,5040,87817,90615,130616,10840,97327,88340,106692,21726,74146,122741,128260,33009,122210,52341,107158,49626,114129,54936,90559,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {440,67396,55796,95799,9578,12834,67078,101648,17400,44183,40380,63258,45044,70029,126212,129790,4111,30443,70024,102113,42217,121003,96138,106210,10646,122268,54626,99108,35704,60725,57042,118298,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2399,40685,35965,83804,74321,90146,104545,127673,21991,45203,51290,54151,85827,100054,104217,127309,5332,106668,20494,46163,60050,122241,82496,124703,33153,101490,54400,62430,38352,107735,61228,90783,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1021,100450,23983,43527,68941,77689,98219,121779,23943,83288,88465,117820,24121,99319,68631,90949,11306,109137,19046,107658,20132,101472,71275,119322,21598,98605,100937,119686,21846,50625,24441,88331,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {11440,91086,41703,87180,67304,93765,83230,91711,29357,103341,81497,82502,35114,86199,39627,86952,14364,66577,17395,85099,52318,71078,52560,98257,36330,104789,71964,126384,48757,127904,94562,107468,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {263,43501,76355,98032,27889,69668,76457,110720,2355,120643,80902,95201,52467,56552,56839,107108,2450,52711,28070,60041,4208,30139,31284,87042,5026,16435,97541,122928,38929,72086,42196,65664,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2316,99234,2865,37076,13650,59469,106849,126247,16150,19007,68119,130381,31704,96950,114374,117937,2550,120429,17651,102750,29735,112112,44659,73769,20322,29864,60446,99827,68738,111872,89024,123484,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3576,127039,108628,109015,31157,51611,51835,73259,30832,40717,104961,121853,56418,126731,85758,125524,14735,80319,25604,108581,15670,17561,94427,116381,32238,103156,54510,73962,48475,102457,121081,126288,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {34,87987,31884,105448,3367,101861,18590,30038,3440,13789,61834,83763,11919,42666,75085,95775,23268,101836,91808,124159,24931,119251,48632,81530,33220,117930,81635,90523,34609,128415,39425,107758,}},
{"0000000000000000000000000000000000000000000000000000000000000004", {3273,116844,30434,92835,24926,113425,65003,116706,13082,82968,28813,101363,28955,69140,41390,101052,16398,102691,55670,122973,85345,119985,98633,109689,21778,101385,85435,129617,24604,78485,27225,28027,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {717,61080,65485,99260,18701,23817,85897,89044,6991,85877,18174,81095,100206,117594,112308,129181,7494,38093,9772,77812,25344,73934,70265,117560,24426,86377,49486,116374,48893,82594,66679,123784,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {4022,130309,41286,74567,57527,115799,60056,88210,9422,122377,55620,103792,11882,13603,70834,90296,11618,89797,37097,83872,25087,105155,44272,47716,21943,126662,82175,93238,44675,56766,62241,76396,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {13872,63903,82061,93988,89015,97375,101032,113858,14921,39129,98531,111543,65980,67917,79663,96943,17924,60128,72417,99911,50358,100096,108135,123879,26917,109495,51185,71878,59397,68930,79476,128986,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {5715,26578,56164,130251,57371,94984,96180,129635,24607,67916,25181,78434,36874,50922,72708,114145,9641,28028,10771,51248,30580,84904,66901,67156,13477,128537,58366,93689,18481,44867,24110,93403,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2541,21976,48318,76834,14478,27970,78324,128382,9590,124681,23543,73719,36658,43828,36860,79199,13555,60394,82766,115201,61475,128898,87349,105854,18579,60627,21892,90057,25332,28761,58772,88258,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {782,81967,8526,25773,20953,129325,99097,105355,9139,23555,55949,65112,62888,110370,110014,130831,3344,19552,62047,122108,3707,104045,84138,102627,28572,43894,80000,93676,102578,124526,107952,115953,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2359,41007,55814,114268,32598,116829,69111,124364,9945,43024,87941,105502,32463,63348,33761,114769,4816,6069,52609,103983,17624,127164,28966,33711,28496,49070,66201,76762,45614,99044,61692,89956,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1203,101437,8387,74329,14437,74978,35514,55736,5615,99162,25087,104181,26671,90234,54624,79270,22110,123225,59615,87993,50069,102619,76148,84664,26293,30053,31407,59604,46042,81432,48405,100058,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1129,57663,59259,96374,28144,36004,34204,94357,4308,75312,10227,13188,11674,91061,23368,59255,1381,88891,44688,86725,100644,128815,107240,130421,18759,105314,46988,107384,27453,50209,68930,101787,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {7105,69154,33332,129127,78031,110920,123978,125583,18201,89164,41391,112185,35404,69313,35521,126412,8168,90196,18814,80599,60119,115779,103078,125284,35077,121290,83811,99887,54682,104596,82852,99285,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {41,28061,28965,93000,26244,96514,105623,113429,2634,4758,29328,85626,15840,79568,41930,46351,3571,68583,54669,113000,63447,67647,75081,85238,53804,117430,63232,68954,59634,66249,74069,123236,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {1344,19400,100145,118849,12589,61549,103310,106063,23392,83587,96273,99533,84754,93725,121971,123043,10803,91672,88143,107104,12972,46555,54239,64966,23922,115073,47709,77816,40573,47900,48009,64405,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {5282,113087,72202,120184,20184,106092,24622,54503,8862,42057,83935,125850,42920,60574,99630,110200,7463,13348,78903,100587,19105,115233,42871,129770,20962,100841,29037,89351,50070,66276,62918,79845,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {499,75985,60387,62039,43214,82140,74181,120663,8299,25989,54452,126283,19290,109445,111713,117209,14810,99452,38575,96977,53663,93239,101958,124106,15845,117124,94815,102073,21706,36388,26582,88207,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1443,93745,7482,47739,3573,55386,6749,51996,4879,44878,73802,81899,14496,23474,94768,113757,5534,129018,32415,109388,42182,49912,63287,68793,7424,47140,87543,116701,30729,114179,78564,94728,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {194,15809,61466,99771,32694,76836,83203,102941,33814,92580,69369,80295,51421,105130,84011,109236,1809,121971,59322,86124,45997,85843,108977,120144,6634,82278,95182,105859,42178,90546,42914,56190,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1251,92021,33281,36571,21587,30616,103318,111790,12073,105155,69933,77627,16370,42502,48738,57216,39247,109486,111791,117623,69958,83447,105736,130233,46478,56288,52796,111501,49975,69361,85427,117236,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {843,53170,20107,130731,40520,96036,77178,112668,11251,28456,20936,113950,51659,75564,94151,104765,25047,72769,85063,112979,55411,103059,68371,108180,25065,127578,87920,89744,34836,36593,42305,92500,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1845,34643,3948,93826,28523,120671,41618,120999,9480,60665,54071,88914,20580,91611,112266,122844,7953,104430,39588,54595,61291,81002,93758,112155,28190,46961,108804,116586,84688,128846,121200,128220,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {6242,71039,28151,47983,43972,130920,56962,126772,15388,34148,58779,86937,27991,121953,57820,112141,26828,88218,70483,125501,53284,105388,113285,127308,29186,75792,90685,113328,32933,99794,72346,126835,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4822,101714,16410,127321,61931,120664,110875,128529,20666,54196,59617,97829,27532,100502,74606,87480,11274,126317,29278,40702,81675,126033,122714,126653,14113,83227,77587,115581,20281,86463,33440,35290,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {16,8660,34899,82137,11354,16014,66935,88029,37743,98170,57384,109756,44298,81513,48636,68803,1525,78164,19368,36460,8413,31518,53579,61218,4535,64280,45215,47574,52218,85387,95171,103019,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4101,12834,4102,9899,34067,71284,124013,126656,29782,84823,34638,50546,49664,55944,62318,126090,13905,120453,50197,65315,68497,104605,68700,111045,37370,94440,68362,91616,80813,117652,113262,129739,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {32,120024,11457,92715,11858,106946,17270,104955,5264,31058,81467,101013,8924,71440,33379,111974,5779,110405,61954,116804,48660,128676,66170,79077,7264,122291,14362,114542,44437,44668,64110,111599,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {858,66569,45648,118415,30501,95195,50579,70984,10936,24342,14211,34428,15996,46637,110961,117260,10400,84314,30171,110793,12565,113927,56412,95766,12168,107464,55738,86492,32032,59200,67481,71702,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {211,122676,37239,121428,68934,71902,92247,107006,42741,83959,51761,71591,88350,110426,106489,116512,17783,116679,54270,107390,68402,101734,82149,82940,33405,83110,69477,100459,46521,124110,73341,106586,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4769,124576,64629,80479,22120,62549,68944,94232,17403,91008,71316,123163,21890,111270,76490,90344,10471,47044,53264,116314,41313,63898,66275,107879,10476,12025,18105,110512,34069,76699,79292,95359,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {5138,31848,62585,102200,19505,110512,75055,95788,20163,110402,42213,77722,30814,79068,53788,106590,8002,101942,100043,120601,34982,45681,85033,104927,35344,57114,53813,62787,35440,46967,91399,100975,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2894,5115,5196,8572,36336,95960,37564,129161,18901,91310,50466,104935,29687,87018,102644,130428,8549,26719,23950,121565,13020,109171,38526,82920,29026,87689,59500,91102,43523,99017,45614,66608,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1367,104522,14112,50350,12231,54289,69397,103123,1667,71581,94377,129905,5701,30789,25558,55713,14377,17373,74024,87484,14933,130381,21638,86808,14973,90798,53173,85556,62005,82706,75190,104125,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {6878,128142,27323,102269,57458,96272,65466,97541,19450,29353,20497,53042,27729,28944,96071,118286,18318,69506,39903,129715,22720,87328,28443,116424,26207,113262,79853,81783,39284,106382,71915,79543,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {855,99963,91677,110615,11775,36471,102112,107351,7670,70393,61866,121293,16957,83792,50239,113548,13386,37185,76361,77268,39732,110971,63898,101071,15523,28157,21894,84925,17833,88688,106745,123467,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {6150,63330,13653,81070,21809,36097,104146,111486,46120,92744,80195,128647,49008,116118,77211,124564,10921,45323,32526,75935,32059,62375,52124,55344,15006,75257,80979,85691,65264,113531,93780,114728,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2380,59548,89300,113702,10048,78922,37470,58562,36249,119477,59456,125432,46250,76087,66266,89859,6428,27046,71910,94978,23501,53483,25929,41461,28723,115395,45333,105123,49146,122747,57220,112804,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {104,109174,59753,99837,35672,130171,63361,90139,13678,106146,27385,79444,33012,93281,33494,39242,19579,111651,41634,58495,109013,130599,130407,130673,46654,51408,95714,117507,67794,68717,70504,86859,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {3906,121884,23161,101594,4585,27946,12447,20685,5743,7500,37455,129359,29834,129486,40114,68848,28662,112806,50155,55122,61901,104853,63992,81014,50363,116253,70770,93152,57355,104509,65163,130699,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {2179,49182,21717,104935,47974,128600,56133,86861,34607,102248,98514,110359,35238,62468,96533,99077,4460,82868,30222,99451,24985,80915,47975,64739,47186,94416,95932,112427,57839,95279,75891,97286,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2393,51044,48697,94711,32072,113561,60971,66114,11648,115600,63028,107394,36859,49360,81828,106100,3549,56549,73049,83176,19671,49426,38193,89614,6854,13779,51553,94935,51173,70050,65221,84140,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1212,112317,47230,53113,37324,68819,70971,81143,34731,88471,38235,43453,62103,75551,94245,124869,7599,81830,9545,121311,9310,126129,80314,81039,11313,12592,11477,43847,16450,29594,45947,107169,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4933,88792,82805,125234,54266,129582,78945,85373,13909,24340,109621,119750,87500,110328,92349,115689,19457,64715,55602,119233,19805,107454,27006,77142,30101,37460,52763,63595,40106,69997,111287,120953,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {468,3944,15466,54643,47697,84273,77788,109110,37872,101578,112624,119392,37964,115576,101892,128471,2942,64824,39360,65610,5022,50715,7299,130864,26504,109085,37799,102966,47540,127974,84699,111888,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {152,17795,36479,98438,963,91244,82844,126318,9842,13902,45762,123348,16796,59916,70473,127991,5005,107646,38330,124983,23979,99587,83600,113996,17940,54116,27243,85751,38587,57331,80240,128712,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {3882,93091,84161,108910,14214,66943,19963,89017,26748,103239,51673,108911,26809,114088,54118,82634,9983,69733,72904,99992,35523,50988,63292,130145,16767,27892,25737,32906,25459,111475,89549,123800,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {905,118643,14169,65925,61932,94198,92388,95889,10827,58627,77111,83599,59045,128885,67112,70945,1775,70797,37161,42307,33323,108750,33485,77874,6376,113619,23914,83669,9559,54895,71552,81625,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {8119,16424,22072,113378,53846,127520,66621,73320,14589,86807,15363,101984,47060,67876,64956,74631,8879,96884,35152,95241,67801,89708,76926,94587,16810,29697,40998,53341,47702,53257,106772,122376,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {228,10819,35319,60103,44307,68355,77942,83730,6176,121442,48580,49837,46950,96382,110090,120199,2678,60160,21914,101856,36385,67996,99247,109630,13690,86582,18578,124766,26532,31241,59554,66774,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1793,60405,27006,31622,90739,126547,111795,126396,6036,99735,28402,91194,15568,81820,78114,99352,18955,25548,100551,106932,53102,102564,87830,129164,42622,112446,44824,90989,51893,103629,57386,101456,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1892,82099,84111,118870,3115,40978,4147,92573,37607,112710,49343,110911,49055,87728,62999,85708,4465,68484,20648,112633,57431,66103,100632,113270,16213,130208,50468,63168,21694,102580,44785,84124,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {10844,116643,27275,102723,54545,127216,56747,61138,14539,92223,30750,112537,23859,25452,94171,98273,12683,31522,25341,55108,22876,125963,38741,107360,77710,120742,80970,112368,85143,122820,85989,109358,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {13733,17229,86407,119283,46909,114706,69539,123078,19368,89137,89142,113704,30426,44446,96938,106254,14764,129591,80361,82004,25635,112512,55102,67715,48791,71227,99385,106860,79732,104754,91227,98140,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {15194,129531,42180,55967,17531,61051,53277,114760,52178,98807,69583,73889,77824,108124,91713,102198,23030,93492,77500,89528,90670,110195,108215,122699,31646,112352,118251,121122,44613,128222,56640,58555,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {1343,37436,63165,79331,41969,127759,48531,72953,1437,89839,9208,110314,5016,89747,42682,106790,4657,111579,13062,106167,44497,124078,64678,129198,24834,32737,93976,125278,37650,49926,46074,47114,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {4823,59193,62107,105820,10704,115728,37436,49368,43020,107891,105170,106685,54075,57542,76771,84151,19232,59718,20295,52897,56345,93561,65349,99799,53327,125006,91605,124473,61846,71645,93432,126758,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {1772,91584,98330,117355,48382,57458,52949,109192,34069,71985,73937,117032,44869,119992,89106,118518,2290,90991,58181,100156,89469,103114,110735,124303,2914,108013,13726,126198,35270,84598,58427,76223,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {48,99494,15015,110216,330,15688,23534,59765,6870,119809,78611,127365,17647,116005,74958,86206,6504,9620,60694,85282,32882,106616,38160,108649,24936,122189,112414,112596,39393,80339,61385,128978,}},
{"0000000000000000000000000000000000000000000000000000000000000002", {101,119154,71529,130536,2187,49873,54555,64141,8928,77312,113791,114916,52778,81760,95052,115749,4213,15415,59980,130039,30767,43413,33548,37031,13464,65693,68774,72431,20625,124619,119166,130780,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {4233,33176,43708,55482,25348,51018,60746,97987,13491,23060,65847,126378,14150,52701,67149,84987,21271,86591,78598,129732,60172,126400,78020,112938,36243,85645,53784,70104,95963,125947,124532,127150,}},
{"0000000000000000000000000000000000000000000000000000000000000000", {83,129624,47935,57492,3098,118571,62848,100824,2201,129786,40709,51811,42027,67793,106728,123029,6383,124311,90864,108178,29820,51826,54355,111489,9130,87309,45926,75107,29967,35844,91034,95581,}},
{"0000000000000000000000000000000000000000000000000000000000000001", {2625,12668,40547,130658,63237,118548,83120,110347,21183,85208,99979,117248,35320,52452,58849,115693,8767,34019,42852,90307,23961,49397,51719,98408,15894,67832,58244,100835,66133,95889,71477,98549,}},
};
// 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);
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;
}
//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 = 800000LL;
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 = 800000LL;
for (unsigned int i = 0; i < 128; ++i)
{
tx.vout[0].nValue -= 1000;
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 = 690000LL;
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 = 790000LL;
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 = 790000LL;
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 = 790000LL;
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 = 790000LL;
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 = 790000LL;
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()