Skip to content

Commit

Permalink
Merge pull request dashpay#5530 from vijaydasmp/bp22_14
Browse files Browse the repository at this point in the history
backport: bitcoin#15545,18418, 20681,20829,21042,21394,21398,21567,21736,21759
  • Loading branch information
PastaPastaPasta authored Aug 28, 2023
2 parents 4ce7ed8 + 22122ba commit 27be6e6
Show file tree
Hide file tree
Showing 31 changed files with 152 additions and 125 deletions.
56 changes: 20 additions & 36 deletions depends/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,44 +89,28 @@ For linux S390X cross compilation:
pkg_add bash gtar

### Dependency Options

The following can be set when running make: `make FOO=bar`

<dl>
<dt>SOURCES_PATH</dt>
<dd>downloaded sources will be placed here</dd>
<dt>BASE_CACHE</dt>
<dd>built packages will be placed here</dd>
<dt>SDK_PATH</dt>
<dd>Path where sdk's can be found (used by macOS)</dd>
<dt>FALLBACK_DOWNLOAD_PATH</dt>
<dd>If a source file can't be fetched, try here before giving up</dd>
<dt>NO_QT</dt>
<dd>Don't download/build/cache qt and its dependencies</dd>
<dt>NO_QR</dt>
<dd>Don't download/build/cache packages needed for enabling qrencode</dd>
<dt>NO_ZMQ</dt>
<dd>Don't download/build/cache packages needed for enabling zeromq</dd>
<dt>NO_WALLET</dt>
<dd>Don't download/build/cache libs needed to enable the wallet</dd>
<dt>NO_BDB</dt>
<dd>Don't download/build/cache BerkeleyDB</dd>
<dt>NO_SQLITE</dt>
<dd>Don't download/build/cache SQLite</dd>
<dt>NO_UPNP</dt>
<dd>Don't download/build/cache packages needed for enabling upnp</dd>
<dt>NO_NATPMP</dt>
<dd>Don't download/build/cache packages needed for enabling NAT-PMP</dd>
<dt>DEBUG</dt>
<dd>disable some optimizations and enable more runtime checking</dd>
<dt>HOST_ID_SALT</dt>
<dd>Optional salt to use when generating host package ids</dd>
<dt>BUILD_ID_SALT</dt>
<dd>Optional salt to use when generating build package ids</dd>
<dt>FORCE_USE_SYSTEM_CLANG</dt>
<dd>(EXPERTS ONLY) When cross-compiling for macOS, use Clang found in the
system's <code>$PATH</code> rather than the default prebuilt release of Clang
from llvm.org. Clang 8 or later is required.</dd>
</dl>
- `SOURCES_PATH`: Downloaded sources will be placed here
- `BASE_CACHE`: Built packages will be placed here
- `SDK_PATH`: Path where SDKs can be found (used by macOS)
- `FALLBACK_DOWNLOAD_PATH`: If a source file can't be fetched, try here before giving up
- `NO_QT`: Don't download/build/cache Qt and its dependencies
- `NO_QR`: Don't download/build/cache packages needed for enabling qrencode
- `NO_ZMQ`: Don't download/build/cache packages needed for enabling ZeroMQ
- `NO_WALLET`: Don't download/build/cache libs needed to enable the wallet
- `NO_BDB`: Don't download/build/cache BerkeleyDB
- `NO_SQLITE`: Don't download/build/cache SQLite
- `NO_UPNP`: Don't download/build/cache packages needed for enabling UPnP
- `NO_NATPMP`: Don't download/build/cache packages needed for enabling NAT-PMP
- `DEBUG`: Disable some optimizations and enable more runtime checking
- `HOST_ID_SALT`: Optional salt to use when generating host package ids
- `BUILD_ID_SALT`: Optional salt to use when generating build package ids
- `FORCE_USE_SYSTEM_CLANG`: (EXPERTS ONLY) When cross-compiling for macOS, use Clang found in the
system's `$PATH` rather than the default prebuilt release of Clang
from llvm.org. Clang 8 or later is required.

If some packages are not built, for example `make NO_WALLET=1`, the appropriate
options will be passed to Dash Core's configure. In this case, `--disable-wallet`.

