Skip to content

backport: bitcoin#16766, #17164, #17283, #17290, #17388, #17437, #17439, #17470, #17568, #17587, #17599 #5314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 18, 2023
Merged
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,14 @@ after_success:
- set -o errexit; source ./ci/extended_lint/06_script.sh

- stage: test
name: 'ARM [GOAL: install] [unit tests, functional tests]'
name: 'ARM [GOAL: install] [bionic] [unit tests, functional tests]'
arch: arm64
env: >-
FILE_ENV="./ci/test/00_setup_env_arm.sh"
QEMU_USER_CMD="" # Can run the tests natively without qemu

- stage: test
name: 'S390x [GOAL: install] [unit tests, functional tests]'
name: 'S390x [GOAL: install] [bionic] [unit tests, functional tests]'
arch: s390x
env: >-
FILE_ENV="./ci/test/00_setup_env_s390x.sh"
Expand Down
2 changes: 2 additions & 0 deletions ci/dash/matrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ elif [ "$BUILD_TARGET" = "linux64_nowallet" ]; then
source ./ci/test/00_setup_env_native_nowallet.sh
elif [ "$BUILD_TARGET" = "mac" ]; then
source ./ci/test/00_setup_env_mac.sh
elif [ "$BUILD_TARGET" = "s390x" ]; then
source ./ci/test/00_setup_env_s390x.sh
fi
5 changes: 1 addition & 4 deletions ci/test/00_setup_env_s390x.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
export LC_ALL=C.UTF-8

export HOST=s390x-unknown-linux-gnu
export DOCKER_NAME_TAG=s390x/ubuntu:18.04
export PACKAGES="clang llvm python3-zmq qtbase5-dev qttools5-dev-tools 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 libqrencode-dev"
export NO_DEPENDS=1
export RUN_UNIT_TESTS=true
export RUN_FUNCTIONAL_TESTS=false
export RUN_FUNCTIONAL_TESTS=true
export GOAL="install"
export BITCOIN_CONFIG="--enable-reduce-exports --with-incompatible-bdb"

lscpu
2 changes: 2 additions & 0 deletions ci/test/04_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ if [ "$TRAVIS_OS_NAME" == "osx" ]; then
else
DOCKER_EXEC free -m -h
DOCKER_EXEC echo "Number of CPUs \(nproc\):" \$\(nproc\)
DOCKER_EXEC echo "Free disk space:"
DOCKER_EXEC df -h
fi

if [ -n "$DPKG_ADD_ARCH" ]; then
Expand Down
5 changes: 5 additions & 0 deletions doc/release-notes-17437.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Low-level RPC Changes
===

