Skip to content
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

backport: trivial 2024 10 23 pr6 #6354

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
277766f
Merge bitcoin/bitcoin#27493: depends: no-longer nuke libc++abi.so* in…
fanquake May 14, 2023
bef9631
Merge bitcoin/bitcoin#27661: doc, test: Document steps to reproduce T…
fanquake May 15, 2023
105442f
Merge bitcoin/bitcoin#26422: build: Use newest `config.{guess,sub}` a…
fanquake May 16, 2023
f27778a
Merge bitcoin/bitcoin#27561: test: Explicitly specify directory where…
fanquake May 22, 2023
ee6b7d6
Merge bitcoin/bitcoin#27721: depends: remove redundant stdlib option
fanquake May 25, 2023
a21b4b1
Merge bitcoin/bitcoin#27802: Update .style.yapf
fanquake Jun 2, 2023
324db8b
Merge bitcoin/bitcoin#27603: test: added coverage to mining_basic.py
glozow Jun 2, 2023
e2fcd1d
Merge bitcoin/bitcoin#27225: doc: document json rpc endpoints
fanquake Jun 2, 2023
fbc6c6e
Merge bitcoin/bitcoin#27875: build: make sure we can overwrite config…
fanquake Jun 16, 2023
ba5f4c0
Merge bitcoin/bitcoin#27906: doc: test: update TestShell instructions
fanquake Jun 18, 2023
ece625c
Merge bitcoin/bitcoin#27914: feerate: For GetFeePerK() return nSatosh…
fanquake Jun 26, 2023
79a20f9
Merge bitcoin/bitcoin#27929: Added static_assert to check that base_b…
fanquake Jun 27, 2023
af944b7
Merge bitcoin/bitcoin#28013: doc: Fix verify-binaries link in contrib…
fanquake Jun 30, 2023
2767a13
Merge bitcoin/bitcoin#28021: docs: fixup honggfuzz fuzz patch
fanquake Jul 3, 2023
5511091
Merge bitcoin/bitcoin#28036: test: Restore unlimited timeout in Index…
fanquake Jul 7, 2023
70cbd3f
Merge bitcoin/bitcoin#28044: test: indexes, fix on error infinite loop
ryanofsky Jul 11, 2023
e3bbd1a
Merge bitcoin-core/gui#740: Show own outputs on PSBT signing window
hebasto Jul 16, 2023
d573e4f
Merge bitcoin/bitcoin#28084: doc: update windows `-fstack-clash-prote…
fanquake Jul 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .style.yapf
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ each_dict_entry_on_separate_line=True
i18n_comment=

# The i18n function call names. The presence of this function stops
# reformattting on that line, because the string it has cannot be moved
# reformatting on that line, because the string it has cannot be moved
# away from the i18n comment.
i18n_function_call=

Expand Down
13 changes: 13 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,16 @@ fi
command -v autoreconf >/dev/null || \
(echo "configuration failed, please install autoconf first" && exit 1)
autoreconf --install --force --warnings=all

Copy link
Collaborator

Choose a reason for hiding this comment

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

26422 - should wait guix builds just in case before get merged.

Copy link
Member Author

Choose a reason for hiding this comment

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

guix was happy here: 70500c9

if expr "'$(build-aux/config.guess --timestamp)" \< "'$(depends/config.guess --timestamp)" > /dev/null; then
chmod ug+w build-aux/config.guess
chmod ug+w src/secp256k1/build-aux/config.guess
cp depends/config.guess build-aux
cp depends/config.guess src/secp256k1/build-aux
fi
if expr "'$(build-aux/config.sub --timestamp)" \< "'$(depends/config.sub --timestamp)" > /dev/null; then
chmod ug+w build-aux/config.sub
chmod ug+w src/secp256k1/build-aux/config.sub
cp depends/config.sub build-aux
cp depends/config.sub src/secp256k1/build-aux
fi
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,8 @@ if test x$use_hardening != xno; then

case $host in
*mingw*)
dnl stack-clash-protection doesn't currently work, and likely should just be skipped for Windows.
dnl stack-clash-protection doesn't compile with GCC 10 and earlier.
dnl In any case, it is a no-op for Windows.
dnl See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90458 for more details.
;;
*)
Expand Down
2 changes: 1 addition & 1 deletion contrib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ Test and Verify Tools
### [TestGen](/contrib/testgen) ###
Utilities to generate test vectors for the data-driven Dash tests.

### [Verify Binaries](/contrib/verifybinaries) ###
### [Verify-Binaries](/contrib/verify-binaries) ###
Copy link
Collaborator

@kwvg kwvg Oct 25, 2024

Choose a reason for hiding this comment

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

(28013) It's still named verifybinaries (source)

This script attempts to download and verify the signature file SHA256SUMS.asc from bitcoin.org.
Copy link
Collaborator

Choose a reason for hiding this comment

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

28013 - (note) - we should dashify contrib/verify-binaries once, should we?

3 changes: 1 addition & 2 deletions depends/hosts/darwin.mk
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ $(foreach TOOL,$(cctools_TOOLS),$(eval darwin_$(TOOL) = $$(build_prefix)/bin/$$(
# Explicitly point to our binaries (e.g. cctools) so that they are
# ensured to be found and preferred over other possibilities.
#
# -stdlib=libc++ -stdlib++-isystem$(OSX_SDK)/usr/include/c++/v1
# -stdlib++-isystem$(OSX_SDK)/usr/include/c++/v1
#
# Forces clang to use the libc++ headers from our SDK and completely
# forget about the libc++ headers from the standard directories
Expand Down Expand Up @@ -107,7 +107,6 @@ darwin_CXX=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \
$(clangxx_prog) --target=$(host) -mmacosx-version-min=$(OSX_MIN_VERSION) \
-B$(build_prefix)/bin -mlinker-version=$(LD64_VERSION) \
-isysroot$(OSX_SDK) \
-stdlib=libc++ \
-stdlib++-isystem$(OSX_SDK)/usr/include/c++/v1 \
-Xclang -internal-externc-isystem$(clang_resource_dir)/include \
-Xclang -internal-externc-isystem$(OSX_SDK)/usr/include
Expand Down
4 changes: 0 additions & 4 deletions depends/packages/native_clang.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ $(package)_file_name=clang+llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-16
$(package)_sha256_hash=48b83ef827ac2c213d5b64f5ad7ed082c8bcb712b46644e0dc5045c6f462c231
endif

define $(package)_preprocess_cmds
rm -f $($(package)_extract_dir)/lib/libc++abi.so*
endef

define $(package)_stage_cmds
mkdir -p $($(package)_staging_prefix_dir)/lib/clang/$($(package)_version)/include && \
mkdir -p $($(package)_staging_prefix_dir)/bin && \
Expand Down
35 changes: 35 additions & 0 deletions doc/JSON-RPC-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,41 @@ The headless daemon `dashd` has the JSON-RPC API enabled by default, the GUI
option. In the GUI it is possible to execute RPC methods in the Debug Console
Dialog.

## Endpoints

There are two JSON-RPC endpoints on the server:

1. `/`
2. `/wallet/<walletname>/`

### `/` endpoint

This endpoint is always active.
It can always service non-wallet requests and can service wallet requests when
exactly one wallet is loaded.

### `/wallet/<walletname>/` endpoint

This endpoint is only activated when the wallet component has been compiled in.
It can service both wallet and non-wallet requests.
It MUST be used for wallet requests when two or more wallets are loaded.

This is the endpoint used by bitcoin-cli when a `-rpcwallet=` parameter is passed in.
Copy link
Collaborator

@kwvg kwvg Oct 25, 2024

Choose a reason for hiding this comment

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

(27225) nit: Dashify


Best practice would dictate using the `/wallet/<walletname>/` endpoint for ALL
requests when multiple wallets are in use.

### Examples

```sh
# Get block count from the / endpoint when rpcuser=alice and rpcport=38332
$ curl --user alice --data-binary '{"jsonrpc": "1.0", "id": "0", "method": "getblockcount", "params": []}' -H 'content-type: text/plain;' localhost:38332/

# Get balance from the /wallet/walletname endpoint when rpcuser=alice, rpcport=38332 and rpcwallet=desc-wallet
$ curl --user alice --data-binary '{"jsonrpc": "1.0", "id": "0", "method": "getbalance", "params": []}' -H 'content-type: text/plain;' localhost:38332/wallet/desc-wallet

```

## Parameter passing

The JSON-RPC server supports both _by-position_ and _by-name_ [parameter
Expand Down
43 changes: 22 additions & 21 deletions doc/fuzzing.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,44 +212,45 @@ $ CC=$(pwd)/honggfuzz/hfuzz_cc/hfuzz-clang \
./configure --disable-wallet --with-gui=no \
--with-sanitizers=address,undefined
$ git apply << "EOF"
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index 455a82e39..2faa3f80f 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -158,7 +158,11 @@ static bool AppInit(int argc, char* argv[])
return fRet;
}

diff --git a/src/compat/compat.h b/src/compat/compat.h
index 8195bceaec..cce2b31ff0 100644
--- a/src/compat/compat.h
+++ b/src/compat/compat.h
@@ -90,8 +90,12 @@ typedef char* sockopt_arg_type;
// building with a binutils < 2.36 is subject to this ld bug.
#define MAIN_FUNCTION __declspec(dllexport) int main(int argc, char* argv[])
#else
+#ifdef HFND_FUZZING_ENTRY_FUNCTION_CXX
+HFND_FUZZING_ENTRY_FUNCTION_CXX(int argc, char* argv[])
+#define MAIN_FUNCTION HFND_FUZZING_ENTRY_FUNCTION_CXX(int argc, char* argv[])
+#else
int main(int argc, char* argv[])
#define MAIN_FUNCTION int main(int argc, char* argv[])
#endif
+#endif
{
#ifdef WIN32
util::WinCmdLineArgs winArgs;

// Note these both should work with the current usage of poll, but best to be safe
// WIN32 poll is broken https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/
diff --git a/src/net.cpp b/src/net.cpp
index cf987b699..636a4176a 100644
index 7601a6ea84..702d0f56ce 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -709,7 +709,7 @@ int V1TransportDeserializer::readHeader(const char *pch, unsigned int nBytes)
@@ -727,7 +727,7 @@ int V1TransportDeserializer::readHeader(Span<const uint8_t> msg_bytes)
}

// Check start string, network magic
- if (memcmp(hdr.pchMessageStart, m_chain_params.MessageStart(), CMessageHeader::MESSAGE_START_SIZE) != 0) {
+ if (false && memcmp(hdr.pchMessageStart, m_chain_params.MessageStart(), CMessageHeader::MESSAGE_START_SIZE) != 0) { // skip network magic checking
LogPrint(BCLog::NET, "HEADER ERROR - MESSAGESTART (%s, %u bytes), received %s, peer=%d\n", hdr.GetCommand(), hdr.nMessageSize, HexStr(hdr.pchMessageStart), m_node_id);
LogPrint(BCLog::NET, "Header error: Wrong MessageStart %s received, peer=%d\n", HexStr(hdr.pchMessageStart), m_node_id);
return -1;
}
@@ -768,7 +768,7 @@ Optional<CNetMessage> V1TransportDeserializer::GetMessage(const std::chrono::mic
@@ -788,7 +788,7 @@ CNetMessage V1TransportDeserializer::GetMessage(const std::chrono::microseconds
RandAddEvent(ReadLE32(hash.begin()));

// Check checksum and header command string
// Check checksum and header message type string
- if (memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) != 0) {
+ if (false && memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) != 0) { // skip checksum checking
LogPrint(BCLog::NET, "CHECKSUM ERROR (%s, %u bytes), expected %s was %s, peer=%d\n",
SanitizeString(msg->m_command), msg->m_message_size,
HexStr(Span<uint8_t>(hash.begin(), hash.begin() + CMessageHeader::CHECKSUM_SIZE)),
LogPrint(BCLog::NET, "Header error: Wrong checksum (%s, %u bytes), expected %s was %s, peer=%d\n",
SanitizeString(msg.m_type), msg.m_message_size,
HexStr(Span{hash}.first(CMessageHeader::CHECKSUM_SIZE)),
EOF
$ make -C src/ dashd
$ mkdir -p inputs/
Expand Down
2 changes: 1 addition & 1 deletion src/policy/feerate.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CFeeRate
/**
* Return the fee in satoshis for a size of 1000 bytes
*/
CAmount GetFeePerK() const { return GetFee(1000); }
CAmount GetFeePerK() const { return nSatoshisPerK; }
friend bool operator<(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK < b.nSatoshisPerK; }
friend bool operator>(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK > b.nSatoshisPerK; }
friend bool operator==(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK == b.nSatoshisPerK; }
Expand Down
2 changes: 2 additions & 0 deletions src/qt/psbtoperationsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ std::string PSBTOperationsDialog::renderTransaction(const PartiallySignedTransac
tx_description.append(tr(" * Sends %1 to %2")
.arg(BitcoinUnits::formatWithUnit(BitcoinUnits::DASH, out.nValue))
.arg(QString::fromStdString(EncodeDestination(address))));
// Check if the address is one of ours
if (m_wallet_model != nullptr && m_wallet_model->wallet().txoutIsMine(out)) tx_description.append(" (" + tr("own address") + ")");
tx_description.append("<br>");
}

Expand Down
10 changes: 7 additions & 3 deletions src/test/util/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
#include <test/util/index.h>

#include <index/base.h>
#include <shutdown.h>
#include <util/check.h>
#include <util/time.h>

void IndexWaitSynced(BaseIndex& index)
void IndexWaitSynced(const BaseIndex& index)
{
const auto timeout{SteadyClock::now() + 120s};
while (!index.BlockUntilSyncedToCurrentChain()) {
Assert(timeout > SteadyClock::now());
// Assert shutdown was not requested to abort the test, instead of looping forever, in case
// there was an unexpected error in the index that caused it to stop syncing and request a shutdown.
Assert(!ShutdownRequested());

UninterruptibleSleep(100ms);
}
assert(index.GetSummary().synced);
}
2 changes: 1 addition & 1 deletion src/test/util/index.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
class BaseIndex;

/** Block until the index is synced to the current chain */
void IndexWaitSynced(BaseIndex& index);
void IndexWaitSynced(const BaseIndex& index);

#endif // BITCOIN_TEST_UTIL_INDEX_H
1 change: 1 addition & 0 deletions src/uint256.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class base_blob
{
protected:
static constexpr int WIDTH = BITS / 8;
static_assert(BITS % 8 == 0, "base_blob currently only supports whole bytes.");
std::array<uint8_t, WIDTH> m_data;
static_assert(WIDTH == sizeof(m_data), "Sanity check");

Expand Down
1 change: 1 addition & 0 deletions test/functional/mining_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def assert_submitblock(block, result_str_1, result_str_2=None):
assert_template(node, bad_block, 'bad-cb-missing')

self.log.info("submitblock: Test invalid coinbase transaction")
assert_raises_rpc_error(-22, "Block does not start with a coinbase", node.submitblock, CBlock().serialize().hex())
assert_raises_rpc_error(-22, "Block does not start with a coinbase", node.submitblock, bad_block.serialize().hex())

self.log.info("getblocktemplate: Test truncated final transaction")
Expand Down
16 changes: 8 additions & 8 deletions test/functional/test-shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ importing the `TestShell` class from the `test_shell` sub-package.
The following `TestShell` methods manage the lifetime of the underlying bitcoind
processes and logging utilities.

* `TestShell.setup()`
* `TestShell.shutdown()`
* `TestShell().setup()`
* `TestShell().shutdown()`

The `TestShell` inherits all `BitcoinTestFramework` members and methods, such
as:
* `TestShell.nodes[index].rpc_method()`
* `TestShell.log.info("Custom log message")`
* `TestShell().nodes[index].rpc_method()`
* `TestShell().log.info("Custom log message")`

The following sections demonstrate how to initialize, run, and shut down a
`TestShell` object.
Expand Down Expand Up @@ -141,7 +141,7 @@ instances and remove all temporary data and logging directories.
20XX-XX-XXTXX:XX:XX.XXXXXXX TestFramework (INFO): Tests successful
```
To prevent the logs from being removed after a shutdown, simply set the
`TestShell.options.nocleanup` member to `True`.
`TestShell().options.nocleanup` member to `True`.
```
>>> test.options.nocleanup = True
>>> test.shutdown()
Expand All @@ -160,9 +160,9 @@ underlying `BitcoinTestFramework`:

The `TestShell` object initializes with the default settings inherited from the
`BitcoinTestFramework` class. The user can override these in
`TestShell.setup(key=value)`.
`TestShell().setup(key=value)`.

**Note:** `TestShell.reset()` will reset test parameters to default values and
**Note:** `TestShell().reset()` will reset test parameters to default values and
can be called after the TestShell is shut down.

| Test parameter key | Default Value | Description |
Expand All @@ -179,7 +179,7 @@ can be called after the TestShell is shut down.
| `perf` | False | Profiles running nodes with `perf` for the duration of the test if set to `True`. |
| `rpc_timeout` | `60` | Sets the RPC server timeout for the underlying bitcoind processes. |
| `setup_clean_chain` | `False` | A 200-block-long chain is initialized from cache by default. Instead, `setup_clean_chain` initializes an empty blockchain if set to `True`. |
| `randomseed` | Random Integer | `TestShell.options.randomseed` is a member of `TestShell` which can be accessed during a test to seed a random generator. User can override default with a constant value for reproducible test runs. |
| `randomseed` | Random Integer | `TestShell().options.randomseed` is a member of `TestShell` which can be accessed during a test to seed a random generator. User can override default with a constant value for reproducible test runs. |
| `supports_cli` | `False` | Whether the bitcoin-cli utility is compiled and available for the test. |
| `tmpdir` | `"/var/folders/.../"` | Sets directory for test logs. Will be deleted upon a successful test run unless `nocleanup` is set to `True` |
| `trace_rpc` | `False` | Logs all RPC calls if set to `True`. |
Expand Down
8 changes: 6 additions & 2 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,12 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, attempts=1, enab

# Test Framework Tests
print("Running Unit Tests for Test Framework Modules")

tests_dir = src_dir + '/test/functional/'
# This allows `test_runner.py` to work from an out-of-source build directory using a symlink,
# a hard link or a copy on any platform. See https://github.com/bitcoin/bitcoin/pull/27561.
sys.path.append(tests_dir)

test_framework_tests = unittest.TestSuite()
for module in TEST_FRAMEWORK_MODULES:
test_framework_tests.addTest(unittest.TestLoader().loadTestsFromName("test_framework.{}".format(module)))
Expand All @@ -554,8 +560,6 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, attempts=1, enab
logging.debug("Early exiting after failure in TestFramework unit tests")
sys.exit(False)

tests_dir = src_dir + '/test/functional/'

flags = ['--cachedir={}'.format(cache_dir)] + args

if enable_coverage:
Expand Down
1 change: 1 addition & 0 deletions test/sanitizer_suppressions/tsan
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ race:src/qt/test/*
deadlock:src/qt/test/*

# External libraries
# https://github.com/bitcoin/bitcoin/pull/27658#issuecomment-1547639621
deadlock:libdb
race:libzmq

Expand Down
Loading