0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-05 10:17:30 -05:00
bitcoin-bitcoin-core/src/test/fuzz
fanquake ce3bdd0ed1
Merge #19316: [net] Cleanup logic around connection types
01e283068b [net] Remove unnecessary default args on CNode constructor (Amiti Uttarwar)
bc5d65b3ca [refactor] Remove IsOutboundDisconnectionCandidate (Amiti Uttarwar)
2f2e13b6c2 [net/refactor] Simplify multiple-connection checks (Amiti Uttarwar)
7f7b83deb2 [net/refactor] Rework ThreadOpenConnections logic (Amiti Uttarwar)
35839e963b [net] Fix bug where AddrFetch connections would be counted as outbound full relay (Amiti Uttarwar)
4972c21b67 [net/refactor] Clarify logic for selecting connections in ThreadOpenConnections (Amiti Uttarwar)
60156f5fc4 [net/refactor] Remove fInbound flag from CNode (Amiti Uttarwar)
7b322df629 [net/refactor] Remove m_addr_fetch member var from CNode (Amiti Uttarwar)
14923422b0 [net/refactor] Remove fFeeler flag from CNode (Amiti Uttarwar)
49efac5cae [net/refactor] Remove m_manual_connection flag from CNode (Amiti Uttarwar)
d3698b5ee3 [net/refactor] Add connection type as a member var to CNode (Amiti Uttarwar)
46578c03e9 [doc] Describe different connection types (Amiti Uttarwar)
442abae2ba [net/refactor] Add AddrFetch connections to ConnectionType enum (Amiti Uttarwar)
af59feb052 [net/refactor] Extract m_addr_known logic from initializer list (Amiti Uttarwar)
e1bc29812d [net/refactor] Add block relay only connections to ConnectionType enum (Amiti Uttarwar)
0e52a659a2 [net/refactor] Add feeler connections to ConnectionType enum (Amiti Uttarwar)
1521c47438 [net/refactor] Add manual connections to ConnectionType enum (Amiti Uttarwar)
26304b4100 [net/refactor] Introduce an enum to distinguish type of connection (Amiti Uttarwar)
3f1b7140e9 scripted-diff: Rename OneShot to AddrFetch (Amiti Uttarwar)

Pull request description:

  **This is part 1 of #19315, which enables the ability to test `outbound` and `block-relay-only` connections from the functional tests.** Please see that PR for more information of overall functionality.

  **This PR simplifies how we manage different connection types.** It introduces an enum with the various types of connections so we can explicitly define the connection type. The existing system relies on a series of independent flags, then has asserts scattered around to ensure that conflicting flags are not enabled at the same time. I find this approach to be both brittle and confusing. While making these changes, I found a small bug due to the silent assumptions.

  This PR also proposes a rename from `OneShot` to `AddrFetch`. I find the name `OneShot` to be very confusing, especially when we also have `onetry` manual connections. Everyone I've talked to offline has agreed that the name is confusing, so I propose a potential alternative. I think this is a good opportunity for a rename since I'm creating an enum to explicitly define the connection types.
  (some context for the unfamiliar: `oneshot` or `addrfetch` connections are short-lived connections created on startup. They connect to the seed peers, send a `getaddr` to solicit addresses, then close the connection.)

  Overview of this PR:
  * rename `oneshot` to `addrfetch`
  * introduce `ConnectionType` enum
  * one by one, add different connection types to the enum
  * expose the `conn_type` on CNode, and use this to reduce reliance on flags (& asserts)
  * fix the bug in counting different type of connections
  * some additional cleanup to simplify logic and make expectations explicit/inclusive rather than implicit/exclusive.

ACKs for top commit:
  jnewbery:
    utACK 01e283068b
  laanwj:
    Code review ACK 01e283068b, the commits are pretty straightforward to follow, and I think this is a move in the right direction overall
  vasild:
    ACK 01e283068
  sdaftuar:
    ACK 01e283068b.
  fanquake:
    ACK 01e283068b - I don't have as much experience with the networking code but these changes look fairly straight forward, the new code seems more robust/understandable and the additional documentation is great. I'm glad that a followup branch is already underway. There might be some more review comments here later today, so keep an eye on the discussion, however I'm going to merge this now.
  jb55:
    wow this code was messy before... ACK 01e283068b

