Skip to content
Merged
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ jobs:
DOCKER_NAME_TAG=ubuntu:16.04
PACKAGES="clang llvm python3-zmq qtbase5-dev qttools5-dev-tools libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev"
NO_DEPENDS=1
RUN_FUNCTIONAL_TESTS=false
GOAL="install"
BITCOIN_CONFIG="--enable-zmq --disable-wallet --with-gui=qt5 CPPFLAGS=-DDEBUG_LOCKORDER --with-sanitizers=thread --disable-hardening --disable-asm CC=clang CXX=clang++"

Expand All @@ -163,6 +164,7 @@ jobs:
HOST=x86_64-unknown-linux-gnu
PACKAGES="clang llvm python3-zmq qtbase5-dev qttools5-dev-tools libssl1.0-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev"
NO_DEPENDS=1
RUN_FUNCTIONAL_TESTS=false
GOAL="install"
BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --enable-glibc-back-compat --enable-reduce-exports --with-gui=qt5 CPPFLAGS=-DDEBUG_LOCKORDER --with-sanitizers=integer,undefined CC=clang CXX=clang++"
# x86_64 Linux, No wallet, no QT(build timing out with for some reason)
Expand All @@ -188,17 +190,20 @@ jobs:

# x86_64 Linux w/ Bitcoin functional tests (Qt5 & system libs)
- stage: test
name: 'x86_64 Linux [GOAL: install] [bitcoin functional]'
env: >-
HOST=x86_64-unknown-linux-gnu
PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libssl1.0-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev"
NO_DEPENDS=1
RUN_UNIT_TESTS=false
RUN_BITCOIN_TESTS=true
RUN_FUNCTIONAL_TESTS=false
GOAL="install"
BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --enable-glibc-back-compat --enable-reduce-exports --with-gui=qt5 CPPFLAGS=-DDEBUG_LOCKORDER"

# x86_64 Linux w/ single fedpeg test that uses upstream bitcoind as mainchain
- stage: test
name: 'x86_64 Linux [GOAL: install] [bitcoind fedpeg test]'
env: >-
HOST=x86_64-unknown-linux-gnu
PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libssl1.0-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev"
Expand All @@ -211,6 +216,7 @@ jobs:
BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --enable-glibc-back-compat --enable-reduce-exports --with-gui=no --disable-tests --disable-bench CPPFLAGS=-DDEBUG_LOCKORDER"
# x86_64 Linux (uses qt5 dev package instead of depends Qt to speed up build and avoid timeout), no functional tests, LIQUID BUILD
- stage: test
name: 'x86_64 Linux [GOAL: install] [liquid build]'
env: >-
HOST=x86_64-unknown-linux-gnu
PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools protobuf-compiler libdbus-1-dev libharfbuzz-dev libprotobuf-dev"
Expand Down
32 changes: 0 additions & 32 deletions .travis/test_06_script_a.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,4 @@ BEGIN_FOLD build
DOCKER_EXEC make $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && DOCKER_EXEC make $GOAL V=1 ; false )
END_FOLD

if [ "$RUN_UNIT_TESTS" = "true" ]; then
BEGIN_FOLD unit-tests
DOCKER_EXEC LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/depends/$HOST/lib make $MAKEJOBS check VERBOSE=1
END_FOLD
fi

if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then
extended="--extended --exclude feature_pruning"
fi

if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then
BEGIN_FOLD functional-tests
DOCKER_EXEC test/functional/test_runner.py --ci --combinedlogslen=4000 --coverage --quiet --failfast ${extended}
END_FOLD
fi

if [ "$RUN_BITCOIN_TESTS" = "true" ]; then
BEGIN_FOLD bitcoin-functional-tests
DOCKER_EXEC test/bitcoin_functional/functional/test_runner.py --combinedlogslen=4000 --coverage --quiet --failfast ${extended}
END_FOLD
fi

if [ "$RUN_FEDPEG_BITCOIND_TEST" = "true" ]; then
BEGIN_FOLD fedpeg-bitcoind-test
BITCOIND_VERSION=0.18.0
BITCOIND_ARCH=x86_64-linux-gnu
DOCKER_EXEC curl -O https://bitcoincore.org/bin/bitcoin-core-$BITCOIND_VERSION/bitcoin-$BITCOIND_VERSION-$BITCOIND_ARCH.tar.gz
DOCKER_EXEC tar -zxf bitcoin-$BITCOIND_VERSION-$BITCOIND_ARCH.tar.gz
DOCKER_EXEC test/functional/feature_fedpeg.py --parent_bitcoin --parent_binpath $(pwd)/bitcoin-$BITCOIND_VERSION/bin/bitcoind
END_FOLD
fi

