Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…itcoin#22798, bitcoin#22994, bitcoin#23014, bitcoin#23126, bitcoin-core/gui#336, gui#342, gui#430

9faa63f Merge bitcoin#22650: Remove -deprecatedrpc=addresses flag and corresponding code/logic (Samuel Dobson)
7cae481 partial Merge bitcoin#22798: doc: Fix RPC result documentation (fanquake)
8ef72e0 Merge bitcoin#22585: fuzz: add guide to fuzzing with Eclipser v1.x (W. J. van der Laan)
2cc9aa1 Merge bitcoin-core/gui#342: wallet: Move wallets loading out from the main GUI thread (Hennadii Stepanov)
3a5f35e Merge bitcoin-core/gui#336: Do not exit and re-enter main event loop during shutdown (W. J. van der Laan)
4a82d49 Merge bitcoin#23126: doc: update developer docs for subtree renaming (fanquake)
0e093b3 Merge bitcoin-core/gui#430: Improvements to the open up transaction in third-party link action (Hennadii Stepanov)
c358d84 Merge bitcoin#23014: ci: Bump distro version, disable feature_bind_extra for two configurations (merge-script)
df518cf Merge bitcoin#22994: ci: use Debian Bullseye in ARM CI (merge-script)
1c75354 build: remove windows native build from cirrus. (Konstantin Akimov)
f437964 Merge bitcoin#21551: ci: Move Windows MSVC build from AppVeyor to Cirrus (MarcoFalke)

Pull request description:

  ## What was done?
  Regular backports from Bitcoin Core v23

  ## How Has This Been Tested?
  Run unit & functional tests

  Backport bitcoin-core/gui#342 made loading heavy wallet by RPC `loadwallet` on my machine from 23 seconds to just 19 seconds (20% faster), due to no waiting 5 seconds on `cs_wallets` mutex.

  ## Breaking Changes
  - The `-deprecatedrpc=addresses` configuration option has been removed.  RPCs
    `gettxout`, `getrawtransaction`, `decoderawtransaction`, `decodescript`,
    `gettransaction verbose=true` and REST endpoints `/rest/tx`, `/rest/getutxos`,
    `/rest/block` no longer return the `addresses` and `reqSigs` fields, which
    were previously deprecated in 22.0.

  ## Checklist:
  - [ ] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  PastaPastaPasta:
    ACK 9faa63f

Tree-SHA512: 9db7b434896565618d96029c8c738b2d29fbb0608666f6f186c7beccd74398d0ee4cbfda91903c022529b131c05a6084004b1ae84e89df90d554f92be3cbf629
  • Loading branch information
PastaPastaPasta committed Feb 22, 2025
2 parents 843a00d + 9faa63f commit 5c1a627
Show file tree
Hide file tree
Showing 42 changed files with 387 additions and 546 deletions.
13 changes: 7 additions & 6 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ env:
CCACHE_DIR: "/tmp/ccache_dir"

# https://cirrus-ci.org/guide/tips-and-tricks/#sharing-configuration-between-tasks
base_template: &BASE_TEMPLATE
filter_template: &FILTER_TEMPLATE
skip: $CIRRUS_REPO_FULL_NAME == "bitcoin-core/gui" && $CIRRUS_PR == "" # No need to run on the read-only mirror, unless it is a PR. https://cirrus-ci.org/guide/writing-tasks/#conditional-task-execution
stateful: false # https://cirrus-ci.org/guide/writing-tasks/#stateful-tasks

base_template: &BASE_TEMPLATE
<< : *FILTER_TEMPLATE
merge_base_script:
# Unconditionally install git (used in fingerprint_script) and set the
# default git author name (used in verify-commits.py)
Expand All @@ -21,7 +25,6 @@ base_template: &BASE_TEMPLATE
- if [ "$CIRRUS_PR" = "" ]; then exit 0; fi
- git fetch $CIRRUS_REPO_CLONE_URL $CIRRUS_BASE_BRANCH
- git merge FETCH_HEAD # Merge base to detect silent merge conflicts
stateful: false # https://cirrus-ci.org/guide/writing-tasks/#stateful-tasks

global_task_template: &GLOBAL_TASK_TEMPLATE
<< : *BASE_TEMPLATE
Expand All @@ -47,7 +50,6 @@ compute_credits_template: &CREDITS_TEMPLATE
# Only use credits for pull requests to the main repo
use_compute_credits: $CIRRUS_REPO_FULL_NAME == 'dashpay/dash' && $CIRRUS_PR != ""


