From 6d0b551df1c6e70105cf6e4a66c6abe7c7c00919 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 30 Sep 2018 11:44:54 -0700 Subject: [PATCH 1/5] Give each NetworkID a dedicated notarizations file --- src/komodo_validation011.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/komodo_validation011.h b/src/komodo_validation011.h index c6a4c0b93..f226d21a5 100644 --- a/src/komodo_validation011.h +++ b/src/komodo_validation011.h @@ -54,6 +54,7 @@ }*/ #include +#include #include #define SATOSHIDEN ((uint64_t)100000000L) @@ -1001,17 +1002,19 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) { static int didinit; static uint256 zero; static FILE *fp; CBlockIndex *pindex; struct notarized_checkpoint *np,N; long fpos; - LogPrintf("dpow: komodod_notarized_update\n"); if ( didinit == 0 ) { char fname[512];int32_t latestht = 0; //decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); pthread_mutex_init(&komodo_mutex,NULL); + std::string suffix = Params().NetworkIDString() == "mainnet" ? "" : "_" + Params.NetworkIDString(); + std::string sep; #ifdef _WIN32 - sprintf(fname,"%s\\notarizations",GetDefaultDataDir().string().c_str()); + sep = "\\"; #else - sprintf(fname,"%s/notarizations",GetDefaultDataDir().string().c_str()); + sep = "/"; #endif + sprintf(fname,"%s%snotarizations%s",GetDefaultDataDir().string().c_str(), sep.c_str(), suffix.c_str()); LogPrintf("dpow: fname.(%s)\n",fname); if ( (fp= fopen(fname,"rb+")) == 0 ) fp = fopen(fname,"wb+"); From ecd51b79c58af6726aea5c48534413c0855cb43c Mon Sep 17 00:00:00 2001 From: Team ChainStrike Date: Sun, 30 Sep 2018 18:59:49 +1000 Subject: [PATCH 2/5] Basic passing dpow test, run like: ./qa/pull-tester/rpc-tests.sh dpow --- qa/rpc-tests/dpow.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/qa/rpc-tests/dpow.py b/qa/rpc-tests/dpow.py index 8c78b92cf..cf56d1ff5 100755 --- a/qa/rpc-tests/dpow.py +++ b/qa/rpc-tests/dpow.py @@ -25,12 +25,13 @@ class DPoWTest(BitcoinTestFramework): self.nodes[0].generate(3) rpc = self.nodes[0] - # Verify that basic RPC functions exist and work - result = rpc.calc_MoM(2,20) - print result - result = rpc.getinfo() - assert result.notarized,42 + print result + # TODO: actually do notarizations on regtest and test for specific data + # TODO: does this have mainnet values somehow? + assert(result['notarized'] >= 0) + assert(result['notarizedhash']) + assert(result['notarizedtxid']) if __name__ == '__main__': DPoWTest().main() From e9a3ade79adb4c778986bd794dc002b840883193 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 30 Sep 2018 12:22:56 -0700 Subject: [PATCH 3/5] Fix detection of mainnet, less noise --- src/komodo_validation011.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_validation011.h b/src/komodo_validation011.h index f226d21a5..1de8dd6ff 100644 --- a/src/komodo_validation011.h +++ b/src/komodo_validation011.h @@ -1007,7 +1007,7 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no char fname[512];int32_t latestht = 0; //decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); pthread_mutex_init(&komodo_mutex,NULL); - std::string suffix = Params().NetworkIDString() == "mainnet" ? "" : "_" + Params.NetworkIDString(); + std::string suffix = Params().NetworkIDString() == "main" ? "" : "_" + Params().NetworkIDString(); std::string sep; #ifdef _WIN32 sep = "\\"; @@ -1048,7 +1048,7 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no } if ( notarized_height == 0 ) { - LogPrintf("dpow: notarized_height=0, aborting\n"); + //LogPrintf("dpow: notarized_height=0, aborting\n"); return; } if ( notarized_height >= nHeight ) @@ -1071,7 +1071,7 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no NOTARIZED_HEIGHT = np->notarized_height = notarized_height; NOTARIZED_HASH = np->notarized_hash = notarized_hash; NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; - LogPrintf("dpow: NOTARIZED (HEIGHT,HASH,DESTTXID) = (%d, %s, %s)\n", NOTARIZED_HEIGHT, NOTARIZED_HASH.GetHex().c_str(), NOTARIZED_DESTTXID.GetHex().c_str()); + LogPrintf("dpow: komodo_notarized_update NOTARIZED (HEIGHT,HASH,DESTTXID) = (%d, %s, %s)\n", NOTARIZED_HEIGHT, NOTARIZED_HASH.GetHex().c_str(), NOTARIZED_DESTTXID.GetHex().c_str()); if ( MoM != zero && MoMdepth > 0 ) { NOTARIZED_MOM = np->MoM = MoM; From 3f240e3e82eba1700be0908104d4678e47b8ee62 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 30 Sep 2018 12:53:11 -0700 Subject: [PATCH 4/5] Remove no longer relevant TODO --- qa/rpc-tests/dpow.py | 1 - 1 file changed, 1 deletion(-) diff --git a/qa/rpc-tests/dpow.py b/qa/rpc-tests/dpow.py index cf56d1ff5..c0036c560 100755 --- a/qa/rpc-tests/dpow.py +++ b/qa/rpc-tests/dpow.py @@ -28,7 +28,6 @@ class DPoWTest(BitcoinTestFramework): result = rpc.getinfo() print result # TODO: actually do notarizations on regtest and test for specific data - # TODO: does this have mainnet values somehow? assert(result['notarized'] >= 0) assert(result['notarizedhash']) assert(result['notarizedtxid']) From be29cb59833df6b64c9e7aec7677eb0bd8e6fabb Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 30 Sep 2018 12:58:21 -0700 Subject: [PATCH 5/5] Improve dpow tests --- qa/rpc-tests/dpow.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qa/rpc-tests/dpow.py b/qa/rpc-tests/dpow.py index c0036c560..fda3f6b9c 100755 --- a/qa/rpc-tests/dpow.py +++ b/qa/rpc-tests/dpow.py @@ -28,9 +28,10 @@ class DPoWTest(BitcoinTestFramework): result = rpc.getinfo() print result # TODO: actually do notarizations on regtest and test for specific data - assert(result['notarized'] >= 0) - assert(result['notarizedhash']) - assert(result['notarizedtxid']) + # regtest should have no notarization data, this test makes sure we do not see mainnet values as well! + assert_equal(result['notarized'],0) + assert_equal(result['notarizedhash'],'0000000000000000000000000000000000000000000000000000000000000000') + assert_equal(result['notarizedtxid'],'0000000000000000000000000000000000000000000000000000000000000000') if __name__ == '__main__': DPoWTest().main()