cd ${TRAVIS_BUILD_DIR} || (echo "could not enter travis build dir $TRAVIS_BUILD_DIR"; exit 1)
26 changes: 26 additions & 0 deletions .travis/test_06_script_b.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,29 @@ if [ "$RUN_FUZZ_TESTS" = "true" ]; then
DOCKER_EXEC test/fuzz/test_runner.py -l DEBUG ${DIR_FUZZ_IN}
END_FOLD
fi

if [ "$RUN_UNIT_TESTS" = "true" ]; then
BEGIN_FOLD unit-tests
DOCKER_EXEC LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/depends/$HOST/lib make $MAKEJOBS check VERBOSE=1
END_FOLD
fi

if [ "$RUN_BITCOIN_TESTS" = "true" ]; then
BEGIN_FOLD bitcoin-functional-tests
DOCKER_EXEC test/bitcoin_functional/functional/test_runner.py --combinedlogslen=4000 --coverage --quiet --failfast ${extended}
END_FOLD
fi

if [ "$RUN_FEDPEG_BITCOIND_TEST" = "true" ]; then
BEGIN_FOLD fedpeg-bitcoind-test
BITCOIND_VERSION=0.18.0
BITCOIND_ARCH=x86_64-linux-gnu
DOCKER_EXEC curl -O https://bitcoincore.org/bin/bitcoin-core-$BITCOIND_VERSION/bitcoin-$BITCOIND_VERSION-$BITCOIND_ARCH.tar.gz
DOCKER_EXEC tar -zxf bitcoin-$BITCOIND_VERSION-$BITCOIND_ARCH.tar.gz
DOCKER_EXEC test/functional/feature_fedpeg.py --parent_bitcoin --parent_binpath $(pwd)/bitcoin-$BITCOIND_VERSION/bin/bitcoind
END_FOLD
fi

if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then
extended="--extended --exclude feature_pruning"
fi
23 changes: 18 additions & 5 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,7 @@ UniValue consumecompactsketch(const JSONRPCRequest& request)
CBlockHeaderAndShortTxIDs cmpctblock;
ssBlock >> cmpctblock;

LOCK(mempool.cs);
PartiallyDownloadedBlock partialBlock(&mempool);
const std::vector<std::pair<uint256, CTransactionRef>> dummy;
ReadStatus status = partialBlock.InitData(cmpctblock, dummy);
Expand Down Expand Up @@ -1367,21 +1368,33 @@ UniValue finalizecompactblock(const JSONRPCRequest& request)

// Cached transactions
std::vector<unsigned char> found_tx(ParseHex(request.params[2].get_str()));
CDataStream ssFound(block_tx, SER_NETWORK, PROTOCOL_VERSION);
CDataStream ssFound(found_tx, SER_NETWORK, PROTOCOL_VERSION);

std::vector<CTransactionRef> found;
ssFound >> found;

// Make mega-list
found.insert(found.end(), transactions.txn.begin(), transactions.txn.end());

// Now construct the final block!
PartiallyDownloadedBlock partialBlock(&mempool);
// Now construct the final block! (use dummy mempool here, otherwise reconstruction may fail)
CTxMemPool dummy_pool;
PartiallyDownloadedBlock partialBlock(&dummy_pool);

const std::vector<std::pair<uint256, CTransactionRef>> dummy;
// "Extra" list is really our combined list that will be put into place using InitData
std::vector<std::pair<uint256, CTransactionRef>> extra_txn;
for (const auto& found_tx : found) {
extra_txn.push_back(std::make_pair(found_tx->GetWitnessHash(), found_tx));
}
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
if (partialBlock.InitData(cmpctblock, dummy) != READ_STATUS_OK || partialBlock.FillBlock(*pblock, found, false /* pow_check*/) != READ_STATUS_OK) {
if (partialBlock.InitData(cmpctblock, extra_txn) != READ_STATUS_OK) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "compact_hex appears malformed.");
}
const std::vector<CTransactionRef> dummy_missing;
auto result = partialBlock.FillBlock(*pblock, dummy_missing, false /* pow_check*/);
if (result == READ_STATUS_FAILED) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Failed to complete block though all transactions were apparently found. Could be random short ID collision; requires full block instead.");
} else if (result != READ_STATUS_OK) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Failed to complete block though all transactions were apparently found.");
}

CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION);
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_blocksign.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def mine_block(self, make_transactions):

# Make a few transactions to make non-empty blocks for compact transmission
if make_transactions:
for i in range(5):
for i in range(20):
miner.sendtoaddress(miner_next.getnewaddress(), int(miner.getbalance()['bitcoin']/10), "", "", True)
# miner makes a block
block = miner.getnewblockhex()
Expand Down
24 changes: 10 additions & 14 deletions test/functional/feature_fedpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
connect_nodes_bi,
disconnect_nodes,
get_auth_cookie,
get_datadir_path,
rpc_port,
Expand Down Expand Up @@ -538,6 +537,7 @@ def run_test(self):
# Watch the address so we can get tx without txindex
parent.importaddress(mainchain_addr)
claim_block = parent.generatetoaddress(50, mainchain_addr)[0]
self.sync_all(self.node_groups)
block_coinbase = parent.getblock(claim_block, 2)["tx"][0]
claim_txid = block_coinbase["txid"]
claim_tx = block_coinbase["hex"]
Expand All @@ -553,11 +553,13 @@ def run_test(self):

# 50 more blocks to allow wallet to make it succeed by relay and consensus
parent.generatetoaddress(50, parent.getnewaddress())
self.sync_all(self.node_groups)
# Wallet still doesn't want to for 2 more confirms
assert_equal(sidechain.createrawpegin(claim_tx, claim_proof)["mature"], False)
# But we can just shoot it off
claim_txid = sidechain.sendrawtransaction(signed_pegin)
sidechain.generatetoaddress(1, sidechain.getnewaddress())
self.sync_all(self.node_groups)
assert_equal(sidechain.gettransaction(claim_txid)["confirmations"], 1)

# Test a confidential pegin.
Expand All @@ -569,6 +571,7 @@ def run_test(self):
txid_fund = parent.sendtoaddress(pegin_addr, 10)
# 10+2 confirms required to get into mempool and confirm
parent.generate(11)
self.sync_all(self.node_groups)
proof = parent.gettxoutproof([txid_fund])
raw = parent.gettransaction(txid_fund)["hex"]
raw_pegin = sidechain.createrawpegin(raw, proof)['hex']
Expand All @@ -579,6 +582,8 @@ def run_test(self):
blind_addr = sidechain.getnewaddress("", "blech32")
sidechain.sendtoaddress(blind_addr, 15)
sidechain.generate(6)
# Make sure sidechain2 knows about the same input
self.sync_all(self.node_groups)
unspent = [u for u in sidechain.listunspent(6, 6) if u["amount"] == 15][0]
assert(unspent["spendable"])
assert("amountcommitment" in unspent)
Expand Down Expand Up @@ -615,23 +620,14 @@ def run_test(self):
assert(final_decoded["vout"][1]["commitmentnonce_fully_valid"])
assert("value" in final_decoded["vout"][2])
assert("asset" in final_decoded["vout"][2])
# check that it is accepted in the mempool
# check that it is accepted in either mempool
accepted = sidechain.testmempoolaccept([pegin_signed["hex"]])[0]
if not accepted["allowed"]:
raise Exception(accepted["reject-reason"])
accepted = sidechain2.testmempoolaccept([pegin_signed["hex"]])[0]
if not accepted["allowed"]:
raise Exception(accepted["reject-reason"])
print("Blinded transaction looks ok!") # need this print to distinguish failures in for loop
# check if they get mined; since we're trying to mine two double spends, disconnect the nodes
disconnect_nodes(sidechain, 3)
disconnect_nodes(sidechain2, 2)
txid1 = sidechain.sendrawtransaction(pegin_signed1["hex"])
blocks = sidechain.generate(3)
assert_equal(sidechain.getrawtransaction(txid1, True, blocks[0])["confirmations"], 3)
txid2 = sidechain2.sendrawtransaction(pegin_signed2["hex"])
blocks = sidechain2.generate(3)
assert_equal(sidechain2.getrawtransaction(txid2, True, blocks[0])["confirmations"], 3)
# reconnect in case we extend the test
connect_nodes_bi(self.nodes, 2, 3)
sidechain.generate(10)

print('Success!')

Expand Down