Expand Down
19 changes: 9 additions & 10 deletions doc/fuzzing.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,33 +128,32 @@ Full configure that was tested on macOS Catalina with `brew` installed `llvm`:
Read the [libFuzzer documentation](https://llvm.org/docs/LibFuzzer.html) for more information. This [libFuzzer tutorial](https://github.com/google/fuzzing/blob/master/tutorial/libFuzzerTutorial.md) might also be of interest.
# Fuzzing Dash Core using american fuzzy lop (`afl-fuzz`)
# Fuzzing Dash Core using afl++
## Quickstart guide
To quickly get started fuzzing Dash Core using [`afl-fuzz`](https://github.com/google/afl):
To quickly get started fuzzing Dash Core using [afl++](https://github.com/AFLplusplus/AFLplusplus):
```sh
$ git clone https://github.com/dashpay/dash
$ cd dash/
$ git clone https://github.com/google/afl
$ make -C afl/
$ make -C afl/llvm_mode/
$ git clone https://github.com/AFLplusplus/AFLplusplus
$ make -C AFLplusplus/ source-only
$ ./autogen.sh
# It is possible to compile with afl-gcc and afl-g++ instead of afl-clang. However, running afl-fuzz
# may require more memory via the -m flag.
$ CC=$(pwd)/afl/afl-clang-fast CXX=$(pwd)/afl/afl-clang-fast++ ./configure --enable-fuzz --enable-c++17
# If afl-clang-lto is not available, see
# https://github.com/AFLplusplus/AFLplusplus#a-selecting-the-best-afl-compiler-for-instrumenting-the-target
$ CC=$(pwd)/AFLplusplus/afl-clang-lto CXX=$(pwd)/AFLplusplus/afl-clang-lto++ ./configure --enable-fuzz --enable-c++17
$ make
# For macOS you may need to ignore x86 compilation checks when running "make". If so,
# try compiling using: AFL_NO_X86=1 make
$ mkdir -p inputs/ outputs/
$ echo A > inputs/thin-air-input
$ FUZZ=bech32 afl/afl-fuzz -i inputs/ -o outputs/ -- src/test/fuzz/fuzz
$ FUZZ=bech32 AFLplusplus/afl-fuzz -i inputs/ -o outputs/ -- src/test/fuzz/fuzz
# You may have to change a few kernel parameters to test optimally - afl-fuzz
# will print an error and suggestion if so.
```
Read the [`afl-fuzz` documentation](https://github.com/google/afl) for more information.
Read the [afl++ documentation](https://github.com/AFLplusplus/AFLplusplus) for more information.
# Fuzzing Dash Core using Honggfuzz
Expand Down
70 changes: 67 additions & 3 deletions src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static void SetupCliArgs(ArgsManager& argsman)
argsman.AddArg("-datadir=<dir>", "Specify data directory", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-generate", strprintf("Generate blocks immediately, equivalent to RPC generatenewaddress followed by RPC generatetoaddress. Optional positional integer arguments are number of blocks to generate (default: %s) and maximum iterations to try (default: %s), equivalent to RPC generatetoaddress nblocks and maxtries arguments. Example: dash-cli -generate 4 1000", DEFAULT_NBLOCKS, DEFAULT_MAX_TRIES), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-getinfo", "Get general information from the remote server. Note that unlike server-side RPC calls, the results of -getinfo is the result of multiple non-atomic requests. Some entries in the result may represent results from different states (e.g. wallet balance may be as of a different block from the chain state reported)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-netinfo", "Get network peer connection information from the remote server. An optional integer argument from 0 to 4 can be passed for different peers listings (default: 0).", ArgsManager::ALLOW_INT, OptionsCategory::OPTIONS);
argsman.AddArg("-netinfo", "Get network peer connection information from the remote server. An optional integer argument from 0 to 4 can be passed for different peers listings (default: 0). Pass \"help\" for detailed help documentation.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-named", strprintf("Pass named instead of positional arguments (default: %s)", DEFAULT_NAMED), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-rpcclienttimeout=<n>", strprintf("Timeout in seconds during HTTP requests, or 0 for no timeout. (default: %d)", DEFAULT_HTTP_CLIENT_TIMEOUT), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-rpcconnect=<ip>", strprintf("Send commands to node running on <ip> (default: %s)", DEFAULT_RPCCONNECT), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
Expand Down Expand Up @@ -312,7 +312,8 @@ class NetinfoRequestHandler : public BaseRequestHandler
}
return UNKNOWN_NETWORK;
}
uint8_t m_details_level{0}; //!< Optional user-supplied arg to set dashboard details level
uint8_t m_details_level{0}; //!< Optional user-supplied arg to set dashboard details level
bool m_is_help_requested{false}; //!< Optional user-supplied arg to print help documentation
bool DetailsRequested() const { return m_details_level > 0 && m_details_level < 5; }
bool IsAddressSelected() const { return m_details_level == 2 || m_details_level == 4; }
bool IsVersionSelected() const { return m_details_level == 3 || m_details_level == 4; }
Expand Down Expand Up @@ -344,6 +345,62 @@ class NetinfoRequestHandler : public BaseRequestHandler
if (gArgs.GetChainName() == CBaseChainParams::REGTEST) return " regtest";
return "";
}
const UniValue NetinfoHelp()
{
return std::string{
"-netinfo level|\"help\" \n\n"
"Returns a network peer connections dashboard with information from the remote server.\n"
"Under the hood, -netinfo fetches the data by calling getpeerinfo and getnetworkinfo.\n"
"An optional integer argument from 0 to 4 can be passed for different peers listings.\n"
"Pass \"help\" to see this detailed help documentation.\n"
"If more than one argument is passed, only the first one is read and parsed.\n"
"Suggestion: use with the Linux watch(1) command for a live dashboard; see example below.\n\n"
"Arguments:\n"
"1. level (integer 0-4, optional) Specify the info level of the peers dashboard (default 0):\n"
" 0 - Connection counts and local addresses\n"
" 1 - Like 0 but with a peers listing (without address or version columns)\n"
" 2 - Like 1 but with an address column\n"
" 3 - Like 1 but with a version column\n"
" 4 - Like 1 but with both address and version columns\n"
"2. help (string \"help\", optional) Print this help documentation instead of the dashboard.\n\n"
"Result:\n\n"
"* The peers listing in levels 1-4 displays all of the peers sorted by direction and minimum ping time:\n\n"
" Column Description\n"
" ------ -----------\n"
" <-> Direction\n"
" \"in\" - inbound connections are those initiated by the peer\n"
" \"out\" - outbound connections are those initiated by us\n"
" type Type of peer connection\n"
" \"full\" - full relay, the default\n"
" \"block\" - block relay; like full relay but does not relay transactions or addresses\n"
" net Network the peer connected through (\"ipv4\", \"ipv6\", \"onion\", \"i2p\", or \"cjdns\")\n"
" mping Minimum observed ping time, in milliseconds (ms)\n"
" ping Last observed ping time, in milliseconds (ms)\n"
" send Time since last message sent to the peer, in seconds\n"
" recv Time since last message received from the peer, in seconds\n"
" txn Time since last novel transaction received from the peer and accepted into our mempool, in minutes\n"
" blk Time since last novel block passing initial validity checks received from the peer, in minutes\n"
" age Duration of connection to the peer, in minutes\n"
" asmap Mapped AS (Autonomous System) number in the BGP route to the peer, used for diversifying\n"
" peer selection (only displayed if the -asmap config option is set)\n"
" id Peer index, in increasing order of peer connections since node startup\n"
" address IP address and port of the peer\n"
" version Peer version and subversion concatenated, e.g. \"70016/Satoshi:21.0.0/\"\n\n"
"* The connection counts table displays the number of peers by direction, network, and the totals\n"
" for each, as well as a column for block relay peers.\n\n"
"* The local addresses table lists each local address broadcast by the node, the port, and the score.\n\n"
"Examples:\n\n"
"Connection counts and local addresses only\n"
"> dash-cli -netinfo\n\n"
"Compact peers listing\n"
"> dash-cli -netinfo 1\n\n"
"Full dashboard\n"
"> dash-cli -netinfo 4\n\n"
"Full live dashboard, adjust --interval or --no-title as needed (Linux)\n"
"> watch --interval 1 --no-title dash-cli -netinfo 4\n\n"
"See this help\n"
"> dash-cli -netinfo help\n"};
}
const int64_t m_time_now{GetSystemTimeInSeconds()};

public:
Expand All @@ -356,6 +413,10 @@ class NetinfoRequestHandler : public BaseRequestHandler
uint8_t n{0};
if (ParseUInt8(args.at(0), &n)) {
m_details_level = n;
} else if (args.at(0) == "help") {
m_is_help_requested = true;
} else {
throw std::runtime_error(strprintf("invalid -netinfo argument: %s", args.at(0)));
}
}
UniValue result(UniValue::VARR);
Expand All @@ -366,6 +427,9 @@ class NetinfoRequestHandler : public BaseRequestHandler

UniValue ProcessReply(const UniValue& batch_in) override
{
if (m_is_help_requested) {
return JSONRPCReplyObj(NetinfoHelp(), NullUniValue, 1);
}
const std::vector<UniValue> batch{JSONRPCProcessBatchReply(batch_in)};
if (!batch[ID_PEERINFO]["error"].isNull()) return batch[ID_PEERINFO];
if (!batch[ID_NETWORKINFO]["error"].isNull()) return batch[ID_NETWORKINFO];
Expand Down Expand Up @@ -417,7 +481,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
// Report detailed peer connections list sorted by direction and minimum ping time.
if (DetailsRequested() && !m_peers.empty()) {
std::sort(m_peers.begin(), m_peers.end());
result += "Peer connections sorted by direction and min ping\n<-> relay net mping ping send recv txn blk uptime ";
result += "<-> relay net mping ping send recv txn blk uptime ";
if (m_is_asmap_on) result += " asmap ";
result += strprintf("%*s %-*s%s\n", m_max_id_length, "id", IsAddressSelected() ? m_max_addr_length : 0, IsAddressSelected() ? "address" : "", IsVersionSelected() ? "version" : "");
for (const Peer& peer : m_peers) {
Expand Down
9 changes: 5 additions & 4 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ std::optional<Consensus::LLMQParams> CChainParams::GetLLMQ(Consensus::LLMQType l
}

/**
* Main network
* Main network on which people trade goods and services.
*/
class CMainParams : public CChainParams {
public:
Expand Down Expand Up @@ -325,7 +325,7 @@ class CMainParams : public CChainParams {
};

/**
* Testnet (v3)
* Testnet (v3): public test network which is reset from time to time.
*/
class CTestNetParams : public CChainParams {
public:
Expand Down Expand Up @@ -496,7 +496,7 @@ class CTestNetParams : public CChainParams {
};

/**
* Devnet
* Devnet: The Development network intended for developers use.
*/
class CDevNetParams : public CChainParams {
public:
Expand Down Expand Up @@ -731,7 +731,8 @@ class CDevNetParams : public CChainParams {
};

/**
* Regression test
* Regression test: intended for private networks only. Has minimal difficulty to ensure that
* blocks can be found instantly.
*/
class CRegTestParams : public CChainParams {
public:
Expand Down
5 changes: 1 addition & 4 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ struct ChainTxData {

/**
* CChainParams defines various tweakable parameters of a given instance of the
* Dash system. There are three: the main network on which people trade goods
* and services, the public test network which gets reset from time to time and
* a regression test mode which is intended for private networks only. It has
* minimal difficulty to ensure that blocks can be found instantly.
* Dash system.
*/
class CChainParams
{
Expand Down
2 changes: 1 addition & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ struct CNodeState {
* - its connection type is IsBlockOnlyConn() == false
* - it gave us a valid connecting header
* - we haven't reached MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT yet
* - it has a better chain than we have
* - its chain tip has at least as much work as ours
*
* CHAIN_SYNC_TIMEOUT: if a peer's best known block has less work than our tip,
* set a timeout CHAIN_SYNC_TIMEOUT seconds in the future:
Expand Down
2 changes: 1 addition & 1 deletion src/script/descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ class DescriptorImpl : public Descriptor
* m_subdescriptor_arg, or just once in case m_subdescriptor_arg is nullptr.
* @param pubkeys The evaluations of the m_pubkey_args field.
* @param script The evaluation of m_subdescriptor_arg (or nullptr when m_subdescriptor_arg is nullptr).
* @param scripts The evaluation of m_subdescriptor_arg (or nullptr when m_subdescriptor_arg is nullptr).
* @param out A FlatSigningProvider to put scripts or public keys in that are necessary to the solver.
* The script arguments to this function are automatically added, as is the origin info of the provided pubkeys.
* @return A vector with scriptPubKeys for this descriptor.
Expand Down
Loading

0 comments on commit 27be6e6

Please sign in to comment.