Tree-SHA512: 7bb644a6ed5849913d777ebc2ff89133ca0fbef680355a9a344e07496a979e6f9ff21a958e8eea93dcd7d5c343682b0c7174b1a3de380a4247eaae73da436e15
2020-08-12 10:01:44 +08:00
..
addition_overflow.cpp tests: Add fuzzing harness for AdditionOverflow(...) 2020-04-08 14:45:27 +00:00
addrdb.cpp fuzz: fix unused variable addrdb compiler warning 2020-07-19 08:31:34 +02:00
asmap.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
asmap_direct.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
autofile.cpp tests: Add fuzzing harness for CAutoFile (streams.h) 2020-07-15 11:41:21 +00:00
banman.cpp tests: Add fuzzing harness for BanMan 2020-07-08 05:31:43 +00:00
base_encode_decode.cpp scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
bech32.cpp tests: Add fuzzing harness for Bech32 encoding/decoding 2019-11-05 09:23:44 +00:00
block.cpp tests: Fill fuzzing coverage gaps for functions in consensus/validation.h 2020-05-14 18:45:42 +00:00
block_header.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
blockfilter.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
bloom_filter.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
buffered_file.cpp refactor: Drop unused CBufferedFile::Seek() 2020-07-26 22:46:28 +03:00
chain.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
checkqueue.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
coins_view.cpp rpc: gettxoutsetinfo can specify hash_type (only legacy option for now) 2020-06-22 00:55:44 +02:00
crypto.cpp Make Hash[160] consume range-like objects 2020-07-30 13:57:54 -07:00
crypto_aes256.cpp tests: Add fuzzing harness for AES256Encrypt/AES256Decrypt 2020-06-25 15:06:13 +00:00
crypto_aes256cbc.cpp tests: Add fuzzing harness for AES256CBCEncrypt/AES256CBCDecrypt 2020-06-25 15:06:13 +00:00
crypto_chacha20.cpp tests: Add fuzzing harness for ChaCha20 2020-06-25 15:06:13 +00:00
crypto_chacha20_poly1305_aead.cpp tests: Add fuzzing harness for ChaCha20Poly1305AEAD 2020-06-25 15:06:13 +00:00
crypto_common.cpp tests: Add fuzzing harness for {Read,Write}{LE,BE}{16,32,64} (crypto/common.h) 2020-06-11 14:05:54 +00:00
crypto_hkdf_hmac_sha256_l32.cpp tests: Add fuzzing harness for CHKDF_HMAC_SHA256_L32 2020-06-25 15:06:13 +00:00
crypto_poly1305.cpp tests: Add fuzzing harness for poly1305_auth(...) 2020-06-25 15:06:13 +00:00
cuckoocache.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
decode_tx.cpp refactor: Replace HexStr(o.begin(), o.end()) with HexStr(o) 2020-06-24 18:41:45 +02:00
descriptor_parse.cpp scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
deserialize.cpp scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
eval_script.cpp scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
fee_rate.cpp tests: Add fuzzing harness for CFeeRate 2020-03-15 16:25:29 +00:00
fees.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
flatfile.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
float.cpp tests: Add fuzzing harness for functions taking floating-point types as input 2020-01-31 12:36:13 +00:00
fuzz.cpp tests: Provide main(...) function in fuzzer 2020-06-25 21:03:27 +00:00
fuzz.h tests: Allow for using non-default fuzzing initialization 2019-10-23 11:10:10 +00:00
FuzzedDataProvider.h tests: Update FuzzedDataProvider.h from upstream (LLVM) 2020-01-27 21:31:42 +00:00
golomb_rice.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
hex.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
http_request.cpp tests: Avoid fuzzer-specific nullptr dereference in libevent when handling PROXY requests 2020-06-02 11:53:08 +00:00
integer.cpp Merge #18413: script: prevent UB when computing abs value for num opcode serialize 2020-05-02 21:24:05 +08:00
key.cpp Make Hash[160] consume range-like objects 2020-07-30 13:57:54 -07:00
key_io.cpp fuzz: Add missing ECC_Start to key_io test 2020-03-11 15:16:54 -04:00
kitchen_sink.cpp refactor: Error message bilingual_str consistency 2020-06-09 15:39:44 +02:00
load_external_block_file.cpp tests: Add fuzzing harness for LoadExternalBlockFile(...) (validation.h) 2020-07-15 11:41:21 +00:00
locale.cpp fuzz: fix unused variable compiler warning 2020-04-17 13:45:43 +02:00
merkleblock.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
message.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
multiplication_overflow.cpp tests: Don't assume presence of __builtin_mul_overflow in MultiplicationOverflow(...) fuzzing harness 2020-03-22 13:29:00 +00:00
net_permissions.cpp Add addr permission flag enabling non-cached addr sharing 2020-07-30 14:38:50 +03:00
netaddress.cpp tests: Add ConsumeSubNet(...). Move and increase coverage in ConsumeNetAddr(...). 2020-07-08 05:05:12 +00:00
p2p_transport_deserializer.cpp net: Use mockable time for ping/pong, add tests 2020-06-19 07:25:36 -04:00
parse_hd_keypath.cpp tests: Add fuzzing coverage for FormatHDKeypath(...) and WriteHDKeypath(...) 2020-04-26 20:23:56 +00:00
parse_iso8601.cpp tests: Add fuzzing harness for ISO-8601 related functions 2019-10-30 13:32:29 +00:00
parse_numbers.cpp tests: Add fuzzing harnesses for various number parsing functions 2019-12-10 16:39:40 +00:00
parse_script.cpp tests: Add ParseScript(...) (core_io) fuzzing harness 2019-12-10 16:39:40 +00:00
parse_univalue.cpp scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
policy_estimator.cpp tests: Add fuzzing harness for CBlockPolicyEstimator::{Read,Write} (policy/fees.h) 2020-07-15 11:41:21 +00:00
policy_estimator_io.cpp tests: Add fuzzing harness for CBlockPolicyEstimator::{Read,Write} (policy/fees.h) 2020-07-15 11:41:21 +00:00
pow.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
prevector.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
primitives_transaction.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
process_message.cpp [net/refactor] Add block relay only connections to ConnectionType enum 2020-08-07 17:18:16 -07:00
process_messages.cpp [net/refactor] Add AddrFetch connections to ConnectionType enum 2020-08-07 17:18:16 -07:00
protocol.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
psbt.cpp psbt: Allow both non_witness_utxo and witness_utxo 2020-06-24 16:31:42 -04:00
random.cpp tests: Add fuzzing harness for functions/classes in random.h 2020-03-29 13:17:04 +00:00
rbf.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
rolling_bloom_filter.cpp Switch from Optional<T> to std::optional<T> (C++17). Run clang-format. 2020-05-14 18:52:57 +00:00
script.cpp fuzz: add missing overrides to signature_checker 2020-07-22 05:27:13 +02:00
script_bitcoin_consensus.cpp tests: Add fuzzing harness for functions in script/bitcoinconsensus.h 2020-05-30 10:37:01 +00:00
script_descriptor_cache.cpp tests: Add fuzzing harness for functions in script/descriptor.h 2020-05-30 10:37:01 +00:00
script_flags.cpp scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
script_interpreter.cpp tests: Add fuzzing harness for functions in script/interpreter.h 2020-05-30 10:37:01 +00:00
script_ops.cpp script: Remove undocumented and unused operator+ 2020-04-15 10:01:55 -04:00
script_sigcache.cpp tests: Add fuzzing harness for functions in script/sigcache.h 2020-05-30 10:37:01 +00:00
script_sign.cpp tests: Add fuzzing harness for functions in script/sign.h 2020-05-30 10:37:01 +00:00
scriptnum_ops.cpp fuzz: add missing overrides to signature_checker 2020-07-22 05:27:13 +02:00
signature_checker.cpp fuzz: add missing overrides to signature_checker 2020-07-22 05:27:13 +02:00
span.cpp Simplify usage of Span in several places 2020-05-12 14:19:40 -07:00
spanparsing.cpp Simplify usage of Span in several places 2020-05-12 14:19:40 -07:00
string.cpp tests: Fill fuzzing coverage gaps for functions in script/script.h, script/script_error.h and script/standard.h 2020-05-30 10:37:01 +00:00
strprintf.cpp tests: Fill fuzzing coverage gaps for functions in util/translation.h 2020-05-14 18:52:57 +00:00
system.cpp fuzz: fix vector size problem in system fuzzer 2020-05-08 20:21:48 +02:00
timedata.cpp tests: Add fuzzing harness for functions in timedata.h 2020-03-24 14:39:23 +00:00
transaction.cpp scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
tx_in.cpp tests: Add fuzzing harness for various CTxIn related functions 2019-12-06 09:10:31 +00:00
tx_out.cpp tests: Add fuzzing harness for various CTxOut related functions 2019-12-06 09:10:44 +00:00
util.h test: Fix fuzzer compilation on macOS 2020-07-21 15:23:49 -07:00