- The RPC gettransaction, listtransactions and listsinceblock responses now also
includes the height of the block that contains the wallet transaction, if any.
3 changes: 0 additions & 3 deletions src/bloom.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ class CBloomFilter
class CRollingBloomFilter
{
public:
// A random bloom filter calls GetRand() at creation time.
// Don't create global CRollingBloomFilter objects, as they may be
// constructed before the randomizer is properly initialized.
CRollingBloomFilter(const unsigned int nElements, const double nFPRate);

void insert(const std::vector<unsigned char>& vKey);
Expand Down
2 changes: 1 addition & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3771,7 +3771,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
addrBind(addrBindIn),
fInbound(fInboundIn),
nKeyedNetGroup(nKeyedNetGroupIn),
addrKnown(5000, 0.001),
m_addr_known{block_relay_only ? nullptr : std::make_unique<CRollingBloomFilter>(5000, 0.001)},
m_block_relay_only_peer(block_relay_only),
id(idIn),
nLocalHostNonce(nLocalHostNonceIn),
Expand Down
10 changes: 6 additions & 4 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ class CNode

// flood relay
std::vector<CAddress> vAddrToSend;
CRollingBloomFilter addrKnown;
const std::unique_ptr<CRollingBloomFilter> m_addr_known;
bool fGetAddr{false};
int64_t nNextAddrSend GUARDED_BY(cs_sendProcessing){0};
int64_t nNextLocalAddrSend GUARDED_BY(cs_sendProcessing){0};
Expand All @@ -1056,7 +1056,7 @@ class CNode
// Don't relay addr messages to peers that we connect to as block-relay-only
// peers (to prevent adversaries from inferring these links from addr
// traffic).
bool IsAddrRelayPeer() const { return !m_block_relay_only_peer; }
bool IsAddrRelayPeer() const { return m_addr_known != nullptr; }

bool IsBlockRelayOnly() const
{
Expand Down Expand Up @@ -1238,7 +1238,8 @@ class CNode

void AddAddressKnown(const CAddress& _addr)
{
addrKnown.insert(_addr.GetKey());
assert(m_addr_known);
m_addr_known->insert(_addr.GetKey());
}

/**
Expand All @@ -1256,7 +1257,8 @@ class CNode
// Known checking here is only to save space from duplicates.
// SendMessages will filter it again for knowns that were added
// after addresses were pushed.
if (_addr.IsValid() && !addrKnown.contains(_addr.GetKey()) && IsAddrCompatible(_addr)) {
assert(m_addr_known);
if (_addr.IsValid() && !m_addr_known->contains(_addr.GetKey()) && IsAddrCompatible(_addr)) {
if (vAddrToSend.size() >= MAX_ADDR_TO_SEND) {
vAddrToSend[insecure_rand.randrange(vAddrToSend.size())] = _addr;
} else {
Expand Down
7 changes: 4 additions & 3 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,7 @@ static void RelayAddress(const CAddress& addr, bool fReachable, CConnman& connma
{
// Relay to a limited number of other nodes
// Use deterministic randomness to send to the same nodes for 24 hours
// at a time so the addrKnowns of the chosen nodes prevent repeats
// at a time so the m_addr_knowns of the chosen nodes prevent repeats
uint64_t hashAddr = addr.GetHash();
const CSipHasher hasher = connman.GetDeterministicRandomizer(RANDOMIZER_ID_ADDRESS_RELAY).Write(hashAddr << 32).Write((GetTime() + hashAddr) / (24*60*60));
FastRandomContext insecure_rand;
Expand Down Expand Up @@ -4530,11 +4530,12 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
make_flags = 0;
}

assert(pto->m_addr_known);
for (const CAddress& addr : pto->vAddrToSend)
{
if (!pto->addrKnown.contains(addr.GetKey()))
if (!pto->m_addr_known->contains(addr.GetKey()))
{
pto->addrKnown.insert(addr.GetKey());
pto->m_addr_known->insert(addr.GetKey());
vAddr.push_back(addr);
// receiver rejects addr messages larger than 1000
if (vAddr.size() >= 1000)
Expand Down
2 changes: 1 addition & 1 deletion src/qt/forms/sendcoinsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@
<number>3</number>
</property>
<item>
<widget class="QLabel" name="labelBalanceText">
<widget class="QLabel" name="labelBalanceName">
<property name="text">
<string>Balance:</string>
</property>
Expand Down
2 changes: 1 addition & 1 deletion src/qt/res/css/general.css
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,7 @@ QDialog#SendCoinsDialog .QScrollArea#scrollArea .QWidget#scrollAreaWidgetContent
background-color: #00000000;
}

QDialog#SendCoinsDialog QLabel#labelBalanceText,
QDialog#SendCoinsDialog QLabel#labelBalanceName,
QDialog#SendCoinsDialog QLabel#labelBalance {
qproperty-alignment: 'AlignLeading | AlignLeft';
min-height: 20px;
Expand Down
15 changes: 9 additions & 6 deletions src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ SendCoinsDialog::SendCoinsDialog(bool _fCoinJoin, QWidget* parent) :
}, GUIUtil::FontWeight::Bold);

GUIUtil::setFont({ui->labelBalance,
ui->labelBalanceText
ui->labelBalanceName,
}, GUIUtil::FontWeight::Bold, 14);

GUIUtil::setFont({ui->labelCoinControlFeatures
Expand Down Expand Up @@ -641,14 +641,17 @@ void SendCoinsDialog::setBalance(const interfaces::WalletBalances& balances)
{
if(model && model->getOptionsModel())
{
CAmount bal = 0;
if (m_coin_control->IsUsingCoinJoin()) {
bal = balances.anonymized_balance;
CAmount balance = 0;
if (model->privateKeysDisabled()) {
balance = balances.watch_only_balance;
ui->labelBalanceName->setText(tr("Watch-only balance:"));
} else if (m_coin_control->IsUsingCoinJoin()) {
balance = balances.anonymized_balance;
} else {
bal = balances.balance;
balance = balances.balance;
}

ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), bal));
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), balance));
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/qt/test/wallettests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,16 @@ void TestGUI(interfaces::Node& node)
sendCoinsDialog.setModel(&walletModel);
transactionView.setModel(&walletModel);

{
// Check balance in send dialog
QLabel* balanceLabel = sendCoinsDialog.findChild<QLabel*>("labelBalance");
QString balanceText = balanceLabel->text();
int unit = walletModel.getOptionsModel()->getDisplayUnit();
CAmount balance = walletModel.wallet().getBalance();
QString balanceComparison = BitcoinUnits::formatWithUnit(unit, balance, false /*, BitcoinUnits::separatorAlways*/);
QCOMPARE(balanceText, balanceComparison);
}

