diff --git a/build_msvc/bitcoind/bitcoind.vcxproj b/build_msvc/bitcoind/bitcoind.vcxproj index 713375e63c..90d735b5df 100644 --- a/build_msvc/bitcoind/bitcoind.vcxproj +++ b/build_msvc/bitcoind/bitcoind.vcxproj @@ -57,9 +57,9 @@ + Replace="@PACKAGE_NAME@" By="Elements Core"> + Replace="@PACKAGE_BUGREPORT@" By="https://github.com/ElementsProject/elements/issues"> nHeight - m_chainman.ActiveHeight(); - bool too_far_ahead = node::fTrimHeaders && (headers_ahead >= node::nHeaderDownloadBuffer); - if (too_far_ahead) { - LOCK(cs_main); - CNodeState *nodestate = State(pfrom.GetId()); - if ((nodestate->pindexBestKnownBlock == nullptr) || + if (node::fTrimHeaders) { + LOCK(cs_main); + if (pindexBestHeader) { + int64_t headers_ahead = pindexBestHeader->nHeight - m_chainman.ActiveHeight(); + if (headers_ahead >= node::nHeaderDownloadBuffer) { + CNodeState *nodestate = State(pfrom.GetId()); + if ((nodestate->pindexBestKnownBlock == nullptr) || (nodestate->pindexBestKnownBlock->nHeight < m_chainman.ActiveHeight())) { - // Our notion of what blocks a peer has available is based on its pindexBestKnownBlock, - // which is based on headers received from it. If we don't have one, or it's too old, - // then we can never get blocks from this peer until we accept headers from it first. - LogPrint(BCLog::NET, "NOT discarding headers from peer=%d, to update its block availability. (current best header %d, active chain height %d)\n", pfrom.GetId(), pindexBestHeader->nHeight, m_chainman.ActiveHeight()); - } else { - LogPrint(BCLog::NET, "Discarding received headers and pausing header sync from peer=%d, because we are too far ahead of block sync. (%d > %d)\n", pfrom.GetId(), pindexBestHeader->nHeight, m_chainman.ActiveHeight()); - if (nodestate->fSyncStarted) { - // Cancel sync from this node, so we don't penalize it later. - // This will cause us to automatically start syncing from a different node (or restart syncing from the same node) later, - // if we still need to sync headers. - nSyncStarted--; - nodestate->fSyncStarted = false; - nodestate->m_headers_sync_timeout = 0us; + // Our notion of what blocks a peer has available is based on its pindexBestKnownBlock, + // which is based on headers received from it. If we don't have one, or it's too old, + // then we can never get blocks from this peer until we accept headers from it first. + LogPrint(BCLog::NET, "NOT discarding headers from peer=%d, to update its block availability. (current best header %d, active chain height %d)\n", pfrom.GetId(), pindexBestHeader->nHeight, m_chainman.ActiveHeight()); + } else { + LogPrint(BCLog::NET, "Discarding received headers and pausing header sync from peer=%d, because we are too far ahead of block sync. (%d > %d)\n", pfrom.GetId(), pindexBestHeader->nHeight, m_chainman.ActiveHeight()); + if (nodestate->fSyncStarted) { + // Cancel sync from this node, so we don't penalize it later. + // This will cause us to automatically start syncing from a different node (or restart syncing from the same node) later, + // if we still need to sync headers. + nSyncStarted--; + nodestate->fSyncStarted = false; + nodestate->m_headers_sync_timeout = 0us; + } + return; } - return; } } } diff --git a/src/rpc/request.cpp b/src/rpc/request.cpp index 2588f8b385..f332eaa46b 100644 --- a/src/rpc/request.cpp +++ b/src/rpc/request.cpp @@ -139,7 +139,10 @@ static fs::path GetMainchainAuthCookieFile() if (gArgs.GetChainName() == "liquidv1") { cookie_file = ".cookie"; } - return fsbridge::AbsPathJoin(GetMainchainDefaultDataDir(), fs::PathFromString(gArgs.GetArg("-mainchainrpccookiefile", cookie_file))); + fs::path cookie_path = fs::PathFromString(gArgs.GetArg("-mainchainrpccookiefile", cookie_file)); + if (cookie_path.is_absolute()) + return cookie_path; + return fsbridge::AbsPathJoin(GetMainchainDefaultDataDir(), cookie_path); } bool GetMainchainAuthCookie(std::string *cookie_out) @@ -148,7 +151,7 @@ bool GetMainchainAuthCookie(std::string *cookie_out) std::string cookie; std::filesystem::path filepath = GetMainchainAuthCookieFile(); - file.open(filepath.string().c_str()); + file.open(filepath); if (!file.is_open()) return false; std::getline(file, cookie); diff --git a/test/functional/feature_confidential_transactions.py b/test/functional/feature_confidential_transactions.py index 3ecb74fdd5..749c4daae2 100755 --- a/test/functional/feature_confidential_transactions.py +++ b/test/functional/feature_confidential_transactions.py @@ -25,6 +25,7 @@ ) import os import re +import tempfile from test_framework.liquid_addr import ( encode, @@ -51,7 +52,7 @@ def skip_test_if_missing_module(self): self.skip_if_no_wallet() def test_wallet_recovery(self): - file_path = "/tmp/blind_details" + file_path = os.path.join(tempfile.gettempdir(), "blind_details") try: os.remove(file_path) except OSError: diff --git a/test/functional/feature_discount_ct.py b/test/functional/feature_discount_ct.py index 007f8a0693..ac128bddcc 100755 --- a/test/functional/feature_discount_ct.py +++ b/test/functional/feature_discount_ct.py @@ -6,6 +6,7 @@ from decimal import Decimal from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( + assert_approx, assert_equal, ) @@ -80,10 +81,12 @@ def run_test(self): assert_equal(len(vout), 3) assert_equal(tx['fee']['bitcoin'], Decimal('-0.00000326')) assert_equal(decoded['vsize'], 326) - assert_equal(decoded['weight'], 1302) + # tx weight can be 1301 or 1302, accept both + assert_approx(decoded['weight'], 1301.5, 0.5) self.generate(node0, 1) tx = node1.getrawtransaction(txid, True) - assert_equal(tx['discountweight'], 1302) + # tx discountweight can be 1301 or 1302, accept both + assert_approx(tx['discountweight'], 1301.5, 0.5) assert_equal(tx['discountvsize'], 326) self.log.info("Send confidential tx to node 0") @@ -98,10 +101,12 @@ def run_test(self): assert_equal(len(vout), 3) assert_equal(tx['fee']['bitcoin'], Decimal('-0.00002575')) assert_equal(decoded['vsize'], 2575) - assert_equal(decoded['weight'], 10300) + # tx weight can be 10299 or 10300, accept both + assert_approx(decoded['weight'], 10299.5, 0.5) self.generate(node0, 1) tx = node1.getrawtransaction(txid, True) - assert_equal(tx['discountweight'], 1302) + # tx discountweight can be 1301 or 1302, accept both + assert_approx(tx['discountweight'], 1301.5, 0.5) assert_equal(tx['discountvsize'], 326) # node1 has discountvsize self.log.info("Send explicit tx to node 1") @@ -116,10 +121,12 @@ def run_test(self): assert_equal(len(vout), 3) assert_equal(tx['fee']['bitcoin'], Decimal('-0.00000326')) assert_equal(decoded['vsize'], 326) - assert_equal(decoded['weight'], 1302) + # tx weight can be 1301 or 1302, accept both + assert_approx(decoded['weight'], 1301.5, 0.5) self.generate(node0, 1) tx = node1.getrawtransaction(txid, True) - assert_equal(tx['discountweight'], 1302) + # tx weight can be 1301 or 1302, accept both + assert_approx(tx['discountweight'], 1301.5, 0.5) assert_equal(tx['discountvsize'], 326) self.log.info("Send confidential (undiscounted) tx to node 1") @@ -134,10 +141,12 @@ def run_test(self): assert_equal(len(vout), 3) assert_equal(tx['fee']['bitcoin'], Decimal('-0.00002575')) assert_equal(decoded['vsize'], 2575) - assert_equal(decoded['weight'], 10300) + # tx weight can be 10299 or 10300, accept both + assert_approx(decoded['weight'], 10299.5, 0.5) self.generate(node0, 1) tx = node1.getrawtransaction(txid, True) - assert_equal(tx['discountweight'], 1302) + # tx discountweight can be 1301 or 1302, accept both + assert_approx(tx['discountweight'], 1301.5, 0.5) assert_equal(tx['discountvsize'], 326) # node1 has discountvsize self.log.info("Send confidential (discounted) tx to node 1") @@ -161,8 +170,10 @@ def run_test(self): else: assert_equal(decoded['fee'][bitcoin], Decimal('0.00000326')) assert_equal(decoded['vsize'], 2575) - assert_equal(decoded['weight'], 10300) - assert_equal(decoded['discountweight'], 1302) + # tx weight can be 10299 or 10300, accept both + assert_approx(decoded['weight'], 10299.5, 0.5) + # tx discountweight can be 1301 or 1302, accept both + assert_approx(decoded['discountweight'], 1301.5, 0.5) assert_equal(decoded['discountvsize'], 326) # node0 only has vsize @@ -191,8 +202,10 @@ def run_test(self): else: assert_equal(decoded['fee'][bitcoin], Decimal('0.00000033')) assert_equal(decoded['vsize'], 2575) - assert_equal(decoded['weight'], 10300) - assert_equal(decoded['discountweight'], 1302) + # tx weight can be 10299 or 10300, accept both + assert_approx(decoded['weight'], 10299.5, 0.5) + # tx discountweight can be 1301 or 1302, accept both + assert_approx(decoded['discountweight'], 1301.5, 0.5) assert_equal(decoded['discountvsize'], 326) # node0 only has vsize tx = node0.getrawtransaction(txid, True) diff --git a/test/functional/feature_fedpeg.py b/test/functional/feature_fedpeg.py index da2bcc4ce5..78788a5968 100755 --- a/test/functional/feature_fedpeg.py +++ b/test/functional/feature_fedpeg.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import time +import os from test_framework.authproxy import JSONRPCException from test_framework.test_framework import BitcoinTestFramework @@ -152,7 +153,7 @@ def setup_network(self, split=False): else: # Need to specify where to find parent cookie file datadir = get_datadir_path(self.options.tmpdir, n) - extra_args.append('-mainchainrpccookiefile='+datadir+"/" + parent_chain + "/.cookie") + extra_args.append('-mainchainrpccookiefile='+os.path.join(datadir, parent_chain, ".cookie")) self.add_nodes(1, [extra_args], chain=["elementsregtest"]) self.start_node(2+n)