From 8b391806c46b7bf2afb795b9a468365c859ed4bb Mon Sep 17 00:00:00 2001 From: ca333 Date: Thu, 1 Mar 2018 03:38:26 +0100 Subject: [PATCH 01/20] update code_of_conduct --- code_of_conduct.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code_of_conduct.md b/code_of_conduct.md index 959fbe4d5..b85fd574e 100644 --- a/code_of_conduct.md +++ b/code_of_conduct.md @@ -41,14 +41,14 @@ is deemed necessary and appropriate to the circumstances. Maintainers are obligated to maintain confidentiality with regard to the reporter of an incident. -You may send reports to [our Conduct email](mailto:conduct@z.cash). +You may send reports to [our Conduct email](mailto:developer@komodoplatform.com). If you wish to contact specific maintainers directly, the following have made themselves available for conduct issues: -- Daira Hopwood (daira at z.cash) -- Sean Bowe (sean at z.cash) - +- Benny Fairbank (benny at komodoplatform.com) +- Support Team (support at komodoplatform.com) +- ca333 (ca333 at komodoplatform.com) This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.3.0, available at From ee5d6946326d89ce8de56d8157c081a9e6fd63c6 Mon Sep 17 00:00:00 2001 From: ca333 Date: Wed, 4 Apr 2018 03:28:48 +0200 Subject: [PATCH 02/20] add BNTN --- src/assetchains | 1 + src/assetchains.old | 1 + src/dpowassets | 1 + src/fiat-cli | 1 + src/fiat/bntn | 2 ++ 5 files changed, 6 insertions(+) create mode 100644 src/fiat/bntn diff --git a/src/assetchains b/src/assetchains index d6e60be12..c3e161142 100755 --- a/src/assetchains +++ b/src/assetchains @@ -52,3 +52,4 @@ komodo_asset PIZZA 100000000 komodo_asset BEER 100000000 komodo_asset NINJA 100000000 komodo_asset OOT 216000000 +komodo_asset BNTN 500000000 diff --git a/src/assetchains.old b/src/assetchains.old index 9839c56e6..6bb60d95a 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -29,6 +29,7 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=PIZZA -ac_supply=100000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=NINJA -ac_supply=100000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=OOT -ac_supply=216000000 -addnode=174.138.107.226 & +./komodod -pubkey=$pubkey -ac_name=BNTN -ac_supply=500000000 -addnode=94.130.169.205 & #sleep $delay #./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 & diff --git a/src/dpowassets b/src/dpowassets index d2f0006ff..bd970c357 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -30,6 +30,7 @@ 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\":\"VOTE2018\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"NINJA\",\"pubkey\":\"$pubkey\"}" 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\":\"USD\",\"pubkey\":\"$pubkey\"}" #curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EUR\",\"pubkey\":\"$pubkey\"}" diff --git a/src/fiat-cli b/src/fiat-cli index 89f82c632..a7ee8c62e 100755 --- a/src/fiat-cli +++ b/src/fiat-cli @@ -25,3 +25,4 @@ echo beer; fiat/beer $1 $2 $3 $4 echo vote2018; fiat/vote2018 $1 $2 $3 $4 echo ninja; fiat/ninja $1 $2 $3 $4 echo oot; fiat/oot $1 $2 $3 $4 +echo bntn: fiat/bntn $1 $2 $3 $4 diff --git a/src/fiat/bntn b/src/fiat/bntn new file mode 100644 index 000000000..7ae6f4e8d --- /dev/null +++ b/src/fiat/bntn @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=BNTN $1 $2 $3 $4 $5 $6 From 50045b3671d71e6ee18ee9e8b9650f40e5820a32 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 4 Apr 2018 18:59:09 +0300 Subject: [PATCH 03/20] Disable cross chain checking of notarization, libscott says it is ok --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index ded368381..8ec38587c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -573,7 +573,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr { notarized = 1; } - if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height && (height < sp->CURRENT_HEIGHT-64 || komodo_verifynotarization(ASSETCHAINS_SYMBOL[0]==0?(char *)"KMD":ASSETCHAINS_SYMBOL,(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "BTC" : "KMD"),height,*notarizedheightp,kmdtxid,desttxid) == 0) ) + if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) //&& (height < sp->CURRENT_HEIGHT-64 || komodo_verifynotarization(ASSETCHAINS_SYMBOL[0]==0?(char *)"KMD":ASSETCHAINS_SYMBOL,(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "BTC" : "KMD"),height,*notarizedheightp,kmdtxid,desttxid) == 0) ) { int32_t nameoffset = (int32_t)strlen(ASSETCHAINS_SYMBOL) + 1; sp->NOTARIZED_HEIGHT = *notarizedheightp; From a3bf7b967a7bd532ba39b7aa4cbd757012ce74cd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 4 Apr 2018 19:36:16 +0300 Subject: [PATCH 04/20] Enable KMD validation for KMD --- src/komodo.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 8ec38587c..78e0006ba 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -573,7 +573,12 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr { notarized = 1; } - if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) //&& (height < sp->CURRENT_HEIGHT-64 || komodo_verifynotarization(ASSETCHAINS_SYMBOL[0]==0?(char *)"KMD":ASSETCHAINS_SYMBOL,(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "BTC" : "KMD"),height,*notarizedheightp,kmdtxid,desttxid) == 0) ) + int32_t validated = 0; + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + validated = 1; + else if ( height < sp->CURRENT_HEIGHT-64 || komodo_verifynotarization((char *)"KMD",(char *)"BTC",height,*notarizedheightp,kmdtxid,desttxid) == 0 ) + validated = 1; + if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height && validated != 0 ) { int32_t nameoffset = (int32_t)strlen(ASSETCHAINS_SYMBOL) + 1; sp->NOTARIZED_HEIGHT = *notarizedheightp; From acb93848cd19c2f8630451d9027fb2eff3d94e4d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 5 Apr 2018 14:39:07 +0300 Subject: [PATCH 05/20] Tweak notarization checks --- src/komodo_notary.h | 4 ++-- src/komodo_utils.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 638327e81..0d07cef52 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -205,7 +205,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam timestamp = komodo_heightstamp(height); if ( height >= KOMODO_NOTARIES_HARDCODED || ASSETCHAINS_SYMBOL[0] != 0 ) { - if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || height <= KOMODO_NOTARIES_HEIGHT1 ) + if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP1) || (ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_NOTARIES_HEIGHT1) ) { if ( did0 == 0 ) { @@ -381,7 +381,7 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33, void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) { struct notarized_checkpoint *np; - if ( notarized_height > nHeight ) + if ( notarized_height >= nHeight ) { printf("komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); return; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 1270b3e55..999200c13 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1365,7 +1365,7 @@ void komodo_configfile(char *symbol,uint16_t port) #ifndef FROM_CLI if ( (fp= fopen(fname,"wb")) != 0 ) { - fprintf(fp,"rpcuser=user%u\nrpcpassword=pass%s\nrpcport=%u\nserver=1\ntxindex=1\nrpcworkqueue=64\n",crc,password,port); + fprintf(fp,"rpcuser=user%u\nrpcpassword=pass%s\nrpcport=%u\nserver=1\ntxindex=1\nrpcworkqueue=64\nrpcallowip=127.0.0.1\n",crc,password,port); fclose(fp); printf("Created (%s)\n",fname); } else printf("Couldnt create (%s)\n",fname); From 88d4a95ae72bfcbaf47ed373706ac68107040c3d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 6 Apr 2018 12:40:00 +0300 Subject: [PATCH 06/20] Test --- src/komodo_gateway.h | 4 ++++ src/komodo_kv.h | 2 +- src/komodo_notary.h | 55 +++++++++++++++++++++++++------------------- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2b3d382ac..055959cc9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -711,6 +711,10 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( height >= activation ) return(-1); } + else if ( block.nBits == KOMODO_MINDIFF_NBITS && total > 0 ) + { + fprintf(stderr,"notary mined ht.%d with extra %.8f\n",height,dstr(total)); + } } else { diff --git a/src/komodo_kv.h b/src/komodo_kv.h index 9aca2d387..453608cc1 100644 --- a/src/komodo_kv.h +++ b/src/komodo_kv.h @@ -171,7 +171,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) memcpy(ptr->key,key,keylen); newflag = 1; HASH_ADD_KEYPTR(hh,KOMODO_KV,ptr->key,ptr->keylen,ptr); - //printf("KV add.(%s) (%s)\n",ptr->key,valueptr); + printf("KV add.(%s) (%s)\n",ptr->key,valueptr); } if ( newflag != 0 || (ptr->flags & KOMODO_KVPROTECTED) == 0 ) { diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 0d07cef52..6b75a39d5 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -131,8 +131,8 @@ const char *Notaries_elected0[][2] = const char *Notaries_elected1[][2] = { - { "0_jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, { "0_jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, + { "0_jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, { "0_kolo_testA", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" }, { "artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" }, { "artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" }, @@ -378,29 +378,6 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33, return(modval); } -void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) -{ - struct notarized_checkpoint *np; - if ( notarized_height >= nHeight ) - { - printf("komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); - return; - } - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - printf("[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height); - portable_mutex_lock(&komodo_mutex); - sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); - np = &sp->NPOINTS[sp->NUM_NPOINTS++]; - memset(np,0,sizeof(*np)); - np->nHeight = nHeight; - sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; - sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; - sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; - sp->MoM = np->MoM = MoM; - sp->MoMdepth = np->MoMdepth = MoMdepth; - portable_mutex_unlock(&komodo_mutex); -} - //struct komodo_state *komodo_stateptr(char *symbol,char *dest); int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp) { @@ -499,6 +476,36 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n return(0); } +void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) +{ + struct notarized_checkpoint *np; uint256 hash,desttxid; int32_t ht; + if ( notarized_height >= nHeight ) + { + fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); + return; + } + if ( (ht= komodo_notarizeddata(notarized_height,&hash,&desttxid)) > 0 ) + { + fprintf(stderr,"komodo_notarized_update %d already there ht.%d hash %s vs %s\n",notarized_height,ht,hash.ToString().cstr(),desttxid.ToString().cstr()); + } + else + { + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height); + portable_mutex_lock(&komodo_mutex); + sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); + np = &sp->NPOINTS[sp->NUM_NPOINTS++]; + memset(np,0,sizeof(*np)); + np->nHeight = nHeight; + sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; + sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; + sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; + sp->MoM = np->MoM = MoM; + sp->MoMdepth = np->MoMdepth = MoMdepth; + portable_mutex_unlock(&komodo_mutex); + } +} + void komodo_init(int32_t height) { static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33]; From bd08718ae870016189d6feaa4c9ef2958990b7f3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 6 Apr 2018 12:41:48 +0300 Subject: [PATCH 07/20] Test --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 6b75a39d5..a1b5aaadd 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -486,7 +486,7 @@ void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t not } if ( (ht= komodo_notarizeddata(notarized_height,&hash,&desttxid)) > 0 ) { - fprintf(stderr,"komodo_notarized_update %d already there ht.%d hash %s vs %s\n",notarized_height,ht,hash.ToString().cstr(),desttxid.ToString().cstr()); + fprintf(stderr,"komodo_notarized_update %d already there ht.%d hash %s vs %s\n",notarized_height,ht,hash.ToString().c_str(),desttxid.ToString().c_str()); } else { From 54ecb7e4e653cd02aadceae9f21dec1bab37eac7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 6 Apr 2018 12:45:36 +0300 Subject: [PATCH 08/20] Test --- src/komodo_gateway.h | 2 ++ src/komodo_notary.h | 33 +++++++++++++-------------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 055959cc9..7b9403d72 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -714,6 +714,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above else if ( block.nBits == KOMODO_MINDIFF_NBITS && total > 0 ) { fprintf(stderr,"notary mined ht.%d with extra %.8f\n",height,dstr(total)); + if ( height > KOMODO_NOTARIES_HEIGHT1 ) + return(-1); } } else diff --git a/src/komodo_notary.h b/src/komodo_notary.h index a1b5aaadd..6388c1b7f 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -484,26 +484,19 @@ void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t not fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); return; } - if ( (ht= komodo_notarizeddata(notarized_height,&hash,&desttxid)) > 0 ) - { - fprintf(stderr,"komodo_notarized_update %d already there ht.%d hash %s vs %s\n",notarized_height,ht,hash.ToString().c_str(),desttxid.ToString().c_str()); - } - else - { - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height); - portable_mutex_lock(&komodo_mutex); - sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); - np = &sp->NPOINTS[sp->NUM_NPOINTS++]; - memset(np,0,sizeof(*np)); - np->nHeight = nHeight; - sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; - sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; - sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; - sp->MoM = np->MoM = MoM; - sp->MoMdepth = np->MoMdepth = MoMdepth; - portable_mutex_unlock(&komodo_mutex); - } + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height); + portable_mutex_lock(&komodo_mutex); + sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); + np = &sp->NPOINTS[sp->NUM_NPOINTS++]; + memset(np,0,sizeof(*np)); + np->nHeight = nHeight; + sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; + sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; + sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; + sp->MoM = np->MoM = MoM; + sp->MoMdepth = np->MoMdepth = MoMdepth; + portable_mutex_unlock(&komodo_mutex); } void komodo_init(int32_t height) From 858a837fc8835afae720fdd02e115cb3811e9120 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 6 Apr 2018 12:46:08 +0300 Subject: [PATCH 09/20] Test --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 6388c1b7f..789c588f2 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -478,7 +478,7 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) { - struct notarized_checkpoint *np; uint256 hash,desttxid; int32_t ht; + struct notarized_checkpoint *np; if ( notarized_height >= nHeight ) { fprintf(stderr,"komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); From 5c079fa330ef5f3d27c38785aed62f646171d075 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 6 Apr 2018 13:18:38 +0300 Subject: [PATCH 10/20] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 151c42383..8dd3688fc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2585,8 +2585,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001); CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()); - if (block.vtx[0].vout[0].nValue > blockReward) - //if (block.vtx[0].GetValueOut() > blockReward) + //if (block.vtx[0].vout[0].nValue > blockReward) + if (block.vtx[0].GetValueOut() > blockReward) return state.DoS(100, error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)", block.vtx[0].GetValueOut(), blockReward), From 0b652b660a3dd8ad732e4d9156ef5eb6fbbb418c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 6 Apr 2018 13:22:26 +0300 Subject: [PATCH 11/20] Test --- src/main.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8dd3688fc..a82f42fbb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2585,13 +2585,16 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001); CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()); - //if (block.vtx[0].vout[0].nValue > blockReward) - if (block.vtx[0].GetValueOut() > blockReward) - return state.DoS(100, + if ( block.vtx[0].GetValueOut() > blockReward) + { + if ( nHeight < KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) + { + return state.DoS(100, error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)", block.vtx[0].GetValueOut(), blockReward), REJECT_INVALID, "bad-cb-amount"); - + } else fprintf(stderr,"nHeight.%d coinbase %.8f vs %.8f\n",(int32_t)nHeight,dstr(block.vtx[0].GetValueOut()),dstr(blockReward)); + } if (!control.Wait()) return state.DoS(100, false); int64_t nTime2 = GetTimeMicros(); nTimeVerify += nTime2 - nTimeStart; From 5ba45a00f1e6afde6bac601f0f2bce0914343e48 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 6 Apr 2018 13:23:39 +0300 Subject: [PATCH 12/20] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a82f42fbb..3ffd1b2ef 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2585,9 +2585,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001); CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()); - if ( block.vtx[0].GetValueOut() > blockReward) + if ( block.vtx[0].GetValueOut() > blockReward ) { - if ( nHeight < KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) + if ( pindex->nHeight < KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) { return state.DoS(100, error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)", From 09a3e8c285b5b6a52ad1f9875b06de510c9b94a3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 6 Apr 2018 13:25:11 +0300 Subject: [PATCH 13/20] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 3ffd1b2ef..469e73454 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2593,7 +2593,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)", block.vtx[0].GetValueOut(), blockReward), REJECT_INVALID, "bad-cb-amount"); - } else fprintf(stderr,"nHeight.%d coinbase %.8f vs %.8f\n",(int32_t)nHeight,dstr(block.vtx[0].GetValueOut()),dstr(blockReward)); + } else fprintf(stderr,"nHeight.%d coinbase %.8f vs %.8f\n",(int32_t)pindex->nHeight,dstr(block.vtx[0].GetValueOut()),dstr(blockReward)); } if (!control.Wait()) return state.DoS(100, false); From 17b29c639e56946d5dbb92c974a5e63af48f85d3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 6 Apr 2018 14:00:56 +0300 Subject: [PATCH 14/20] Test --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 789c588f2..4689e38ed 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -239,7 +239,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam if ( Pubkeys == 0 ) { komodo_init(height); - printf("Pubkeys.%p htind.%d vs max.%d\n",Pubkeys,htind,KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP); + //printf("Pubkeys.%p htind.%d vs max.%d\n",Pubkeys,htind,KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP); } pthread_mutex_lock(&komodo_mutex); n = Pubkeys[htind].numnotaries; From 4614c6c903f7318730a0b7ce209e1624d6ae8ee8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 6 Apr 2018 15:11:10 +0300 Subject: [PATCH 15/20] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7b9403d72..da4b3b7e1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -684,7 +684,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } n = block.vtx[0].vout.size(); script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data(); - if ( n <= 2 || script[0] != 0x6a ) + //if ( n <= 2 || script[0] != 0x6a ) { int64_t val,prevtotal = 0; int32_t overflow = 0; total = 0; From b0bd536aad06dbe893b42d5760a3794e178aba78 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 6 Apr 2018 17:25:31 +0300 Subject: [PATCH 16/20] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 469e73454..7aa1fe1db 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2587,13 +2587,13 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()); if ( block.vtx[0].GetValueOut() > blockReward ) { - if ( pindex->nHeight < KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) + if ( pindex->nHeight >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) { return state.DoS(100, error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)", block.vtx[0].GetValueOut(), blockReward), REJECT_INVALID, "bad-cb-amount"); - } else fprintf(stderr,"nHeight.%d coinbase %.8f vs %.8f\n",(int32_t)pindex->nHeight,dstr(block.vtx[0].GetValueOut()),dstr(blockReward)); + } else fprintf(stderr,"allow nHeight.%d coinbase %.8f vs %.8f\n",(int32_t)pindex->nHeight,dstr(block.vtx[0].GetValueOut()),dstr(blockReward)); } if (!control.Wait()) return state.DoS(100, false); From 6b30b27c1c6f565b2932d93bc9bfc08dbf1098fd Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 6 Apr 2018 17:44:47 +0300 Subject: [PATCH 17/20] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 7aa1fe1db..2d699f9e5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2584,7 +2584,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin int64_t nTime1 = GetTimeMicros(); nTimeConnect += nTime1 - nTimeStart; LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001); - CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()); + CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()) + sum; if ( block.vtx[0].GetValueOut() > blockReward ) { if ( pindex->nHeight >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) @@ -2593,7 +2593,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)", block.vtx[0].GetValueOut(), blockReward), REJECT_INVALID, "bad-cb-amount"); - } else fprintf(stderr,"allow nHeight.%d coinbase %.8f vs %.8f\n",(int32_t)pindex->nHeight,dstr(block.vtx[0].GetValueOut()),dstr(blockReward)); + } else fprintf(stderr,"allow nHeight.%d coinbase %.8f vs %.8f interest %.8f\n",(int32_t)pindex->nHeight,dstr(block.vtx[0].GetValueOut()),dstr(blockReward),dstr(sum)); } if (!control.Wait()) return state.DoS(100, false); From 882ad91524cd20aaa83a8f26a7e0a76bea97ab7a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 6 Apr 2018 17:56:26 +0300 Subject: [PATCH 18/20] Test --- src/komodo.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 78e0006ba..cc15174fb 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -573,11 +573,11 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr { notarized = 1; } - int32_t validated = 0; - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + int32_t validated = 1; + /*if ( ASSETCHAINS_SYMBOL[0] != 0 ) validated = 1; else if ( height < sp->CURRENT_HEIGHT-64 || komodo_verifynotarization((char *)"KMD",(char *)"BTC",height,*notarizedheightp,kmdtxid,desttxid) == 0 ) - validated = 1; + validated = 1;*/ if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height && validated != 0 ) { int32_t nameoffset = (int32_t)strlen(ASSETCHAINS_SYMBOL) + 1; @@ -628,8 +628,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len+4+3+(scriptbuf[1] == 0x4d),j,zero,0); } } - } else if ( height >= sp->CURRENT_HEIGHT-64 )//KOMODO_MAINNET_START ) - printf("notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s (%s) len.%d opretlen.%d\n",notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len],len,opretlen); + } else //if ( height >= sp->CURRENT_HEIGHT-64 )//KOMODO_MAINNET_START ) + printf("validated.%d notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s (%s) len.%d opretlen.%d\n",validated,notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len],len,opretlen); } else if ( i == 0 && j == 1 && opretlen == 149 ) { From dc836ee40cad2fbd6a482ed1896ad776ab653194 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 6 Apr 2018 18:18:55 +0300 Subject: [PATCH 19/20] Test --- src/komodo_bitcoind.h | 4 ++-- src/komodo_gateway.h | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 6f8357985..edd4d6569 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -902,8 +902,8 @@ int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 has } } else fprintf(stderr,"[%s] unexpected error notary_hash %s ht.%d at ht.%d\n",ASSETCHAINS_SYMBOL,notarized_hash.ToString().c_str(),notarized_height,notary->nHeight); } - else if ( notarized_height > 0 && notarized_height != 73880 && notarized_height >= 170000 ) - fprintf(stderr,"[%s] couldnt find notarized.(%s %d) ht.%d\n",ASSETCHAINS_SYMBOL,notarized_hash.ToString().c_str(),notarized_height,pindex->nHeight); + //else if ( notarized_height > 0 && notarized_height != 73880 && notarized_height >= 170000 ) + // fprintf(stderr,"[%s] couldnt find notarized.(%s %d) ht.%d\n",ASSETCHAINS_SYMBOL,notarized_hash.ToString().c_str(),notarized_height,pindex->nHeight); return(0); } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index da4b3b7e1..a799927f9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -725,7 +725,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } return(0); } - if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_COMMISSION != 0 ) + /*if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_COMMISSION != 0 ) { script = (uint8_t *)block.vtx[0].vout[0].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) @@ -1013,16 +1013,16 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } 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)); + //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 + //if ( height > 200000 ) + //{ + // printf("REJECT: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num); + // return(-1); + //} + //} // disabled 'X' path } else { @@ -1051,7 +1051,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above printf("not proper vout with opreturn format %s ht.%d cmp.%d %d\n",ASSETCHAINS_SYMBOL,height,script[offset] == opcode,(int32_t)block.vtx[0].vout[n-1].scriptPubKey.size()); return(-1); } - return(0); + return(0);*/ } const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) From cf7f440296051d591b1c52afcd3766177e832907 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 6 Apr 2018 18:29:45 +0300 Subject: [PATCH 20/20] Test --- src/komodo_gateway.h | 2 +- src/main.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a799927f9..c8fc03980 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -711,7 +711,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( height >= activation ) return(-1); } - else if ( block.nBits == KOMODO_MINDIFF_NBITS && total > 0 ) + else if ( block.nBits == KOMODO_MINDIFF_NBITS && total > 0 ) // to deal with fee stealing { fprintf(stderr,"notary mined ht.%d with extra %.8f\n",height,dstr(total)); if ( height > KOMODO_NOTARIES_HEIGHT1 ) diff --git a/src/main.cpp b/src/main.cpp index 2d699f9e5..f45ad7bad 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2585,7 +2585,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs-1), nTimeConnect * 0.000001); CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus()) + sum; - if ( block.vtx[0].GetValueOut() > blockReward ) + if ( block.vtx[0].GetValueOut() > blockReward+1 ) { if ( pindex->nHeight >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) { @@ -2593,7 +2593,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)", block.vtx[0].GetValueOut(), blockReward), REJECT_INVALID, "bad-cb-amount"); - } else fprintf(stderr,"allow nHeight.%d coinbase %.8f vs %.8f interest %.8f\n",(int32_t)pindex->nHeight,dstr(block.vtx[0].GetValueOut()),dstr(blockReward),dstr(sum)); + } else if ( NOTARY_PUBKEY33[0] != 0 ) + fprintf(stderr,"allow nHeight.%d coinbase %.8f vs %.8f interest %.8f\n",(int32_t)pindex->nHeight,dstr(block.vtx[0].GetValueOut()),dstr(blockReward),dstr(sum)); } if (!control.Wait()) return state.DoS(100, false);