Commit graph

26251 commits

Author SHA1 Message Date
Andrew Chow
6173269866 Set and check the sqlite user version 2020-10-14 11:28:18 -04:00
Andrew Chow
9d3d2d263c Use network magic as sqlite wallet application ID 2020-10-14 11:28:18 -04:00
Andrew Chow
9af5de3798 Use SQLite for descriptor wallets
MakeWalletDatabase no longer has a default DatabaseFormat. Instead
callers, like CWallet::Create, need to specify the database type to
create if the file does not exist. If it exists and NONE is given, then
CreateWalletDatabase will try to autodetect the type.
2020-10-14 11:28:18 -04:00
Andrew Chow
9b78f3ce8e walletutil: Wallets can also be sqlite 2020-10-14 11:28:18 -04:00
Andrew Chow
ac38a87225 Determine wallet file type based on file magic 2020-10-14 11:28:18 -04:00
Andrew Chow
6045f77003 Implement SQLiteDatabase::MakeBatch 2020-10-14 11:28:18 -04:00
Andrew Chow
727e6b2a4e Implement SQLiteDatabase::Verify 2020-10-14 11:28:18 -04:00
Andrew Chow
b4df8fdb19 Implement SQLiteDatabase::Rewrite
Rewrite uses the VACUUM command which does exactly what we want. A
specific advertised use case is to compact a database and ensure that
any deleted data is actually deleted.
2020-10-14 11:28:18 -04:00
Andrew Chow
010e365906 Implement SQLiteDatabase::TxnBegin, TxnCommit, and TxnAbort 2020-10-14 11:28:18 -04:00
Andrew Chow
ac5c1617e7 Implement SQLiteDatabase::Backup 2020-10-14 11:28:18 -04:00
Andrew Chow
f6f9cd6a64 Implement SQLiteBatch::StartCursor, ReadAtCursor, and CloseCursor 2020-10-14 11:28:18 -04:00
Andrew Chow
bf90e033f4 Implement SQLiteBatch::ReadKey, WriteKey, EraseKey, and HasKey 2020-10-14 11:28:18 -04:00
Andrew Chow
7aa45620e2 Add SetupSQLStatements 2020-10-14 11:28:18 -04:00
Andrew Chow
6636a2608a Implement SQLiteBatch::Close 2020-10-14 11:28:18 -04:00
Andrew Chow
93825352a3 Implement SQLiteDatabase::Close 2020-10-14 11:28:18 -04:00
Andrew Chow
a0de83372b Implement SQLiteDatabase::Open 2020-10-14 11:28:18 -04:00
Andrew Chow
3bfa0fe125 Initialize and Shutdown sqlite3 globals
sqlite3 recommends that sqlite3_initialize be called when the
application starts, and sqlite3_shutdown when it stops. Since we don't
always use sqlite3, we initialize it when a SQLiteDatabse is constructed
(calling sqlite3_initialize after initialized is a no-op). We call
sqlite3_shutdown when we see that there are no databases opened. The
number of open databases is tracked by an atomic g_dbs_open.
2020-10-14 11:28:18 -04:00
Andrew Chow
5a488b3d77 Constructors, destructors, and relevant private fields for SQLiteDatabase/Batch 2020-10-14 11:28:17 -04:00
Andrew Chow
ca8b7e04ab Implement SQLiteDatabaseVersion 2020-10-14 11:27:40 -04:00
Andrew Chow
7577b6e1c8 Add SQLiteDatabase and SQLiteBatch dummy classes 2020-10-14 11:27:37 -04:00
Andrew Chow
e87df82580 Add sqlite to travis and depends 2020-10-14 11:18:13 -04:00
Andrew Chow
54729f3f4e Add libsqlite3 2020-10-14 11:18:12 -04:00
Jon Atack
6272604bef
refactor: enable -netinfo to add future networks (i2p, cjdns)
After this commit, a new network may be added by changing 4 lines:
- increment the value of `m_networks_size`
- add the network name to `m_networks`
- add the network name to this line: `result += "        ipv4    ipv6   onion   total  block-relay\n";`
- add "counts.at(i).at(<m_networks pos>)" to this line: `result += strprintf("%-5s  %5i   %5i   %5i   %5i   %5i\n...`
2020-10-14 16:29:37 +02:00
Luke Dashjr
5b57dc5458 RPC: getpeerinfo: Wrap long help line for bytesrecv_per_msg 2020-10-14 14:16:43 +00:00
Luke Dashjr
d681a28219 RPC: getpeerinfo: Deprecate "whitelisted" field (replaced by "permissions") 2020-10-14 14:16:42 +00:00
Neha Narula
da0988daf1 scripted-diff: rename vRecvGetData
-BEGIN VERIFY SCRIPT-
sed -i 's/vRecvGetData/m_getdata_requests/g' src/net_processing.cpp
-END VERIFY SCRIPT-
2020-10-14 10:08:44 -04:00
Neha Narula
ba951812ec Guard vRecvGetData (now in net processing) with its own mutex
This requires slightly reorganizing the logic in GETBLOCKTXN to
maintain locking order.
2020-10-14 10:08:44 -04:00
Neha Narula
2d9f2fca43 Move vRecvGetData to net processing 2020-10-14 10:08:44 -04:00
Neha Narula
673247b58c Lock before checking if orphan_work_set is empty; indicate it is guarded 2020-10-14 10:08:44 -04:00
Neha Narula
8803aee668 Move m_orphan_work_set to net_processing 2020-10-14 10:08:37 -04:00
Wladimir J. van der Laan
99a1d572ea
Merge #18750: build: optionally skip external warnings
ba8950ee01 build: optionally skip external warnings (Vasil Dimov)