task:
name: 'lint [bookworm]'
<< : *BASE_TEMPLATE
Expand All @@ -62,12 +64,11 @@ task:
fingerprint_script: cat .python-version /etc/os-release
lint_script:
- ./ci/lint_run_all.sh

task:
name: 'ARM [unit tests, no functional tests] [buster]'
name: 'ARM [unit tests, no functional tests] [bullseye]'
<< : *GLOBAL_TASK_TEMPLATE
arm_container:
image: debian:buster
image: debian:bullseye
cpu: 2
memory: 8G
env:
Expand Down
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trim_trailing_whitespace = true
[*.{h,cpp,py,sh}]
indent_size = 4

# .cirrus.yml, .appveyor.yml, .fuzzbuzz.yml, etc.
# .cirrus.yml, .fuzzbuzz.yml, etc.
[*.yml]
indent_size = 2

Expand Down
2 changes: 1 addition & 1 deletion ci/test/00_setup_env_native_valgrind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export LC_ALL=C.UTF-8
export PACKAGES="valgrind clang llvm python3-zmq libevent-dev bsdmainutils libboost-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev"
export USE_VALGRIND=1
export NO_DEPENDS=1
export TEST_RUNNER_EXTRA="--exclude rpc_bind --timeout-factor=4" # Excluded for now, see https://github.com/bitcoin/bitcoin/issues/17765#issuecomment-602068547
export TEST_RUNNER_EXTRA="--exclude rpc_bind,feature_bind_extra --timeout-factor=4" # Excluded for now, see https://github.com/bitcoin/bitcoin/issues/17765#issuecomment-602068547
export GOAL="install"
export BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --with-gui=no --enable-suppress-external-warnings CC=clang-18 CXX=clang++-18" # TODO enable GUI
1 change: 1 addition & 0 deletions ci/test/00_setup_env_s390x.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fi
# Use debian to avoid 404 apt errors
export CONTAINER_NAME=ci_s390x
export RUN_UNIT_TESTS=true
export TEST_RUNNER_EXTRA="--exclude rpc_bind,feature_bind_extra" # Excluded for now, see https://github.com/bitcoin/bitcoin/issues/17765#issuecomment-602068547
export RUN_FUNCTIONAL_TESTS=true
export GOAL="install"
export BITCOIN_CONFIG="--enable-reduce-exports --disable-gui-tests --with-boost-process" # GUI tests disabled for now, see https://github.com/bitcoin/bitcoin/issues/23730
32 changes: 18 additions & 14 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -1132,37 +1132,41 @@ Subtrees

Several parts of the repository are subtrees of software maintained elsewhere.

Some of these are maintained by active developers of Bitcoin Core, in which case changes should probably go
directly upstream without being PRed directly against the project. They will be merged back in the next
subtree merge.
Some of these are maintained by active developers of Dash Core, in which case
changes should go directly upstream without being PRed directly against the project.
They will be merged back in the next subtree merge.

Others are external projects without a tight relationship with our project. Changes to these should also
be sent upstream, but bugfixes may also be prudent to PR against Dash Core so that they can be integrated
quickly. Cosmetic changes should be purely taken upstream.
Others are external projects without a tight relationship with our project. Changes
to these should also be sent upstream, but bugfixes may also be prudent to PR against
a Dash Core subtree, so that they can be integrated quickly. Cosmetic changes
should be taken upstream.

There is a tool in `test/lint/git-subtree-check.sh` ([instructions](../test/lint#git-subtree-checksh)) to check a subtree directory for consistency with
its upstream repository.
There is a tool in `test/lint/git-subtree-check.sh` ([instructions](../test/lint#git-subtree-checksh))
to check a subtree directory for consistency with its upstream repository.

Current subtrees include:

- src/leveldb
- Upstream at https://github.com/google/leveldb ; Maintained by Google, but
open important PRs to Core to avoid delay.
- Subtree at https://github.com/bitcoin-core/leveldb-subtree ; maintained by Core contributors.
- Upstream at https://github.com/google/leveldb ; maintained by Google. Open
important PRs to the subtree to avoid delay.
- **Note**: Follow the instructions in [Upgrading LevelDB](#upgrading-leveldb) when
merging upstream changes to the LevelDB subtree.

- src/crc32c
- Used by leveldb for hardware acceleration of CRC32C checksums for data integrity.
- Upstream at https://github.com/google/crc32c ; Maintained by Google.
- Subtree at https://github.com/bitcoin-core/crc32c-subtree ; maintained by Core contributors.
- Upstream at https://github.com/google/crc32c ; maintained by Google.

- src/secp256k1
- Upstream at https://github.com/bitcoin-core/secp256k1/ ; actively maintained by Core contributors.
- Upstream at https://github.com/bitcoin-core/secp256k1/ ; maintained by Core contributors.

- src/crypto/ctaes
- Upstream at https://github.com/bitcoin-core/ctaes ; actively maintained by Core contributors.
- Upstream at https://github.com/bitcoin-core/ctaes ; maintained by Core contributors.

- src/univalue
- Upstream at https://github.com/bitcoin-core/univalue ; actively maintained by Core contributors, deviates from upstream https://github.com/jgarzik/univalue
- Subtree at https://github.com/bitcoin-core/univalue-subtree ; maintained by Core contributors.
- Deviates from upstream https://github.com/jgarzik/univalue.

- src/minisketch
- Upstream at https://github.com/sipa/minisketch ; maintained by Core contributors.
Expand Down
67 changes: 67 additions & 0 deletions doc/fuzzing.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,73 @@ $ honggfuzz/honggfuzz --exit_upon_crash --quiet --timeout 4 -n 1 -Q \
-debug
```
# Fuzzing Bitcoin Core using Eclipser (v1.x)
## Quickstart guide
To quickly get started fuzzing Bitcoin Core using [Eclipser v1.x](https://github.com/SoftSec-KAIST/Eclipser/tree/v1.x):
```sh
$ git clone https://github.com/bitcoin/bitcoin
$ cd bitcoin/
$ sudo vim /etc/apt/sources.list # Uncomment the lines starting with 'deb-src'.
$ sudo apt-get update
$ sudo apt-get build-dep qemu
$ sudo apt-get install libtool libtool-bin wget automake autoconf bison gdb
```
At this point, you must install the .NET core. The process differs, depending on your Linux distribution.
See [this link](https://docs.microsoft.com/en-us/dotnet/core/install/linux) for details.
On ubuntu 20.04, the following should work:
```sh
$ wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
$ sudo dpkg -i packages-microsoft-prod.deb
$ rm packages-microsoft-prod.deb
$ sudo apt-get update
$ sudo apt-get install -y dotnet-sdk-2.1
```
You will also want to make sure Python is installed as `python` for the Eclipser install to succeed.
```sh
$ git clone https://github.com/SoftSec-KAIST/Eclipser.git
$ cd Eclipser
$ git checkout v1.x
$ make
$ cd ..
$ ./autogen.sh
$ ./configure --enable-fuzz
$ make
$ mkdir -p outputs/
$ FUZZ=bech32 dotnet Eclipser/build/Eclipser.dll fuzz -p src/test/fuzz/fuzz -t 36000 -o outputs --src stdin
```
This will perform 10 hours of fuzzing.
To make further use of the inputs generated by Eclipser, you
must first decode them:
```sh
$ dotnet Eclipser/build/Eclipser.dll decode -i outputs/testcase -o decoded_outputs
```
This will place raw inputs in the directory `decoded_outputs/decoded_stdins`. Crashes are in the `outputs/crashes` directory, and must
be decoded in the same way.
Fuzzing with Eclipser will likely be much more effective if using an existing corpus:
```sh
$ git clone https://github.com/bitcoin-core/qa-assets
$ FUZZ=bech32 dotnet Eclipser/build/Eclipser.dll fuzz -p src/test/fuzz/fuzz -t 36000 -i qa-assets/fuzz_seed_corpus/bech32 outputs --src stdin
```
Note that fuzzing with Eclipser on certain targets (those that create 'full nodes', e.g. `process_message*`) will,
for now, slowly fill `/tmp/` with improperly cleaned-up files, which will cause spurious crashes.
See [this proposed patch](https://github.com/bitcoin/bitcoin/pull/22472) for more information.
Read the [Eclipser documentation for v1.x](https://github.com/SoftSec-KAIST/Eclipser/tree/v1.x) for more details on using Eclipser.
# OSS-Fuzz
Bitcoin Core participates in Google's [OSS-Fuzz](https://github.com/google/oss-fuzz/tree/master/projects/bitcoin-core)
Expand Down
9 changes: 9 additions & 0 deletions doc/release-notes-22650.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Updated RPCs
------------

- The `-deprecatedrpc=addresses` configuration option has been removed. RPCs
`gettxout`, `getrawtransaction`, `decoderawtransaction`, `decodescript`,
`gettransaction verbose=true` and REST endpoints `/rest/tx`, `/rest/getutxos`,
`/rest/block` no longer return the `addresses` and `reqSigs` fields, which
were previously deprecated in 21.0. (#6569)

2 changes: 1 addition & 1 deletion src/bitcoin-tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ static void MutateTx(CMutableTransaction& tx, const std::string& command,
static void OutputTxJSON(const CTransaction& tx)
{
UniValue entry(UniValue::VOBJ);
TxToUniv(tx, uint256(), /* include_addresses */ false, entry);
TxToUniv(tx, uint256(), entry);

std::string jsonOutput = entry.write(4);
tfm::format(std::cout, "%s\n", jsonOutput);
Expand Down
6 changes: 3 additions & 3 deletions src/core_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ UniValue ValueFromAmount(const CAmount amount);
std::string FormatScript(const CScript& script);
std::string EncodeHexTx(const CTransaction& tx);
std::string SighashToStr(unsigned char sighash_type);
void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex, bool include_addresses);
void ScriptToUniv(const CScript& script, UniValue& out, bool include_address);
void TxToUniv(const CTransaction& tx, const uint256& hashBlock, bool include_addresses, UniValue& entry, bool include_hex = true, const CTxUndo* txundo = nullptr, const CSpentIndexTxInfo* ptxSpentInfo = nullptr);
void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool include_hex, bool include_address = true);
void ScriptToUniv(const CScript& script, UniValue& out);
void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, bool include_hex = true, int serialize_flags = 0, const CTxUndo* txundo = nullptr, const CSpentIndexTxInfo* ptxSpentInfo = nullptr);

#endif // BITCOIN_CORE_IO_H
46 changes: 9 additions & 37 deletions src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,56 +152,28 @@ std::string EncodeHexTx(const CTransaction& tx)
return HexStr(ssTx);
}

void ScriptToUniv(const CScript& script, UniValue& out, bool include_address)
void ScriptToUniv(const CScript& script, UniValue& out)
{
out.pushKV("asm", ScriptToAsmStr(script));
out.pushKV("hex", HexStr(script));

std::vector<std::vector<unsigned char>> solns;
TxoutType type = Solver(script, solns);
out.pushKV("type", GetTxnOutputType(type));

CTxDestination address;
if (include_address && ExtractDestination(script, address) && type != TxoutType::PUBKEY) {
out.pushKV("address", EncodeDestination(address));
}
ScriptPubKeyToUniv(script, out, /* include_hex */ true, /* include_address */ false);
}

// TODO: from v21 ("addresses" and "reqSigs" deprecated) this method should be refactored to remove the `include_addresses` option
// this method can also be combined with `ScriptToUniv` as they will overlap
void ScriptPubKeyToUniv(const CScript& scriptPubKey,
UniValue& out, bool fIncludeHex, bool include_addresses)
void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool include_hex, bool include_address)
{
TxoutType type;
CTxDestination address;
std::vector<CTxDestination> addresses;
int nRequired;

out.pushKV("asm", ScriptToAsmStr(scriptPubKey));
if (fIncludeHex)
out.pushKV("hex", HexStr(scriptPubKey));
if (include_hex) out.pushKV("hex", HexStr(scriptPubKey));

if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired) || type == TxoutType::PUBKEY) {
out.pushKV("type", GetTxnOutputType(type));
return;
}
std::vector<std::vector<unsigned char>> solns;
const TxoutType type{Solver(scriptPubKey, solns)};

if (ExtractDestination(scriptPubKey, address)) {
if (include_address && ExtractDestination(scriptPubKey, address) && type != TxoutType::PUBKEY) {
out.pushKV("address", EncodeDestination(address));
}
out.pushKV("type", GetTxnOutputType(type));

if (include_addresses) {
UniValue a(UniValue::VARR);
for (const CTxDestination& addr : addresses) {
a.push_back(EncodeDestination(addr));
}
out.pushKV("addresses", a);
out.pushKV("reqSigs", nRequired);
}
}

void TxToUniv(const CTransaction& tx, const uint256& hashBlock, bool include_addresses, UniValue& entry, bool include_hex, const CTxUndo* txundo, const CSpentIndexTxInfo* ptxSpentInfo)
void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, bool include_hex, int serialize_flags, const CTxUndo* txundo, const CSpentIndexTxInfo* ptxSpentInfo)
{
uint256 txid = tx.GetHash();
entry.pushKV("txid", txid.GetHex());
Expand Down Expand Up @@ -269,7 +241,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, bool include_add
out.pushKV("n", (int64_t)i);

UniValue o(UniValue::VOBJ);
ScriptPubKeyToUniv(txout.scriptPubKey, o, true, include_addresses);
ScriptPubKeyToUniv(txout.scriptPubKey, o, true);
out.pushKV("scriptPubKey", o);

// Add spent information if spentindex is enabled
Expand Down
8 changes: 4 additions & 4 deletions src/qt/addressbookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ void AddressBookPage::onEditAction()
if(indexes.isEmpty())
return;

EditAddressDialog dlg(
auto dlg = new EditAddressDialog(
tab == SendingTab ?
EditAddressDialog::EditSendingAddress :
EditAddressDialog::EditReceivingAddress, this);
dlg.setModel(model);
dlg->setModel(model);
QModelIndex origIndex = proxyModel->mapToSource(indexes.at(0));
dlg.loadRow(origIndex.row());
dlg.exec();
dlg->loadRow(origIndex.row());
GUIUtil::ShowModalDialogAndDeleteOnClose(dlg);
}

void AddressBookPage::on_newAddress_clicked()
Expand Down
20 changes: 10 additions & 10 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#include <QThread>
#include <QTimer>
#include <QTranslator>
#include <QWindow>

#if defined(QT_STATIC)
#include <QtPlugin>
Expand Down Expand Up @@ -256,6 +257,8 @@ void BitcoinApplication::createOptionsModel(bool resetSettings)
void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
{
window = new BitcoinGUI(node(), networkStyle, nullptr);
connect(window, &BitcoinGUI::quitRequested, this, &BitcoinApplication::requestShutdown);

pollShutdownTimer = new QTimer(window);
connect(pollShutdownTimer, &QTimer::timeout, window, &BitcoinGUI::detectShutdown);
}
Expand Down Expand Up @@ -290,7 +293,7 @@ void BitcoinApplication::startThread()

/* communication to and from thread */
connect(&m_executor.value(), &InitExecutor::initializeResult, this, &BitcoinApplication::initializeResult);
connect(&m_executor.value(), &InitExecutor::shutdownResult, this, &BitcoinApplication::shutdownResult);
connect(&m_executor.value(), &InitExecutor::shutdownResult, this, &QCoreApplication::quit);
connect(&m_executor.value(), &InitExecutor::runawayException, this, &BitcoinApplication::handleRunawayException);
connect(this, &BitcoinApplication::requestedInitialize, &m_executor.value(), &InitExecutor::initialize);
connect(this, &BitcoinApplication::requestedShutdown, &m_executor.value(), &InitExecutor::shutdown);
Expand Down Expand Up @@ -321,13 +324,17 @@ void BitcoinApplication::requestInitialize()

void BitcoinApplication::requestShutdown()
{
for (const auto w : QGuiApplication::topLevelWindows()) {
w->hide();
}

// Show a simple window indicating shutdown status
// Do this first as some of the steps may take some time below,
// for example the RPC console may still be executing a command.
shutdownWindow.reset(ShutdownWindow::showShutdownWindow(window));

qDebug() << __func__ << ": Requesting shutdown";
window->hide();

// Must disconnect node signals otherwise current thread can deadlock since
// no event loop is running.
window->unsubscribeFromCoreSignals();
Expand Down Expand Up @@ -407,15 +414,10 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead
pollShutdownTimer->start(SHUTDOWN_POLLING_DELAY);
} else {
Q_EMIT splashFinished(); // Make sure splash screen doesn't stick around during shutdown
quit(); // Exit first main loop invocation
requestShutdown();
}
}

void BitcoinApplication::shutdownResult()
{
quit(); // Exit second main loop invocation after shutdown finished
}

void BitcoinApplication::handleRunawayException(const QString &message)
{
QMessageBox::critical(
Expand Down Expand Up @@ -745,8 +747,6 @@ int GuiMain(int argc, char* argv[])
#if defined(Q_OS_WIN)
WinShutdownMonitor::registerShutdownBlockReason(QObject::tr("%1 didn't yet exit safely…").arg(PACKAGE_NAME), (HWND)app.getMainWinId());
#endif
app.exec();
app.requestShutdown();
app.exec();
rv = app.getReturnValue();
} else {
Expand Down
Loading

0 comments on commit 5c1a627

Please sign in to comment.