// Send two transactions, and verify they are added to transaction list.
TransactionTableModel* transactionTableModel = walletModel.getTransactionTableModel();
QCOMPARE(transactionTableModel->rowCount({}), 105);
Expand Down
4 changes: 2 additions & 2 deletions src/script/descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,8 @@ std::unique_ptr<DescriptorImpl> ParseScript(uint32_t key_exp_index, Span<const c
}
}
if (ctx == ParseScriptContext::P2SH) {
if (script_size + 3 > 520) {
error = strprintf("P2SH script is too large, %d bytes is larger than 520 bytes", script_size + 3);
if (script_size + 3 > MAX_SCRIPT_ELEMENT_SIZE) {
error = strprintf("P2SH script is too large, %d bytes is larger than %d bytes", script_size + 3, MAX_SCRIPT_ELEMENT_SIZE);
return nullptr;
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/test/fuzz/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ FUZZ_TARGET_INIT(net, initialize_net)
}
},
[&] {
// if (node.m_addr_known == nullptr) {
// return;
// }
if (node.m_addr_known == nullptr) {
return;
}
const std::optional<CAddress> addr_opt = ConsumeDeserializable<CAddress>(fuzzed_data_provider);
if (!addr_opt) {
return;
}
node.AddAddressKnown(*addr_opt);
},
[&] {
// if (node.m_addr_known == nullptr) {
// return;
// }
if (node.m_addr_known == nullptr) {
return;
}
const std::optional<CAddress> addr_opt = ConsumeDeserializable<CAddress>(fuzzed_data_provider);
if (!addr_opt) {
return;
Expand Down
3 changes: 2 additions & 1 deletion src/test/util_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ BOOST_FIXTURE_TEST_CASE(util_ChainMerge, ChainMergeTestingSetup)
desc += " ";
desc += argstr + 1;
conf += argstr + 1;
conf += "\n";
}
std::istringstream conf_stream(conf);
BOOST_CHECK(parser.ReadConfigStream(conf_stream, "filepath", error));
Expand Down Expand Up @@ -1026,7 +1027,7 @@ BOOST_FIXTURE_TEST_CASE(util_ChainMerge, ChainMergeTestingSetup)
// Results file is formatted like:
//
// <input> || <output>
BOOST_CHECK_EQUAL(out_sha_hex, "3e70723862e346ed6e9b48d8efa13d4d56334c0b73fbf3c3a6ac8b8f4d914f65");
BOOST_CHECK_EQUAL(out_sha_hex, "f8cff01ad967dfc82cf71208aa2b60f01a0aa621c28356af5ca91d1d7370c217");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

17388 how'd you calculate this?

Copy link
Collaborator Author

@knst knst Apr 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed text of message and checked mismatched hash result after running tests

}

BOOST_AUTO_TEST_CASE(util_ReadWriteSettings)
Expand Down
Loading