Pull request description:

  Add an option to `./configure` to suppress compilation warnings from
  external headers. The option is off by default (no change in behavior,
  show warnings from external headers).

  This option is useful if e.g. Boost or Qt is installed outside of
  `/usr/include` (warnings from headers in `/usr/include` are already
  suppressed by default) and those warnings stand in the way of compiling
  Bitcoin Core with `-Werror[=...]` or they just clutter the build output
  too much and make our own warnings hard to spot.

  `-isystem /usr/include` bricks GCC's `#include_next`, so we use
  `-idirafter` instead. This way we don't have to treat `/usr/include`
  specially.

ACKs for top commit:
  practicalswift:
    ACK ba8950ee01: diff looks correct!
  hebasto:
    ACK ba8950ee01, tested on Linux Mint 20 (x86_64).
  luke-jr:
    utACK ba8950ee01

Tree-SHA512: 9b54fae8590be6c79f2688a5aca09e0a9067f481dabecdd49bb278c08a62ac2b0cc704c894fbd53240e77ac84da0c7a237845df0a696cfbdb0359e1c8e2e10c9
2020-10-14 14:57:15 +02:00
Jon Atack
82fd40216c
refactor: promote some -netinfo localvars to class members 2020-10-14 14:56:07 +02:00
Jon Atack
5133fab37e
cli: simplify -netinfo using getpeerinfo network field 2020-10-14 14:56:05 +02:00
Jon Atack
4938a109ad
rpc, test: expose CNodeStats network in RPC getpeerinfo 2020-10-14 14:56:03 +02:00
Jon Atack
6df7882029
net: add peer network to CNodeStats 2020-10-14 14:55:55 +02:00
Wladimir J. van der Laan
9efa55c715
Merge #20130: Wallet: remove db mode string
135afa749c wallet: remove db mode string (Ivan Metlushko)

Pull request description:

  This is a [follow-up](https://github.com/bitcoin/bitcoin/pull/19077#discussion_r500261927) for #19077

  This PR simplifies DB interface by removing mode string from `WalletDatabase` and `WalletBatch`.

  The mode string was used to determine two flags for the instantiation of db connection:
  1) read-only flag. Never used on connection level. And on batch level Is only used within `BerkeleyDatabase::Rewrite` where it's replaced with bool flag.
  2) create flag. Is not required as we always check `require_existing` & `require_create` flags in `MakeDatabase()` before creating actual database instance. So we can safely default to always creating database if it doesn't exist yet.

ACKs for top commit:
  achow101:
    ACK 135afa749c
  laanwj:
    Code review ACK 135afa749c

Tree-SHA512: f49c07c7387c02e517a58199620a678a918f8dfc20d1347d29fd6adea0bc89698c26cb8eef42b0977961c11c207c4bbe109bc31059f47c126cc600b01fd987eb
2020-10-14 14:50:22 +02:00
MarcoFalke
3750f664b3
Merge #20129: tests: don't export in6addr_loopback
8e4d62280e tests: don't export in6addr_loopback (Vasil Dimov)

Pull request description:

  Don't export `in6addr_loopback` because that upsets
  `contrib/devtools/symbol-check.py`

  Fixes https://github.com/bitcoin/bitcoin/issues/20127

ACKs for top commit:
  sipa:
    utACK 8e4d62280e
  hebasto:
    ACK 8e4d62280e

Tree-SHA512: 216ffb53df55d2888317a81d18745308aaf93a3f3b45aa778166f7c91edb9741c28424d6333b35cefb5ece42b74e20ea21c761d93d8432798e7ec12097c2758f
2020-10-14 10:33:55 +02:00
MarcoFalke
fa1f6f237d
net: Send post-verack handshake messages at most once 2020-10-14 10:09:50 +02:00
fanquake
e21b824386
Merge #20109: Release notes and followups from 19339
88197b0769 [doc] release notes for max fee checking (gzhao408)
c201d73df3 style and nits for fee-checking in BroadcastTransaction (gzhao408)

Pull request description:

  Pretty trivial... addresses some tiny comments from #19339. Also fixes a docs typo from #19940 and adds a release note about the error message change for testmempoolaccept.

ACKs for top commit:
  achow101:
    ACK 88197b0769
  MarcoFalke:
    cr re-ACK 88197b0769

