From 373668be25c1097ea826e78a9050de855f16527f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 25 Apr 2018 14:29:10 +0300 Subject: [PATCH 01/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] 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/27] -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/27] 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/27] +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/27] +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/27] 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/27] 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/27] 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/27] 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/27] 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/27] -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/27] 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/27] 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/27] 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/27] +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/27] 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/27] 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