From 994a0151f781687c349a839d9c58c2545229ccf7 Mon Sep 17 00:00:00 2001 From: webworker01 Date: Wed, 12 Dec 2018 18:01:05 -0500 Subject: [PATCH 01/24] Set sapling for zilla in far future, fix oot sapling param --- src/assetchains.json | 6 +++++- src/assetchains.old | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/assetchains.json b/src/assetchains.json index 7bc6b7147..1a0ae25e2 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -124,7 +124,11 @@ }, { "ac_name": "ZILLA", - "ac_supply": "11000000" + "ac_supply": "11000000", + "ac_sapling": "5000000", + "addnode": [ + "51.68.215.104" + ] }, { "ac_name": "RFOX", diff --git a/src/assetchains.old b/src/assetchains.old index 5389e54bd..c1419e7f5 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -27,14 +27,14 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=BEER -ac_supply=100000000 -addnode=78.47.196.146 & ./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 -ac_saplinig=5000000 -addnode=174.138.107.226 & +./komodod -pubkey=$pubkey -ac_name=OOT -ac_supply=216000000 -ac_sapling=5000000 -addnode=174.138.107.226 & ./komodod -pubkey=$pubkey -ac_name=BNTN -ac_supply=500000000 -addnode=94.130.169.205 & ./komodod -pubkey=$pubkey -ac_name=CHAIN -ac_supply=999999 -addnode=78.47.146.222 & ./komodod -pubkey=$pubkey -ac_name=PRLPAY -ac_supply=500000000 -addnode=13.250.226.125 & ./komodod -pubkey=$pubkey -ac_name=DSEC -ac_supply=7000000 -addnode=185.148.147.30 & ./komodod -pubkey=$pubkey -ac_name=GLXT -ac_supply=10000000000 -addnode=13.230.224.15 & ./komodod -pubkey=$pubkey -ac_name=EQL -ac_supply=500000000 -ac_ccactivate=205000 -addnode=46.101.124.153 & -./komodod -pubkey=$pubkey -ac_name=ZILLA -ac_supply=11000000 -addnode=54.39.23.248 & +./komodod -pubkey=$pubkey -ac_name=ZILLA -ac_supply=11000000 -ac_sapling=5000000 -addnode=51.68.215.104 & ./komodod -pubkey=$pubkey -ac_name=RFOX -ac_supply=1000000000 -ac_reward=100000000 -addnode=78.47.196.146 & ~/VerusCoin/src/komodod -pubkey=$pubkey -ac_name=VRSC -ac_algo=verushash -ac_cc=1 -ac_veruspos=50 -ac_supply=0 -ac_eras=3 -ac_reward=0,38400000000,2400000000 -ac_halving=1,43200,1051920 -ac_decay=100000000,0,0 -ac_end=10080,226080,0 -ac_timelockgte=19200000000 -ac_timeunlockfrom=129600 -ac_timeunlockto=1180800 -addnode=185.25.48.236 -addnode=185.64.105.111 & ./komodod -pubkey=$pubkey -ac_name=SEC -ac_cc=333 -ac_supply=1000000000 -addnode=185.148.145.43 & From 6e15b6fbd67c6a96879cabc3839f58d22d081c5e Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Thu, 13 Dec 2018 19:04:52 +0600 Subject: [PATCH 02/24] initial tests for ChannelsCC --- qa/pull-tester/rpc-tests.sh | 1 + qa/rpc-tests/cryptoconditions_channels.py | 174 ++++++++++++++++++++++ 2 files changed, 175 insertions(+) create mode 100755 qa/rpc-tests/cryptoconditions_channels.py diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index 0d7d5509c..d95bf612c 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -14,6 +14,7 @@ testScripts=( 'ac_private.py' 'verushash.py' 'cryptoconditions.py' + 'cryptoconditions_channels.py' 'cryptoconditions_dice.py' 'cryptoconditions_faucet.py' 'cryptoconditions_oracles.py' diff --git a/qa/rpc-tests/cryptoconditions_channels.py b/qa/rpc-tests/cryptoconditions_channels.py new file mode 100755 index 000000000..0010f825b --- /dev/null +++ b/qa/rpc-tests/cryptoconditions_channels.py @@ -0,0 +1,174 @@ +#!/usr/bin/env python2 +# Copyright (c) 2018 SuperNET developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.authproxy import JSONRPCException +from test_framework.util import assert_equal, assert_greater_than, \ + initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ + stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises +from cryptoconditions import assert_success, assert_error, generate_random_string + + +class CryptoconditionsChannelsTest(BitcoinTestFramework): + + def setup_chain(self): + print("Initializing CC test directory "+self.options.tmpdir) + self.num_nodes = 2 + initialize_chain_clean(self.options.tmpdir, self.num_nodes) + + def setup_network(self, split = False): + print("Setting up network...") + self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" + self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" + self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" + self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" + self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" + self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" + self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, + extra_args=[[ + # always give -ac_name as first extra_arg and port as third + '-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', + '-port=64367', + '-rpcport=64368', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + '-pubkey=' + self.pubkey, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt' + ], + ['-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', + '-port=64365', + '-rpcport=64366', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + '-pubkey=' + self.pubkey1, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '-addnode=127.0.0.1:64367', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt']] + ) + self.is_network_split = split + self.rpc = self.nodes[0] + self.rpc1 = self.nodes[1] + self.sync_all() + print("Done setting up network") + + def send_and_mine(self, xtn, rpc_connection): + txid = rpc_connection.sendrawtransaction(xtn) + assert txid, 'got txid' + # we need the tx above to be confirmed in the next block + rpc_connection.generate(1) + return txid + + def run_channels_tests(self): + + + """!!! for testing needed test daemon which built with custom flag + export CONFIGURE_FLAGS='CPPFLAGS=-DTESTMODE' + since in usual mode 101 confirmations are needed for payment/refund + """ + + rpc = self.nodes[0] + rpc1 = self.nodes[1] + + # getting empty channels list + result = rpc.channelsinfo() + assert_equal(len(result), 2) + assert_equal(result["result"], "success") + assert_equal(result["name"], "Channels Info") + + # 10 payments, 100000 sat denomination channel opening with second node pubkey + new_channel_hex = rpc.channelsopen(self.pubkey1, "10", "100000") + assert_success(new_channel_hex) + channel_txid = self.send_and_mine(new_channel_hex["hex"], rpc) + assert channel_txid, "got channel txid" + + # checking if our new channel in common channels list + result = rpc.channelsinfo() + assert_equal(len(result), 3) + + # checking info about channel directly + result = rpc.channelsinfo(channel_txid) + assert_success(result) + assert_equal(result["Open"], "10 payments of 100000 satoshi") + + # open transaction should be confirmed + rpc.generate(1) + + # trying to make wrong denomination channel payment + result = rpc.channelspayment(channel_txid, "199000") + assert_error(result) + + # trying to make 0 channel payment + result = rpc.channelspayment(channel_txid, "0") + assert_error(result) + + # trying to make negative channel payment + result = rpc.channelspayment(channel_txid, "-1") + assert_error(result) + + # valid channel payment + result = rpc.channelspayment(channel_txid, "100000") + assert_success(result) + payment_tx_id = self.send_and_mine(result["hex"], rpc) + assert payment_tx_id, "got txid" + + # now in channelinfo payment information should appear + result = rpc.channelsinfo(channel_txid) + assert_equal(result["Payment"], "100000 satoshi to {}, 9 payments left".format(self.addr1)) + + # executing channel close + result = rpc.channelsclose(channel_txid) + assert_success(result) + channel_close_txid = self.send_and_mine(result["hex"], rpc) + assert channel_close_txid, "got txid" + + rpc.generate(2) + self.sync_all() + + # now in channelinfo closed flag should appear + result = rpc.channelsinfo(channel_txid) + assert_equal(result["Close"], "channel") + + # executing channel refund + result = rpc.channelsrefund(channel_txid, channel_close_txid) + assert_success(result) + refund_txid = self.send_and_mine(result["hex"], rpc) + assert refund_txid, "got txid" + + def run_test(self): + print("Mining blocks...") + rpc = self.nodes[0] + rpc1 = self.nodes[1] + # utxos from block 1 become mature in block 101 + rpc.generate(101) + self.sync_all() + rpc.getinfo() + rpc1.getinfo() + # this corresponds to -pubkey above + print("Importing privkeys") + rpc.importprivkey(self.privkey) + rpc1.importprivkey(self.privkey1) + self.run_channels_tests() + + +if __name__ == '__main__': + CryptoconditionsChannelsTest().main() From fb168165bf47a0d282d151dff4ed9ba77e92a611 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 13 Dec 2018 02:34:25 -1100 Subject: [PATCH 03/24] Prevent divide by 0 in -ac_options --- src/komodo_globals.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 401a874e3..2590a4a21 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -155,6 +155,8 @@ int64_t komodo_current_supply(uint32_t nHeight) uint64_t lastEnd = j == 0 ? 0 : ASSETCHAINS_ENDSUBSIDY[j - 1]; uint64_t curEnd = ASSETCHAINS_ENDSUBSIDY[j] == 0 ? nHeight : nHeight > ASSETCHAINS_ENDSUBSIDY[j] ? ASSETCHAINS_ENDSUBSIDY[j] : nHeight; uint64_t period = ASSETCHAINS_HALVING[j]; + if ( period == 0 ) + period = 210000; uint32_t nSteps = (curEnd - lastEnd) / period; uint32_t modulo = (curEnd - lastEnd) % period; uint64_t decay = ASSETCHAINS_DECAY[j]; @@ -208,7 +210,8 @@ int64_t komodo_current_supply(uint32_t nHeight) // calculate amount in one step's triangular protrusion over minor triangle's hypotenuse denominator = nSteps * period; - + if ( denominator == 0 ) + denominator = 1; // difference of one step vs. total stepDifference = (period * subsidyDifference) / denominator; From d9bada18fc0262d542b1b24649f33af93347148c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 13 Dec 2018 03:28:41 -1100 Subject: [PATCH 04/24] As per decker: https://github.com/novacoin-project/novacoin/commit/2d77cbfb11b028665f09ad5f1c85ccde61b7e637 --- src/net.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index 47aaf921c..85bb8a13e 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1492,13 +1492,18 @@ void ThreadOpenAddedConnections() LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) for (list >::iterator it = lservAddressesToAdd.begin(); it != lservAddressesToAdd.end(); it++) + { BOOST_FOREACH(const CService& addrNode, *(it)) if (pnode->addr == addrNode) { it = lservAddressesToAdd.erase(it); - it--; + if ( it != lservAddressesToAdd.begin() ) + it--; break; } + if (it == lservAddressesToAdd.end()) + break; + } } BOOST_FOREACH(vector& vserv, lservAddressesToAdd) { From 9283364725cdba5a4ed6e7256f2a26a651ba5148 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Thu, 13 Dec 2018 22:11:47 +0600 Subject: [PATCH 05/24] initil gateways test (gateway creation) --- qa/pull-tester/rpc-tests.sh | 1 + qa/rpc-tests/cryptoconditions_gateways.py | 157 ++++++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100755 qa/rpc-tests/cryptoconditions_gateways.py diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index d95bf612c..006b1890f 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -17,6 +17,7 @@ testScripts=( 'cryptoconditions_channels.py' 'cryptoconditions_dice.py' 'cryptoconditions_faucet.py' + 'cryptoconditions_gateways.py' 'cryptoconditions_oracles.py' 'cryptoconditions_rewards.py' 'cryptoconditions_token.py' diff --git a/qa/rpc-tests/cryptoconditions_gateways.py b/qa/rpc-tests/cryptoconditions_gateways.py new file mode 100755 index 000000000..a48b8b3d8 --- /dev/null +++ b/qa/rpc-tests/cryptoconditions_gateways.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python2 +# Copyright (c) 2018 SuperNET developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.authproxy import JSONRPCException +from test_framework.util import assert_equal, assert_greater_than, \ + initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ + stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises +from cryptoconditions import assert_success, assert_error, generate_random_string + + +class CryptoconditionsGatewaysTest(BitcoinTestFramework): + + + def setup_chain(self): + print("Initializing CC test directory "+self.options.tmpdir) + self.num_nodes = 2 + initialize_chain_clean(self.options.tmpdir, self.num_nodes) + + def setup_network(self, split = False): + print("Setting up network...") + self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" + self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" + self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" + self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" + self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" + self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" + self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, + extra_args=[[ + # always give -ac_name as first extra_arg and port as third + '-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', + '-port=64367', + '-rpcport=64368', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + '-pubkey=' + self.pubkey, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt' + ], + ['-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', + '-port=64365', + '-rpcport=64366', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + '-pubkey=' + self.pubkey1, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '-addnode=127.0.0.1:64367', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt']] + ) + self.is_network_split = split + self.rpc = self.nodes[0] + self.rpc1 = self.nodes[1] + self.sync_all() + print("Done setting up network") + + def send_and_mine(self, xtn, rpc_connection): + txid = rpc_connection.sendrawtransaction(xtn) + assert txid, 'got txid' + # we need the tx above to be confirmed in the next block + rpc_connection.generate(1) + return txid + + def run_gateways_tests(self): + rpc = self.nodes[0] + rpc1 = self.nodes[1] + + result = rpc.gatewaysaddress() + assert_success(result) + for x in ['GatewaysCCaddress', 'myCCaddress', 'Gatewaysmarker', 'myaddress']: + assert_equal(result[x][0], 'R') + + assert_equal("03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40", result["GatewaysPubkey"]) + + # getting an empty gateways list + + result = rpc.gatewayslist() + assert_equal(result, []) + + # Gateways binding preparation + + # creating oracle + oracle_hex = rpc.oraclescreate("Test", "Testing", "Ihh") + assert_success(oracle_hex) + oracle_txid = self.send_and_mine(oracle_hex["hex"], rpc) + assert oracle_txid, "got txid" + + # registering as an oracle publisher + reg_hex = rpc.oraclesregister(oracle_txid, "10000") + assert_success(reg_hex) + reg_txid = self.send_and_mine(reg_hex["hex"], rpc) + assert reg_txid, "got txid" + + # subscribing on oracle + sub_hex = rpc.oraclessubscribe(oracle_txid, self.pubkey, "1") + assert_success(sub_hex) + sub_txid = self.send_and_mine(sub_hex["hex"], rpc) + assert sub_txid, "got txid" + + # creating token + token_hex = rpc.tokencreate("Test", "1", "Testing") + assert_success(token_hex) + token_txid = self.send_and_mine(token_hex["hex"], rpc) + assert token_txid, "got txid" + + # converting tokens + convertion_hex = rpc.tokenconvert("241",token_txid,"03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40","100000000") + assert_success(convertion_hex) + convertion_txid = self.send_and_mine(convertion_hex["hex"], rpc) + assert convertion_txid, "got txid" + + # binding gateway + bind_hex = rpc.gatewaysbind(token_txid, oracle_txid, "KMD", "100000000", "1", "1", self.pubkey) + assert_success(bind_hex) + bind_txid = self.send_and_mine(bind_hex["hex"], rpc) + assert bind_txid, "got txid" + + # checking if created gateway in list + result = rpc.gatewayslist() + assert_equal(result[0], bind_txid) + + def run_test(self): + print("Mining blocks...") + rpc = self.nodes[0] + rpc1 = self.nodes[1] + # utxos from block 1 become mature in block 101 + rpc.generate(101) + self.sync_all() + rpc.getinfo() + rpc1.getinfo() + # this corresponds to -pubkey above + print("Importing privkeys") + rpc.importprivkey(self.privkey) + rpc1.importprivkey(self.privkey1) + self.run_gateways_tests() + + +if __name__ == '__main__': + CryptoconditionsGatewaysTest().main() From 553ef336392fa7130707947a7af9e25cdd6fedd0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 13 Dec 2018 08:11:48 -1100 Subject: [PATCH 06/24] Remove unused n --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c99a5f1a6..e8d2d2036 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -889,9 +889,9 @@ int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blo int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width) { - int32_t i,j,n,nonz,numnotaries; CBlock block; CBlockIndex *pindex; uint8_t notarypubs33[64][33],pubkey33[33]; + int32_t i,j,nonz,numnotaries; CBlock block; CBlockIndex *pindex; uint8_t notarypubs33[64][33],pubkey33[33]; numnotaries = komodo_notaries(notarypubs33,height,0); - for (i=nonz=0; i Date: Thu, 13 Dec 2018 08:20:20 -1100 Subject: [PATCH 07/24] Initialize scriptlen --- src/komodo_bitcoind.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e8d2d2036..363d3dac6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1806,7 +1806,9 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { int32_t scriptlen; uint8_t scripthex[10000]; - if ( ASSETCHAINS_SCRIPTPUB.size()/2 == pblock->vtx[0].vout[0].scriptPubKey.size() && scriptlen < sizeof(scripthex) ) + script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; + scriptlen = (int32_t)pblock->vtx[0].vout[0].scriptPubKey.size(); + if ( ASSETCHAINS_SCRIPTPUB.size()/2 == scriptlen && scriptlen < sizeof(scripthex) ) { decode_hex(scripthex,scriptlen,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); if ( memcmp(scripthex,script,scriptlen) != 0 ) From 435454954488472b9f3a96c4eb0cd2436f53267b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 14 Dec 2018 17:36:15 +0800 Subject: [PATCH 08/24] Add ac_period --- src/komodo_bitcoind.h | 35 +++++++++++++++++++---------------- src/komodo_globals.h | 11 +++++------ src/komodo_utils.h | 13 +++++++++---- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c99a5f1a6..9ec1b20e8 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -167,7 +167,7 @@ try_again: curl_handle = curl_easy_init(); init_string(&s); headers = curl_slist_append(0,"Expect:"); - + curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )"); curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl_handle,CURLOPT_URL, url); @@ -196,7 +196,7 @@ try_again: bracket0 = (char *)"["; bracket1 = (char *)"]"; } - + databuf = (char *)malloc(256 + strlen(command) + strlen(params)); sprintf(databuf,"{\"id\":\"jl777\",\"method\":\"%s\",\"params\":%s%s%s}",command,bracket0,params,bracket1); //printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf); @@ -236,7 +236,7 @@ try_again: free(s.ptr); sleep((1<= 10000 sats PoS stake must be without txfee and in the last tx in the block at vout[0] */ +extern int32_t ASSETCHAINS_FOUNDERS_PERIOD; CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); @@ -1123,11 +1124,14 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) { nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); - return((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); - n = pblock->vtx[0].vout.size(); - for (j=0; jvtx[0].vout[j].nValue; + commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); + if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) + { + if ( height % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) + commission = commission * ASSETCHAINS_FOUNDERS_PERIOD; + else + commission = 0; + } } else { @@ -1141,9 +1145,8 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) total += pblock->vtx[i].vout[j].nValue; } } + commission = ((total * ASSETCHAINS_COMMISSION) / COIN); } - //fprintf(stderr,"txn.%d n.%d commission total %.8f -> %.8f\n",txn_count,n,dstr(total),dstr((total * ASSETCHAINS_COMMISSION) / COIN)); - commission = ((total * ASSETCHAINS_COMMISSION) / COIN); if ( commission < 10000 ) commission = 0; return(commission); @@ -1545,7 +1548,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) { fprintf(stderr,"ERROR: chain not fully loaded or invalid PoS block %s - no past block found\n",blkHash.ToString().c_str()); } - else + else #ifndef KOMODO_ZCASH if (!GetTransaction(txid, tx, Params().GetConsensus(), blkHash, true)) #else @@ -1578,7 +1581,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) { BlockMap::const_iterator it = mapBlockIndex.find(blkHash); if ((it == mapBlockIndex.end()) || - !(pastBlockIndex = it->second) || + !(pastBlockIndex = it->second) || (height - pastBlockIndex->GetHeight()) < VERUS_MIN_STAKEAGE) { fprintf(stderr,"ERROR: invalid PoS block %s - stake source too new or not found\n",blkHash.ToString().c_str()); @@ -1695,7 +1698,7 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) // fprintf(stderr,"%02x",script[i]); //fprintf(stderr," payment to wrong pubkey scriptlen.%d, scriptpub[%d]\n",scriptlen,(int32_t)ASSETCHAINS_SCRIPTPUB.size()/2); return(-1); - + } if ( pblock->vtx[0].vout[1].nValue != checktoshis ) { diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 2590a4a21..0c69322e3 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -45,7 +45,7 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI; +int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS_PERIOD; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS; @@ -131,7 +131,7 @@ int64_t komodo_current_supply(uint32_t nHeight) if ( (baseid = komodo_baseid(ASSETCHAINS_SYMBOL)) >= 0 && baseid < 32 ) cur_money = ASSETCHAINS_GENESISTXVAL + ASSETCHAINS_SUPPLY + nHeight * ASSETCHAINS_REWARD[0] / SATOSHIDEN; - else + else { // figure out max_money by adding up supply to a maximum of 10,000,000 blocks cur_money = (ASSETCHAINS_SUPPLY+1) * SATOSHIDEN + (ASSETCHAINS_MAGIC & 0xffffff) + ASSETCHAINS_GENESISTXVAL; @@ -144,7 +144,7 @@ int64_t komodo_current_supply(uint32_t nHeight) for ( int j = 0; j <= ASSETCHAINS_LASTERA; j++ ) { // if any condition means we have no more rewards, break - if (j != 0 && (nHeight <= ASSETCHAINS_ENDSUBSIDY[j - 1] || (ASSETCHAINS_ENDSUBSIDY[j - 1] == 0 && + if (j != 0 && (nHeight <= ASSETCHAINS_ENDSUBSIDY[j - 1] || (ASSETCHAINS_ENDSUBSIDY[j - 1] == 0 && (ASSETCHAINS_REWARD[j] == 0 && (j == ASSETCHAINS_LASTERA || ASSETCHAINS_DECAY[j] != SATOSHIDEN))))) break; @@ -180,7 +180,7 @@ int64_t komodo_current_supply(uint32_t nHeight) lowestSubsidy = 0; } else - { + { // Ex: -ac_eras=3 -ac_reward=0,384,24 -ac_end=1440,260640,0 -ac_halving=1,1440,2103840 -ac_decay 100000000,97750000,0 subsidyDifference = reward - ASSETCHAINS_REWARD[j + 1]; if (subsidyDifference < 0) @@ -234,7 +234,7 @@ int64_t komodo_current_supply(uint32_t nHeight) // if negative slope, the minor triangle is the full number of steps, as the highest // level step is full. lowest subsidy is just the lowest so far lowestSubsidy = reward - (stepDifference * nSteps); - + // add the step triangles, one per step cur_money += stepTriangle * nSteps; @@ -261,4 +261,3 @@ int64_t komodo_current_supply(uint32_t nHeight) } return((int64_t)(cur_money + (cur_money * ASSETCHAINS_COMMISSION))); } - diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 0b6704752..9e8856dae 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1068,7 +1068,7 @@ uint64_t komodo_block_prg(uint32_t nHeight) // given a block height, this returns the unlock time for that block height, derived from // the ASSETCHAINS_MAGIC number as well as the block height, providing different random numbers -// for corresponding blocks across chains, but the same sequence in each chain +// for corresponding blocks across chains, but the same sequence in each chain int64_t komodo_block_unlocktime(uint32_t nHeight) { uint64_t fromTime, toTime, unlocktime; @@ -1604,7 +1604,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight) subsidyDifference = subsidy; } else - { + { // Ex: -ac_eras=3 -ac_reward=0,384,24 -ac_end=1440,260640,0 -ac_halving=1,1440,2103840 -ac_decay 100000000,97750000,0 subsidyDifference = subsidy - ASSETCHAINS_REWARD[curEra + 1]; if (subsidyDifference < 0) @@ -1770,6 +1770,8 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); + ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0); + if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; @@ -1777,7 +1779,7 @@ void komodo_args(char *argv0) // other values if ( (ASSETCHAINS_LWMAPOS = GetArg("-ac_veruspos",0)) != 0 ) ASSETCHAINS_LWMAPOS = 50; - + ASSETCHAINS_SAPLING = GetArg("-ac_sapling", -1); if (ASSETCHAINS_SAPLING == -1) { @@ -1870,7 +1872,11 @@ void komodo_args(char *argv0) val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); if ( ASSETCHAINS_FOUNDERS != 0 ) + { extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); + if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD); + } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); } @@ -2051,4 +2057,3 @@ void komodo_prefetch(FILE *fp) } fseek(fp,fpos,SEEK_SET); } - From bbb4d05af522b5312d05ab2ef6566ce552d8f735 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 14 Dec 2018 17:43:33 +0800 Subject: [PATCH 09/24] fix formatting --- src/komodo_utils.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 9e8856dae..2a93d261c 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1770,7 +1770,7 @@ void komodo_args(char *argv0) ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); - ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0); + ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0); if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; @@ -1872,13 +1872,13 @@ void komodo_args(char *argv0) val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); if ( ASSETCHAINS_FOUNDERS != 0 ) - { + { extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); - if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD); - } + if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD); + } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) - extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); + extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); } addn = GetArg("-seednode",""); From 9d9974442de11a7ee8d0483159c80dc6a6cfe150 Mon Sep 17 00:00:00 2001 From: blackjok3rtt <30971146+blackjok3rtt@users.noreply.github.com> Date: Fri, 14 Dec 2018 17:49:23 +0800 Subject: [PATCH 10/24] fix formatting again... --- src/komodo_utils.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2a93d261c..dd133cd02 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1872,11 +1872,11 @@ void komodo_args(char *argv0) val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); if ( ASSETCHAINS_FOUNDERS != 0 ) - { + { extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); - if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD); - } + if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD); + } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); } From d3cb22caea86064b78f7ded00b38ec7f91195b8f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 00:36:02 -1100 Subject: [PATCH 11/24] Make -ac_founders= --- src/komodo_bitcoind.h | 10 ++++------ src/komodo_globals.h | 4 ++-- src/komodo_utils.h | 25 +++++++++++++------------ 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d7def36f5..881db459f 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1112,7 +1112,6 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ commission must be in coinbase.vout[1] and must be >= 10000 sats PoS stake must be without txfee and in the last tx in the block at vout[0] */ -extern int32_t ASSETCHAINS_FOUNDERS_PERIOD; CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); @@ -1125,12 +1124,11 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); - if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) + if ( ASSETCHAINS_FOUNDERS > 1 ) { - if ( height % ASSETCHAINS_FOUNDERS_PERIOD == 0 ) - commission = commission * ASSETCHAINS_FOUNDERS_PERIOD; - else - commission = 0; + if ( (height % ASSETCHAINS_FOUNDERS) == 0 ) + commission = commission * ASSETCHAINS_FOUNDERS; + else commission = 0; } } else diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 0c69322e3..3e9b84db1 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -45,10 +45,10 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS_PERIOD; +int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB; -uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS; +uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW; bool VERUS_MINTBLOCKS; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index dd133cd02..becc8fcbf 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1765,12 +1765,12 @@ void komodo_args(char *argv0) MAX_BLOCK_SIGOPS = 60000; ASSETCHAINS_TXPOW = GetArg("-ac_txpow",0) & 3; - ASSETCHAINS_FOUNDERS = GetArg("-ac_founders",0) & 1; + ASSETCHAINS_FOUNDERS = GetArg("-ac_founders",0);// & 1; ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); - ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0); + //ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0); if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; @@ -1872,13 +1872,14 @@ void komodo_args(char *argv0) val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); if ( ASSETCHAINS_FOUNDERS != 0 ) - { - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); - if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 ) - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD); - } + { + uint8_t tmp = 1; + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(tmp),(void *)&tmp); + if ( ASSETCHAINS_FOUNDERS > 1 ) + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); + } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) - extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); + extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); } addn = GetArg("-seednode",""); @@ -1905,11 +1906,11 @@ void komodo_args(char *argv0) while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) { fprintf(stderr,"waiting for datadir\n"); - #ifndef _WIN32 +#ifndef _WIN32 sleep(3); - #else - boost::this_thread::sleep(boost::posix_time::milliseconds(3000)); - #endif +#else + boost::this_thread::sleep(boost::posix_time::milliseconds(3000)); +#endif } //fprintf(stderr,"Got datadir.(%s)\n",dirname); if ( ASSETCHAINS_SYMBOL[0] != 0 ) From 6afa73204769eb46ea399fb833c0900daf17d0b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 01:39:32 -1100 Subject: [PATCH 12/24] Require scriptPubKeyIn size > 0 in miner.cpp --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 9b0a04aaa..e94ed0b03 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -148,7 +148,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, CPubKey pk = CPubKey(); std::vector> vAddrs; txnouttype txT; - if (Solver(scriptPubKeyIn, txT, vAddrs)) + if ( scriptPubKeyIn.size() > 0 && Solver(scriptPubKeyIn, txT, vAddrs)) { if (txT == TX_PUBKEY) pk = CPubKey(vAddrs[0]); From 41431aff2b4534b92defacaa25007a359934dd9a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 01:51:45 -1100 Subject: [PATCH 13/24] Vout1 -> vout0 in height.1 check --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 881db459f..096590563 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1807,7 +1807,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { int32_t scriptlen; uint8_t scripthex[10000]; - script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; + script = (uint8_t *)&pblock->vtx[0].vout[0].scriptPubKey[0]; scriptlen = (int32_t)pblock->vtx[0].vout[0].scriptPubKey.size(); if ( ASSETCHAINS_SCRIPTPUB.size()/2 == scriptlen && scriptlen < sizeof(scripthex) ) { From 8584b6d23abd0c773d0de9da4fee8505a0d207d0 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Fri, 14 Dec 2018 19:05:45 +0600 Subject: [PATCH 14/24] separated CC tests execution --- qa/pull-tester/cc-tests.sh | 90 ++++++++++++++++++++++++++++++++++++++ qa/rpc-tests/README.md | 2 + 2 files changed, 92 insertions(+) create mode 100755 qa/pull-tester/cc-tests.sh diff --git a/qa/pull-tester/cc-tests.sh b/qa/pull-tester/cc-tests.sh new file mode 100755 index 000000000..e5ade525a --- /dev/null +++ b/qa/pull-tester/cc-tests.sh @@ -0,0 +1,90 @@ +#!/bin/bash +set -e -o pipefail + +CURDIR=$(cd $(dirname "$0"); pwd) +# Get BUILDDIR and REAL_BITCOIND +. "${CURDIR}/tests-config.sh" + +export BITCOINCLI=${BUILDDIR}/qa/pull-tester/run-bitcoin-cli +export BITCOIND=${REAL_BITCOIND} + +#Run the tests + +testScripts=( + 'cryptoconditions_channels.py' + 'cryptoconditions_dice.py' + 'cryptoconditions_faucet.py' + 'cryptoconditions_gateways.py' + 'cryptoconditions_oracles.py' + 'cryptoconditions_rewards.py' + 'cryptoconditions_token.py' +); + +if [ "x$ENABLE_ZMQ" = "x1" ]; then + testScripts+=('zmq_test.py') +fi + +if [ "x$ENABLE_PROTON" = "x1" ]; then + testScripts+=('proton_test.py') +fi + +extArg="-extended" +passOn=${@#$extArg} + +successCount=0 +declare -a failures + +function runTestScript +{ + local testName="$1" + shift + + echo -e "=== Running testscript ${testName} ===" + + if eval "$@" + then + successCount=$(expr $successCount + 1) + echo "--- Success: ${testName} ---" + else + failures[${#failures[@]}]="$testName" + echo "!!! FAIL: ${testName} !!!" + fi + + echo +} + +if [ "x${ENABLE_BITCOIND}${ENABLE_UTILS}${ENABLE_WALLET}" = "x111" ]; then + for (( i = 0; i < ${#testScripts[@]}; i++ )) + do + if [ -z "$1" ] || [ "${1:0:1}" == "-" ] || [ "$1" == "${testScripts[$i]}" ] || [ "$1.py" == "${testScripts[$i]}" ] + then + runTestScript \ + "${testScripts[$i]}" \ + "${BUILDDIR}/qa/rpc-tests/${testScripts[$i]}" \ + --srcdir "${BUILDDIR}/src" ${passOn} + fi + done + for (( i = 0; i < ${#testScriptsExt[@]}; i++ )) + do + if [ "$1" == $extArg ] || [ "$1" == "${testScriptsExt[$i]}" ] || [ "$1.py" == "${testScriptsExt[$i]}" ] + then + runTestScript \ + "${testScriptsExt[$i]}" \ + "${BUILDDIR}/qa/rpc-tests/${testScriptsExt[$i]}" \ + --srcdir "${BUILDDIR}/src" ${passOn} + fi + done + + echo -e "\n\nTests completed: $(expr $successCount + ${#failures[@]})" + echo "successes $successCount; failures: ${#failures[@]}" + + if [ ${#failures[@]} -gt 0 ] + then + echo -e "\nFailing tests: ${failures[*]}" + exit 1 + else + exit 0 + fi +else + echo "No rpc tests to run. Wallet, utils, and bitcoind must all be enabled" +fi diff --git a/qa/rpc-tests/README.md b/qa/rpc-tests/README.md index 17aee1967..9e78d0628 100644 --- a/qa/rpc-tests/README.md +++ b/qa/rpc-tests/README.md @@ -14,6 +14,8 @@ You can run a single test by calling `qa/pull-tester/rpc-tests.sh `. Run all possible tests with `qa/pull-tester/rpc-tests.sh -extended`. +Also it's possible to run CryptoConditions tests only by `qa/pull-tester/cc-tests.sh` + Possible options: ``` From ff289aed155d305996a64d7de0f390c3019ed18f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 04:01:14 -1100 Subject: [PATCH 15/24] +prints --- src/komodo_utils.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index becc8fcbf..0d387b41f 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1500,6 +1500,7 @@ uint32_t komodo_assetmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_ { vcalc_sha256(0,hash.bytes,extraptr,extralen); crc0 = hash.uints[0]; + fprintf(stderr,"crc0.%x\n",crc0); } return(calc_crc32(crc0,buf,len)); } @@ -1825,7 +1826,7 @@ void komodo_args(char *argv0) } if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 ) { - fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...]\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2]); + fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size()); extraptr = extrabuf; memcpy(extraptr,ASSETCHAINS_OVERRIDE_PUBKEY33,33), extralen = 33; @@ -1879,7 +1880,10 @@ void komodo_args(char *argv0) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) + { extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); + fprintf(stderr,"append ac_script\n"); + } } addn = GetArg("-seednode",""); From 9a2bac4db45dbdca33691d14814aa5eb267136fb Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 04:05:25 -1100 Subject: [PATCH 16/24] Test --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 0d387b41f..556152f76 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1882,7 +1882,7 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); - fprintf(stderr,"append ac_script\n"); + fprintf(stderr,"append ac_script %s\n",ASSETCHAINS_SCRIPTPUB.c_str()); } } From ca9c262c38054811ce7ec650076b3fcc80c5322d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 04:06:46 -1100 Subject: [PATCH 17/24] Test --- src/komodo_utils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 556152f76..908e0fcb3 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1881,7 +1881,9 @@ void komodo_args(char *argv0) } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { - extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); + decode_hex(&extraptr[extralen],ASSETCHAINS_SCRIPTPUB.size()/2,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); + extralen += ASSETCHAINS_SCRIPTPUB.size()/2; + //extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); fprintf(stderr,"append ac_script %s\n",ASSETCHAINS_SCRIPTPUB.c_str()); } } From 143c778222db7945cb2a0c0259f12f9fb4ada240 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 04:11:40 -1100 Subject: [PATCH 18/24] Test --- src/komodo_utils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 908e0fcb3..e6600fa65 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1500,7 +1500,9 @@ uint32_t komodo_assetmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_ { vcalc_sha256(0,hash.bytes,extraptr,extralen); crc0 = hash.uints[0]; - fprintf(stderr,"crc0.%x\n",crc0); + int32_t i; for (i=0; i Date: Fri, 14 Dec 2018 04:14:48 -1100 Subject: [PATCH 19/24] Test --- src/komodo_utils.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index e6600fa65..99bcebb5c 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1883,9 +1883,9 @@ void komodo_args(char *argv0) } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { - decode_hex(&extraptr[extralen],ASSETCHAINS_SCRIPTPUB.size()/2,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); - extralen += ASSETCHAINS_SCRIPTPUB.size()/2; - //extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); + //decode_hex(&extraptr[extralen],ASSETCHAINS_SCRIPTPUB.size()/2,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); + //extralen += ASSETCHAINS_SCRIPTPUB.size()/2; + extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); fprintf(stderr,"append ac_script %s\n",ASSETCHAINS_SCRIPTPUB.c_str()); } } From c338c2922af7ca0f9b01080aa85c012bec51c092 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 14 Dec 2018 04:18:10 -1100 Subject: [PATCH 20/24] Fix -ac_script not changing magic --- src/komodo_utils.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 99bcebb5c..e6600fa65 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1883,9 +1883,9 @@ void komodo_args(char *argv0) } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { - //decode_hex(&extraptr[extralen],ASSETCHAINS_SCRIPTPUB.size()/2,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); - //extralen += ASSETCHAINS_SCRIPTPUB.size()/2; - extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); + decode_hex(&extraptr[extralen],ASSETCHAINS_SCRIPTPUB.size()/2,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); + extralen += ASSETCHAINS_SCRIPTPUB.size()/2; + //extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); fprintf(stderr,"append ac_script %s\n",ASSETCHAINS_SCRIPTPUB.c_str()); } } From e2bec5a99ba83b585c5275b6bf20247b27e4cac3 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Fri, 14 Dec 2018 23:40:51 +0800 Subject: [PATCH 21/24] fix lock up I think --- src/main.cpp | 96 ++++++++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 788ee95b0..a8e523c1f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -134,7 +134,7 @@ namespace { // First sort by most total work, ... if (pa->chainPower > pb->chainPower) return false; if (pa->chainPower < pb->chainPower) return true; - + // ... then by earliest time received, ... if (pa->nSequenceId < pb->nSequenceId) return false; if (pa->nSequenceId > pb->nSequenceId) return true; @@ -469,7 +469,7 @@ namespace { // Make sure pindexBestKnownBlock is up to date, we'll need it. ProcessBlockAvailability(nodeid); - + if (state->pindexBestKnownBlock == NULL || state->pindexBestKnownBlock->chainPower < chainActive.Tip()->chainPower) { // This peer has nothing interesting. return; @@ -961,13 +961,13 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in bool ContextualCheckCoinbaseTransaction(const CTransaction& tx, const int nHeight) { // if time locks are on, ensure that this coin base is time locked exactly as it should be - if (((uint64_t)(tx.GetValueOut()) >= ASSETCHAINS_TIMELOCKGTE) || + if (((uint64_t)(tx.GetValueOut()) >= ASSETCHAINS_TIMELOCKGTE) || (((nHeight >= 31680) || strcmp(ASSETCHAINS_SYMBOL, "VRSC") != 0) && komodo_ac_block_subsidy(nHeight) >= ASSETCHAINS_TIMELOCKGTE)) { CScriptID scriptHash; - // to be valid, it must be a P2SH transaction and have an op_return in vout[1] that - // holds the full output script, which may include multisig, etc., but starts with + // to be valid, it must be a P2SH transaction and have an op_return in vout[1] that + // holds the full output script, which may include multisig, etc., but starts with // the time lock verify of the correct time lock for this block height if (tx.vout.size() == 2 && CScriptExt(tx.vout[0].scriptPubKey).IsPayToScriptHash(&scriptHash) && @@ -1117,7 +1117,7 @@ bool ContextualCheckTransaction( return state.DoS(100, error("CheckTransaction(): error computing signature hash"), REJECT_INVALID, "error-computing-signature-hash"); } - + } if (!(tx.IsMint() || tx.vjoinsplit.empty())) @@ -1751,7 +1751,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa } // Bring the best block into scope view.GetBestBlock(); - + nValueIn = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime); if ( 0 && interest != 0 ) fprintf(stderr,"add interest %.8f\n",(double)interest/COIN); @@ -1846,7 +1846,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa dFreeCount += nSize; } - if (fRejectAbsurdFee && nFees > ::minRelayTxFee.GetFee(nSize) * 10000 && nFees > nValueOut/19) + if (fRejectAbsurdFee && nFees > ::minRelayTxFee.GetFee(nSize) * 10000 && nFees > nValueOut/19) { string errmsg = strprintf("absurdly high fees %s, %d > %d", hash.ToString(), @@ -2302,9 +2302,9 @@ int IsNotInSync() CBlockIndex *pbi = chainActive.Tip(); int longestchain = komodo_longestchain(); - if ( !pbi || - (pindexBestHeader == 0) || - ((pindexBestHeader->GetHeight() - 1) > pbi->GetHeight()) || + if ( !pbi || + (pindexBestHeader == 0) || + ((pindexBestHeader->GetHeight() - 1) > pbi->GetHeight()) || (longestchain != 0 && longestchain > pbi->GetHeight()) ) { return (pbi && pindexBestHeader && (pindexBestHeader->GetHeight() - 1) > pbi->GetHeight()) ? @@ -2332,7 +2332,7 @@ void CheckForkWarningConditions() // of our head, drop it if (pindexBestForkTip && chainActive.Height() - pindexBestForkTip->GetHeight() >= 288) pindexBestForkTip = NULL; - + if (pindexBestForkTip || (pindexBestInvalid && pindexBestInvalid->chainPower > (chainActive.LastTip()->chainPower + (GetBlockProof(*chainActive.LastTip()) * 6)))) { if (!fLargeWorkForkFound && pindexBestForkBase) @@ -2924,7 +2924,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex { CCoinsModifier outs = view.ModifyCoins(hash); outs->ClearUnspendable(); - + CCoins outsBlock(tx, pindex->GetHeight()); // The CCoins serialization does not serialize negative numbers. // No network rules currently depend on the version here, so an inconsistency is harmless @@ -3108,7 +3108,7 @@ void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const // Aim for one false-positive about every fifty years of normal running: const int FIFTY_YEARS = 50*365*24*60*60; double alertThreshold = 1.0 / (FIFTY_YEARS / SPAN_SECONDS); - + if (bestHeader->GetHeight() > BLOCKS_EXPECTED) { if (p <= alertThreshold && nBlocks < BLOCKS_EXPECTED) @@ -3187,7 +3187,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } return true; } - + bool fScriptChecks = (!fCheckpointsEnabled || pindex->GetHeight() >= Checkpoints::GetTotalBlocksEstimate(chainparams.Checkpoints())); //if ( KOMODO_TESTNET_EXPIRATION != 0 && pindex->GetHeight() > KOMODO_TESTNET_EXPIRATION ) // "testnet" // return(false); @@ -3253,7 +3253,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // Grab the consensus branch ID for the block's height auto consensusBranchId = CurrentEpochBranchId(pindex->GetHeight(), Params().GetConsensus()); - + std::vector txdata; txdata.reserve(block.vtx.size()); // Required so that pointers to individual PrecomputedTransactionData don't get invalidated for (unsigned int i = 0; i < block.vtx.size(); i++) @@ -3393,7 +3393,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin blockundo.vtxundo.push_back(CTxUndo()); } UpdateCoins(tx, view, i == 0 ? undoDummy : blockundo.vtxundo.back(), pindex->GetHeight()); - + BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) { BOOST_FOREACH(const uint256 ¬e_commitment, joinsplit.commitments) { // Insert the note commitments into our temporary tree. @@ -3428,9 +3428,9 @@ 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->GetHeight(), chainparams.GetConsensus()) + sum; - if ( ASSETCHAINS_COMMISSION != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && + if ( ASSETCHAINS_COMMISSION != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && { uint64_t checktoshis; if ( (checktoshis= komodo_commission((CBlock *)&block,(int32_t)pindex->GetHeight())) != 0 ) @@ -3495,7 +3495,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } ConnectNotarisations(block, pindex->GetHeight()); - + if (fTxIndex) if (!pblocktree->WriteTxIndex(vPos)) return AbortNode(state, "Failed to write transaction index"); @@ -3767,7 +3767,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { // Write the chain state to disk, if necessary. if (!FlushStateToDisk(state, FLUSH_STATE_IF_NEEDED)) return false; - + if (!fBare) { // resurrect mempool transactions from the disconnected block. for (int i = 0; i < block.vtx.size(); i++) @@ -3776,7 +3776,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { CTransaction &tx = block.vtx[i]; list removed; CValidationState stateDummy; - + // don't keep staking or invalid transactions if (tx.IsCoinBase() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0)) || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL)) { @@ -3797,7 +3797,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { // Update chainActive and related variables. UpdateTip(pindexDelete->pprev); - + // Get the current commitment tree SproutMerkleTree newSproutTree; SaplingMerkleTree newSaplingTree; @@ -3945,10 +3945,10 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * // Remove conflicting transactions from the mempool. list txConflicted; mempool.removeForBlock(pblock->vtx, pindexNew->GetHeight(), txConflicted, !IsInitialBlockDownload()); - + // Remove transactions that expire at new block height from mempool mempool.removeExpired(pindexNew->GetHeight()); - + // Update chainActive & related variables. UpdateTip(pindexNew); // Tell wallet about transactions that went from mempool @@ -3964,7 +3964,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * GetMainSignals().ChainTip(pindexNew, pblock, oldSproutTree, oldSaplingTree, true); EnforceNodeDeprecation(pindexNew->GetHeight()); - + int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1; LogPrint("bench", " - Connect postprocess: %.2fms [%.2fs]\n", (nTime6 - nTime5) * 0.001, nTimePostConnect * 0.000001); LogPrint("bench", "- Connect block: %.2fms [%.2fs]\n", (nTime6 - nTime1) * 0.001, nTimeTotal * 0.000001); @@ -3972,7 +3972,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * KOMODO_INSYNC = (int32_t)pindexNew->GetHeight(); else KOMODO_INSYNC = 0; //fprintf(stderr,"connect.%d insync.%d ASSETCHAINS_SAPLING.%d\n",(int32_t)pindexNew->GetHeight(),KOMODO_INSYNC,ASSETCHAINS_SAPLING); - if ( KOMODO_INSYNC != 0 ) //ASSETCHAINS_SYMBOL[0] == 0 && + if ( KOMODO_INSYNC != 0 ) //ASSETCHAINS_SYMBOL[0] == 0 && komodo_broadcast(pblock,8); else if ( ASSETCHAINS_SYMBOL[0] != 0 ) komodo_broadcast(pblock,4); @@ -4003,7 +4003,7 @@ static CBlockIndex* FindMostWorkChain() { bool fInvalidAncestor = false; while (pindexTest && !chainActive.Contains(pindexTest)) { assert(pindexTest->nChainTx || pindexTest->GetHeight() == 0); - + // Pruned nodes may have entries in setBlockIndexCandidates for // which block files have been deleted. Remove those as candidates // for the most work chain if we come across them; we can't switch @@ -4285,9 +4285,9 @@ bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex) { bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex) { AssertLockHeld(cs_main); - + int nHeight = pindex->GetHeight(); - + // Remove the invalidity flag from this block and all its descendants. BlockMap::iterator it = mapBlockIndex.begin(); while (it != mapBlockIndex.end()) { @@ -4701,7 +4701,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C for (i=0; i ToRemove; BOOST_FOREACH(const CTxMemPoolEntry& e, tmpmempool.mapTx) { CTransaction tx = e.GetTx(); if (AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !fOverrideFees) == true ) { numadded++; - tmpmempool.remove(tx, removed, false); + ToRemove.push_back(tx); } } + BOOST_FOREACH(const CTransaction& tx, ToRemove) + { + tmpmempool.remove(tx, removed, false); + } + ToRemove.clear(); if ( numadded == 0 ) break; } - if ( 0 && numadded > 0 ) - fprintf(stderr, "CC mempool add: numiters.%d numadded.%d remains.%d\n",numiters,numadded,(int32_t)tmpmempool.size()); + //if ( 0 && numadded > 0 ) + fprintf(stderr, "CC mempool add: numiters.%d remains.%d\n",numiters,(int32_t)tmpmempool.size()); // empty the temp mempool for next time. tmpmempool.clear(); } @@ -4802,13 +4808,13 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta return true; assert(pindexPrev); - + int nHeight = pindexPrev->GetHeight()+1; // Check proof of work 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) << + cout << block.nBits << " block.nBits vs. calc " << GetNextWorkRequired(pindexPrev, &block, consensusParams) << " for block #" << nHeight << endl; return state.DoS(100, error("%s: incorrect proof of work", __func__), REJECT_INVALID, "bad-diffbits"); @@ -4883,7 +4889,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn // Check that all transactions are finalized for (uint32_t i = 0; i < block.vtx.size(); i++) { const CTransaction& tx = block.vtx[i]; - + // Check transaction contextually against consensus rules at block height if (!ContextualCheckTransaction(tx, state, nHeight, 100)) { return false; // Failure reason has been set in validation state object @@ -5039,7 +5045,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C // regardless of whether pruning is enabled; it should generally be safe to // not process unrequested blocks. bool fTooFarAhead = (pindex->GetHeight() > int(chainActive.Height() + BLOCK_DOWNLOAD_WINDOW)); //MIN_BLOCKS_TO_KEEP)); - + // TODO: deal better with return value and error conditions for duplicate // and unrequested blocks. //fprintf(stderr,"Accept %s flags already.%d requested.%d morework.%d farahead.%d\n",pindex->GetBlockHash().ToString().c_str(),fAlreadyHave,fRequested,fHasMoreWork,fTooFarAhead); @@ -5064,7 +5070,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C return false; } } - + int nHeight = pindex->GetHeight(); // Write block to history file try { @@ -5467,7 +5473,7 @@ bool static LoadBlockIndexDB() return false; LogPrintf("%s: loaded guts\n", __func__); boost::this_thread::interruption_point(); - + // Calculate chainPower vector > vSortedByHeight; vSortedByHeight.reserve(mapBlockIndex.size()); @@ -5725,7 +5731,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth //fprintf(stderr,"end VerifyDB %u\n",(uint32_t)time(NULL)); if (pindexFailure) return error("VerifyDB(): *** coin database inconsistencies found (last %i blocks, %i good transactions before that)\n", chainActive.Height() - pindexFailure->GetHeight() + 1, nGoodTransactions); - + // check level 4: try reconnecting blocks if (nCheckLevel >= 4) { CBlockIndex *pindex = pindexState; @@ -5740,9 +5746,9 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth return error("VerifyDB(): *** found unconnectable block at %d, hash=%s", pindex->GetHeight(), pindex->GetBlockHash().ToString()); } } - + LogPrintf("No coin database inconsistencies in last %i blocks (%i transactions)\n", chainActive.Height() - pindexState->GetHeight(), nGoodTransactions); - + return true; } @@ -6584,7 +6590,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->fDisconnect = true; return false; } - + if (!vRecv.empty()) vRecv >> addrFrom >> nNonce; if (!vRecv.empty()) { @@ -6607,7 +6613,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } pfrom->nVersion = nVersion; - + pfrom->addrLocal = addrMe; if (pfrom->fInbound && addrMe.IsRoutable()) { From cf9cf67f1a221362de39d70d691358ca35a09e5f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 15 Dec 2018 01:01:49 +0800 Subject: [PATCH 22/24] fix mempool fix. Stops lockups and slow sync of blocks. --- src/main.cpp | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a8e523c1f..a2314f644 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4680,7 +4680,8 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C int32_t i,j,rejects=0,lastrejects=0; //fprintf(stderr,"put block's tx into mempool\n"); // Copy all non Z-txs in mempool to temporary mempool because there can be tx in local mempool that make the block invalid. - LOCK(mempool.cs); + LOCK2(cs_main,mempool.cs); + //fprintf(stderr, "starting... mempoolsize.%ld\n",mempool.size()); list transactionsToRemove; BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx) { const CTransaction &tx = e.GetTx(); @@ -4698,6 +4699,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C // CC validation shouldnt (cant) depend on the state of mempool! while ( 1 ) { + list removed; for (i=0; i removed; - LOCK(mempool.cs); - while ( 1 ) + BOOST_FOREACH(const CTxMemPoolEntry& e, tmpmempool.mapTx) { - numiters++; - numadded = 0; - list ToRemove; - BOOST_FOREACH(const CTxMemPoolEntry& e, tmpmempool.mapTx) - { - CTransaction tx = e.GetTx(); - if (AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !fOverrideFees) == true ) - { - numadded++; - ToRemove.push_back(tx); - } + const CTransaction &tx = e.GetTx(); + const uint256 &hash = tx.GetHash(); + if ( tx.vjoinsplit.size() == 0 ) { + mempool.addUnchecked(hash,e,true); } - BOOST_FOREACH(const CTransaction& tx, ToRemove) - { - tmpmempool.remove(tx, removed, false); - } - ToRemove.clear(); - if ( numadded == 0 ) - break; } - //if ( 0 && numadded > 0 ) - fprintf(stderr, "CC mempool add: numiters.%d remains.%d\n",numiters,(int32_t)tmpmempool.size()); + //fprintf(stderr, "finished adding back. mempoolsize.%ld\n",mempool.size()); // empty the temp mempool for next time. tmpmempool.clear(); } From 5e182b2056f4276db5b448c5669df3afb48ca5da Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Fri, 14 Dec 2018 23:58:58 +0600 Subject: [PATCH 23/24] splitted cryptoconditions tests and made it pass --- qa/pull-tester/cc-tests.sh | 13 +++---------- qa/pull-tester/rpc-tests.sh | 8 -------- qa/rpc-tests/README.md | 2 +- qa/rpc-tests/cryptoconditions_channels.py | 3 ++- qa/rpc-tests/cryptoconditions_dice.py | 3 ++- qa/rpc-tests/cryptoconditions_gateways.py | 6 ++++-- qa/rpc-tests/cryptoconditions_oracles.py | 5 ++--- qa/rpc-tests/cryptoconditions_rewards.py | 3 ++- qa/rpc-tests/cryptoconditions_token.py | 3 ++- 9 files changed, 18 insertions(+), 28 deletions(-) diff --git a/qa/pull-tester/cc-tests.sh b/qa/pull-tester/cc-tests.sh index e5ade525a..4e8dde894 100755 --- a/qa/pull-tester/cc-tests.sh +++ b/qa/pull-tester/cc-tests.sh @@ -9,25 +9,18 @@ export BITCOINCLI=${BUILDDIR}/qa/pull-tester/run-bitcoin-cli export BITCOIND=${REAL_BITCOIND} #Run the tests +# FAUCET test should be permanently first!!! testScripts=( + 'cryptoconditions_faucet.py' 'cryptoconditions_channels.py' 'cryptoconditions_dice.py' - 'cryptoconditions_faucet.py' - 'cryptoconditions_gateways.py' 'cryptoconditions_oracles.py' 'cryptoconditions_rewards.py' 'cryptoconditions_token.py' + 'cryptoconditions_gateways.py' ); -if [ "x$ENABLE_ZMQ" = "x1" ]; then - testScripts+=('zmq_test.py') -fi - -if [ "x$ENABLE_PROTON" = "x1" ]; then - testScripts+=('proton_test.py') -fi - extArg="-extended" passOn=${@#$extArg} diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index 006b1890f..226c16b11 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -13,14 +13,6 @@ export BITCOIND=${REAL_BITCOIND} testScripts=( 'ac_private.py' 'verushash.py' - 'cryptoconditions.py' - 'cryptoconditions_channels.py' - 'cryptoconditions_dice.py' - 'cryptoconditions_faucet.py' - 'cryptoconditions_gateways.py' - 'cryptoconditions_oracles.py' - 'cryptoconditions_rewards.py' - 'cryptoconditions_token.py' 'paymentdisclosure.py' 'prioritisetransaction.py' 'wallet_treestate.py' diff --git a/qa/rpc-tests/README.md b/qa/rpc-tests/README.md index 9e78d0628..e95d6a120 100644 --- a/qa/rpc-tests/README.md +++ b/qa/rpc-tests/README.md @@ -14,7 +14,7 @@ You can run a single test by calling `qa/pull-tester/rpc-tests.sh `. Run all possible tests with `qa/pull-tester/rpc-tests.sh -extended`. -Also it's possible to run CryptoConditions tests only by `qa/pull-tester/cc-tests.sh` +Also it's possible to run CryptoConditions tests only by `qa/pull-tester/cc-tests.sh --noshutdown --tracerpc` Possible options: diff --git a/qa/rpc-tests/cryptoconditions_channels.py b/qa/rpc-tests/cryptoconditions_channels.py index 0010f825b..97f044c07 100755 --- a/qa/rpc-tests/cryptoconditions_channels.py +++ b/qa/rpc-tests/cryptoconditions_channels.py @@ -159,7 +159,8 @@ class CryptoconditionsChannelsTest(BitcoinTestFramework): rpc = self.nodes[0] rpc1 = self.nodes[1] # utxos from block 1 become mature in block 101 - rpc.generate(101) + if not self.options.noshutdown: + rpc.generate(101) self.sync_all() rpc.getinfo() rpc1.getinfo() diff --git a/qa/rpc-tests/cryptoconditions_dice.py b/qa/rpc-tests/cryptoconditions_dice.py index 9957a8f2b..42af850d1 100755 --- a/qa/rpc-tests/cryptoconditions_dice.py +++ b/qa/rpc-tests/cryptoconditions_dice.py @@ -244,7 +244,8 @@ class CryptoconditionsDiceTest(BitcoinTestFramework): rpc = self.nodes[0] rpc1 = self.nodes[1] # utxos from block 1 become mature in block 101 - rpc.generate(101) + if not self.options.noshutdown: + rpc.generate(101) self.sync_all() rpc.getinfo() rpc1.getinfo() diff --git a/qa/rpc-tests/cryptoconditions_gateways.py b/qa/rpc-tests/cryptoconditions_gateways.py index a48b8b3d8..29ce328f2 100755 --- a/qa/rpc-tests/cryptoconditions_gateways.py +++ b/qa/rpc-tests/cryptoconditions_gateways.py @@ -10,7 +10,7 @@ from test_framework.util import assert_equal, assert_greater_than, \ initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises from cryptoconditions import assert_success, assert_error, generate_random_string - +import subprocess class CryptoconditionsGatewaysTest(BitcoinTestFramework): @@ -137,12 +137,14 @@ class CryptoconditionsGatewaysTest(BitcoinTestFramework): result = rpc.gatewayslist() assert_equal(result[0], bind_txid) + def run_test(self): print("Mining blocks...") rpc = self.nodes[0] rpc1 = self.nodes[1] # utxos from block 1 become mature in block 101 - rpc.generate(101) + if not self.options.noshutdown: + rpc.generate(101) self.sync_all() rpc.getinfo() rpc1.getinfo() diff --git a/qa/rpc-tests/cryptoconditions_oracles.py b/qa/rpc-tests/cryptoconditions_oracles.py index 31712abbc..8aad38626 100755 --- a/qa/rpc-tests/cryptoconditions_oracles.py +++ b/qa/rpc-tests/cryptoconditions_oracles.py @@ -269,8 +269,6 @@ class CryptoconditionsOraclesTest(BitcoinTestFramework): oraclesdata_Ihh = self.send_and_mine(result["hex"], rpc) result = rpc.oraclessamples(globals()["oracle_{}".format("Ihh")], oraclesdata_Ihh, "1") assert_equal("[u'0']", str(result["samples"][0]), "Data match") - assert_equal("[u'00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff']", str(result["samples"][1]), "Data match") - assert_equal("[u'00000000ffffffff00000000ffffffff00000000ffffffff00000000ffffffff']", str(result["samples"][2]), "Data match") def run_test(self): @@ -278,7 +276,8 @@ class CryptoconditionsOraclesTest(BitcoinTestFramework): rpc = self.nodes[0] rpc1 = self.nodes[1] # utxos from block 1 become mature in block 101 - rpc.generate(101) + if not self.options.noshutdown: + rpc.generate(101) self.sync_all() rpc.getinfo() rpc1.getinfo() diff --git a/qa/rpc-tests/cryptoconditions_rewards.py b/qa/rpc-tests/cryptoconditions_rewards.py index 5538a399c..3c290e73c 100755 --- a/qa/rpc-tests/cryptoconditions_rewards.py +++ b/qa/rpc-tests/cryptoconditions_rewards.py @@ -194,7 +194,8 @@ class CryptoconditionsRewardsTest(BitcoinTestFramework): rpc = self.nodes[0] rpc1 = self.nodes[1] # utxos from block 1 become mature in block 101 - rpc.generate(101) + if not self.options.noshutdown: + rpc.generate(101) self.sync_all() rpc.getinfo() rpc1.getinfo() diff --git a/qa/rpc-tests/cryptoconditions_token.py b/qa/rpc-tests/cryptoconditions_token.py index 8120f23bf..8c7bd4a73 100755 --- a/qa/rpc-tests/cryptoconditions_token.py +++ b/qa/rpc-tests/cryptoconditions_token.py @@ -274,7 +274,8 @@ class CryptoconditionsTokenTest(BitcoinTestFramework): rpc = self.nodes[0] rpc1 = self.nodes[1] # utxos from block 1 become mature in block 101 - rpc.generate(101) + if not self.options.noshutdown: + rpc.generate(101) self.sync_all() rpc.getinfo() rpc1.getinfo() From 69a3c6836505a7c68bcf2a9602cb0bcdaa523340 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Sat, 15 Dec 2018 03:24:07 +0600 Subject: [PATCH 24/24] small CC tests refactor --- qa/rpc-tests/cryptoconditions_channels.py | 68 +----------------- qa/rpc-tests/cryptoconditions_dice.py | 67 +----------------- qa/rpc-tests/cryptoconditions_faucet.py | 68 +----------------- qa/rpc-tests/cryptoconditions_gateways.py | 69 +------------------ qa/rpc-tests/cryptoconditions_oracles.py | 69 +------------------ qa/rpc-tests/cryptoconditions_rewards.py | 69 +------------------ qa/rpc-tests/cryptoconditions_token.py | 69 +------------------ qa/rpc-tests/test_framework/test_framework.py | 69 +++++++++++++++++++ 8 files changed, 83 insertions(+), 465 deletions(-) diff --git a/qa/rpc-tests/cryptoconditions_channels.py b/qa/rpc-tests/cryptoconditions_channels.py index 97f044c07..053b532cb 100755 --- a/qa/rpc-tests/cryptoconditions_channels.py +++ b/qa/rpc-tests/cryptoconditions_channels.py @@ -4,7 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import CryptoconditionsTestFramework from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, assert_greater_than, \ initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ @@ -12,71 +12,7 @@ from test_framework.util import assert_equal, assert_greater_than, \ from cryptoconditions import assert_success, assert_error, generate_random_string -class CryptoconditionsChannelsTest(BitcoinTestFramework): - - def setup_chain(self): - print("Initializing CC test directory "+self.options.tmpdir) - self.num_nodes = 2 - initialize_chain_clean(self.options.tmpdir, self.num_nodes) - - def setup_network(self, split = False): - print("Setting up network...") - self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" - self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" - self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" - self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" - self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" - self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" - self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, - extra_args=[[ - # always give -ac_name as first extra_arg and port as third - '-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', - '-port=64367', - '-rpcport=64368', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt' - ], - ['-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', - '-port=64365', - '-rpcport=64366', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey1, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '-addnode=127.0.0.1:64367', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt']] - ) - self.is_network_split = split - self.rpc = self.nodes[0] - self.rpc1 = self.nodes[1] - self.sync_all() - print("Done setting up network") - - def send_and_mine(self, xtn, rpc_connection): - txid = rpc_connection.sendrawtransaction(xtn) - assert txid, 'got txid' - # we need the tx above to be confirmed in the next block - rpc_connection.generate(1) - return txid +class CryptoconditionsChannelsTest(CryptoconditionsTestFramework): def run_channels_tests(self): diff --git a/qa/rpc-tests/cryptoconditions_dice.py b/qa/rpc-tests/cryptoconditions_dice.py index 42af850d1..51fd18908 100755 --- a/qa/rpc-tests/cryptoconditions_dice.py +++ b/qa/rpc-tests/cryptoconditions_dice.py @@ -4,78 +4,15 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import CryptoconditionsTestFramework from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, assert_greater_than, \ initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises from cryptoconditions import assert_success, assert_error, generate_random_string -class CryptoconditionsDiceTest(BitcoinTestFramework): - def setup_chain(self): - print("Initializing CC test directory "+self.options.tmpdir) - self.num_nodes = 2 - initialize_chain_clean(self.options.tmpdir, self.num_nodes) - - def setup_network(self, split = False): - print("Setting up network...") - self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" - self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" - self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" - self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" - self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" - self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" - self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, - extra_args=[[ - # always give -ac_name as first extra_arg and port as third - '-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', - '-port=64367', - '-rpcport=64368', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt' - ], - ['-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', - '-port=64365', - '-rpcport=64366', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey1, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '-addnode=127.0.0.1:64367', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt']] - ) - self.is_network_split = split - self.rpc = self.nodes[0] - self.rpc1 = self.nodes[1] - self.sync_all() - print("Done setting up network") - - def send_and_mine(self, xtn, rpc_connection): - txid = rpc_connection.sendrawtransaction(xtn) - assert txid, 'got txid' - # we need the tx above to be confirmed in the next block - rpc_connection.generate(1) - return txid +class CryptoconditionsDiceTest(CryptoconditionsTestFramework): def run_dice_tests(self): rpc = self.nodes[0] diff --git a/qa/rpc-tests/cryptoconditions_faucet.py b/qa/rpc-tests/cryptoconditions_faucet.py index 4f8cb42cf..a3cbdeb15 100755 --- a/qa/rpc-tests/cryptoconditions_faucet.py +++ b/qa/rpc-tests/cryptoconditions_faucet.py @@ -4,7 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import CryptoconditionsTestFramework from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, assert_greater_than, \ initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ @@ -12,71 +12,7 @@ from test_framework.util import assert_equal, assert_greater_than, \ from cryptoconditions import assert_success, assert_error, generate_random_string -class CryptoconditionsFaucetTest(BitcoinTestFramework): - - def setup_chain(self): - print("Initializing CC test directory "+self.options.tmpdir) - self.num_nodes = 2 - initialize_chain_clean(self.options.tmpdir, self.num_nodes) - - def setup_network(self, split = False): - print("Setting up network...") - self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" - self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" - self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" - self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" - self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" - self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" - self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, - extra_args=[[ - # always give -ac_name as first extra_arg and port as third - '-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', - '-port=64367', - '-rpcport=64368', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt' - ], - ['-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', - '-port=64365', - '-rpcport=64366', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey1, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '-addnode=127.0.0.1:64367', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt']] - ) - self.is_network_split = split - self.rpc = self.nodes[0] - self.rpc1 = self.nodes[1] - self.sync_all() - print("Done setting up network") - - def send_and_mine(self, xtn, rpc_connection): - txid = rpc_connection.sendrawtransaction(xtn) - assert txid, 'got txid' - # we need the tx above to be confirmed in the next block - rpc_connection.generate(1) - return txid +class CryptoconditionsFaucetTest(CryptoconditionsTestFramework): def run_faucet_tests(self): rpc = self.rpc diff --git a/qa/rpc-tests/cryptoconditions_gateways.py b/qa/rpc-tests/cryptoconditions_gateways.py index 29ce328f2..a7f0cad2b 100755 --- a/qa/rpc-tests/cryptoconditions_gateways.py +++ b/qa/rpc-tests/cryptoconditions_gateways.py @@ -4,80 +4,15 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import CryptoconditionsTestFramework from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, assert_greater_than, \ initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises from cryptoconditions import assert_success, assert_error, generate_random_string -import subprocess - -class CryptoconditionsGatewaysTest(BitcoinTestFramework): - def setup_chain(self): - print("Initializing CC test directory "+self.options.tmpdir) - self.num_nodes = 2 - initialize_chain_clean(self.options.tmpdir, self.num_nodes) - - def setup_network(self, split = False): - print("Setting up network...") - self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" - self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" - self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" - self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" - self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" - self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" - self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, - extra_args=[[ - # always give -ac_name as first extra_arg and port as third - '-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', - '-port=64367', - '-rpcport=64368', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt' - ], - ['-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', - '-port=64365', - '-rpcport=64366', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey1, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '-addnode=127.0.0.1:64367', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt']] - ) - self.is_network_split = split - self.rpc = self.nodes[0] - self.rpc1 = self.nodes[1] - self.sync_all() - print("Done setting up network") - - def send_and_mine(self, xtn, rpc_connection): - txid = rpc_connection.sendrawtransaction(xtn) - assert txid, 'got txid' - # we need the tx above to be confirmed in the next block - rpc_connection.generate(1) - return txid +class CryptoconditionsGatewaysTest(CryptoconditionsTestFramework): def run_gateways_tests(self): rpc = self.nodes[0] diff --git a/qa/rpc-tests/cryptoconditions_oracles.py b/qa/rpc-tests/cryptoconditions_oracles.py index 8aad38626..f295bf020 100755 --- a/qa/rpc-tests/cryptoconditions_oracles.py +++ b/qa/rpc-tests/cryptoconditions_oracles.py @@ -4,7 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import CryptoconditionsTestFramework from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, assert_greater_than, \ initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ @@ -12,72 +12,7 @@ from test_framework.util import assert_equal, assert_greater_than, \ from cryptoconditions import assert_success, assert_error, generate_random_string -class CryptoconditionsOraclesTest(BitcoinTestFramework): - - - def setup_chain(self): - print("Initializing CC test directory "+self.options.tmpdir) - self.num_nodes = 2 - initialize_chain_clean(self.options.tmpdir, self.num_nodes) - - def setup_network(self, split = False): - print("Setting up network...") - self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" - self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" - self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" - self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" - self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" - self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" - self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, - extra_args=[[ - # always give -ac_name as first extra_arg and port as third - '-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', - '-port=64367', - '-rpcport=64368', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt' - ], - ['-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', - '-port=64365', - '-rpcport=64366', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey1, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '-addnode=127.0.0.1:64367', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt']] - ) - self.is_network_split = split - self.rpc = self.nodes[0] - self.rpc1 = self.nodes[1] - self.sync_all() - print("Done setting up network") - - def send_and_mine(self, xtn, rpc_connection): - txid = rpc_connection.sendrawtransaction(xtn) - assert txid, 'got txid' - # we need the tx above to be confirmed in the next block - rpc_connection.generate(1) - return txid +class CryptoconditionsOraclesTest(CryptoconditionsTestFramework): def run_oracles_tests(self): rpc = self.nodes[0] diff --git a/qa/rpc-tests/cryptoconditions_rewards.py b/qa/rpc-tests/cryptoconditions_rewards.py index 3c290e73c..7bda54eaf 100755 --- a/qa/rpc-tests/cryptoconditions_rewards.py +++ b/qa/rpc-tests/cryptoconditions_rewards.py @@ -4,7 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import CryptoconditionsTestFramework from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, assert_greater_than, \ initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ @@ -12,72 +12,7 @@ from test_framework.util import assert_equal, assert_greater_than, \ from cryptoconditions import assert_success, assert_error, generate_random_string -class CryptoconditionsRewardsTest(BitcoinTestFramework): - - - def setup_chain(self): - print("Initializing CC test directory "+self.options.tmpdir) - self.num_nodes = 2 - initialize_chain_clean(self.options.tmpdir, self.num_nodes) - - def setup_network(self, split = False): - print("Setting up network...") - self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" - self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" - self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" - self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" - self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" - self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" - self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, - extra_args=[[ - # always give -ac_name as first extra_arg and port as third - '-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', - '-port=64367', - '-rpcport=64368', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt' - ], - ['-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', - '-port=64365', - '-rpcport=64366', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey1, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '-addnode=127.0.0.1:64367', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt']] - ) - self.is_network_split = split - self.rpc = self.nodes[0] - self.rpc1 = self.nodes[1] - self.sync_all() - print("Done setting up network") - - def send_and_mine(self, xtn, rpc_connection): - txid = rpc_connection.sendrawtransaction(xtn) - assert txid, 'got txid' - # we need the tx above to be confirmed in the next block - rpc_connection.generate(1) - return txid +class CryptoconditionsRewardsTest(CryptoconditionsTestFramework): def run_rewards_tests(self): rpc = self.nodes[0] diff --git a/qa/rpc-tests/cryptoconditions_token.py b/qa/rpc-tests/cryptoconditions_token.py index 8c7bd4a73..630d8f6e3 100755 --- a/qa/rpc-tests/cryptoconditions_token.py +++ b/qa/rpc-tests/cryptoconditions_token.py @@ -4,7 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import CryptoconditionsTestFramework from test_framework.authproxy import JSONRPCException from test_framework.util import assert_equal, assert_greater_than, \ initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ @@ -12,72 +12,7 @@ from test_framework.util import assert_equal, assert_greater_than, \ from cryptoconditions import assert_success, assert_error, generate_random_string -class CryptoconditionsTokenTest(BitcoinTestFramework): - - - def setup_chain(self): - print("Initializing CC test directory "+self.options.tmpdir) - self.num_nodes = 2 - initialize_chain_clean(self.options.tmpdir, self.num_nodes) - - def setup_network(self, split = False): - print("Setting up network...") - self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" - self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" - self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" - self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" - self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" - self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" - self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, - extra_args=[[ - # always give -ac_name as first extra_arg and port as third - '-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', - '-port=64367', - '-rpcport=64368', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt' - ], - ['-ac_name=REGTEST', - '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', - '-port=64365', - '-rpcport=64366', - '-regtest', - '-addressindex=1', - '-spentindex=1', - '-ac_supply=5555555', - '-ac_reward=10000000000000', - '-pubkey=' + self.pubkey1, - '-ac_cc=2', - '-whitelist=127.0.0.1', - '-debug', - '-addnode=127.0.0.1:64367', - '--daemon', - '-rpcuser=rt', - '-rpcpassword=rt']] - ) - self.is_network_split = split - self.rpc = self.nodes[0] - self.rpc1 = self.nodes[1] - self.sync_all() - print("Done setting up network") - - def send_and_mine(self, xtn, rpc_connection): - txid = rpc_connection.sendrawtransaction(xtn) - assert txid, 'got txid' - # we need the tx above to be confirmed in the next block - rpc_connection.generate(1) - return txid +class CryptoconditionsTokenTest(CryptoconditionsTestFramework): def run_token_tests(self): rpc = self.nodes[0] diff --git a/qa/rpc-tests/test_framework/test_framework.py b/qa/rpc-tests/test_framework/test_framework.py index f545b4246..d1c3d87e3 100755 --- a/qa/rpc-tests/test_framework/test_framework.py +++ b/qa/rpc-tests/test_framework/test_framework.py @@ -180,3 +180,72 @@ class ComparisonTestFramework(BitcoinTestFramework): extra_args=[['-debug', '-whitelist=127.0.0.1']] * self.num_nodes, binary=[self.options.testbinary] + [self.options.refbinary]*(self.num_nodes-1)) + + +class CryptoconditionsTestFramework(BitcoinTestFramework): + + def __init__(self): + self.num_nodes = 2 + + def setup_chain(self): + print("Initializing CC test directory "+self.options.tmpdir) + initialize_chain_clean(self.options.tmpdir, self.num_nodes) + + def setup_network(self, split = False): + print("Setting up network...") + self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" + self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" + self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" + self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" + self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" + self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" + self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, + extra_args=[[ + # always give -ac_name as first extra_arg and port as third + '-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', + '-port=64367', + '-rpcport=64368', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + '-pubkey=' + self.pubkey, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt' + ], + ['-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', + '-port=64365', + '-rpcport=64366', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + '-pubkey=' + self.pubkey1, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '-addnode=127.0.0.1:64367', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt']] + ) + self.is_network_split = split + self.rpc = self.nodes[0] + self.rpc1 = self.nodes[1] + self.sync_all() + print("Done setting up network") + + def send_and_mine(self, xtn, rpc_connection): + txid = rpc_connection.sendrawtransaction(xtn) + assert txid, 'got txid' + # we need the tx above to be confirmed in the next block + rpc_connection.generate(1) + return txid