From 373668be25c1097ea826e78a9050de855f16527f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 14:29:10 +0300 Subject: [PATCH 01/62] Test miner caused getinfo delay --- src/komodo_gateway.h | 308 ------------------------------------------- src/miner.cpp | 2 +- 2 files changed, 1 insertion(+), 309 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 93767844d..3c919d203 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -725,314 +725,6 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } return(0); } -/* - //fprintf(stderr,"ht.%d n.%d nValue %.8f (%d %d %d)\n",height,n,dstr(block.vtx[0].vout[1].nValue),KOMODO_PAX,komodo_isrealtime(&ht),KOMODO_PASSPORT_INITDONE); - offset += komodo_scriptitemlen(&opretlen,&script[offset]); - //printf("offset.%d opretlen.%d [%02x %02x %02x %02x]\n",offset,opretlen,script[0],script[1],script[2],script[3]); - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - { - opcode = 'X'; - if ( height >= 235300 ) - return(-1); - strcpy(symbol,(char *)"KMD"); - if ( komodo_isrealtime(&ht) == 0 || KOMODO_PASSPORT_INITDONE == 0 ) // init time already in DB - return(0); - } - else - { - strcpy(symbol,ASSETCHAINS_SYMBOL); - opcode = 'I'; - if ( (baseid= komodo_baseid(symbol)) < 0 ) - { - if ( block.vtx[0].vout.size() != 1 ) - { - printf("%s has more than one coinbase?\n",symbol); - return(-1); - } - return(0); - } - while ( KOMODO_PASSPORT_INITDONE == 0 ) - komodo_passport_iteration(); - komodo_passport_iteration(); - // grandfathering preexisting - if ( height < 777 ) - return(0); - if ( baseid == USD ) // 6820 in balance calcs - { - if ( height <= 6821 || height <= 2000 || height == 2968 || height == 2960 || height == 2649 || height == 3275 || height == 3282 || height == 3328 || height == 3468 ) - return(0); - } - else if ( baseid == EUR ) - { - if ( height < 1200 || height == 1408 || height == 1111 || height == 1094 || height == 1092 || height == 1080 || height == 1053 || height == 1005 || height == 822 || height == 821 || height == 810 || height == 797 || height == 790 || height == 787 || height == 785 || height == 1313 || height == 1288 || height == 1263 || height == 1262 || height <= 211 || height == 210 || height == 188 || height == 185 || height == 182 || height == 181 || height == 171 || height == 170 || height == 169 || height == 168 || height == 167 || height == 166 || height == 165 || height == 164 || height == 163 || height == 162 ) - return(0); - } - else if ( baseid == JPY ) - { - if ( height == 1038 || height == 1039 || height == 1040 || height == 1041 || height == 1014 || height == 998 || height == 973 || height == 139 || height == 971 || height == 141 || height == 816 || height == 814 || height == 803 || height == 142 || height == 782 || height == 145 || height == 181 || height == 186 || height == 192 || height == 190 || height == 189 || height == 255 || height == 218 || height == 233 || height == 259 || height == 278 || height == 361 || height == 367 || height == 733 || height == 688 || height == 468 ) - return(0); - } - else if ( baseid == GBP ) - { - if ( height == 1025 || height == 1026 || height == 1027 || height == 1028 || height == 997 || height == 970 || height == 953 || height == 951 || height == 803 || height == 800 || height == 786 || height == 123 || height == 771 || height == 137 || height == 139 || height == 140 || height == 146 || height == 194 || height == 200 || height == 202 || height == 203 || height == 205 || height == 210 || height == 216 || height == 271 || height == 233 || height == 294 ) - return(0); - } - else if ( baseid == AUD ) - { - if ( height == 1012 || height == 1013 || height == 1014 || height == 985 || height == 958 || height == 936 || height == 933 || height == 790 || height == 788 || height == 778 || height == 124 || height == 777 || height == 122 || height == 140 || height == 142 || height == 143 || height == 186 || height == 196 || height == 198 || height == 201 || height == 210 || height == 192 ) - return(0); - } - else if ( baseid == CAD ) - { - if ( height < 1000 || height == 836 || height == 781 || height == 779 || height == 798 || height == 794 || height == 1181 || height == 1179 || height == 1159 || height == 1134 || height == 1132 || height == 121 || height == 970 || height == 119 || height == 299 || height == 302 || height == 303 || height == 306 || height == 308 || height == 355 || height == 362 || height == 367 || height == 363 || height == 364 || height == 380 || height == 373 || height == 390 || height == 437 || height == 777 ) - return(0); - } - else if ( baseid == CHF ) - { - if ( height == 987 || height == 988 || height == 989 || height == 960 || height == 931 || height == 914 || height == 122 || height == 912 || height == 141 || height == 780 || height == 145 || height == 777 || height == 151 || height == 775 || height == 765 || height == 195 || height == 764 || height == 737 || height == 194 || height == 193 || height == 198 || height == 207 || height == 216 || height == 227 || height == 256 || height == 260 || height == 276 || height == 289 || height == 292 || height == 349 ) - return(0); - } - else if ( baseid == NZD ) - { - if ( height < 1000 || height == 787 || height == 786 || height == 784 || height == 785 || height == 777 || height == 1113 || height == 1083 || height == 1067 || height == 265 || height == 1064 || height == 920 || height == 913 || height == 124 || height == 911 || height == 903 || height == 900 || height == 879 || height == 122 || height == 266 || height == 269 || height == 270 || height == 278 || height == 307 || height == 318 || height == 322 || height == 335 || height == 395 || height == 406 || height == 314 ) - return(0); - } - else if ( baseid == CNY ) - { - if ( height == 987 || height == 988 || height == 989 || height == 982 || height == 957 || height == 931 || height == 119 || height == 929 || height == 134 || height == 782 || height == 137 || height == 775 || height == 143 || height == 772 || height == 186 || height == 763 || height == 761 || height == 734 || height == 183 || height == 190 || height == 192 || height == 211 || height == 203 || height == 226 || height == 263 || height == 264 || height == 277 || height == 342 || height == 613 || height == 525 ) - return(0); - } - else if ( baseid == RUB ) - { - if ( height == 819 || height == 812 || height == 810 || height == 802 || height == 801 || height == 1074 || height == 1040 || height == 1014 || height == 163 || height == 1013 || height == 877 || height == 867 || height == 863 || height == 834 || height == 158 || height == 126 || height == 106 || height == 105 || height == 174 || height == 175 || height == 176 || height == 177 || height == 181 || height == 183 || height == 184 || height == 187 ) - return(0); - } - else if ( baseid == MXN ) - { - if ( height == 1079 || height == 1080 || height == 1081 || height == 1069 || height == 1048 || height == 1028 || height == 121 || height == 1027 || height == 146 || height == 894 || height == 891 || height == 148 || height == 882 || height == 879 || height == 151 || height == 856 || height == 158 || height == 822 || height == 197 || height == 203 || height == 207 || height == 209 || height == 213 || height == 217 || height == 218 || height == 226 || height == 283 || height == 302 || height == 319 || height == 318 || height == 569 ) - return(0); - } - else if ( baseid == BRL ) - { - if ( height == 1003 || height == 1004 || height == 1005 || height == 972 || height == 943 || height == 922 || height == 118 || height == 920 || height == 145 || height == 787 || height == 783 || height == 147 || height == 781 || height == 774 || height == 148 || height == 771 || height == 154 || height == 751 || height == 156 || height == 188 || height == 193 || height == 195 || height == 199 || height == 203 || height == 225 || height == 230 || height == 262 || height == 266 || height == 284 || height == 300 || height == 640 ) - return(0); - } - else if ( baseid == INR ) - { - if ( height == 998 || height == 999 || height == 1000 || height == 788 || height == 786 || height == 775 || height == 753 || height == 125 || height == 153 || height == 155 || height == 159 || height == 204 || height == 206 || height == 211 || height == 217 || height == 220 || height == 229 || height == 265 || height == 292 || height == 300 ) - return(0); - } - else if ( baseid == PLN ) - { - if ( height == 1029 || height == 1030 || height == 1031 || height == 1009 || height == 984 || height == 960 || height == 959 || height == 798 || height == 794 || height == 792 || height == 782 || height == 775 || height == 755 || height == 122 || height == 120 || height == 158 || height == 160 || height == 163 || height == 225 || height == 217 || height == 219 || height == 229 || height == 234 || height == 286 || height == 231 || height == 292 ) - return(0); - } - else if ( baseid == HKD ) - { - if ( height == 1013 || height == 1014 || height == 1015 || height == 1002 || height == 979 || height == 947 || height == 123 || height == 946 || height == 153 || height == 811 || height == 808 || height == 806 || height == 155 || height == 795 || height == 157 || height == 773 || height == 205 || height == 208 || height == 210 || height == 211 || height == 215 || height == 221 || height == 231 || height == 255 || height == 273 || height == 293 || height == 310 || height == 654 ) - return(0); - } - else if ( baseid == TRY ) - { - if ( height == 1022 || height == 1023 || height == 1051 || height == 991 || height == 974 || height == 949 || height == 141 || height == 948 || height == 783 || height == 153 || height == 781 || height == 779 || height == 776 || height == 768 || height == 765 || height == 121 || height == 142 || height == 144 || height == 143 || height == 149 || height == 204 || height == 210 || height == 216 || height == 229 || height == 280 || height == 145 ) - return(0); - } - else if ( baseid == NOK ) - { - if ( height == 987 || height == 988 || height == 989 || height == 962 || height == 911 || height == 907 || height == 125 || height == 765 || height == 150 || height == 762 || height == 760 || height == 753 || height == 152 || height == 751 || height == 151 || height == 154 || height == 160 || height == 195 || height == 203 || height == 207 || height == 211 || height == 220 || height == 236 || height == 253 || height == 278 || height == 283 ) - return(0); - } - else if ( baseid == ZAR ) - { - if ( height == 979 || height == 980 || height == 981 || height == 956 || height == 937 || height == 906 || height == 905 || height == 122 || height == 756 || height == 754 || height == 752 || height == 749 || height == 742 || height == 739 || height == 120 || height == 151 || height == 153 || height == 157 || height == 159 || height == 206 || height == 213 || height == 216 || height == 222 || height == 277 || height == 287 || height == 215 ) - return(0); - } - else if ( baseid == SEK ) - { - if ( height == 960 || height == 961 || height == 962 || height == 943 || height == 925 || height == 896 || height == 147 || height == 894 || height == 759 || height == 751 || height == 749 || height == 742 || height == 740 || height == 716 || height == 123 || height == 148 || height == 150 || height == 151 || height == 157 || height == 199 || height == 200 || height == 201 || height == 206 || height == 256 || height == 257 || height == 268 ) - return(0); - } - else if ( baseid == CZK ) - { - if ( height < 1000 || height == 1084 || height == 1085 || height == 1086 || height == 778 || height == 1079 || height == 1054 || height == 1032 || height == 121 || height == 1030 || height == 182 || height == 876 || height == 873 || height == 871 || height == 184 || height == 862 || height == 185 || height == 861 || height == 186 || height == 838 || height == 238 || height == 242 || height == 246 || height == 248 || height == 250 || height == 251 || height == 256 || height == 282 || height == 322 || height == 343 || height == 433 || height == 323 || height == 276 ) - return(0); - } - else if ( baseid == HUF ) - { - if ( height < 2200 || height == 1531 || height == 1528 || height == 1530 || height == 1451 || height == 1448 || height == 1442 || height == 1418 || height == 1407 || height == 1406 || height == 1392 || height == 1391 || height == 1387 || height == 1383 || height == 1335 || height == 1337 || height == 1338 || height == 1649 || height == 2378 || height == 2376 || height == 2371 || height == 1330 || height == 2326 || height == 1344 || height == 2305 || height == 2304 || height == 2171 || height == 2168 || height == 2166 || height == 2156 || height == 2135 || height == 1343 || height == 1342 || height == 1341 || height == 1340 || height == 1339 || height == 1336 || height == 1334 || height == 1333 || height == 1346 || height == 1400 || height == 1525 || height == 1509 ) - return(0); - } - else if ( baseid == DKK ) - { - if ( height == 1241 || height == 945 || height == 898 || height == 894 || height == 892 || height == 866 || height == 857 || height == 853 || height == 834 || height == 812 || height == 792 || height == 784 || height == 778 || height == 783 || height == 1214 || height == 1186 || height == 1158 || height == 126 || height == 1156 || height == 329 || height == 1021 || height == 1016 || height == 1014 || height == 333 || height == 1003 || height == 1002 || height == 978 || height == 332 || height == 337 || height == 381 || height == 390 || height == 386 || height == 401 || height == 389 || height == 396 || height == 428 || height == 473 || height == 490 || height == 493 ) - return(0); - } - else if ( baseid == ILS ) - { - if ( height == 1017 || height == 1018 || height == 1019 || height == 1010 || height == 985 || height == 954 || height == 120 || height == 952 || height == 143 || height == 819 || height == 817 || height == 808 || height == 145 || height == 786 || height == 155 || height == 753 || height == 151 || height == 149 || height == 199 || height == 193 || height == 201 || height == 209 || height == 284 || height == 305 || height == 676 || height == 702 || height == 406 ) - return(0); - } - else if ( baseid == MYR ) - { - if ( height == 1020 || height == 1021 || height == 1022 || height == 1015 || height == 984 || height == 950 || height == 949 || height == 823 || height == 820 || height == 818 || height == 812 || height == 809 || height == 126 || height == 789 || height == 144 || height == 746 || height == 146 || height == 147 || height == 148 || height == 150 || height == 205 || height == 210 || height == 215 || height == 219 || height == 222 || height == 290 || height == 242 || height == 312 ) - return(0); - } - else if ( baseid == PHP ) - { - if ( height == 859 || height == 817 || height == 812 || height == 811 || height == 792 || height == 779 || height == 778 || height == 781 || height == 1154 || height == 1114 || height == 1077 || height == 1076 || height == 931 || height == 927 || height == 925 || height == 918 || height == 891 || height == 127 || height == 125 || height == 272 || height == 275 || height == 276 || height == 278 || height == 328 || height == 330 || height == 335 || height == 344 || height == 315 ) - return(0); - } - else if ( baseid == KRW ) - { - if ( height == 1021 || height == 1022 || height == 1023 || height == 1010 || height == 950 || height == 916 || height == 138 || height == 914 || height == 140 || height == 785 || height == 782 || height == 781 || height == 142 || height == 775 || height == 148 || height == 772 || height == 751 || height == 147 || height == 146 || height == 159 || height == 175 || height == 181 || height == 184 || height == 186 || height == 188 || height == 196 || height == 209 || height == 238 ) - return(0); - } - else if ( baseid == RON ) - { - if ( height == 1008 || height == 1009 || height == 1010 || height == 1003 || height == 973 || height == 940 || height == 939 || height == 806 || height == 802 || height == 800 || height == 793 || height == 789 || height == 768 || height == 123 || height == 141 || height == 143 || height == 144 || height == 150 || height == 197 || height == 200 || height == 202 || height == 217 || height == 240 || height == 276 ) - return(0); - } - else if ( baseid == SGD ) - { - if ( height == 1016 || height == 1017 || height == 1018 || height == 1010 || height == 984 || height == 951 || height == 950 || height == 801 || height == 798 || height == 792 || height == 788 || height == 122 || height == 769 || height == 120 || height == 158 || height == 160 || height == 164 || height == 169 || height == 229 || height == 234 || height == 246 || height == 297 || height == 299 || height == 316 || height == 233 ) - return(0); - } - else if ( baseid == THB ) - { - if ( height == 977 || height == 978 || height == 968 || height == 933 || height == 898 || height == 897 || height == 788 || height == 786 || height == 779 || height == 777 || height == 757 || height == 119 || height == 140 || height == 142 || height == 146 || height == 152 || height == 196 || height == 200 || height == 214 || height == 260 || height == 263 ) - return(0); - } - else if ( baseid == BGN ) - { - if ( height == 1044 || height == 1045 || height == 1046 || height == 1030 || height == 995 || height == 960 || height == 959 || height == 830 || height == 822 || height == 819 || height == 810 || height == 809 || height == 781 || height == 124 || height == 122 || height == 189 || height == 193 || height == 200 || height == 194 || height == 250 || height == 256 || height == 260 || height == 280 ) - return(0); - } - else if ( baseid == HRK ) - { - if ( height == 1027 || height == 1028 || height == 1029 || height == 1022 || height == 999 || height == 969 || height == 967 || height == 832 || height == 829 || height == 827 || height == 817 || height == 792 || height == 754 || height == 125 || height == 123 || height == 184 || height == 186 || height == 187 || height == 227 || height == 230 || height == 235 || height == 240 || height == 242 || height == 261 || height == 336 ) - return(0); - } - else if ( baseid == IDR ) - { - if ( height == 836 || height == 1036 || height == 837 || height == 720 || height == 715 || height == 714 || height == 696 || height == 695 || height == 694 || height == 693 || height == 119 || height == 689 || height == 120 || height == 669 || height == 123 || height == 662 || height == 122 || height == 634 || height == 121 || height == 609 || height == 124 || height == 174 || height == 603 || height == 595 || height == 166 || height == 176 || height == 589 || height == 172 || height == 587 || height == 179 || height == 239 || height == 175 || height == 245 || height == 260 ) - return(0); - } - } - if ( script[offset] == opcode && opretlen < block.vtx[0].vout[n-1].scriptPubKey.size() ) - { - if ( (num= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,&script[offset],opretlen,opcode == 'X')) > 0 ) - { - for (i=1; iRTmask & (1LL << 32)) == 0 ) - { - if ( rtflag == 0 ) - printf("[%s] skip checkdeposit.%s not RT %llx\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]],(long long)sp->RTmask); - sleep(60); - rtflag = 1; - //matched++; - //continue; - } - if ( rtflag != 0 ) - printf("[%s] %s reached RT\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]); - } - if ( (pax= komodo_paxfinds(txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one - { - pax->type = opcode; - if ( opcode == 'I' && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) ) - { - printf("checkdeposit.[%s.%d]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",ASSETCHAINS_SYMBOL,height,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed)); - return(-1); - } - if ( pax->fiatoshis == block.vtx[0].vout[i].nValue ) - { - matched++; - if ( pax->marked != 0 && height >= 80820 ) - { - printf(">>>>>>>>>>> %c errs.%d i.%d match %.8f vs %.8f paxmarked.%d kht.%d ht.%d [%s].%d\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax->marked,pax->height,pax->otherheight,ASSETCHAINS_SYMBOL,height); - } - else - { - } - if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) - { - //check deposit validates AUD.1047 [3] 0.14585530 -> 0.01000000 (0.14585530 0.01000000 0.01000000) - char destaddr[64],coinaddr[64]; uint8_t pubkey33[33]; - checktoshis = PAX_fiatdest(&seed,0,destaddr,pubkey33,coinaddr,pax->height,CURRENCIES[baseids[i-1]],pax->fiatoshis); - //checktoshis = komodo_paxprice(&seed,pax->height,CURRENCIES[baseids[i-1]],(char *)"KMD",(uint64_t)pax->komodoshis); - if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->komodoshis,checktoshis,seed) < 0 ) - { - printf("paxcmp FAIL when check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); - return(-1); - } //else printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); - } - } - else if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) - { - for (j=0; j<32; j++) - printf("%02x",((uint8_t *)&txids[i-1])[j]); - printf(" cant paxfind %c txid [%d]\n",opcode,height); - printf(">>>>>>>>>>> %c errs.%d i.%d match %.8f vs %.8f pax.%p [%s] ht.%d\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax,ASSETCHAINS_SYMBOL,height); - return(-1); - } - } - else //if ( kmdheights[i-1] > 0 && otherheights[i-1] > 0 ) - { - hash = block.GetHash(); - for (j=0; j= activation ) - return(-1); - } - } - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - { - //if ( height > 0 && (height < chainActive.Tip()->nHeight || (height >= chainActive.Tip()->nHeight && komodo_isrealtime(&ht) != 0)) && matched != num ) - //{ - // printf("WOULD REJECT %s: ht.%d (%c) matched.%d vs num.%d tip.%d isRT.%d\n",symbol,height,opcode,matched,num,(int32_t)chainActive.Tip()->nHeight,komodo_isrealtime(&ht)); - // can easily happen depending on order of loading - //if ( height > 200000 ) - //{ - // printf("REJECT: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num); - // return(-1); - //} - //} // disabled 'X' path - } - else - { - if ( height > 0 && (height < chainActive.Tip()->nHeight || (height >= chainActive.Tip()->nHeight && komodo_isrealtime(&ht) != 0)) && matched != num ) - { - printf("REJECT %s: ht.%d (%c) matched.%d vs num.%d tip.%d isRT.%d\n",symbol,height,opcode,matched,num,(int32_t)chainActive.Tip()->nHeight,komodo_isrealtime(&ht)); - return(-1); - } - } - } - else - { - for (i=0; i= activation ) - return(-1); - } - //printf("opretlen.%d num.%d\n",opretlen,num); - } - else - { - for (i=0; i Date: Wed, 25 Apr 2018 14:38:31 +0300 Subject: [PATCH 02/62] Test --- src/rpcmisc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 5b117d03f..b4e63b9b0 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -88,12 +88,13 @@ UniValue getinfo(const UniValue& params, bool fHelp) + HelpExampleCli("getinfo", "") + HelpExampleRpc("getinfo", "") ); - + fprintf(stderr,"before LOCK cs_main\n"); #ifdef ENABLE_WALLET LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); #else LOCK(cs_main); #endif + fprintf(stderr,"after LOCK cs_main\n"); proxyType proxy; GetProxy(NET_IPV4, proxy); @@ -124,6 +125,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("blocks", (int)chainActive.Height())); if ( (longestchain= komodo_longestchain()) != 0 && chainActive.Height() > longestchain ) longestchain = chainActive.Height(); + fprintf(stderr,"after longestchain\n"); obj.push_back(Pair("longestchain", longestchain)); obj.push_back(Pair("timeoffset", GetTimeOffset())); if ( chainActive.Tip() != 0 ) From 265660f7cb1ce04d0e19c8ba1d32e3fe73a2fb21 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 15:04:16 +0300 Subject: [PATCH 03/62] streamline --- src/miner.cpp | 8 ++++---- src/rpcmisc.cpp | 6 +++--- src/rpcnet.cpp | 8 +++++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 093c2295d..190f01d55 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -113,11 +113,11 @@ extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33]; uint32_t Mining_start,Mining_height; int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp); int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize); -uint64_t komodo_paxtotal(); +//uint64_t komodo_paxtotal(); int32_t komodo_baseid(char *origbase); int32_t komodo_is_issuer(); int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *symbol,int32_t tokomodo); -int32_t komodo_isrealtime(int32_t *kmdheightp); +//int32_t komodo_isrealtime(int32_t *kmdheightp); int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag); uint64_t komodo_commission(const CBlock *block); int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig); @@ -133,7 +133,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) return NULL; } CBlock *pblock = &pblocktemplate->block; // pointer for convenience - if ( ASSETCHAINS_SYMBOL[0] != 0 && komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 && chainActive.Tip()->nHeight >= ASSETCHAINS_MINHEIGHT ) + /*if ( ASSETCHAINS_SYMBOL[0] != 0 && komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 && chainActive.Tip()->nHeight >= ASSETCHAINS_MINHEIGHT ) { isrealtime = komodo_isrealtime(&kmdheight); deposits = komodo_paxtotal(); @@ -154,7 +154,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) KOMODO_ON_DEMAND = 0; if ( 0 && deposits != 0 ) printf("miner KOMODO_DEPOSIT %llu pblock->nHeight %d mempool.GetTotalTxSize(%d)\n",(long long)komodo_paxtotal(),(int32_t)chainActive.Tip()->nHeight,(int32_t)mempool.GetTotalTxSize()); - } + }*/ // -regtest only: allow overriding block.nVersion with // -blockversion=N to test forking scenarios if (Params().MineBlocksOnDemand()) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index b4e63b9b0..33a947b8c 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -88,13 +88,13 @@ UniValue getinfo(const UniValue& params, bool fHelp) + HelpExampleCli("getinfo", "") + HelpExampleRpc("getinfo", "") ); - fprintf(stderr,"before LOCK cs_main\n"); + //fprintf(stderr,"before LOCK cs_main\n"); #ifdef ENABLE_WALLET LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); #else LOCK(cs_main); #endif - fprintf(stderr,"after LOCK cs_main\n"); + //fprintf(stderr,"after LOCK cs_main\n"); proxyType proxy; GetProxy(NET_IPV4, proxy); @@ -125,7 +125,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("blocks", (int)chainActive.Height())); if ( (longestchain= komodo_longestchain()) != 0 && chainActive.Height() > longestchain ) longestchain = chainActive.Height(); - fprintf(stderr,"after longestchain\n"); + //fprintf(stderr,"after longestchain\n"); obj.push_back(Pair("longestchain", longestchain)); obj.push_back(Pair("timeoffset", GetTimeOffset())); if ( chainActive.Tip() != 0 ) diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index 1d492f35a..3ef614815 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -169,9 +169,11 @@ int32_t KOMODO_LONGESTCHAIN; int32_t komodo_longestchain() { int32_t ht,n=0,num=0,maxheight=0,height = 0; - LOCK(cs_main); - vector vstats; - CopyNodeStats(vstats); + { + LOCK(cs_main); + vector vstats; + CopyNodeStats(vstats); + } BOOST_FOREACH(const CNodeStats& stats, vstats) { //fprintf(stderr,"komodo_longestchain iter.%d\n",n); From 6bb74a025699b6d8388c4c50ce3100bc54fa74e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 15:09:12 +0300 Subject: [PATCH 04/62] Test --- src/rpcmisc.cpp | 2 +- src/rpcnet.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 33a947b8c..b55d3e104 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -49,7 +49,7 @@ int32_t komodo_longestchain(); int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); -extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE; +extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); #define KOMODO_VERSION "0.1.1" diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index 3ef614815..48116a3c4 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -169,9 +169,9 @@ int32_t KOMODO_LONGESTCHAIN; int32_t komodo_longestchain() { int32_t ht,n=0,num=0,maxheight=0,height = 0; + vector vstats; { LOCK(cs_main); - vector vstats; CopyNodeStats(vstats); } BOOST_FOREACH(const CNodeStats& stats, vstats) From daf214b1b6bd8f9300f666240b773a18fbc65dac Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 15:17:07 +0300 Subject: [PATCH 05/62] Rely on cached KOMODO_LONGESTCHAIN in netinfo --- src/komodo_events.h | 6 ++++-- src/komodo_gateway.h | 2 +- src/rpcmisc.cpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index c64ccbaa2..54e2b7f8c 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -39,11 +39,13 @@ struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t height,char *dest,uint256 notarized_hash,uint256 notarized_desttxid,int32_t notarizedheight,uint256 MoM,int32_t MoMdepth) { - struct komodo_event_notarized N; - if ( NOTARY_PUBKEY33[0] != 0 && komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid) != 0 ) + static uint32_t counter; char *coin; struct komodo_event_notarized N; + coin = (ASSETCHAINS_SYMBOL[0] == 0) ? (char *)"KMD" : ASSETCHAINS_SYMBOL; + if ( counter < 10 && NOTARY_PUBKEY33[0] != 0 && strcmp(symbol,coin) == 0 && komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid) != 0 ) { if ( height > 50000 || ASSETCHAINS_SYMBOL[0] != 0 ) printf("[%s] error validating notarization ht.%d notarized_height.%d, if on a pruned %s node this can be ignored\n",ASSETCHAINS_SYMBOL,height,notarizedheight,dest); + counter++; } else { diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3c919d203..ad7237217 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1459,7 +1459,7 @@ void komodo_passport_iteration() if ( sp != 0 && isrealtime == 0 ) refsp->RTbufs[0][2] = 0; } - komodo_paxtotal(); + komodo_paxtotal(); // calls komodo_isrealtime(), which calls komodo_longestchain() refsp->RTmask |= RTmask; if ( expired == 0 && KOMODO_PASSPORT_INITDONE == 0 ) { diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index b55d3e104..1e22c5180 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -123,7 +123,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) } #endif obj.push_back(Pair("blocks", (int)chainActive.Height())); - if ( (longestchain= komodo_longestchain()) != 0 && chainActive.Height() > longestchain ) + if ( (longestchain= KOMODO_LONGESTCHAIN) != 0 && chainActive.Height() > longestchain ) longestchain = chainActive.Height(); //fprintf(stderr,"after longestchain\n"); obj.push_back(Pair("longestchain", longestchain)); From 001bc04a08225fbbc321e6311553591bf0d2914e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 15:26:37 +0300 Subject: [PATCH 06/62] Test --- src/miner.cpp | 4 ++-- src/rpcmisc.cpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 190f01d55..d4a8e35c3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -115,8 +115,8 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33, int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize); //uint64_t komodo_paxtotal(); int32_t komodo_baseid(char *origbase); -int32_t komodo_is_issuer(); -int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *symbol,int32_t tokomodo); +//int32_t komodo_is_issuer(); +//int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *symbol,int32_t tokomodo); //int32_t komodo_isrealtime(int32_t *kmdheightp); int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag); uint64_t komodo_commission(const CBlock *block); diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 1e22c5180..cd57fe701 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -114,6 +114,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) if ( ASSETCHAINS_SYMBOL[0] != 0 ) obj.push_back(Pair("KMDnotarized_height", kmdnotarized_height)); obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height + 1) : 0)); + fprintf(stderr,"after notarized\n"); #ifdef ENABLE_WALLET if (pwalletMain) { obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); @@ -122,10 +123,10 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("interest", ValueFromAmount(komodo_interestsum()))); } #endif + fprintf(stderr,"after wallet\n"); obj.push_back(Pair("blocks", (int)chainActive.Height())); if ( (longestchain= KOMODO_LONGESTCHAIN) != 0 && chainActive.Height() > longestchain ) longestchain = chainActive.Height(); - //fprintf(stderr,"after longestchain\n"); obj.push_back(Pair("longestchain", longestchain)); obj.push_back(Pair("timeoffset", GetTimeOffset())); if ( chainActive.Tip() != 0 ) From 94d3d09da0851f681ea56983612c0cf0e6a5daea Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 15:37:32 +0300 Subject: [PATCH 07/62] Test --- src/komodo_globals.h | 1 + src/rpcmisc.cpp | 15 +++++++++------ src/wallet/rpcwallet.cpp | 2 ++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index f9e0f6688..8be3b741e 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -54,6 +54,7 @@ char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC; uint32_t ASSETCHAINS_MAGIC = 2387029918; +uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10; uint32_t KOMODO_INITDONE; diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index cd57fe701..205282533 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -49,6 +49,7 @@ int32_t komodo_longestchain(); int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); +extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); @@ -88,17 +89,18 @@ UniValue getinfo(const UniValue& params, bool fHelp) + HelpExampleCli("getinfo", "") + HelpExampleRpc("getinfo", "") ); - //fprintf(stderr,"before LOCK cs_main\n"); + fprintf(stderr,"before LOCK cs_main %u\n",(uint32_t)time(NULL)); #ifdef ENABLE_WALLET LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); #else LOCK(cs_main); #endif - //fprintf(stderr,"after LOCK cs_main\n"); + fprintf(stderr,"after LOCK cs_main %u\n",(uint32_t)time(NULL)); proxyType proxy; GetProxy(NET_IPV4, proxy); notarized_height = komodo_notarized_height(¬arized_hash,¬arized_desttxid); + fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL)); UniValue obj(UniValue::VOBJ); obj.push_back(Pair("version", CLIENT_VERSION)); @@ -107,14 +109,14 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("notarized", notarized_height)); obj.push_back(Pair("notarizedhash", notarized_hash.ToString())); obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString())); - txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); + /*txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); if ( txid_height > 0 ) obj.push_back(Pair("notarizedtxid_height", txid_height)); - else obj.push_back(Pair("notarizedtxid_height", "mempool")); + else obj.push_back(Pair("notarizedtxid_height", "mempool"));*/ if ( ASSETCHAINS_SYMBOL[0] != 0 ) obj.push_back(Pair("KMDnotarized_height", kmdnotarized_height)); obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height + 1) : 0)); - fprintf(stderr,"after notarized\n"); + fprintf(stderr,"after notarized_confirms %u\n",(uint32_t)time(NULL)); #ifdef ENABLE_WALLET if (pwalletMain) { obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); @@ -123,10 +125,11 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("interest", ValueFromAmount(komodo_interestsum()))); } #endif - fprintf(stderr,"after wallet\n"); + fprintf(stderr,"after wallet %u\n",(uint32_t)time(NULL)); obj.push_back(Pair("blocks", (int)chainActive.Height())); if ( (longestchain= KOMODO_LONGESTCHAIN) != 0 && chainActive.Height() > longestchain ) longestchain = chainActive.Height(); + fprintf(stderr,"after longestchain %u\n",(uint32_t)time(NULL)); obj.push_back(Pair("longestchain", longestchain)); obj.push_back(Pair("timeoffset", GetTimeOffset())); if ( chainActive.Tip() != 0 ) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6c1c5361b..7c7f6cc50 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -486,6 +486,7 @@ int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_ #define CRYPTO777_KMDADDR "RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA" extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern int32_t KOMODO_PAX; +extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; int32_t komodo_is_issuer(); int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); int32_t komodo_isrealtime(int32_t *kmdheightp); @@ -2712,6 +2713,7 @@ uint64_t komodo_interestsum() } } } + KOMODO_INTERESTSUM = sum; return(sum); } From 247428bdb26fa933cab185a56757ee3906cde635 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 15:47:19 +0300 Subject: [PATCH 08/62] Test --- src/bitcoind.cpp | 4 ++-- src/komodo_gateway.h | 3 +++ src/rpcmisc.cpp | 12 ++++++------ src/wallet/rpcwallet.cpp | 1 + 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 7d57322d0..2ada533f1 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -56,8 +56,8 @@ void WaitForShutdown(boost::thread_group* threadGroup) if ( ASSETCHAINS_SYMBOL[0] == 0 ) { komodo_passport_iteration(); - MilliSleep(1000); - } else MilliSleep(1000); + MilliSleep(10000); + } else MilliSleep(10000); fShutdown = ShutdownRequested(); } if (threadGroup) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ad7237217..efd784291 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1322,6 +1322,8 @@ int32_t komodo_faststateinit(struct komodo_state *sp,char *fname,char *symbol,ch return(-1); } +uint64_t komodo_interestsum(); + void komodo_passport_iteration() { static long lastpos[34]; static char userpass[33][1024]; static uint32_t lasttime,callcounter; @@ -1333,6 +1335,7 @@ void komodo_passport_iteration() fprintf(stderr,"[%s] PASSPORT iteration waiting for KOMODO_INITDONE\n",ASSETCHAINS_SYMBOL); sleep(3); } + komodo_interestsum(); refsp = komodo_stateptr(symbol,dest); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 205282533..5dff6e015 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -90,11 +90,11 @@ UniValue getinfo(const UniValue& params, bool fHelp) + HelpExampleRpc("getinfo", "") ); fprintf(stderr,"before LOCK cs_main %u\n",(uint32_t)time(NULL)); -#ifdef ENABLE_WALLET - LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); -#else +//#ifdef ENABLE_WALLET +// LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); +//#else LOCK(cs_main); -#endif +//#endif fprintf(stderr,"after LOCK cs_main %u\n",(uint32_t)time(NULL)); proxyType proxy; @@ -120,9 +120,9 @@ UniValue getinfo(const UniValue& params, bool fHelp) #ifdef ENABLE_WALLET if (pwalletMain) { obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); - obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); + obj.push_back(Pair("balance", ValueFromAmount(KOMODO_WALLETBALANCE))); //pwalletMain->GetBalance() if ( ASSETCHAINS_SYMBOL[0] == 0 ) - obj.push_back(Pair("interest", ValueFromAmount(komodo_interestsum()))); + obj.push_back(Pair("interest", ValueFromAmount(KOMODO_INTERESTSUM))); //komodo_interestsum() } #endif fprintf(stderr,"after wallet %u\n",(uint32_t)time(NULL)); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 7c7f6cc50..627ffe550 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2714,6 +2714,7 @@ uint64_t komodo_interestsum() } } KOMODO_INTERESTSUM = sum; + KOMODO_WALLETBALANCE = pwalletMain->GetBalance(); return(sum); } From a6cbaa25ce8a471222d68617213bae0442152c71 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 15:53:45 +0300 Subject: [PATCH 09/62] Test --- src/komodo_gateway.h | 8 ++++++-- src/rpcmisc.cpp | 4 +--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index efd784291..dc364c0c8 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1326,7 +1326,7 @@ uint64_t komodo_interestsum(); void komodo_passport_iteration() { - static long lastpos[34]; static char userpass[33][1024]; static uint32_t lasttime,callcounter; + static long lastpos[34]; static char userpass[33][1024]; static uint32_t lasttime,callcounter,lastinterest; int32_t maxseconds = 10; FILE *fp; uint8_t *filedata; long fpos,datalen,lastfpos; int32_t baseid,limit,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t buf[3],starttime; cJSON *infoobj,*result; uint64_t RTmask = 0; expired = 0; @@ -1335,7 +1335,11 @@ void komodo_passport_iteration() fprintf(stderr,"[%s] PASSPORT iteration waiting for KOMODO_INITDONE\n",ASSETCHAINS_SYMBOL); sleep(3); } - komodo_interestsum(); + if ( komodo_chainactive_timestamp() > lastinterest ) + { + komodo_interestsum(); + lastinterest = komodo_chainactive_timestamp(); + } refsp = komodo_stateptr(symbol,dest); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 5dff6e015..99a977bd8 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -89,13 +89,11 @@ UniValue getinfo(const UniValue& params, bool fHelp) + HelpExampleCli("getinfo", "") + HelpExampleRpc("getinfo", "") ); - fprintf(stderr,"before LOCK cs_main %u\n",(uint32_t)time(NULL)); //#ifdef ENABLE_WALLET // LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); //#else - LOCK(cs_main); +// LOCK(cs_main); //#endif - fprintf(stderr,"after LOCK cs_main %u\n",(uint32_t)time(NULL)); proxyType proxy; GetProxy(NET_IPV4, proxy); From 3e9fcad0ad0745e29868f846a78688a1c0a23dfe Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 15:59:33 +0300 Subject: [PATCH 10/62] Test --- src/komodo_bitcoind.h | 2 +- src/komodo_events.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 72136427c..2174a8d80 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -411,7 +411,7 @@ int32_t komodo_verifynotarizedscript(int32_t height,uint8_t *script,int32_t len, for (i=0; i<32; i++) ((uint8_t *)&hash)[i] = script[2+i]; if ( hash == NOTARIZED_HASH ) - return(0); + return(1); for (i=0; i<32; i++) printf("%02x",((uint8_t *)&NOTARIZED_HASH)[i]); printf(" notarized, "); diff --git a/src/komodo_events.h b/src/komodo_events.h index 54e2b7f8c..324e97436 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -39,17 +39,17 @@ struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t height,char *dest,uint256 notarized_hash,uint256 notarized_desttxid,int32_t notarizedheight,uint256 MoM,int32_t MoMdepth) { - static uint32_t counter; char *coin; struct komodo_event_notarized N; + static uint32_t counter; int32_t verified=0; char *coin; struct komodo_event_notarized N; coin = (ASSETCHAINS_SYMBOL[0] == 0) ? (char *)"KMD" : ASSETCHAINS_SYMBOL; - if ( counter < 10 && NOTARY_PUBKEY33[0] != 0 && strcmp(symbol,coin) == 0 && komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid) != 0 ) + if ( counter < 100 && NOTARY_PUBKEY33[0] != 0 && (verified= komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid)) < 0 ) { - if ( height > 50000 || ASSETCHAINS_SYMBOL[0] != 0 ) + //if ( height > 50000 || ASSETCHAINS_SYMBOL[0] != 0 ) printf("[%s] error validating notarization ht.%d notarized_height.%d, if on a pruned %s node this can be ignored\n",ASSETCHAINS_SYMBOL,height,notarizedheight,dest); counter++; } - else + else if ( strcmp(symbol,coin) == 0 ) { - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + if ( verified != 0 ) fprintf(stderr,"validated [%s] ht.%d notarized %d\n",ASSETCHAINS_SYMBOL,height,notarizedheight); memset(&N,0,sizeof(N)); N.blockhash = notarized_hash; From 6a8fb557dd0c30cc7916cc1a2945b1543fa65fcd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 16:04:07 +0300 Subject: [PATCH 11/62] Test --- src/komodo_events.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index 324e97436..123ab067b 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -41,9 +41,9 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig { static uint32_t counter; int32_t verified=0; char *coin; struct komodo_event_notarized N; coin = (ASSETCHAINS_SYMBOL[0] == 0) ? (char *)"KMD" : ASSETCHAINS_SYMBOL; - if ( counter < 100 && NOTARY_PUBKEY33[0] != 0 && (verified= komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid)) < 0 ) + if ( NOTARY_PUBKEY33[0] != 0 && (verified= komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid)) < 0 ) { - //if ( height > 50000 || ASSETCHAINS_SYMBOL[0] != 0 ) + if ( counter < 10 ) printf("[%s] error validating notarization ht.%d notarized_height.%d, if on a pruned %s node this can be ignored\n",ASSETCHAINS_SYMBOL,height,notarizedheight,dest); counter++; } From 6f1de9852a8ead9d15095ab0bc6d55646ab39aa9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 16:05:40 +0300 Subject: [PATCH 12/62] -prints --- src/rpcmisc.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 99a977bd8..c8b8a1aa6 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -98,7 +98,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) proxyType proxy; GetProxy(NET_IPV4, proxy); notarized_height = komodo_notarized_height(¬arized_hash,¬arized_desttxid); - fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL)); + //fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL)); UniValue obj(UniValue::VOBJ); obj.push_back(Pair("version", CLIENT_VERSION)); @@ -107,14 +107,14 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("notarized", notarized_height)); obj.push_back(Pair("notarizedhash", notarized_hash.ToString())); obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString())); - /*txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); + txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); if ( txid_height > 0 ) obj.push_back(Pair("notarizedtxid_height", txid_height)); - else obj.push_back(Pair("notarizedtxid_height", "mempool"));*/ + else obj.push_back(Pair("notarizedtxid_height", "mempool")); if ( ASSETCHAINS_SYMBOL[0] != 0 ) obj.push_back(Pair("KMDnotarized_height", kmdnotarized_height)); obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height + 1) : 0)); - fprintf(stderr,"after notarized_confirms %u\n",(uint32_t)time(NULL)); + //fprintf(stderr,"after notarized_confirms %u\n",(uint32_t)time(NULL)); #ifdef ENABLE_WALLET if (pwalletMain) { obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); @@ -123,11 +123,11 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("interest", ValueFromAmount(KOMODO_INTERESTSUM))); //komodo_interestsum() } #endif - fprintf(stderr,"after wallet %u\n",(uint32_t)time(NULL)); + //fprintf(stderr,"after wallet %u\n",(uint32_t)time(NULL)); obj.push_back(Pair("blocks", (int)chainActive.Height())); if ( (longestchain= KOMODO_LONGESTCHAIN) != 0 && chainActive.Height() > longestchain ) longestchain = chainActive.Height(); - fprintf(stderr,"after longestchain %u\n",(uint32_t)time(NULL)); + //fprintf(stderr,"after longestchain %u\n",(uint32_t)time(NULL)); obj.push_back(Pair("longestchain", longestchain)); obj.push_back(Pair("timeoffset", GetTimeOffset())); if ( chainActive.Tip() != 0 ) From 1407ad8be114e43c05e8a026a3953111eff91119 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 16:10:24 +0300 Subject: [PATCH 13/62] Test --- src/komodo_events.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index 123ab067b..9ef3a2816 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -41,15 +41,14 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig { static uint32_t counter; int32_t verified=0; char *coin; struct komodo_event_notarized N; coin = (ASSETCHAINS_SYMBOL[0] == 0) ? (char *)"KMD" : ASSETCHAINS_SYMBOL; - if ( NOTARY_PUBKEY33[0] != 0 && (verified= komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid)) < 0 ) + if ( (ASSETCHAINS_SYMBOL[0] == 0 && height > 800000) && NOTARY_PUBKEY33[0] != 0 && (verified= komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid)) < 0 ) { - if ( counter < 10 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && height > 800000 && counter++ < 10 ) printf("[%s] error validating notarization ht.%d notarized_height.%d, if on a pruned %s node this can be ignored\n",ASSETCHAINS_SYMBOL,height,notarizedheight,dest); - counter++; } else if ( strcmp(symbol,coin) == 0 ) { - if ( verified != 0 ) + if ( NOTARY_PUBKEY33[0] != 0 && verified != 0 ) fprintf(stderr,"validated [%s] ht.%d notarized %d\n",ASSETCHAINS_SYMBOL,height,notarizedheight); memset(&N,0,sizeof(N)); N.blockhash = notarized_hash; From 29da16c835dee55f398c238c9af19b72357888b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 16:26:42 +0300 Subject: [PATCH 14/62] +print --- src/komodo_events.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index 9ef3a2816..c7e17ed54 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -49,7 +49,7 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig else if ( strcmp(symbol,coin) == 0 ) { if ( NOTARY_PUBKEY33[0] != 0 && verified != 0 ) - fprintf(stderr,"validated [%s] ht.%d notarized %d\n",ASSETCHAINS_SYMBOL,height,notarizedheight); + fprintf(stderr,"validated [%s] ht.%d notarized %d\n",coin,height,notarizedheight); memset(&N,0,sizeof(N)); N.blockhash = notarized_hash; N.desttxid = notarized_desttxid; From 61f8caf2c34c836115d740df396a3d3fd4a68adb Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 18:16:08 +0300 Subject: [PATCH 15/62] +prints --- src/miner.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index d4a8e35c3..69a0be857 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -211,7 +211,10 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) : pblock->GetBlockTime(); if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight)) + { + fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); continue; + } if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 ) { //fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime); @@ -306,21 +309,28 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) // Size limits unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); if (nBlockSize + nTxSize >= nBlockMaxSize) + { + fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",nBlockSize,nTxSize,nBlockMaxSize); continue; + } // Legacy limits on sigOps: unsigned int nTxSigOps = GetLegacySigOpCount(tx); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) + { + fprintf(stderr,"nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",nBlockSigOps,nTxSigOps,MAX_BLOCK_SIGOPS); continue; - + } // Skip free transactions if we're past the minimum block size: const uint256& hash = tx.GetHash(); double dPriorityDelta = 0; CAmount nFeeDelta = 0; mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) + { + fprintf(stderr,"fee rate skip\n"); continue; - + } // Prioritise by fee once past the priority size or we run out of high-priority // transactions: if (!fSortedByFee && @@ -332,22 +342,28 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) } if (!view.HaveInputs(tx)) + { + fprintf(stderr,"dont have inputs\n"); continue; - + } CAmount nTxFees = view.GetValueIn(chainActive.Tip()->nHeight,&interest,tx,chainActive.Tip()->nTime)-tx.GetValueOut(); nTxSigOps += GetP2SHSigOpCount(tx, view); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) + { + fprintf(stderr,"nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",nBlockSigOps,nTxSigOps,MAX_BLOCK_SIGOPS); continue; - + } // Note that flags: we don't want to set mempool/IsStandard() // policy here, but we still have to ensure that the block we // create only contains transactions that are valid in new blocks. CValidationState state; PrecomputedTransactionData txdata(tx); if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) + { + fprintf(stderr,"context failure\n"); continue; - + } UpdateCoins(tx, view, nHeight); // Added From d1f503b5a62f628f81441297b84cda09cfa03eea Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 18:17:53 +0300 Subject: [PATCH 16/62] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 69a0be857..90f2f2b52 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -310,7 +310,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); if (nBlockSize + nTxSize >= nBlockMaxSize) { - fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",nBlockSize,nTxSize,nBlockMaxSize); + fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",nBlockSize,nTxSize,(int32_t)nBlockMaxSize); continue; } From 9876909ccd3c81ceead9a9345d98c3e87d63f896 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 18:19:25 +0300 Subject: [PATCH 17/62] Test --- src/miner.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 90f2f2b52..b7f163432 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -310,7 +310,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); if (nBlockSize + nTxSize >= nBlockMaxSize) { - fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",nBlockSize,nTxSize,(int32_t)nBlockMaxSize); + fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); continue; } @@ -318,7 +318,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) unsigned int nTxSigOps = GetLegacySigOpCount(tx); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) { - fprintf(stderr,"nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",nBlockSigOps,nTxSigOps,MAX_BLOCK_SIGOPS); + fprintf(stderr,"nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); continue; } // Skip free transactions if we're past the minimum block size: @@ -351,7 +351,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) nTxSigOps += GetP2SHSigOpCount(tx, view); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) { - fprintf(stderr,"nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",nBlockSigOps,nTxSigOps,MAX_BLOCK_SIGOPS); + fprintf(stderr,"nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); continue; } // Note that flags: we don't want to set mempool/IsStandard() From efee0b0e9d44768d8178ca182ea2ff5f5648568e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 18:50:55 +0300 Subject: [PATCH 18/62] Fix 700kb limit --- src/consensus/consensus.h | 2 +- src/komodo_globals.h | 1 + src/komodo_utils.h | 1 + src/miner.cpp | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/consensus/consensus.h b/src/consensus/consensus.h index d2e7dec3f..89e225267 100644 --- a/src/consensus/consensus.h +++ b/src/consensus/consensus.h @@ -17,7 +17,7 @@ static const int32_t OVERWINTER_MAX_TX_VERSION = 3; /** The maximum allowed size for a serialized block, in bytes (network rule) */ static const unsigned int MAX_BLOCK_SIZE = 2000000; /** The maximum allowed number of signature check operations in a block (network rule) */ -static const unsigned int MAX_BLOCK_SIGOPS = 20000; +unsigned int MAX_BLOCK_SIGOPS = 20000; /** The maximum size of a transaction (network rule) */ static const unsigned int MAX_TX_SIZE = 100000; /** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */ diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 8be3b741e..1b9b365a8 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -61,6 +61,7 @@ uint32_t KOMODO_INITDONE; char KMDUSERPASS[4096],BTCUSERPASS[4096]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; uint64_t PENDING_KOMODO_TX; extern int32_t KOMODO_LOADINGBLOCKS; +extern unsigned int MAX_BLOCK_SIGOPS; struct komodo_kv *KOMODO_KV; pthread_mutex_t KOMODO_KV_mutex,KOMODO_CC_mutex; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 24be6a0dc..915f0d5d9 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1534,6 +1534,7 @@ void komodo_args(char *argv0) } if ( name.c_str()[0] != 0 ) { + MAX_BLOCK_SIGOPS = 60000; ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); ASSETCHAINS_ENDSUBSIDY = GetArg("-ac_end",0); ASSETCHAINS_REWARD = GetArg("-ac_reward",0); diff --git a/src/miner.cpp b/src/miner.cpp index b7f163432..561cc3978 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -318,7 +318,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) unsigned int nTxSigOps = GetLegacySigOpCount(tx); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) { - fprintf(stderr,"nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); + fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); continue; } // Skip free transactions if we're past the minimum block size: @@ -351,7 +351,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) nTxSigOps += GetP2SHSigOpCount(tx, view); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) { - fprintf(stderr,"nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); + fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); continue; } // Note that flags: we don't want to set mempool/IsStandard() From 9d657620611222c74e81aa5568e1618d1dc94bca Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 18:52:27 +0300 Subject: [PATCH 19/62] Test --- src/consensus/consensus.h | 2 +- src/komodo_globals.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/consensus/consensus.h b/src/consensus/consensus.h index 89e225267..c2972e598 100644 --- a/src/consensus/consensus.h +++ b/src/consensus/consensus.h @@ -17,7 +17,7 @@ static const int32_t OVERWINTER_MAX_TX_VERSION = 3; /** The maximum allowed size for a serialized block, in bytes (network rule) */ static const unsigned int MAX_BLOCK_SIZE = 2000000; /** The maximum allowed number of signature check operations in a block (network rule) */ -unsigned int MAX_BLOCK_SIGOPS = 20000; +extern unsigned int MAX_BLOCK_SIGOPS; /** The maximum size of a transaction (network rule) */ static const unsigned int MAX_TX_SIZE = 100000; /** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */ diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 1b9b365a8..342d28fe8 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -61,7 +61,7 @@ uint32_t KOMODO_INITDONE; char KMDUSERPASS[4096],BTCUSERPASS[4096]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771; uint64_t PENDING_KOMODO_TX; extern int32_t KOMODO_LOADINGBLOCKS; -extern unsigned int MAX_BLOCK_SIGOPS; +unsigned int MAX_BLOCK_SIGOPS = 20000; struct komodo_kv *KOMODO_KV; pthread_mutex_t KOMODO_KV_mutex,KOMODO_CC_mutex; From 51376f3c5321f59c2d1adfc61db3f78e1ac43ac4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 19:06:27 +0300 Subject: [PATCH 20/62] ASSETCHAINS HF MAXSIGOPS -> 60000 --- src/miner.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 561cc3978..59d1b8a11 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -212,7 +212,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff) || IsExpiredTx(tx, nHeight)) { - fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); + //fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight)); continue; } if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 ) @@ -310,7 +310,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); if (nBlockSize + nTxSize >= nBlockMaxSize) { - fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); + //fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); continue; } @@ -318,7 +318,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) unsigned int nTxSigOps = GetLegacySigOpCount(tx); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) { - fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); + //fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); continue; } // Skip free transactions if we're past the minimum block size: @@ -328,7 +328,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) { - fprintf(stderr,"fee rate skip\n"); + //fprintf(stderr,"fee rate skip\n"); continue; } // Prioritise by fee once past the priority size or we run out of high-priority @@ -343,7 +343,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if (!view.HaveInputs(tx)) { - fprintf(stderr,"dont have inputs\n"); + //fprintf(stderr,"dont have inputs\n"); continue; } CAmount nTxFees = view.GetValueIn(chainActive.Tip()->nHeight,&interest,tx,chainActive.Tip()->nTime)-tx.GetValueOut(); @@ -351,7 +351,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) nTxSigOps += GetP2SHSigOpCount(tx, view); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) { - fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); + //fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); continue; } // Note that flags: we don't want to set mempool/IsStandard() @@ -361,7 +361,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) PrecomputedTransactionData txdata(tx); if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) { - fprintf(stderr,"context failure\n"); + //fprintf(stderr,"context failure\n"); continue; } UpdateCoins(tx, view, nHeight); From 16ec83024fbf268f04c97cd8cc44da9b52340b25 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 21:50:20 +0300 Subject: [PATCH 21/62] -print --- src/txmempool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index d9eb9debc..dd985f500 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -413,7 +413,7 @@ void CTxMemPool::removeExpired(unsigned int nBlockHeight) { const CTransaction& tx = it->GetTx(); tipindex = chainActive.Tip(); - if (IsExpiredTx(tx, nBlockHeight) || (tipindex != 0 && komodo_validate_interest(tx,tipindex->nHeight+1,tipindex->GetMedianTimePast() + 777,1)) < 0) + if (IsExpiredTx(tx, nBlockHeight) || (tipindex != 0 && komodo_validate_interest(tx,tipindex->nHeight+1,tipindex->GetMedianTimePast() + 777,0)) < 0) { transactionsToRemove.push_back(tx); } From 0c5985cbf09e0a962702fa16f3bfa8851369528a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 23:16:59 +0300 Subject: [PATCH 22/62] Test larger BLOCK_DOWNLOAD_WINDOW --- src/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.h b/src/main.h index ef46cd83d..956d8351e 100644 --- a/src/main.h +++ b/src/main.h @@ -94,7 +94,7 @@ static const unsigned int MAX_HEADERS_RESULTS = 160; * Larger windows tolerate larger download speed differences between peer, but increase the potential * degree of disordering of blocks on disk (which make reindexing and in the future perhaps pruning * harder). We'll probably want to make this a per-peer adaptive value at some point. */ -static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024; +static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024 * 2; /** Time to wait (in seconds) between writing blocks/block index to disk. */ static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60; /** Time to wait (in seconds) between flushing chainstate to disk. */ From b3e591ac5c85279462c8ef38c605dc7935c20855 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 23:54:24 +0300 Subject: [PATCH 23/62] Revert bigger window --- src/komodo_gateway.h | 4 +++- src/main.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index dc364c0c8..5819529c1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -707,9 +707,11 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim { if ( overflow != 0 || total > COIN/10 ) { - fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); if ( height >= activation ) + { + fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); return(-1); + } } else if ( block.nBits == KOMODO_MINDIFF_NBITS && total > 0 ) // to deal with fee stealing { diff --git a/src/main.h b/src/main.h index 956d8351e..ef46cd83d 100644 --- a/src/main.h +++ b/src/main.h @@ -94,7 +94,7 @@ static const unsigned int MAX_HEADERS_RESULTS = 160; * Larger windows tolerate larger download speed differences between peer, but increase the potential * degree of disordering of blocks on disk (which make reindexing and in the future perhaps pruning * harder). We'll probably want to make this a per-peer adaptive value at some point. */ -static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024 * 2; +static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024; /** Time to wait (in seconds) between writing blocks/block index to disk. */ static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60; /** Time to wait (in seconds) between flushing chainstate to disk. */ From 8f95f7e1381e00b6a7862ecfd5d2405a1e09d5aa Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 26 Apr 2018 11:11:55 +0300 Subject: [PATCH 24/62] Fix header special case for non-KMD --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 515833651..ab27a998f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3914,7 +3914,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta int nHeight = pindexPrev->nHeight+1; // Check proof of work - if ( (nHeight < 235300 || nHeight > 236000) && block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams)) + if ( (ASSETCHAINS_SYMBOL[0] != 0 || nHeight < 235300 || nHeight > 236000) && block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams)) { cout << block.nBits << " block.nBits vs. calc " << GetNextWorkRequired(pindexPrev, &block, consensusParams) << endl; return state.DoS(100, error("%s: incorrect proof of work", __func__), From 69d23911ced8e29749765cf971aa14cfb61863f5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 26 Apr 2018 15:14:12 +0300 Subject: [PATCH 25/62] +prevMoMheight to getinfo --- src/komodo_notary.h | 51 +++++++++++++++++++++++++++++++-------------- src/rpcmisc.cpp | 7 ++++--- 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 24e8500fd..55ec44e39 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -383,22 +383,6 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33, } //struct komodo_state *komodo_stateptr(char *symbol,char *dest); -int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp) -{ - char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) - { - *hashp = sp->NOTARIZED_HASH; - *txidp = sp->NOTARIZED_DESTTXID; - return(sp->NOTARIZED_HEIGHT); - } - else - { - memset(hashp,0,sizeof(*hashp)); - memset(txidp,0,sizeof(*txidp)); - return(0); - } -} struct notarized_checkpoint *komodo_npptr(int32_t height) { @@ -415,6 +399,40 @@ struct notarized_checkpoint *komodo_npptr(int32_t height) return(0); } +int32_t komodo_prevMoMheight() +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + for (i=sp->NUM_NPOINTS-1; i>=0; i--) + { + np = &sp->NPOINTS[i]; + if ( bits256_nonz(np->MoM) != 0 ) + return(np->notarized_height); + } + } + return(0); +} + +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + *hashp = sp->NOTARIZED_HASH; + *txidp = sp->NOTARIZED_DESTTXID; + *prevMoMheightp = komodo_prevMoMheight(); + return(sp->NOTARIZED_HEIGHT); + } + else + { + *prevhtp = 0; + memset(hashp,0,sizeof(*hashp)); + memset(txidp,0,sizeof(*txidp)); + return(0); + } +} + int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip) { struct notarized_checkpoint *np = 0; @@ -508,6 +526,7 @@ void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t not np = &sp->NPOINTS[sp->NUM_NPOINTS++]; memset(np,0,sizeof(*np)); np->nHeight = nHeight; + sp->PREVNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index c8b8a1aa6..079354a7b 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -46,7 +46,7 @@ int32_t Jumblr_depositaddradd(char *depositaddr); int32_t Jumblr_secretaddradd(char *secretaddr); uint64_t komodo_interestsum(); int32_t komodo_longestchain(); -int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp); +int32_t komodo_notarized_height(int32_t *prevhtp,uint256 *hashp,uint256 *txidp); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; @@ -61,7 +61,7 @@ extern uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,AS UniValue getinfo(const UniValue& params, bool fHelp) { - uint256 notarized_hash,notarized_desttxid; int32_t notarized_height,longestchain,kmdnotarized_height,txid_height; + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,kmdnotarized_height,txid_height; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -97,7 +97,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) proxyType proxy; GetProxy(NET_IPV4, proxy); - notarized_height = komodo_notarized_height(¬arized_hash,¬arized_desttxid); + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); //fprintf(stderr,"after notarized_height %u\n",(uint32_t)time(NULL)); UniValue obj(UniValue::VOBJ); @@ -105,6 +105,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("protocolversion", PROTOCOL_VERSION)); obj.push_back(Pair("KMDversion", KOMODO_VERSION)); obj.push_back(Pair("notarized", notarized_height)); + obj.push_back(Pair("prevMoMheight", prevMoMheight)); obj.push_back(Pair("notarizedhash", notarized_hash.ToString())); obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString())); txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); From a8de9f38883b2962f9d86b96c062806d4de86247 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 26 Apr 2018 15:19:07 +0300 Subject: [PATCH 26/62] Test --- src/komodo_notary.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 55ec44e39..3c81f5115 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -401,13 +401,14 @@ struct notarized_checkpoint *komodo_npptr(int32_t height) int32_t komodo_prevMoMheight() { + static uint256 zero; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) { for (i=sp->NUM_NPOINTS-1; i>=0; i--) { np = &sp->NPOINTS[i]; - if ( bits256_nonz(np->MoM) != 0 ) + if ( np->MoM != zero ) return(np->notarized_height); } } @@ -426,7 +427,7 @@ int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 * } else { - *prevhtp = 0; + *prevMoMheightp = 0; memset(hashp,0,sizeof(*hashp)); memset(txidp,0,sizeof(*txidp)); return(0); @@ -526,7 +527,6 @@ void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t not np = &sp->NPOINTS[sp->NUM_NPOINTS++]; memset(np,0,sizeof(*np)); np->nHeight = nHeight; - sp->PREVNOTARIZED_HEIGHT = sp->NOTARIZED_HEIGHT; sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; From c010c5335ccbdd37fc0a4fa174919b65602f2a15 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 26 Apr 2018 19:25:01 +0300 Subject: [PATCH 27/62] Support ac_cc --- src/komodo_port.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/komodo_port.c b/src/komodo_port.c index d866ea5c8..e92da3af1 100644 --- a/src/komodo_port.c +++ b/src/komodo_port.c @@ -791,9 +791,9 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr return(komodo_assetport(*magicp,extralen)); } -uint16_t komodo_calcport(char *name,uint64_t supply,uint64_t endsubsidy,uint64_t reward,uint64_t halving,uint64_t decay) +uint16_t komodo_calcport(char *name,uint64_t supply,uint64_t endsubsidy,uint64_t reward,uint64_t halving,uint64_t decay,uint64_t commission,uint8_t staked,int32_t cc) { - uint8_t extrabuf[4096],*extraptr=0; int32_t extralen=0; + uint8_t extrabuf[4096],*extraptr=0; int32_t extralen=0; uint64_t val; if ( halving != 0 && halving < 1440 ) { halving = 1440; @@ -809,26 +809,28 @@ uint16_t komodo_calcport(char *name,uint64_t supply,uint64_t endsubsidy,uint64_t decay = 0; printf("decay cant be more than 100000000\n"); } - if ( endsubsidy != 0 || reward != 0 || halving != 0 || decay != 0 || ASSETCHAINS_COMMISSION != 0 ) + if ( endsubsidy != 0 || reward != 0 || halving != 0 || decay != 0 || commission != 0 || cc != 0 || staked != 0 ) { - printf("end.%llu reward.%llu halving.%llu decay.%llu perc.%llu\n",(long long)endsubsidy,(long long)reward,(long long)halving,(long long)decay,(long long)ASSETCHAINS_COMMISSION); + //printf("end.%llu reward.%llu halving.%llu decay.%llu perc.%llu\n",(long long)endsubsidy,(long long)reward,(long long)halving,(long long)decay,(long long)commission); extraptr = extrabuf; memcpy(extraptr,ASSETCHAINS_OVERRIDE_PUBKEY33,33), extralen = 33; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(endsubsidy),(void *)&endsubsidy); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(reward),(void *)&reward); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(halving),(void *)&halving); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(decay),(void *)&decay); - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_COMMISSION),(void *)&ASSETCHAINS_COMMISSION); + val = commission | (((uint64_t)staked & 0xff) << 32) | (((uint64_t)cc & 0xffffff) << 40); + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); } return(komodo_port(name,supply,&ASSETCHAINS_MAGIC,extraptr,extralen)); } int main(int argc, char * argv[]) { - uint16_t rpcport; int32_t i,j,offset=0,num = 1; uint64_t supply=10,endsubsidy,reward,halving,decay; uint8_t *allocated=0; + uint16_t rpcport; int32_t i,j,offset=0,num = 1; uint64_t supply=10,commission=0,endsubsidy,reward,halving,decay; uint8_t *allocated=0,staked=0; uint32_t cc = 1; endsubsidy = reward = halving = decay = 0; if ( argc < 2 ) { + // staked, commission and cc hardcoded printf("%s name supply endsubsidy reward halving decay\n",argv[0]); printf("%s -gen num name supply endsubsidy reward halving decay\n",argv[0]); return(-1); @@ -849,8 +851,8 @@ int main(int argc, char * argv[]) halving = (long long)atof(argv[offset + 5]); if ( argc > offset + 6 ) decay = (long long)atof(argv[offset + 6]); - rpcport = 1 + komodo_calcport(argv[offset + 1],supply,endsubsidy,reward,halving,decay); - printf("./komodod -ac_name=%s -ac_supply=%llu -ac_end=%llu -ac_reward=%llu -ac_halving=%llu -ac_decay=%llu & # rpcport %u\n",argv[offset + 1],(long long)supply,(long long)endsubsidy,(long long)reward,(long long)halving,(long long)decay,rpcport); + rpcport = 1 + komodo_calcport(argv[offset + 1],supply,endsubsidy,reward,halving,decay,commission,staked,cc); + printf("./komodod -ac_name=%s -ac_cc=%u -ac_supply=%llu -ac_end=%llu -ac_reward=%llu -ac_halving=%llu -ac_decay=%llu & # rpcport %u\n",argv[offset + 1],cc,(long long)supply,(long long)endsubsidy,(long long)reward,(long long)halving,(long long)decay,rpcport); if ( allocated != 0 ) { char name[64],newname[64]; @@ -859,14 +861,14 @@ int main(int argc, char * argv[]) allocated[rpcport-1] = 1; for (i=0; i Date: Thu, 26 Apr 2018 21:59:09 +0300 Subject: [PATCH 28/62] Restore netinfo lock --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 079354a7b..0a413d52c 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -92,7 +92,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) //#ifdef ENABLE_WALLET // LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); //#else -// LOCK(cs_main); + LOCK(cs_main); //#endif proxyType proxy; From 32885e742213826e02d8d4791d7e6156e2942ffc Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 26 Apr 2018 23:09:53 +0300 Subject: [PATCH 29/62] Update getinfo cached for asset chains --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5819529c1..677fca916 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1340,6 +1340,7 @@ void komodo_passport_iteration() if ( komodo_chainactive_timestamp() > lastinterest ) { komodo_interestsum(); + komodo_paxtotal(); // calls komodo_isrealtime(), which calls komodo_longestchain() lastinterest = komodo_chainactive_timestamp(); } refsp = komodo_stateptr(symbol,dest); @@ -1468,7 +1469,7 @@ void komodo_passport_iteration() if ( sp != 0 && isrealtime == 0 ) refsp->RTbufs[0][2] = 0; } - komodo_paxtotal(); // calls komodo_isrealtime(), which calls komodo_longestchain() + //komodo_paxtotal(); // calls komodo_isrealtime(), which calls komodo_longestchain() refsp->RTmask |= RTmask; if ( expired == 0 && KOMODO_PASSPORT_INITDONE == 0 ) { From 4875678883ed1e26e5fa0c1fc9f55f30ac35f1ed Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 26 Apr 2018 23:21:22 +0300 Subject: [PATCH 30/62] Fix --- src/bitcoind.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 2ada533f1..43fc6f848 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -45,6 +45,8 @@ static bool fDaemon; #define KOMODO_ASSETCHAIN_MAXLEN 65 extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; void komodo_passport_iteration(); +uint64_t komodo_interestsum(); +uint64_t komodo_paxtotal(); void WaitForShutdown(boost::thread_group* threadGroup) { @@ -57,7 +59,13 @@ void WaitForShutdown(boost::thread_group* threadGroup) { komodo_passport_iteration(); MilliSleep(10000); - } else MilliSleep(10000); + } + else + { + komodo_interestsum(); + komodo_paxtotal(); // calls komodo_isrealtime(), which calls komodo_longestchain() + MilliSleep(10000); + } fShutdown = ShutdownRequested(); } if (threadGroup) From b32a9f1a5f0065e878892d9550c96c61fd2f65e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 26 Apr 2018 23:30:27 +0300 Subject: [PATCH 31/62] Directly call longestchain() --- src/bitcoind.cpp | 6 +++--- src/komodo_gateway.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 43fc6f848..5c12cfa2f 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -46,7 +46,7 @@ static bool fDaemon; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; void komodo_passport_iteration(); uint64_t komodo_interestsum(); -uint64_t komodo_paxtotal(); +int32_t komodo_longestchain(); void WaitForShutdown(boost::thread_group* threadGroup) { @@ -63,8 +63,8 @@ void WaitForShutdown(boost::thread_group* threadGroup) else { komodo_interestsum(); - komodo_paxtotal(); // calls komodo_isrealtime(), which calls komodo_longestchain() - MilliSleep(10000); + komodo_longestchain(); + MilliSleep(20000); } fShutdown = ShutdownRequested(); } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 677fca916..7eb5d9ab8 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1340,7 +1340,7 @@ void komodo_passport_iteration() if ( komodo_chainactive_timestamp() > lastinterest ) { komodo_interestsum(); - komodo_paxtotal(); // calls komodo_isrealtime(), which calls komodo_longestchain() + komodo_longestchain(); lastinterest = komodo_chainactive_timestamp(); } refsp = komodo_stateptr(symbol,dest); From 5725f8ea5df57206fcc0205a566504e2df90448b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 26 Apr 2018 23:43:05 +0300 Subject: [PATCH 32/62] Wallet utility needs unsigned int MAX_BLOCK_SIGOPS = 20000; --- src/wallet-utility.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet-utility.cpp b/src/wallet-utility.cpp index a0adc8684..42875d868 100644 --- a/src/wallet-utility.cpp +++ b/src/wallet-utility.cpp @@ -16,6 +16,7 @@ uint16_t BITCOIND_RPCPORT = 7771; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC; uint32_t ASSETCHAINS_MAGIC = 2387029918; +unsigned int MAX_BLOCK_SIGOPS = 20000; void show_help() { From b0fa5bad4d808abfc7f6239279ff0da0863a8f7f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 27 Apr 2018 13:16:37 +0300 Subject: [PATCH 33/62] calc_MoM --- src/komodo_ccdata.h | 21 ++++++++++++++++++++- src/rpcblockchain.cpp | 20 ++++++++++++++++++++ src/rpcserver.cpp | 1 + src/rpcserver.h | 1 + 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/komodo_ccdata.h b/src/komodo_ccdata.h index 32db78283..545c8b87a 100644 --- a/src/komodo_ccdata.h +++ b/src/komodo_ccdata.h @@ -42,6 +42,25 @@ bits256 iguana_merkle(bits256 *tree,int32_t txn_count) return(tree[n]); } +uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth) +{ + static uint256 zero; bits256 MoM,*tree; CBlockIndex *pindex; + tree = (bits256 *)calloc(MoMdepth,sizeof(*tree)); + for (i=0; ihashMerkleRoot,sizeof(bits256)); + else + { + free(tree); + return(zero); + } + } + MoM = iguana_merkle(tree,MoMdepth); + free(tree); + return(*(uint256 *)&MoM); +} + struct komodo_ccdata_entry *komodo_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t kmdstarti,int32_t kmdendi) { struct komodo_ccdata_entry *allMoMs=0; bits256 *tree,tmp; struct komodo_ccdata *ccdata,*tmpptr; int32_t i,num,max; @@ -73,7 +92,7 @@ struct komodo_ccdata_entry *komodo_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t for (i=0; i Date: Fri, 27 Apr 2018 13:17:48 +0300 Subject: [PATCH 34/62] syntax --- src/komodo_ccdata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_ccdata.h b/src/komodo_ccdata.h index 545c8b87a..675420c94 100644 --- a/src/komodo_ccdata.h +++ b/src/komodo_ccdata.h @@ -44,7 +44,7 @@ bits256 iguana_merkle(bits256 *tree,int32_t txn_count) uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth) { - static uint256 zero; bits256 MoM,*tree; CBlockIndex *pindex; + static uint256 zero; bits256 MoM,*tree; CBlockIndex *pindex; int32_t i; tree = (bits256 *)calloc(MoMdepth,sizeof(*tree)); for (i=0; i Date: Fri, 27 Apr 2018 13:19:33 +0300 Subject: [PATCH 35/62] -LOCK cs_main --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 0a413d52c..079354a7b 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -92,7 +92,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) //#ifdef ENABLE_WALLET // LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); //#else - LOCK(cs_main); +// LOCK(cs_main); //#endif proxyType proxy; From 593f9a707508289d73870a55dea6bda7b063dba7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 27 Apr 2018 13:29:25 +0300 Subject: [PATCH 36/62] iguana_merkle needs 3x men --- src/komodo_ccdata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_ccdata.h b/src/komodo_ccdata.h index 675420c94..70e601946 100644 --- a/src/komodo_ccdata.h +++ b/src/komodo_ccdata.h @@ -45,7 +45,7 @@ bits256 iguana_merkle(bits256 *tree,int32_t txn_count) uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth) { static uint256 zero; bits256 MoM,*tree; CBlockIndex *pindex; int32_t i; - tree = (bits256 *)calloc(MoMdepth,sizeof(*tree)); + tree = (bits256 *)calloc(MoMdepth * 3,sizeof(*tree)); for (i=0; i Date: Fri, 27 Apr 2018 15:18:28 +0300 Subject: [PATCH 37/62] Handle MoMdepth overflow --- src/komodo_ccdata.h | 2 ++ src/rpcblockchain.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_ccdata.h b/src/komodo_ccdata.h index 70e601946..058e38cee 100644 --- a/src/komodo_ccdata.h +++ b/src/komodo_ccdata.h @@ -45,6 +45,8 @@ bits256 iguana_merkle(bits256 *tree,int32_t txn_count) uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth) { static uint256 zero; bits256 MoM,*tree; CBlockIndex *pindex; int32_t i; + if ( MoMdepth >= height ) + return(zero); tree = (bits256 *)calloc(MoMdepth * 3,sizeof(*tree)); for (i=0; i= height ) throw runtime_error("calc_MoM illegal height or MoMdepth\n"); //fprintf(stderr,"height_MoM height.%d\n",height); MoM = komodo_calcMoM(height,MoMdepth); From 69a1f51513da4a3d6cfd9d590ca7ad6e43aac868 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 27 Apr 2018 17:46:57 +0300 Subject: [PATCH 38/62] genCOIN -> COIN_7776 --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 915f0d5d9..36766a1f7 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1476,7 +1476,7 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr printf("ports\n"); }*/ -char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7778\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":1,\\\"VALIDATE\\\":1,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; +char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp) @@ -1619,7 +1619,7 @@ void komodo_args(char *argv0) sprintf(&magicstr[i<<1],"%02x",magic[i]); magicstr[8] = 0; #ifndef FROM_CLI - sprintf(fname,"gen%s",ASSETCHAINS_SYMBOL); + sprintf(fname,"%s_7776",ASSETCHAINS_SYMBOL); if ( (fp= fopen(fname,"wb")) != 0 ) { fprintf(fp,iguanafmtstr,name.c_str(),name.c_str(),name.c_str(),name.c_str(),magicstr,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,"78.47.196.146"); From 7b4e9279fb5be8d47a15aab5853864cd33c020b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 27 Apr 2018 22:25:31 +0300 Subject: [PATCH 39/62] Test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 1b557d08b..6e5e582fa 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -680,7 +680,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr else { komodo_rwccdata(ASSETCHAINS_SYMBOL,1,&ccdata,&MoMoMdata); - //printf("[%s] matched.%d VALID (%s) MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth); + printf("[%s] matched.%d VALID (%s) MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth); } if ( MoMoMdata.pairs != 0 ) free(MoMoMdata.pairs); From 2f5cd4adf91be6ed6ca1a0d1a8d6e05fe1942500 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 27 Apr 2018 22:31:11 +0300 Subject: [PATCH 40/62] Test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 6e5e582fa..96259de23 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -672,7 +672,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else ccdata.len = MoMoMdata.len = 0; } } - if ( MoM == zero || MoMdepth > 1440 || MoMdepth < 0 ) + if ( MoM == zero || MoMdepth > *notarizedheightp || MoMdepth < 0 ) { memset(&MoM,0,sizeof(MoM)); MoMdepth = 0; From 9a496880aebfd8170158148b54907e321aedd1fd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 28 Apr 2018 12:09:15 +0300 Subject: [PATCH 41/62] Assume notarized if TEST* chain --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 96259de23..e46f35c84 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -615,7 +615,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr memset(&MoMoMdata,0,sizeof(MoMoMdata)); if ( matched == 0 && bitweight(signedmask) >= KOMODO_MINRATIFY ) notarized = 1; - if ( strcmp("PIZZA",ccdata.symbol) == 0 ) + if ( strcmp("PIZZA",ccdata.symbol) == 0 || strncmp("TEST",ccdata.symbol,4) == 0 ) notarized = 1; if ( 0 && opretlen != 149 ) printf("[%s].%d (%s) matched.%d i.%d j.%d notarized.%d %llx opretlen.%d len.%d offset.%d opoffset.%d\n",ASSETCHAINS_SYMBOL,height,ccdata.symbol,matched,i,j,notarized,(long long)signedmask,opretlen,len,offset,opoffset); From 0d88e6d57b70d7492425054e664292971e896f0f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 28 Apr 2018 14:26:22 +0300 Subject: [PATCH 42/62] SCALE* exemption --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index e46f35c84..74c6e2010 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -615,7 +615,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr memset(&MoMoMdata,0,sizeof(MoMoMdata)); if ( matched == 0 && bitweight(signedmask) >= KOMODO_MINRATIFY ) notarized = 1; - if ( strcmp("PIZZA",ccdata.symbol) == 0 || strncmp("TEST",ccdata.symbol,4) == 0 ) + if ( strcmp("PIZZA",ccdata.symbol) == 0 || strncmp("SCALE",ccdata.symbol,5) == 0 ) notarized = 1; if ( 0 && opretlen != 149 ) printf("[%s].%d (%s) matched.%d i.%d j.%d notarized.%d %llx opretlen.%d len.%d offset.%d opoffset.%d\n",ASSETCHAINS_SYMBOL,height,ccdata.symbol,matched,i,j,notarized,(long long)signedmask,opretlen,len,offset,opoffset); From 4add33cf7e98c0559cf1d5e75094e2ac16128db2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 29 Apr 2018 10:05:50 +0300 Subject: [PATCH 43/62] Restore LOCK cs_main in getinfo --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 079354a7b..0a413d52c 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -92,7 +92,7 @@ UniValue getinfo(const UniValue& params, bool fHelp) //#ifdef ENABLE_WALLET // LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); //#else -// LOCK(cs_main); + LOCK(cs_main); //#endif proxyType proxy; From 61a186ae07eb079e668f6eeefc8b31edff280d2d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 29 Apr 2018 12:28:12 +0300 Subject: [PATCH 44/62] Create copy of fiat into ac so we can deprecate usage of fiat/* --- src/ac/axo | 2 ++ src/ac/beer | 2 ++ src/ac/bet | 2 ++ src/ac/bntn | 2 ++ src/ac/bots | 2 ++ src/ac/btch | 2 ++ src/ac/ceal | 2 ++ src/ac/chain | 2 ++ src/ac/coqui | 2 ++ src/ac/crypto | 2 ++ src/ac/dex | 2 ++ src/ac/etomic | 2 ++ src/ac/hodl | 2 ++ src/ac/jumblr | 2 ++ src/ac/kv | 2 ++ src/ac/mesh | 2 ++ src/ac/mgw | 2 ++ src/ac/mnz | 2 ++ src/ac/mshark | 2 ++ src/ac/ninja | 2 ++ src/ac/oot | 2 ++ src/ac/pangea | 2 ++ src/ac/pizza | 2 ++ src/ac/prlpay | 2 ++ src/ac/revs | 2 ++ src/ac/supernet | 2 ++ src/ac/vote2018 | 2 ++ src/ac/wlc | 2 ++ 28 files changed, 56 insertions(+) create mode 100755 src/ac/axo create mode 100755 src/ac/beer create mode 100755 src/ac/bet create mode 100755 src/ac/bntn create mode 100755 src/ac/bots create mode 100755 src/ac/btch create mode 100755 src/ac/ceal create mode 100755 src/ac/chain create mode 100755 src/ac/coqui create mode 100755 src/ac/crypto create mode 100755 src/ac/dex create mode 100755 src/ac/etomic create mode 100755 src/ac/hodl create mode 100755 src/ac/jumblr create mode 100755 src/ac/kv create mode 100755 src/ac/mesh create mode 100755 src/ac/mgw create mode 100755 src/ac/mnz create mode 100755 src/ac/mshark create mode 100755 src/ac/ninja create mode 100755 src/ac/oot create mode 100755 src/ac/pangea create mode 100755 src/ac/pizza create mode 100755 src/ac/prlpay create mode 100755 src/ac/revs create mode 100755 src/ac/supernet create mode 100755 src/ac/vote2018 create mode 100755 src/ac/wlc diff --git a/src/ac/axo b/src/ac/axo new file mode 100755 index 000000000..18d38cac0 --- /dev/null +++ b/src/ac/axo @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=AXO $1 $2 $3 $4 $5 $6 diff --git a/src/ac/beer b/src/ac/beer new file mode 100755 index 000000000..34317bb93 --- /dev/null +++ b/src/ac/beer @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=BEER $1 $2 $3 $4 $5 $6 diff --git a/src/ac/bet b/src/ac/bet new file mode 100755 index 000000000..ed99ce59f --- /dev/null +++ b/src/ac/bet @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=BET $1 $2 $3 $4 $5 $6 diff --git a/src/ac/bntn b/src/ac/bntn new file mode 100755 index 000000000..7ae6f4e8d --- /dev/null +++ b/src/ac/bntn @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=BNTN $1 $2 $3 $4 $5 $6 diff --git a/src/ac/bots b/src/ac/bots new file mode 100755 index 000000000..15c0fc288 --- /dev/null +++ b/src/ac/bots @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=BOTS $1 $2 $3 $4 $5 $6 diff --git a/src/ac/btch b/src/ac/btch new file mode 100755 index 000000000..6a57ea8d1 --- /dev/null +++ b/src/ac/btch @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=BTCH $1 $2 $3 $4 $5 $6 diff --git a/src/ac/ceal b/src/ac/ceal new file mode 100755 index 000000000..0cbeba67b --- /dev/null +++ b/src/ac/ceal @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=CEAL $1 $2 $3 $4 $5 $6 diff --git a/src/ac/chain b/src/ac/chain new file mode 100755 index 000000000..c55d30fbd --- /dev/null +++ b/src/ac/chain @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=CHAIN $1 $2 $3 $4 $5 $6 diff --git a/src/ac/coqui b/src/ac/coqui new file mode 100755 index 000000000..d4fcb63d5 --- /dev/null +++ b/src/ac/coqui @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=COQUI $1 $2 $3 $4 $5 $6 diff --git a/src/ac/crypto b/src/ac/crypto new file mode 100755 index 000000000..5a3d46188 --- /dev/null +++ b/src/ac/crypto @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=CRYPTO $1 $2 $3 $4 $5 $6 diff --git a/src/ac/dex b/src/ac/dex new file mode 100755 index 000000000..67331201a --- /dev/null +++ b/src/ac/dex @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=DEX $1 $2 $3 $4 $5 $6 diff --git a/src/ac/etomic b/src/ac/etomic new file mode 100755 index 000000000..76eb0191c --- /dev/null +++ b/src/ac/etomic @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=ETOMIC $1 $2 $3 $4 $5 $6 diff --git a/src/ac/hodl b/src/ac/hodl new file mode 100755 index 000000000..a5430db59 --- /dev/null +++ b/src/ac/hodl @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=HODL $1 $2 $3 $4 $5 $6 diff --git a/src/ac/jumblr b/src/ac/jumblr new file mode 100755 index 000000000..2969c5009 --- /dev/null +++ b/src/ac/jumblr @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=JUMBLR $1 $2 $3 $4 $5 $6 diff --git a/src/ac/kv b/src/ac/kv new file mode 100755 index 000000000..997fccb33 --- /dev/null +++ b/src/ac/kv @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=KV $1 $2 $3 $4 $5 $6 diff --git a/src/ac/mesh b/src/ac/mesh new file mode 100755 index 000000000..19b359509 --- /dev/null +++ b/src/ac/mesh @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=MESH $1 $2 $3 $4 $5 $6 diff --git a/src/ac/mgw b/src/ac/mgw new file mode 100755 index 000000000..9afa86b7a --- /dev/null +++ b/src/ac/mgw @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=MGW $1 $2 $3 $4 $5 $6 diff --git a/src/ac/mnz b/src/ac/mnz new file mode 100755 index 000000000..f4e1f3501 --- /dev/null +++ b/src/ac/mnz @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=MNZ $1 $2 $3 $4 $5 $6 diff --git a/src/ac/mshark b/src/ac/mshark new file mode 100755 index 000000000..1f0c950c6 --- /dev/null +++ b/src/ac/mshark @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=MSHARK $1 $2 $3 $4 $5 $6 diff --git a/src/ac/ninja b/src/ac/ninja new file mode 100755 index 000000000..f7722abb0 --- /dev/null +++ b/src/ac/ninja @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=NINJA $1 $2 $3 $4 $5 $6 diff --git a/src/ac/oot b/src/ac/oot new file mode 100755 index 000000000..4c7c6b683 --- /dev/null +++ b/src/ac/oot @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=OOT $1 $2 $3 $4 $5 $6 diff --git a/src/ac/pangea b/src/ac/pangea new file mode 100755 index 000000000..9920189ea --- /dev/null +++ b/src/ac/pangea @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=PANGEA $1 $2 $3 $4 $5 $6 diff --git a/src/ac/pizza b/src/ac/pizza new file mode 100755 index 000000000..d8400d9d3 --- /dev/null +++ b/src/ac/pizza @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=PIZZA $1 $2 $3 $4 $5 $6 diff --git a/src/ac/prlpay b/src/ac/prlpay new file mode 100755 index 000000000..3d1063d13 --- /dev/null +++ b/src/ac/prlpay @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=PRLPAY $1 $2 $3 $4 $5 $6 diff --git a/src/ac/revs b/src/ac/revs new file mode 100755 index 000000000..b898eb5dc --- /dev/null +++ b/src/ac/revs @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=REVS $1 $2 $3 $4 $5 $6 diff --git a/src/ac/supernet b/src/ac/supernet new file mode 100755 index 000000000..d841ffa0e --- /dev/null +++ b/src/ac/supernet @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=SUPERNET $1 $2 $3 $4 $5 $6 diff --git a/src/ac/vote2018 b/src/ac/vote2018 new file mode 100755 index 000000000..4e385d76f --- /dev/null +++ b/src/ac/vote2018 @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=VOTE2018 $1 $2 $3 $4 $5 $6 diff --git a/src/ac/wlc b/src/ac/wlc new file mode 100755 index 000000000..ef7c47b90 --- /dev/null +++ b/src/ac/wlc @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=WLC $1 $2 $3 $4 $5 $6 From 6494f040c52173fe6e05382437bd4e43750594af Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 29 Apr 2018 14:59:20 +0300 Subject: [PATCH 45/62] Redundant calls to dpow KMD --- src/dpowassets | 6 ++++-- src/komodo_notary.h | 12 ++++++------ src/miner.cpp | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/dpowassets b/src/dpowassets index 14bb39912..f00ade7f6 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -2,9 +2,10 @@ set -x source pubkey.txt echo $pubkey +sleep 3 +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KMD\",\"pubkey\":\"$pubkey\"}" - -curl --url "http://127.0.0.1:7776" --data "{\"timeout\":60000,\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"REVS\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"REVS\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SUPERNET\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DEX\",\"pubkey\":\"$pubkey\"}" @@ -32,4 +33,5 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"OOT\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BNTN\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PRLPAY\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KMD\",\"pubkey\":\"$pubkey\"}" diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 3c81f5115..25a03f83b 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -142,7 +142,7 @@ const char *Notaries_elected1[][2] = {"artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" }, {"artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" }, {"badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" }, - {"badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, + {"badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" }, // 10 {"batman_AR", "033ecb640ec5852f42be24c3bf33ca123fb32ced134bed6aa2ba249cf31b0f2563" }, {"batman_SH", "02ca5898931181d0b8aafc75ef56fce9c43656c0b6c9f64306e7c8542f6207018c" }, {"ca333_EU", "03fc87b8c804f12a6bd18efd43b0ba2828e4e38834f6b44c0bfee19f966a12ba99" }, @@ -152,7 +152,7 @@ const char *Notaries_elected1[][2] = {"cipi_AR", "02c4f89a5b382750836cb787880d30e23502265054e1c327a5bfce67116d757ce8" }, {"cipi_NA", "02858904a2a1a0b44df4c937b65ee1f5b66186ab87a751858cf270dee1d5031f18" }, {"crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, - {"crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, + {"crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" }, // 20 {"dwy_EU", "0259c646288580221fdf0e92dbeecaee214504fdc8bbdf4a3019d6ec18b7540424" }, {"emmanux_SH", "033f316114d950497fc1d9348f03770cd420f14f662ab2db6172df44c389a2667a" }, {"etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, @@ -162,7 +162,7 @@ const char *Notaries_elected1[][2] = {"goldenman_EU", "02d6f13a8f745921cdb811e32237bb98950af1a5952be7b3d429abd9152f8e388d" }, {"indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, {"indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, - {"indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, + {"indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, // 30 {"indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, {"jackson_AR", "038ff7cfe34cb13b524e0941d5cf710beca2ffb7e05ddf15ced7d4f14fbb0a6f69" }, {"jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" }, @@ -172,7 +172,7 @@ const char *Notaries_elected1[][2] = {"komodopioneers_SH", "033ace50aedf8df70035b962a805431363a61cc4e69d99d90726a2d48fb195f68c" }, {"libscott_SH", "03301a8248d41bc5dc926088a8cf31b65e2daf49eed7eb26af4fb03aae19682b95" }, {"lukechilds_AR", "031aa66313ee024bbee8c17915cf7d105656d0ace5b4a43a3ab5eae1e14ec02696" }, - {"madmax_AR", "03891555b4a4393d655bf76f0ad0fb74e5159a615b6925907678edc2aac5e06a75" }, + {"madmax_AR", "03891555b4a4393d655bf76f0ad0fb74e5159a615b6925907678edc2aac5e06a75" }, // 40 {"meshbits_AR", "02957fd48ae6cb361b8a28cdb1b8ccf5067ff68eb1f90cba7df5f7934ed8eb4b2c" }, {"meshbits_SH", "025c6e94877515dfd7b05682b9cc2fe4a49e076efe291e54fcec3add78183c1edb" }, {"metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, @@ -182,7 +182,7 @@ const char *Notaries_elected1[][2] = {"peer2cloud_AR", "034e5563cb885999ae1530bd66fab728e580016629e8377579493b386bf6cebb15" }, {"peer2cloud_SH", "03396ac453b3f23e20f30d4793c5b8ab6ded6993242df4f09fd91eb9a4f8aede84" }, {"polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" }, - {"hyper_AR", "020f2f984d522051bd5247b61b080b4374a7ab389d959408313e8062acad3266b4" }, + {"hyper_AR", "020f2f984d522051bd5247b61b080b4374a7ab389d959408313e8062acad3266b4" }, // 50 {"hyper_EU", "03d00cf9ceace209c59fb013e112a786ad583d7de5ca45b1e0df3b4023bb14bf51" }, {"hyper_SH", "0383d0b37f59f4ee5e3e98a47e461c861d49d0d90c80e9e16f7e63686a2dc071f3" }, {"hyper_NA", "03d91c43230336c0d4b769c9c940145a8c53168bf62e34d1bccd7f6cfc7e5592de" }, @@ -192,7 +192,7 @@ const char *Notaries_elected1[][2] = {"alien_EU", "020aab8308d4df375a846a9e3b1c7e99597b90497efa021d50bcf1bbba23246527" }, {"thegaltmines_NA", "031bea28bec98b6380958a493a703ddc3353d7b05eb452109a773eefd15a32e421" }, {"titomane_AR", "029d19215440d8cb9cc6c6b7a4744ae7fb9fb18d986e371b06aeb34b64845f9325" }, - {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, + {"titomane_EU", "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" }, // 60 {"titomane_SH", "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" }, {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, diff --git a/src/miner.cpp b/src/miner.cpp index 59d1b8a11..aece99e38 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -845,8 +845,8 @@ void static BitcoinMiner() for (i=1; i<66; i++) if ( memcmp(pubkeys[i],pubkeys[0],33) == 0 ) break; - if ( externalflag == 0 && i != 66 ) - printf("VIOLATION at %d\n",i); + if ( externalflag == 0 && i != 66 && mids[i] >= 0 ) + printf("VIOLATION at %d, notaryid.%d\n",i,mids[i]); for (j=gpucount=0; j<65; j++) { if ( mids[j] >= 0 || notaryid == 34 ) From e4a383e340e1bf1ef0dc8e57d5a4c5b49f1f8d9e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 30 Apr 2018 00:36:12 +0300 Subject: [PATCH 46/62] Add notary 3 to recent miners print --- src/miner.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index aece99e38..71537bce9 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -840,7 +840,7 @@ void static BitcoinMiner() if ( i == 33 ) externalflag = 1; else externalflag = 0; - if ( NOTARY_PUBKEY33[0] != 0 && (notaryid < 3 || notaryid == 34 || notaryid == 51 || notaryid == 52) ) + if ( NOTARY_PUBKEY33[0] != 0 ) { for (i=1; i<66; i++) if ( memcmp(pubkeys[i],pubkeys[0],33) == 0 ) @@ -849,9 +849,12 @@ void static BitcoinMiner() printf("VIOLATION at %d, notaryid.%d\n",i,mids[i]); for (j=gpucount=0; j<65; j++) { - if ( mids[j] >= 0 || notaryid == 34 ) - fprintf(stderr,"%d ",mids[j]); - else fprintf(stderr,"GPU "); + if ( notaryid <= 3 || notaryid == 34 || notaryid == 51 || notaryid == 52 ) + { + if ( mids[j] >= 0 ) + fprintf(stderr,"%d ",mids[j]); + else fprintf(stderr,"GPU "); + } if ( mids[j] == -1 ) gpucount++; } From 2c7ba74d0eeb8a26547ce5ab1fd767505bc2a0f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 30 Apr 2018 00:38:30 +0300 Subject: [PATCH 47/62] Fix --- src/miner.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 71537bce9..dace45ee4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -868,7 +868,8 @@ void static BitcoinMiner() roundrobin_delay += ((delta * i) / 64) - delta; //fprintf(stderr,"delta.%f %f %f\n",delta,(double)(gpucount - j/3) / 2,(delta * i) / 64); } - fprintf(stderr," <- prev minerids from ht.%d notary.%d gpucount.%d %.2f%% t.%u %d\n",pindexPrev->nHeight,notaryid,gpucount,100.*(double)gpucount/j,(uint32_t)time(NULL),roundrobin_delay); + if ( notaryid <= 3 || notaryid == 34 || notaryid == 51 || notaryid == 52 ) + fprintf(stderr," <- prev minerids from ht.%d notary.%d gpucount.%d %.2f%% t.%u %d\n",pindexPrev->nHeight,notaryid,gpucount,100.*(double)gpucount/j,(uint32_t)time(NULL),roundrobin_delay); } for (j=0; j<65; j++) if ( mids[j] == notaryid ) From 4fff8a632e7c4b80c7609fd2ea07fb106f579383 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 30 Apr 2018 00:44:45 +0300 Subject: [PATCH 48/62] Add 56 and 57 for miners display --- src/miner.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index dace45ee4..b57144dbc 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -831,6 +831,9 @@ void static BitcoinMiner() j = 65; if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 ) { + int32_t dispflag = 0; + if ( notaryid <= 3 || notaryid == 34 || notaryid == 51 || notaryid == 52 || notaryid == 56 || notaryid == 57 ) + dispflag = 1; komodo_eligiblenotary(pubkeys,mids,blocktimes,&nonzpkeys,pindexPrev->nHeight); if ( nonzpkeys > 0 ) { @@ -849,7 +852,7 @@ void static BitcoinMiner() printf("VIOLATION at %d, notaryid.%d\n",i,mids[i]); for (j=gpucount=0; j<65; j++) { - if ( notaryid <= 3 || notaryid == 34 || notaryid == 51 || notaryid == 52 ) + if ( dispflag != 0 ) { if ( mids[j] >= 0 ) fprintf(stderr,"%d ",mids[j]); @@ -868,7 +871,7 @@ void static BitcoinMiner() roundrobin_delay += ((delta * i) / 64) - delta; //fprintf(stderr,"delta.%f %f %f\n",delta,(double)(gpucount - j/3) / 2,(delta * i) / 64); } - if ( notaryid <= 3 || notaryid == 34 || notaryid == 51 || notaryid == 52 ) + if ( dispflag != 0 ) fprintf(stderr," <- prev minerids from ht.%d notary.%d gpucount.%d %.2f%% t.%u %d\n",pindexPrev->nHeight,notaryid,gpucount,100.*(double)gpucount/j,(uint32_t)time(NULL),roundrobin_delay); } for (j=0; j<65; j++) From 8f2def7895ff75504a7c2b2800c21c5d3eb7979f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 30 Apr 2018 11:49:03 +0300 Subject: [PATCH 49/62] Update display notary --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index b57144dbc..445ea2dad 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -832,7 +832,7 @@ void static BitcoinMiner() if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 ) { int32_t dispflag = 0; - if ( notaryid <= 3 || notaryid == 34 || notaryid == 51 || notaryid == 52 || notaryid == 56 || notaryid == 57 ) + if ( notaryid <= 3 || notaryid == 32 || (notaryid >= 43 && notaryid <= 45) &¬aryid == 51 || notaryid == 52 || notaryid == 56 || notaryid == 57 ) dispflag = 1; komodo_eligiblenotary(pubkeys,mids,blocktimes,&nonzpkeys,pindexPrev->nHeight); if ( nonzpkeys > 0 ) From 8fc79ac9fb8808bbd3b88d70979a351983006733 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 1 May 2018 13:18:19 +0300 Subject: [PATCH 50/62] Reduce miner created latency --- src/komodo.h | 3 ++- src/miner.cpp | 44 +++++++++++++++++++++++--------------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 74c6e2010..5b2872946 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -680,7 +680,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr else { komodo_rwccdata(ASSETCHAINS_SYMBOL,1,&ccdata,&MoMoMdata); - printf("[%s] matched.%d VALID (%s) MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth); + if ( matched != 0 ) + printf("[%s] matched.%d VALID (%s) MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth); } if ( MoMoMdata.pairs != 0 ) free(MoMoMdata.pairs); diff --git a/src/miner.cpp b/src/miner.cpp index 445ea2dad..8400e2a17 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -476,23 +476,25 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) UpdateTime(pblock, Params().GetConsensus(), pindexPrev); pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); } + pblock->nSolution.clear(); + pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 && pblock->nTime < pindexPrev->nTime+60 ) { pblock->nTime = pindexPrev->nTime + 60; - while ( pblock->GetBlockTime() > GetAdjustedTime() + 10 ) - sleep(1); + //while ( pblock->GetBlockTime() > GetAdjustedTime() + 10 ) + // sleep(1); //fprintf(stderr,"block.nTime %u vs prev.%u, gettime.%u vs adjusted.%u\n",(uint32_t)pblock->nTime,(uint32_t)(pindexPrev->nTime + 60),(uint32_t)pblock->GetBlockTime(),(uint32_t)(GetAdjustedTime() + 60)); } - pblock->nSolution.clear(); - pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); - - CValidationState state; - if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) + else { - //static uint32_t counter; - //if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 ) - // fprintf(stderr,"warning: miner testblockvalidity failed\n"); - return(0); + CValidationState state; + if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) + { + //static uint32_t counter; + //if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 ) + // fprintf(stderr,"warning: miner testblockvalidity failed\n"); + return(0); + } } } @@ -788,7 +790,7 @@ void static BitcoinMiner() static uint32_t counter; if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 ) fprintf(stderr,"created illegal block, retry\n"); - sleep(3); + sleep(1); continue; } unique_ptr pblocktemplate(ptr); @@ -953,15 +955,6 @@ void static BitcoinMiner() for (z=31; z>=16; z--) fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); fprintf(stderr," POW\n");*/ - CValidationState state; - if ( !TestBlockValidity(state,B, chainActive.Tip(), true, false)) - { - h = UintToArith256(B.GetHash()); - for (z=31; z>=0; z--) - fprintf(stderr,"%02x",((uint8_t *)&h)[z]); - fprintf(stderr," Invalid block mined, try again\n"); - return(false); - } if ( ASSETCHAINS_STAKED == 0 ) { if ( Mining_start != 0 && time(NULL) < Mining_start+roundrobin_delay ) @@ -993,6 +986,15 @@ void static BitcoinMiner() fprintf(stderr," mined block!\n"); } } + CValidationState state; + if ( !TestBlockValidity(state,B, chainActive.Tip(), true, false)) + { + h = UintToArith256(B.GetHash()); + for (z=31; z>=0; z--) + fprintf(stderr,"%02x",((uint8_t *)&h)[z]); + fprintf(stderr," Invalid block mined, try again\n"); + return(false); + } KOMODO_CHOSEN_ONE = 1; // Found a solution SetThreadPriority(THREAD_PRIORITY_NORMAL); From 82f1287731de001fc7807444291c81a2188e35c8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 1 May 2018 13:53:11 +0300 Subject: [PATCH 51/62] -prints --- src/komodo_events.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index c7e17ed54..53e72ae95 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -41,9 +41,9 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig { static uint32_t counter; int32_t verified=0; char *coin; struct komodo_event_notarized N; coin = (ASSETCHAINS_SYMBOL[0] == 0) ? (char *)"KMD" : ASSETCHAINS_SYMBOL; - if ( (ASSETCHAINS_SYMBOL[0] == 0 && height > 800000) && NOTARY_PUBKEY33[0] != 0 && (verified= komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid)) < 0 ) + if ( (ASSETCHAINS_SYMBOL[0] == 0 && height > 814000) && NOTARY_PUBKEY33[0] != 0 && (verified= komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid)) < 0 ) { - if ( ASSETCHAINS_SYMBOL[0] == 0 && height > 800000 && counter++ < 10 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && height > 814000 && counter++ < 10 ) printf("[%s] error validating notarization ht.%d notarized_height.%d, if on a pruned %s node this can be ignored\n",ASSETCHAINS_SYMBOL,height,notarizedheight,dest); } else if ( strcmp(symbol,coin) == 0 ) From 4f61808ffcfe1f2b3e248c30105fe2a48e0205d1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 1 May 2018 16:25:54 +0300 Subject: [PATCH 52/62] -print --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index ab27a998f..511a7413c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3766,7 +3766,7 @@ bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex, if (blockhdr.GetBlockTime() > GetAdjustedTime() + 60) { CBlockIndex *tipindex; - fprintf(stderr,"ht.%d future block %u vs time.%u + 60\n",height,(uint32_t)blockhdr.GetBlockTime(),(uint32_t)GetAdjustedTime()); + //fprintf(stderr,"ht.%d future block %u vs time.%u + 60\n",height,(uint32_t)blockhdr.GetBlockTime(),(uint32_t)GetAdjustedTime()); if ( (tipindex= chainActive.Tip()) != 0 && tipindex->GetBlockHash() == blockhdr.hashPrevBlock && blockhdr.GetBlockTime() < GetAdjustedTime() + 60 + 5 ) { //fprintf(stderr,"it is the next block, let's wait for %d seconds\n",GetAdjustedTime() + 60 - blockhdr.GetBlockTime()); From eb1ba5a0fe930b05292f0164f53519db05fcbe8b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 07:18:05 +0300 Subject: [PATCH 53/62] improve miner to reduce out of order timestamps --- src/dpowassets | 3 --- src/miner.cpp | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/dpowassets b/src/dpowassets index f00ade7f6..a144eab28 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -3,7 +3,6 @@ set -x source pubkey.txt echo $pubkey sleep 3 -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KMD\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"REVS\",\"pubkey\":\"$pubkey\"}" @@ -33,5 +32,3 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"OOT\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BNTN\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PRLPAY\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KMD\",\"pubkey\":\"$pubkey\"}" - diff --git a/src/miner.cpp b/src/miner.cpp index 8400e2a17..c46ade13d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -418,7 +418,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked)); nFees += txfees; pblock->nTime = blocktime; - if ( GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) + if ( 0 && GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) { fprintf(stderr,"need to wait %d seconds to mine:\n",(int32_t)(pblock->nTime - GetAdjustedTime())); while ( GetAdjustedTime()+30 < pblock->nTime ) @@ -834,7 +834,7 @@ void static BitcoinMiner() if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 ) { int32_t dispflag = 0; - if ( notaryid <= 3 || notaryid == 32 || (notaryid >= 43 && notaryid <= 45) &¬aryid == 51 || notaryid == 52 || notaryid == 56 || notaryid == 57 ) + if ( notaryid <= 3 || notaryid == 32 || (notaryid >= 43 && notaryid <= 45) ||notaryid == 51 || notaryid == 52 || notaryid == 56 || notaryid == 57 || notaryid == 62 ) dispflag = 1; komodo_eligiblenotary(pubkeys,mids,blocktimes,&nonzpkeys,pindexPrev->nHeight); if ( nonzpkeys > 0 ) @@ -955,9 +955,19 @@ void static BitcoinMiner() for (z=31; z>=16; z--) fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); fprintf(stderr," POW\n");*/ + if ( B.nTime > GetAdjustedTime() ) + { + printf("need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetAdjustedTime())); + while ( GetAdjustedTime() < B.nTime ) + sleep(1); + } if ( ASSETCHAINS_STAKED == 0 ) { - if ( Mining_start != 0 && time(NULL) < Mining_start+roundrobin_delay ) + if ( NOTARY_PUBKEY33[0] != 0 ) + { + MilliSleep((rand() % 2700) + 1000); + } + /*if ( Mining_start != 0 && time(NULL) < Mining_start+roundrobin_delay ) { //printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+roundrobin_delay-time(NULL))); //int32_t nseconds = Mining_start+roundrobin_delay-time(NULL); @@ -968,13 +978,12 @@ void static BitcoinMiner() else if ( ASSETCHAINS_SYMBOL[0] != 0 ) { sleep(rand() % 30); - } + }*/ } else { if ( NOTARY_PUBKEY33[0] != 0 ) { - printf("need to wait %d seconds to submit staked block\n",(int32_t)(B.nTime - GetAdjustedTime())); while ( GetAdjustedTime() < B.nTime ) sleep(1); } From 97e9d76edcaf99a53897b0208fa0df9c3964d848 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 07:19:10 +0300 Subject: [PATCH 54/62] Test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index c46ade13d..e46756fa9 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -418,7 +418,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked)); nFees += txfees; pblock->nTime = blocktime; - if ( 0 && GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) + if ( GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) { fprintf(stderr,"need to wait %d seconds to mine:\n",(int32_t)(pblock->nTime - GetAdjustedTime())); while ( GetAdjustedTime()+30 < pblock->nTime ) @@ -957,7 +957,7 @@ void static BitcoinMiner() fprintf(stderr," POW\n");*/ if ( B.nTime > GetAdjustedTime() ) { - printf("need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetAdjustedTime())); + fprintf(stderr,"need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetAdjustedTime())); while ( GetAdjustedTime() < B.nTime ) sleep(1); } From 6181f7d5bb090278859d7bc8c12f719828c20cc2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 07:22:41 +0300 Subject: [PATCH 55/62] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index e46756fa9..dfb12565d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -955,7 +955,7 @@ void static BitcoinMiner() for (z=31; z>=16; z--) fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]); fprintf(stderr," POW\n");*/ - if ( B.nTime > GetAdjustedTime() ) + if ( NOTARY_PUBKEY33[0] != 0 && B.nTime > GetAdjustedTime() ) { fprintf(stderr,"need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetAdjustedTime())); while ( GetAdjustedTime() < B.nTime ) From 4cc387ec2c414606e723915990c4591413f50425 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 08:44:03 +0300 Subject: [PATCH 56/62] Detect new block during wait --- src/miner.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/miner.cpp b/src/miner.cpp index dfb12565d..2f7c3b1c9 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -959,7 +959,14 @@ void static BitcoinMiner() { fprintf(stderr,"need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetAdjustedTime())); while ( GetAdjustedTime() < B.nTime ) + { sleep(1); + if ( chainActive.Tip()->nHeight >= Mining_height ) + { + fprintf(stderr,"new block arrived\n"); + return(false); + } + } } if ( ASSETCHAINS_STAKED == 0 ) { From 9bf6c59e33245d27895a04b6160a3b8e000d478b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 09:05:00 +0300 Subject: [PATCH 57/62] PoS mining latency fix --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 2f7c3b1c9..99e1dac83 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -421,7 +421,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) { fprintf(stderr,"need to wait %d seconds to mine:\n",(int32_t)(pblock->nTime - GetAdjustedTime())); - while ( GetAdjustedTime()+30 < pblock->nTime ) + while ( 0 && GetAdjustedTime()+30 < pblock->nTime ) { sleep(30); fprintf(stderr,"%d ",(int32_t)(pblock->nTime - GetAdjustedTime())); From b92a8cd4bf62c46466b4508bafde3b675b881c93 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 09:34:51 +0300 Subject: [PATCH 58/62] Block PoS miner, need to cache first timestamp --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 99e1dac83..2f7c3b1c9 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -421,7 +421,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( GetAdjustedTime() < pblock->nTime )//|| pblock->GetBlockTime() > GetAdjustedTime() + 60) { fprintf(stderr,"need to wait %d seconds to mine:\n",(int32_t)(pblock->nTime - GetAdjustedTime())); - while ( 0 && GetAdjustedTime()+30 < pblock->nTime ) + while ( GetAdjustedTime()+30 < pblock->nTime ) { sleep(30); fprintf(stderr,"%d ",(int32_t)(pblock->nTime - GetAdjustedTime())); From e7018d1da8dcc3e2b1a0240b0503d6899e283b84 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 13:13:47 +0300 Subject: [PATCH 59/62] Exemption for TXSCL* --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 5b2872946..ec1bc8013 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -615,7 +615,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr memset(&MoMoMdata,0,sizeof(MoMoMdata)); if ( matched == 0 && bitweight(signedmask) >= KOMODO_MINRATIFY ) notarized = 1; - if ( strcmp("PIZZA",ccdata.symbol) == 0 || strncmp("SCALE",ccdata.symbol,5) == 0 ) + if ( strcmp("PIZZA",ccdata.symbol) == 0 || strncmp("TXSCL",ccdata.symbol,5) == 0 ) notarized = 1; if ( 0 && opretlen != 149 ) printf("[%s].%d (%s) matched.%d i.%d j.%d notarized.%d %llx opretlen.%d len.%d offset.%d opoffset.%d\n",ASSETCHAINS_SYMBOL,height,ccdata.symbol,matched,i,j,notarized,(long long)signedmask,opretlen,len,offset,opoffset); From 98ec2dc219b153e0365a5d1b911ec8b97b510cd1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 14:20:34 +0300 Subject: [PATCH 60/62] Add 1 second to timestamp to reduce diff growth --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 2f7c3b1c9..ac1116b4e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -480,7 +480,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 && pblock->nTime < pindexPrev->nTime+60 ) { - pblock->nTime = pindexPrev->nTime + 60; + pblock->nTime = pindexPrev->nTime + 61; //while ( pblock->GetBlockTime() > GetAdjustedTime() + 10 ) // sleep(1); //fprintf(stderr,"block.nTime %u vs prev.%u, gettime.%u vs adjusted.%u\n",(uint32_t)pblock->nTime,(uint32_t)(pindexPrev->nTime + 60),(uint32_t)pblock->GetBlockTime(),(uint32_t)(GetAdjustedTime() + 60)); From be381f22ffe1b3748d1e6953a2f8a1e16b713fe0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 May 2018 16:18:00 +0300 Subject: [PATCH 61/62] 65 seconds to slow down diff --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index ac1116b4e..a62f39846 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -480,7 +480,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 && pblock->nTime < pindexPrev->nTime+60 ) { - pblock->nTime = pindexPrev->nTime + 61; + pblock->nTime = pindexPrev->nTime + 65; //while ( pblock->GetBlockTime() > GetAdjustedTime() + 10 ) // sleep(1); //fprintf(stderr,"block.nTime %u vs prev.%u, gettime.%u vs adjusted.%u\n",(uint32_t)pblock->nTime,(uint32_t)(pindexPrev->nTime + 60),(uint32_t)pblock->GetBlockTime(),(uint32_t)(GetAdjustedTime() + 60)); From fb38b77469996d6f7e87121f3d96bf3929a309da Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 4 May 2018 17:39:21 +0300 Subject: [PATCH 62/62] Monthly cap --- src/komodo_interest.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 23ed985ca..8fd6becea 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -80,13 +80,15 @@ uint64_t komodo_moneysupply(int32_t height) } #endif -uint64_t _komodo_interestnew(uint64_t nValue,uint32_t nLockTime,uint32_t tiptime) +uint64_t _komodo_interestnew(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime) { int32_t minutes; uint64_t interest = 0; if ( nLockTime >= LOCKTIME_THRESHOLD && tiptime > nLockTime && (minutes= (tiptime - nLockTime) / 60) >= 60 ) { if ( minutes > 365 * 24 * 60 ) minutes = 365 * 24 * 60; + if ( txheight >= 1000000 && minutes > 31 * 24 * 60 ) + minutes = 31 * 24 * 60; minutes -= 59; interest = ((nValue / 10512000) * minutes); } @@ -97,7 +99,7 @@ uint64_t komodo_interestnew(int32_t txheight,uint64_t nValue,uint32_t nLockTime, { uint64_t interest = 0; if ( txheight < KOMODO_ENDOFERA && nLockTime >= LOCKTIME_THRESHOLD && tiptime != 0 && nLockTime < tiptime && nValue >= 10*COIN ) //komodo_moneysupply(txheight) < MAX_MONEY && - interest = _komodo_interestnew(nValue,nLockTime,tiptime); + interest = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); return(interest); } @@ -151,21 +153,21 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else if ( txheight < 1000000 ) { interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); - interestnew = _komodo_interestnew(nValue,nLockTime,tiptime); + interestnew = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); if ( interest < interestnew ) printf("pathA current interest %.8f vs new %.8f for ht.%d %.8f locktime.%u tiptime.%u\n",dstr(interest),dstr(interestnew),txheight,dstr(nValue),nLockTime,tiptime); } - else interest = _komodo_interestnew(nValue,nLockTime,tiptime); + else interest = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); } else if ( txheight < 1000000 ) { numerator = (nValue * KOMODO_INTEREST); interest = (numerator / denominator) / COIN; - interestnew = _komodo_interestnew(nValue,nLockTime,tiptime); + interestnew = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); if ( interest < interestnew ) printf("pathB current interest %.8f vs new %.8f for ht.%d %.8f locktime.%u tiptime.%u\n",dstr(interest),dstr(interestnew),txheight,dstr(nValue),nLockTime,tiptime); } - else interest = _komodo_interestnew(nValue,nLockTime,tiptime); + else interest = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); } else { @@ -187,11 +189,11 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin numerator = (nValue / 20); // assumes 5%! interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)); //fprintf(stderr,"interest %llu %.8f <- numerator.%llu minutes.%d\n",(long long)interest,(double)interest/COIN,(long long)numerator,(int32_t)minutes); - interestnew = _komodo_interestnew(nValue,nLockTime,tiptime); + interestnew = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); if ( interest < interestnew ) fprintf(stderr,"pathC current interest %.8f vs new %.8f for ht.%d %.8f locktime.%u tiptime.%u\n",dstr(interest),dstr(interestnew),txheight,dstr(nValue),nLockTime,tiptime); } - else interest = _komodo_interestnew(nValue,nLockTime,tiptime); + else interest = _komodo_interestnew(txheight,nValue,nLockTime,tiptime); } if ( 0 && numerator == (nValue * KOMODO_INTEREST) ) fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu) prod.%llu\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes));