0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-04 10:07:27 -05:00
Commit graph

4507 commits

Author SHA1 Message Date
Antoine Poinsot
d60229ede5
fuzz: make the parsed descriptor testing into a function
We'll be reusing it in the new target.
2023-07-21 10:40:13 +02:00
Andrew Chow
4d828ef427
Merge bitcoin/bitcoin#28085: refactor: use Span for SipHash::Write
7d92b1430a refactor: use Span for SipHash::Write (Sebastian Falbesoner)

Pull request description:

  This simple refactoring PR changes the interface for the `SipHash` arbitrary-data `Write` method to take a `Span<unsigned char>` instead of having to pass data and length. (`Span<std::byte>` seems to be more modern, but vectors of `unsigned char` are still used prety much everywhere where SipHash is called, and I didn't find it very appealing having to clutter the code with `Make(Writable)ByteSpan` helpers).

ACKs for top commit:
  sipa:
    utACK 7d92b1430a
  MarcoFalke:
    lgtm ACK 7d92b1430a
  achow101:
    ACK 7d92b1430a

Tree-SHA512: f17a27013c942aead4b09f5a64e0c3ff8dbc7e83fe63eb9a2e3ace8be9921c9cbba3ec67e3e83fbe3332ca941c42370efd059e702c060f9b508307e9657c66f2
2023-07-19 16:27:08 -04:00
MarcoFalke
fa633aa690
streams: Teach AutoFile how to XOR 2023-07-19 18:12:42 +02:00
fanquake
24d5cf9314
Merge bitcoin/bitcoin#27425: test: move remaining rand code from util/setup_common to util/random
1cd45d4e08 test: move random.h include header from setup_common.h to cpp (Jon Atack)
1b246fdd14 test: move remaining random test util code from setup_common to random (jonatack)

Pull request description:

  and drop the `util/random` dependency on `util/setup_common`.  This improves code separation and allows `util/setup_common` to call `util/random` functions without creating a circular dependency, thereby addressing https://github.com/bitcoin/bitcoin/pull/26940#issuecomment-1497266140 by glozow (thanks!)

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 1cd45d4e08 🌂

Tree-SHA512: 6ce63d9103ba9b04eebbd8ad02fe9aa79e356296533404034a1ae88e9b7ca0bc9a5c51fd754b71cf4e7b55b18bcd4d5474b2d588edee3851e3b3ce0e4d309a93
2023-07-19 10:26:11 +01:00
Andrew Chow
bc88f3ab90
Merge bitcoin/bitcoin#27997: Descriptors: rule out unspendable miniscript descriptors
c7db88af71 descriptor: assert we never parse a sane miniscript with no pubkey (Antoine Poinsot)
a49402a9ec qa: make sure we don't let unspendable Miniscript descriptors be imported (Antoine Poinsot)
639e3b6c97 descriptor: refuse to parse unspendable miniscript descriptors (Antoine Poinsot)
e3280eae1b miniscript: make GetStackSize() and GetOps() return optionals (Antoine Poinsot)

Pull request description:

  `IsSane()` in Miniscript does not ensure a Script is actually spendable. This is an issue as we would accept any sane Miniscript when parsing a descriptor. Fix this by explicitly checking a Miniscript descriptor is both sane and spendable when parsing it.

  This bug was exposed due to a check added in #22838 (https://github.com/bitcoin/bitcoin/pull/22838#discussion_r1226859880) that triggered a fuzz crash (https://github.com/bitcoin/bitcoin/pull/22838#issuecomment-1612510057).

ACKs for top commit:
  sipa:
    utACK c7db88af71
  achow101:
    ACK c7db88af71

Tree-SHA512: e79bc9f7842e98a4e8f358f05811fca51b15b4b80a171c0d2b17cf4bb1f578a18e4397bc2ece9817d392e0de0196ee6a054b7318441fd3566dd22e1f03eb64a5
2023-07-17 19:16:09 -04:00
Andrew Chow
306157ae92
Merge bitcoin/bitcoin#27993: Make poly1305 support incremental computation + modernize
4e5c933f6a Switch all callers from poly1305_auth to Poly1305 class (Pieter Wuille)
8871f7d1ae tests: add more Poly1305 test vectors (Pieter Wuille)
40e6c5b9fc crypto: add Poly1305 class with std::byte Span interface (Pieter Wuille)
50269b391f crypto: switch poly1305 to incremental implementation (Pieter Wuille)

Pull request description:

  Our current Poly1305 code (src/crypto/poly1305.*) only supports computing the entire tag in one go (the `poly1305_auth` function takes a key and message, and outputs the tag). However, the RFC8439 authenticated encryption (as used in BIP324, see #27634) scheme makes use of Poly1305 in a way where the message consists of 3 different pieces:
  * The additionally authenticated data (AAD), padded to 16 bytes.
  * The ciphertext, padded to 16 bytes.
  * The length of the AAD and the length of the ciphertext, together another 16 bytes.

  Implementing RFC8439 using the existing `poly1305_auth` function requires creating a temporary copy with all these pieces of data concatenated just for the purpose of computing the tag (the approach used in #25361).

  This PR replaces the poly1305 code with new code from https://github.com/floodyberry/poly1305-donna (with minor adjustments to make it match our coding style and use our utility functions, documented in the commit) which supports incremental operation, and then adds a C++ wrapper interface using std::byte Spans around it, and adds tests that incremental and all-at-once computation match.

ACKs for top commit:
  achow101:
    ACK 4e5c933f6a
  theStack:
    ACK 4e5c933f6a
  stratospher:
    tested ACK 4e5c933.

Tree-SHA512: df6e9a2a4a38a480f9e4360d3e3def5311673a727a4a85b008a084cf6843b260dc82cec7c73e1cecaaccbf10f3521a0ae7dba388b65d0b086770f7fbc5223e2a
2023-07-17 18:30:39 -04:00
fanquake
bf03fed2c7
Merge bitcoin/bitcoin#28065: fuzz: Flatten all FUZZ_TARGET macros into one
fa6dfaaf45 scripted-diff: Use new FUZZ_TARGET macro everywhere (MarcoFalke)
fa36ad8b09 fuzz: Accept options in FUZZ_TARGET macro (MarcoFalke)

Pull request description:

  The `FUZZ_TARGET` macros have many issues:
  * The developer will have to pick the right macro to pass the wanted option.
  * Adding a new option requires doubling the number of existing macros in the worst case.

  Fix all issues by using only a single macro.

  This refactor does not change behavior.

ACKs for top commit:
  dergoegge:
    ACK fa6dfaaf45

Tree-SHA512: 49a34553867a1734ce89e616b2d7c29b784a67cd8990db6573f0c7b18957636ef0c81d3d0d444a04c12cdc98bc4c4aa7a2ec94e6232dc363620a746e28416444
2023-07-17 13:36:53 +01:00
Sebastian Falbesoner
7d92b1430a refactor: use Span for SipHash::Write
Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
2023-07-17 13:27:46 +02:00
MarcoFalke
fa367422ef
fuzz: Bump FuzzedDataProvider.h
From fa8401f9bf/compiler-rt/include/fuzzer/FuzzedDataProvider.h
2023-07-17 09:39:52 +02:00
Suhas Daftuar
3cfc75366e test: Clear block index flags when testing snapshots
When simulating a snapshot, remove the HAVE_DATA status for blocks below the
snapshot height, to simulate never having downloaded them at all. This makes
tests more realistic (and more closely match what will happen when using
assumeutxo).
2023-07-14 17:10:49 -04:00
Suhas Daftuar
471da5f6e7 Move block-arrival information / preciousblock counters to ChainstateManager
Block arrival information (and the preciousblock RPC, a related concept) are
both chainstate-agnostic, so these are moved to ChainstateManager. This should
just be a refactor, without any observable behavior changes.
2023-07-14 17:09:06 -04:00
Suhas Daftuar
1cfc887d00 Remove CChain dependency in node/blockstorage 2023-07-14 14:54:57 -04:00
Andrew Chow
ee467b8238
Merge bitcoin/bitcoin#27549: fuzz: addrman, add coverage for network field in Select(), Size() and GetAddr()
35a2175ad8 fuzz: addrman, add coverage for `network` field in `Select()`, `Size()` and `GetAddr()` (brunoerg)

Pull request description:

  This PR adds fuzz coverage for `network` field in `Select()`, `Size()` and `GetAddr()`, there was only call to them without passing a network.
  https://marcofalke.github.io/b-c-cov/fuzz.coverage/src/addrman.cpp.gcov.html

ACKs for top commit:
  amitiuttarwar:
    for the record, ACK 35a2175ad8 - only small changes from the version (previously) proposed in 27213
  achow101:
    ACK 35a2175ad8
  mzumsande:
    Code Review ACK 35a2175ad8, haven't tested this yet, but I will let the fuzzer run for a while now.

Tree-SHA512: dddb8322298d6c373c8e68d57538470b11825a9a310a355828c351d5c0b19ff6779d024a800e3ea90126d0c050e86f71fd22cd23d1a306c784cef0f82c45e3ca
2023-07-13 19:07:15 -04:00
MarcoFalke
fa6dfaaf45
scripted-diff: Use new FUZZ_TARGET macro everywhere
-BEGIN VERIFY SCRIPT-

  ren() { sed --regexp-extended -i "s|$1|$2|g" $(git grep -l --extended-regexp "$1"); }

  # Replace FUZZ_TARGET_INIT
  ren 'FUZZ_TARGET_INIT\((.+), (.+)\)' 'FUZZ_TARGET(\1, .init = \2)'

  # Delete unused FUZZ_TARGET_INIT
  sed -i -e '37,39d' src/test/fuzz/fuzz.h

-END VERIFY SCRIPT-
2023-07-13 20:37:14 +02:00
MarcoFalke
fa36ad8b09
fuzz: Accept options in FUZZ_TARGET macro
* This allows to reduce the number of total macros.
* Also, adding a new option no longer requires doubling the number of
  macros in the worst case.
2023-07-13 20:37:05 +02:00
Andrew Chow
05ad4de158
Merge bitcoin/bitcoin#27411: p2p: Restrict self-advertisements with privacy networks to avoid fingerprinting
e7cf8657e1 test: add unit test for local address advertising (Martin Zumsande)
f4754b9dfb net: restrict self-advertisements with privacy networks (Martin Zumsande)
e4d541c7cf net, refactor: pass reference for peer address in GetReachabilityFrom (Martin Zumsande)
62d73f5370 net, refactor: pass CNode instead of CNetAddr to GetLocalAddress (Martin Zumsande)

Pull request description:

  The current logic for self-advertisements works such that we detect as many local addresses as we can, and then, using the scoring matrix from `CNetAddr::GetReachabilityFrom()`, self-advertise with the address that fits best to our peer.
  It is in general not hard for our peers to distinguish our self-advertisements from other addrs we send them, because we self-advertise every ~24h and because the first addr we send over a connection is likely our self-advertisement.

  `GetReachabilityFrom()` currently only takes into account actual reachability, but not whether we'd _want_ to announce our identity for one network to peers from other networks, which is not straightforward in connection with privacy networks.

  While the general approach is to prefer self-advertising with the address for the network our peer is on, there are several special situations in which we don't have one, and as a result could allow self-advertise other local addresses, for example:

  A) We run i2p and clearnet, use `-i2pacceptincoming=0` (so we have no local i2p address), and we have a local ipv4 address. In this case, we'd advertise the ipv4 address to our outbound i2p peers.

  B) Our `-discover` logic cannot detect any local clearnet addresses in our network environment, but we are actually reachable over clearnet. If we ran bitcoind clearnet-only, we'd always advertise the address our peer sees us with instead, and could get inbound peers this way. Now, if we also have an onion service running (but aren't using tor as a proxy for clearnet connections), we could advertise our onion address to clearnet peers, so that they would be able to connect our clearnet and onion identities.

  This PR tries to avoid these situations by
  1.) never advertising our local Tor or I2P address to peers from other networks.
  2.) never advertising local addresses from non-anonymity networks to peers from Tor or I2P

  Note that this affects only our own self-advertisements, the rules to forward other people's addrs are not changed.

  [Edit] after Initial [discussion](https://github.com/bitcoin/bitcoin/pull/27411#issuecomment-1497176155): CJDNS is not being treated like Tor and I2P at least for now, because it has different privacy properties and for the practical reason that it has still very few bitcoin nodes.

ACKs for top commit:
  achow101:
    ACK e7cf8657e1
  vasild:
    ACK e7cf8657e1
  luke-jr:
    utACK e7cf8657e1

Tree-SHA512: 3db8415dea6f82223d11a23bd6cbb3b8cf68831321280e926034a1f110cbe22562570013925f6fa20d8f08e41d0202fd69c733d9f16217318a660d2a1a21b795
2023-07-13 13:50:58 -04:00
Pieter Wuille
4e5c933f6a Switch all callers from poly1305_auth to Poly1305 class
This also removes the old poly1305_auth interface, as it no longer serves any
function. The new Poly1305 class based interface is more modern and safe.
2023-07-12 22:43:55 -04:00
Pieter Wuille
8871f7d1ae tests: add more Poly1305 test vectors 2023-07-12 22:43:52 -04:00
Pieter Wuille
40e6c5b9fc crypto: add Poly1305 class with std::byte Span interface 2023-07-12 22:40:55 -04:00
Andrew Chow
b4794740f8
Merge bitcoin/bitcoin#27985: Add support for RFC8439 variant of ChaCha20
0bf87476f5 test: add ChaCha20 test triggering 32-bit block counter overflow (Sebastian Falbesoner)
7f2a985147 tests: improve ChaCha20 unit tests (Pieter Wuille)
511a8d406e crypto: Implement RFC8439-compatible variant of ChaCha20 (Pieter Wuille)

Pull request description:

  Based on and replaces part of #25361, part of the BIP324 project (#27634). See also #19225 for background.

  There are two variants of ChaCha20 in use. The currently implemented one uses a 64-bit nonce and a 64-bit block counter, while the one used in RFC8439 (and thus BIP324) uses a 96-bit nonce and 32-bit block counter. This PR changes the logic to use the 96-bit nonce variant, though in a way that's compatible with >256 GiB output (by automatically incrementing the first 32-bit part of the nonce when the block counter overflows).

  For those who reviewed the original PR, the biggest change is here that the 96-bit nonce is passed as a Nonce96 type (pair of 32-bit + 64-bit integer) rather than a 12-byte array.

ACKs for top commit:
  achow101:
    ACK 0bf87476f5
  theStack:
    Code-review ACK 0bf87476f5

Tree-SHA512: 62e4cbd5388b8d50ef1a0dc99b6f4ad36c7b4419032035f8e622dda63a62311dd923032217e20054bcd836865d4be5c074f9e5538ca158f94f08eab75c5519c1
2023-07-12 12:58:44 -04:00
Ryan Ofsky
99b3af78bd
Merge bitcoin/bitcoin#28044: test: indexes, fix on error infinite loop
89ba8905f5 test: indexes, fix on error infinite loop (furszy)

Pull request description:

  Coming from https://github.com/bitcoin/bitcoin/pull/28036#issuecomment-1623813703, I thought that we were going to fix it there but seems that got merged without it for some reason.

  As index sync failures trigger a shutdown request without notifying `BaseIndex::BlockUntilSyncedToCurrentChain` in any way, we also need to check whether a shutdown was requested or not inside 'IndexWaitSynced'.

  Otherwise, any error inside the index sync process will hang the test forever.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 89ba8905f5
  jamesob:
    ACK 89ba890
  ryanofsky:
    Code review ACK 89ba8905f5. Just comment update since last review

Tree-SHA512: 1f6daf34e51d3fbc802799bfa4ac0ef0d8f774db5f9e2f5d35df18a77679778475c94efc3da1fb723ebaf3583e4075e4a5cbe4a5104ad0c50e2b32076e247b29
2023-07-11 12:30:56 -04:00
furszy
89ba8905f5
test: indexes, fix on error infinite loop
As index sync failures trigger a shutdown request without notifying
BaseIndex::BlockUntilSyncedToCurrentChain in any way, we also need
to check whether a shutdown was requested or not inside 'IndexWaitSynced'.

Otherwise, any error inside the index sync process will hang the test
forever.
2023-07-10 15:27:13 -03:00
Ryan Ofsky
ef29d5d7e2
Merge bitcoin/bitcoin#27607: index: make startup more efficient
ca91c244ef index: verify blocks data existence only once (furszy)
fcbdaeef4d init: don't start indexes sync thread prematurely (furszy)
2ec89f1970 refactor: simplify pruning violation check (furszy)
c82ef91eae make GetFirstStoredBlock assert that 'start_block' always has data (furszy)
430e7027a1 refactor: index, decouple 'Init' from 'Start' (furszy)
225e213110 refactor: init indexes, decouple 'Start()' from the creation step (furszy)
2ebc7e68cc doc: describe 'init load' thread actions (Martin Zumsande)
04575106b2 scripted-diff: rename 'loadblk' thread name to 'initload' (furszy)
ed4462cc78 init: start indexes sync earlier (furszy)

Pull request description:

  Simplifies index startup code, eliminating the `g_indexes_ready_to_sync` variable,
  deduplicating code and moving the prune violation check out of the `BaseIndex` class.

  Also makes startup more efficient by running the prune violation check once for all indexes
  instead of once for each index, and by delaying the prune violation check and moving it off
  of the main thread so the node can start up faster and perform the block data availability
  verification even when the '-reindex" or the "-reindex-chainstate" flags are enabled (which
  hasn't  being possible so far).

ACKs for top commit:
  ryanofsky:
    Code review ACK ca91c244ef. Just rebase and suggested changes since last review (Start return check, and code simplification)
  TheCharlatan:
    re-ACK ca91c244ef

Tree-SHA512: e9c98ce89aeb29e8d0f505f17b34aa54fe44efefbf017f4746e3b446ab4de25ade4f707254a0bbe4b99b69731b04a4067ce529eb7aa834ced196784b694cf7ce
2023-07-10 11:56:11 -04:00
furszy
ca91c244ef
index: verify blocks data existence only once
At present, during init, we traverse the chain (once per index)
to confirm that all necessary blocks to sync each index up to
the current tip are present.

To make the process more efficient, we can fetch the oldest block
from the indexers and perform the chain data existence check from
that point only once.

This also moves the pruning violation check to the end of the
'loadinit' thread, which is where the reindex, block loading and
chain activation processes happen.

Making the node's startup process faster, allowing us to remove
the global g_indexes_ready_to_sync flag, and enabling the
execution of the pruning violation verification even when the
reindex or reindex-chainstate flags are enabled (which has being
skipped so far).
2023-07-10 10:50:50 -03:00
furszy
2ec89f1970
refactor: simplify pruning violation check
By generalizing 'GetFirstStoredBlock' and implementing
'CheckBlockDataAvailability' we can dedup code and
avoid repeating work when multiple indexes are enabled.
E.g. get the oldest block across all indexes and
perform the pruning violation check from that point
up to the tip only once (this feature is being introduced
in a follow-up commit).

This commit shouldn't change behavior in any way.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
2023-07-10 10:50:50 -03:00
furszy
c82ef91eae
make GetFirstStoredBlock assert that 'start_block' always has data
And transfer the responsibility of verifying whether 'start_block'
has data or not to the caller.

This is because the 'GetFirstStoredBlock' function responsibility
is to return the first block containing data. And the current
implementation can return 'start_block' when it has no data!. Which
is misleading at least.

Edge case behavior change:
Previously, if the block tip lacked data but all preceding blocks
contained data, there was no prune violation. And now, such
scenario will result in a prune violation.
2023-07-10 10:47:17 -03:00
furszy
430e7027a1
refactor: index, decouple 'Init' from 'Start'
So indexes can be initialized without spawning
the sync thread.

This makes asynchronous indexes startup
possible in the following commits.
2023-07-10 10:47:17 -03:00
Sebastian Falbesoner
0bf87476f5 test: add ChaCha20 test triggering 32-bit block counter overflow
Verify that our ChaCha20 implementation using the 96/32 split interface
is compatible with >256 GiB outputs by triggering a 32-bit block counter
overflow and checking that the keystream matches one created with an
alternative implementation using a 64/64 split interface with the
corresponding input data. The test case data was generated with the
following Python script using the PyCryptodome library (version 3.15.0):

----------------------------------------------------------------------------------------------
from Crypto.Cipher import ChaCha20
key = bytes(list(range(32))); nonce = 0xdeadbeef12345678; pos = 2**32 - 1
c = ChaCha20.new(key=key, nonce=nonce.to_bytes(8, 'little'))
c.seek(pos * 64); stream = c.encrypt(bytes([0])*128)
print(f"Key: {key.hex()}\nNonce: {hex(nonce)}\nPos: {hex(pos)}\nStream: {stream.hex()}")
----------------------------------------------------------------------------------------------
2023-07-09 10:08:41 -04:00
furszy
3e8bf2e10c
test: make assumeUTXO test capture the expected fatal error
The test is exercising the error, so it can capture it before
the test framework displays it on the console as an unforeseen
fatal error.
2023-07-08 11:45:34 -03:00
Pieter Wuille
7f2a985147 tests: improve ChaCha20 unit tests 2023-07-07 17:17:20 -04:00
Pieter Wuille
511a8d406e crypto: Implement RFC8439-compatible variant of ChaCha20
There are two variants of ChaCha20 in use. The original one uses a 64-bit
nonce and a 64-bit block counter, while the one used in RFC8439 uses a
96-bit nonce and 32-bit block counter. This commit changes the interface
to use the 96/32 split (but automatically incrementing the first 32-bit
part of the nonce when the 32-bit block counter overflows, so to retain
compatibility with >256 GiB output).

Simultaneously, also merge the SetIV and Seek64 functions, as we almost
always call both anyway.

Co-authored-by: dhruv <856960+dhruv@users.noreply.github.com>
2023-07-07 17:16:27 -04:00
fanquake
a9dde841e1
Merge bitcoin/bitcoin#28012: util: Allow FastRandomContext::randbytes for std::byte, Allow std::byte serialization
fac6af16f4 Allow std::byte serialization (MarcoFalke)
fade43edc4 Allow FastRandomContext::randbytes for all byte types (MarcoFalke)

Pull request description:

  I need this for some stuff, but it should also be useful by itself for other developers that need it.

ACKs for top commit:
  sipa:
    utACK fac6af16f4
  dergoegge:
    Code review ACK fac6af16f4

Tree-SHA512: db4b1bbd6bf6ef6503d59b0b4ed1681db8d935d2d10f8d89f071978ea59b49a1d319bccb4e9717c0c88a4908bbeca4fd0cbff6c655d8a443554fd14146fe16de
2023-07-07 10:48:09 +01:00
fanquake
299f17a69e
Merge bitcoin/bitcoin#28036: test: Restore unlimited timeout in IndexWaitSynced
fabed7eb79 test: Restore unlimited timeout in IndexWaitSynced (MarcoFalke)

Pull request description:

  The timeout was unlimited before, so just restore that value for now: https://github.com/bitcoin/bitcoin/pull/27988#issuecomment-1619218007 .

  (Strictly speaking, this is a behavior change for the blockfilterindex and txindex tests, because it only restores the coinstatsindex behavior.)

ACKs for top commit:
  ajtowns:
    utACK fabed7eb79
  mzumsande:
    ACK fabed7eb79
  furszy:
    ACK fabed7eb

Tree-SHA512: 66a878be58bbe53ad8e0c23f05569dd42df688be747551fbd202ada22d20a8285714e58fa2a71664deadb070ddf86cfad88c01042ff95ed26f6b40e4a10cec0a
2023-07-07 09:57:37 +01:00
Ryan Ofsky
75135c673e
Merge bitcoin/bitcoin#27861: kernel: Rm ShutdownRequested and AbortNode from validation code.
6eb33bd0c2 kernel: Add fatalError method to notifications (TheCharlatan)
7320db96f8 kernel: Add flushError method to notifications (TheCharlatan)
3fa9094b92 scripted-diff: Rename FatalError to FatalErrorf (TheCharlatan)
edb55e2777 kernel: Pass interrupt reference to chainman (TheCharlatan)
e2d680a32d util: Add SignalInterrupt class and use in shutdown.cpp (TheCharlatan)

Pull request description:

  Get rid of all `ShutdownRequested` calls in validation code by introducing an interrupt object that applications can use to cancel long-running kernel operations.

  Replace all `AbortNode` calls in validation code with new fatal error and flush error notifications so kernel applications can be notified about failures and choose how to handle them.

  ---

  This pull request is part of the `libbitcoinkernel` project https://github.com/bitcoin/bitcoin/issues/27587 https://github.com/orgs/bitcoin/projects/3 and more specifically its "Step 2: Decouple most non-consensus code from libbitcoinkernel".

  The pull request mostly allows dropping the kernel dependency on shutdown.cpp. The only dependency left after this is a `StartShutdown` call which will be removed in followup PR https://github.com/bitcoin/bitcoin/pull/27711. This PR also drops the last reference to the `uiInterface` global in kernel code. The process of moving the `uiInterface` out of the kernel was started in https://github.com/bitcoin/bitcoin/pull/27636.

  This pull request contains a subset of patches originally proposed in #27711. It will be part of a series of changes required to make handling of interrupts (or in other words the current shutdown procedure) in the kernel library more transparent and less reliable on global mutable state. The set of patches contained here was originally proposed by @ryanofsky [here](https://github.com/bitcoin/bitcoin/pull/27711#issuecomment-1580779869).

ACKs for top commit:
  achow101:
    light ACK 6eb33bd0c2
  hebasto:
    ACK 6eb33bd0c2, I have reviewed the code and it looks OK.
  ryanofsky:
    Code review ACK 6eb33bd0c2. No changes since last review other than rebase.

Tree-SHA512: 7d2d05fa4805428a09466d43c11ae32946cbb25aa5e741b1eec9cd142e4de4bb311e13ebf1bb125ae490c9d08274f2d56c93314e10f3d69e7fec7445e504987c
2023-07-06 17:07:27 -04:00
MarcoFalke
fabed7eb79
test: Restore unlimited timeout in IndexWaitSynced
The timeout was unlimited before, so just restore that value for now:
https://github.com/bitcoin/bitcoin/pull/27988#issuecomment-1619218007
2023-07-06 14:19:59 +02:00
Andrew Chow
f08d914a67
Merge bitcoin/bitcoin#27920: wallet: bugfix, always use apostrophe for spkm descriptor ID
5df988b534 test: add coverage for descriptor ID (furszy)
6a9510d2da wallet: bugfix, always use apostrophe for spkm descriptor ID (furszy)
97a965d98f refactor: extract descriptor ID calculation from spkm GetID() (furszy)
1d207e3931 wallet: do not allow loading descriptor with an invalid ID (furszy)

Pull request description:

  Aiming to fix #27915.

  As we re-write the descriptor's db record every time that
  the wallet is loaded (at `TopUp` time), if the spkm ID differs
  from the one in db, the wallet will enter in an unrecoverable
  corruption state (due to the storage of a descriptor with an ID
  that is not linked to any other descriptor record in DB), and
  no soft version will be able to open it anymore.

  Because we cannot change the past, to stay compatible between
  releases, we need to always use the apostrophe version for the
  spkm IDs.

ACKs for top commit:
  achow101:
    ACK 5df988b534
  Sjors:
    tACK 5df988b534

Tree-SHA512: f63fc4aac7d21a4e515657471758d28857575e751865bfa359298f8b89b2568970029ca487a873c1786a5716325f453f06cd417ed193f3366417f6e8c2987332
2023-07-03 21:42:01 -04:00
Andrew Chow
6744d840df
Merge bitcoin/bitcoin#27745: addrman: select addresses by network follow-up
cd8ef5b3e6 test: ensure addrman test is finite (Amiti Uttarwar)
b9f1e86f12 addrman: change asserts to Assumes (Amiti Uttarwar)
768770771f doc: update `Select` function description (Amiti Uttarwar)
2b6bd12eea refactor: de-duplicate lookups (Amiti Uttarwar)

Pull request description:

  this PR addresses outstanding review comments from #27214

ACKs for top commit:
  achow101:
    ACK cd8ef5b3e6
  mzumsande:
    Code Review ACK cd8ef5b3e6
  brunoerg:
    crACK cd8ef5b3e6

Tree-SHA512: 669f67904263e3f51c39b175eabf5fa1b1e7b6841e889656afec33d0bd93fb446de9403f0a91b186ddeaf29498c8938484a0547b1188256c4e7c90db6f30bb55
2023-06-30 13:29:04 -04:00
fanquake
3367e1c850
Merge bitcoin/bitcoin#28009: script, test: python typing and linter updates
6c97757a48 script: appease spelling linter (Jon Atack)
1316119ce7 script: update ignored-words.txt (Jon Atack)
146c861da2 script: update linter dependencies (Jon Atack)
92408224a4 test: fix PEP484 no implicit optional argument types errors (Jon Atack)
f86a301433 script, test: add missing python type annotations (Jon Atack)

Pull request description:

  With these updates, `./test/lint/lint-python.py` and `./test/lint/lint-spelling.py` should be green again for developers using relatively recent Python dependencies, in particular mypy 0.991 (released 11/2022) and later. Please see the commit messages for details.

ACKs for top commit:
  fanquake:
    ACK 6c97757a48

Tree-SHA512: 8a46a4d36d5978affdcecf4f2ace20ca1b52d483e098304911a2169afe60ccb9b042fa90c04b762d94f3ce53d2cafe6f24476ae839867a770c7f31e7e7242d99
2023-06-30 16:20:37 +01:00
MarcoFalke
fac6af16f4
Allow std::byte serialization 2023-06-30 12:09:45 +02:00
fanquake
47ab00666e
Merge bitcoin/bitcoin#27988: test: Use same timeout for all index sync
fa086248e5 test: Use same timeout for all index sync (MarcoFalke)

Pull request description:

  Seems odd to use different timeouts.

  Fix this by using the same timeout for all syncs.

  May also fix https://github.com/bitcoin/bitcoin/issues/27355 or at least make it less frequent?

ACKs for top commit:
  mzumsande:
    code review ACK fa086248e5

Tree-SHA512: a61619247c97f3a88dd19eb3f200adedd120e6da8c4e4f2cf83621545b8c289dbad77e16f13cf7973a090f7b2c3391cb0297f09b0cc95fe4f55de21ae247670f
2023-06-30 10:06:58 +01:00
Jon Atack
6c97757a48 script: appease spelling linter 2023-06-29 16:14:07 -06:00
fanquake
3210f224db
refactor: remove in-code warning suppression
Should no-longer be needed post #27872. If it is, then
suppress-external-warnings should be fixed.
2023-06-29 14:41:33 +01:00
fanquake
3d51f7c9a8
Merge bitcoin/bitcoin#27932: test: Fuzz on macOS
fae7c50d20 test: Run fuzz tests on macOS (MarcoFalke)

Pull request description:

  Any reason not to?

ACKs for top commit:
  jamesob:
    Github ACK fae7c50d20
  dergoegge:
    utACK fae7c50d20

Tree-SHA512: e45122d73fafb17cea312258314b826cb0745e08daadd28465f687ec02d4c127d2f8cbe20179a9fff5712038850c02c968abb4838fa088b7555e28709317d3a3
2023-06-29 13:08:58 +01:00
Antoine Poinsot
e3280eae1b
miniscript: make GetStackSize() and GetOps() return optionals
The value is only set for satisfiable nodes, so it was undefined for
non-satisfiable nodes. Make it clear in the interface by returning
std::nullopt if the node isn't satisfiable instead of an undefined
value.
2023-06-29 11:35:42 +02:00
furszy
5df988b534
test: add coverage for descriptor ID
Tests vectors were calculated by running the same tests on
v25. Which was the last release prior to introducing the
diff in the descriptor's string representation ('h' format).

Co-authored-by: Sjors Provoost <sjors@sprovoost.nl>
2023-06-28 09:37:16 -03:00
MarcoFalke
fa086248e5
test: Use same timeout for all index sync 2023-06-28 12:45:36 +02:00
TheCharlatan
6eb33bd0c2
kernel: Add fatalError method to notifications
FatalError replaces what previously was the AbortNode function in
shutdown.cpp.

This commit is part of the libbitcoinkernel project and further removes
the shutdown's and, more generally, the kernel library's dependency on
interface_ui with a kernel notification method. By removing interface_ui
from the kernel library, its dependency on boost is reduced to just
boost::multi_index. At the same time it also takes a step towards
de-globalising the interrupt infrastructure.

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
Co-authored-by: TheCharlatan <seb.kung@gmail.com>
2023-06-28 09:52:33 +02:00
TheCharlatan
7320db96f8
kernel: Add flushError method to notifications
This is done in addition with the following commit. Both have the goal
of getting rid of direct calls to AbortNode from kernel code. This extra
flushError method is added to notify specifically about errors that
arrise when flushing (syncing) block data to disk. Unlike other
instances, the current calls to AbortNode in the blockstorage flush
functions do not report an error to their callers.

This commit is part of the libbitcoinkernel project and further removes
the shutdown's and, more generally, the kernel library's dependency on
interface_ui with a kernel notification method. By removing interface_ui
from the kernel library, its dependency on boost is reduced to just
boost::multi_index. At the same time it also takes a step towards
de-globalising the interrupt infrastructure.
2023-06-28 09:52:32 +02:00
TheCharlatan
edb55e2777
kernel: Pass interrupt reference to chainman
This and the following commit seek to decouple the libbitcoinkernel
library from the shutdown code. As a library, it should it should have
its own flexible interrupt infrastructure without relying on node-wide
globals.

The commit takes the first step towards this goal by de-globalising
`ShutdownRequested` calls in kernel code.

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
Co-authored-by: TheCharlatan <seb.kung@gmail.com>
2023-06-28 09:52:27 +02:00
MarcoFalke
fa38d86235
Use only Span{} constructor for byte-like types where possible
This removes bloat that is not needed.
2023-06-27 10:13:37 +02:00