Tree-SHA512: fff16d731426b9b4db5222df02633983402f4c7241551eec98bb1554145dbdc132f40ed8ca4abd5edcebe1f4d1e879fb6d11bd91730604f6552c10cdf65706a1
2020-10-14 12:19:42 +08:00
Neha Narula
9c47cb29f9 [Rename only] Rename orphan_work_set to m_orphan_work_set.
This helps distinguish the member from any local variables.
2020-10-13 17:38:38 -04:00
MarcoFalke
fa299ac273
test: Speed up wallet_resendwallettransactions test with mockscheduler RPC 2020-10-13 15:38:18 +02:00
MarcoFalke
3333077823
rpc: Adjust witness-tx deserialize error message 2020-10-13 14:57:52 +02:00
MarcoFalke
ec0453cd57
Merge bitcoin-core/gui#102: Fix SplashScreen crash when run with -disablewallet
c056064a4a gui: Fix SplashScreen crash when run with -disablewallet (Hennadii Stepanov)

Pull request description:

  This PR fixes the bug introduced in https://github.com/bitcoin/bitcoin/pull/19099:

  ```
  $ src/qt/bitcoin-qt -disablewallet
  bitcoin-qt: interfaces/node.cpp:236: auto interfaces::(anonymous namespace)::NodeImpl::walletClient()::(anonymous class)::operator()() const: Assertion `"m_context->wallet_client" && check' failed.
  Aborted (core dumped)
  ```

ACKs for top commit:
  Sjors:
    tACK c056064
  promag:
    ACK c056064a4a.

Tree-SHA512: 263d9efd5899cc6e447dfc5142bf911ca627149fac0a1c5e5b58dd196aa5e0d12fe13e3f750fb5f3c4338222f7959935d2f77391263f967dbca2e0e79a416a29
2020-10-13 14:42:12 +02:00
MarcoFalke
cd6e193d4c
Merge #20126: test: p2p_leak_tx.py improvements (use MiniWallet, add p2p_lock acquires)
5b77f8098d test: add p2p_lock acquires in p2p_leak_tx.py (Sebastian Falbesoner)
cc8c6823b4 test: use MiniWallet for p2p_leak_tx.py (Sebastian Falbesoner)

Pull request description:

  This PR enables one more of the non-wallet functional tests (p2p_leak_tx.py) to be run even with the Bitcoin Core wallet disabled by using the new MiniWallet instead, as proposed in #20078. It also adds missing p2p_lock acquires that need to be held while modifying internal p2p Interface state (in this case the `last_message` dictionary) to avoid data races.

ACKs for top commit:
  laanwj:
    Code review ACK 5b77f8098d

Tree-SHA512: 6661bc6e3491a9af4bf040f379e5955c525136397e99d3eadde92e247580d0d87efff750e6d3b1f6d9a4e578144a433a982f574ef056b44dd6bca33873a1bae6
2020-10-13 14:27:30 +02:00
fanquake
ad90dd9f31
Merge #20141: Avoid the use of abs64 in timedata
d1292f25f2 Avoid the use of abs64 in timedata (Pieter Wuille)

Pull request description:

  Fixes #20135.

ACKs for top commit:
  kallewoof:
    ACK d1292f25f2
  jonatack:
    ACK d1292f25f2 code/logic review, verified there are no remaining callers of `abs64()`, verified no warnings in a debug build
  practicalswift:
    ACK d1292f25f2
  MarcoFalke:
    ACK d1292f25f2 🎹

Tree-SHA512: d17e95c668eb5e02ea546433b3d1b5a0ccbfb2c9cec62fa67dad1844d7e278a2576fbc0b75bddbf4db9af7331e978148c7bef7fce7e6a07e0eb917ef1392f302
2020-10-13 20:00:39 +08:00
Ivan Metlushko
135afa749c wallet: remove db mode string
We never need to open database in read-only mode as it's controlled
separately for every batch.

Also we can safely create database if it doesn't exist already
because require_existing option is verified in MakeDatabase
before creating a new WalletDatabase instance.
2020-10-13 18:42:59 +07:00
Pieter Wuille
d1292f25f2 Avoid the use of abs64 in timedata 2020-10-12 19:50:16 -07:00
Pieter Wuille
0e2a5e448f tests: dumping and minimizing of script assets data
This adds a --dumptests flag to the feature_taproot.py test, to dump all its
generated test cases to files, in a format compatible with the
script_assets_test unit test. A fuzzer for said format is added as well, whose
primary purpose is coverage-based minimization of those dumps.
2020-10-12 17:18:47 -07:00
Pieter Wuille
4567ba034c tests: add generic qa-asset-based script verification unit test
This adds a unit test that does generic script verification tests,
with positive/negative witnesses/scriptsigs, under various flags.
The test data is large (several MB) so it's stored in the qa-assets
repo.
2020-10-12 17:18:47 -07:00
Pieter Wuille
f06e6d0345 tests: functional tests for Schnorr/Taproot/Tapscript
A large functional test is added that automatically generates random transactions which
exercise various aspects of the new rules, and verifies they are accepted into the mempool
(when appropriate), and correctly accepted/rejected in (Python-constructed) blocks.

Includes sighashing code and many tests by Johnson Lau.
Includes a test by Matthew Zipkin.
Includes several tests and improvements by Greg Sanders.
2020-10-12 17:18:47 -07:00