Merge c08bf2b574 into merged_master (Bitcoin PR #15437)

This commit is contained in:
Andrew Poelstra 2020-11-09 21:20:35 +00:00
commit 55b110cabc
14 changed files with 70 additions and 420 deletions

View file

@ -15,7 +15,7 @@ BIPs that are implemented by Bitcoin Core (up-to-date up to **v0.19.0**):
* [`BIP 35`](https://github.com/bitcoin/bips/blob/master/bip-0035.mediawiki): The 'mempool' protocol message (and the protocol version bump to 60002) has been implemented since **v0.7.0** ([PR #1641](https://github.com/bitcoin/bitcoin/pull/1641)). As of **v0.13.0**, this is only available for `NODE_BLOOM` (BIP 111) peers.
* [`BIP 37`](https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki): The bloom filtering for transaction relaying, partial Merkle trees for blocks, and the protocol version bump to 70001 (enabling low-bandwidth SPV clients) has been implemented since **v0.8.0** ([PR #1795](https://github.com/bitcoin/bitcoin/pull/1795)). Disabled by default since **v0.19.0**, can be enabled by the `-peerbloomfilters` option.
* [`BIP 42`](https://github.com/bitcoin/bips/blob/master/bip-0042.mediawiki): The bug that would have caused the subsidy schedule to resume after block 13440000 was fixed in **v0.9.2** ([PR #3842](https://github.com/bitcoin/bitcoin/pull/3842)).
* [`BIP 61`](https://github.com/bitcoin/bips/blob/master/bip-0061.mediawiki): The 'reject' protocol message (and the protocol version bump to 70002) was added in **v0.9.0** ([PR #3185](https://github.com/bitcoin/bitcoin/pull/3185)). Starting **v0.17.0**, whether to send reject messages can be configured with the `-enablebip61` option, and support is deprecated as of **v0.18.0**.
* [`BIP 61`](https://github.com/bitcoin/bips/blob/master/bip-0061.mediawiki): The 'reject' protocol message (and the protocol version bump to 70002) was added in **v0.9.0** ([PR #3185](https://github.com/bitcoin/bitcoin/pull/3185)). Starting **v0.17.0**, whether to send reject messages can be configured with the `-enablebip61` option, and support is deprecated (disabled by default) as of **v0.18.0**. Support was removed in **v0.20.0** ([PR #15437](https://github.com/bitcoin/bitcoin/pull/15437)).
* [`BIP 65`](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki): The CHECKLOCKTIMEVERIFY softfork was merged in **v0.12.0** ([PR #6351](https://github.com/bitcoin/bitcoin/pull/6351)), and backported to **v0.11.2** and **v0.10.4**. Mempool-only CLTV was added in [PR #6124](https://github.com/bitcoin/bitcoin/pull/6124).
* [`BIP 66`](https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki): The strict DER rules and associated version 3 blocks have been implemented since **v0.10.0** ([PR #5713](https://github.com/bitcoin/bitcoin/pull/5713)).
* [`BIP 68`](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki): Sequence locks have been implemented as of **v0.12.1** ([PR #7184](https://github.com/bitcoin/bitcoin/pull/7184)), and have been activated since *block 419328*.

View file

@ -1,12 +1,12 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10.
.TH ELEMENTSD "1" "May 2019" "elementsd v0.17.0.1" "User Commands"
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.6.
.TH ELEMENTSD "1" "February 2019" "elementsd v0.17.99.0" "User Commands"
.SH NAME
elementsd \- manual page for elementsd v0.17.0.1
elementsd \- manual page for elementsd v0.17.99.0
.SH SYNOPSIS
.B elementsd
[\fI\,options\/\fR] \fI\,Start Elements Core Daemon\/\fR
.SH DESCRIPTION
Elements Core Daemon version v0.17.0.1\-dirty
Elements Core Daemon version v0.17.99.0
.SH OPTIONS
.HP
\-?
@ -23,7 +23,7 @@ long fork (%s in cmd is replaced by message)
If this block is in the chain assume that it and its ancestors are valid
and potentially skip their script verification (0 to verify all,
default:
0000000000000000000f1c54590ee18d15ec70e68c8cd4cfbadb1b4f11697eee,
0000000000000000002e63058c023a9a1de233554f28c7b21380b6c9003f36a8,
testnet:
0000000000000037a8cd3e06cd5edbfe9dd1dbcc5dacab279376ef7cfc2b4c75)
.HP
@ -56,9 +56,7 @@ Specify data directory
.HP
\fB\-dbcache=\fR<n>
.IP
Maximum database cache size <n> MiB (4 to 16384, default: 450). In
addition, unused mempool memory is shared for this cache (see
\fB\-maxmempool\fR).
Set database cache size in MiB (4 to 16384, default: 450)
.HP
\fB\-debuglogfile=\fR<file>
.IP
@ -100,7 +98,7 @@ Whether to save the mempool on shutdown and load on restart (default: 1)
\fB\-pid=\fR<file>
.IP
Specify pid file. Relative paths will be prefixed by a net\-specific
datadir location. (default: bitcoind.pid)
datadir location. (default: elementsd.pid)
.HP
\fB\-prune=\fR<n>
.IP
@ -181,10 +179,6 @@ Allow DNS lookups for \fB\-addnode\fR, \fB\-seednode\fR and \fB\-connect\fR (def
Query for peer addresses via DNS lookup, if low on addresses (default: 1
unless \fB\-connect\fR used)
.HP
\fB\-enablebip61\fR
.IP
Send reject messages per BIP61 (default: 0)
.HP
\fB\-externalip=\fR<ip>
.IP
Specify your own public address
@ -279,6 +273,10 @@ Tor control port to use if onion listening enabled (default:
.IP
Tor control port password (default: empty)
.HP
\fB\-upnp\fR
.IP
Use UPnP to map the listening port (default: 0)
.HP
\fB\-whitebind=\fR<addr>
.IP
Bind to given address and whitelist peers connecting to it. Use
@ -390,7 +388,7 @@ by TxID)
.HP
\fB\-walletrbf\fR
.IP
Send transactions with full\-RBF opt\-in enabled (RPC only, default: 1)
Send transactions with full\-RBF opt\-in enabled (RPC only, default: 0)
.HP
\fB\-zapwallettxes=\fR<mode>
.IP
@ -404,35 +402,17 @@ ZeroMQ notification options:
.IP
Enable publish hash block in <address>
.HP
\fB\-zmqpubhashblockhwm=\fR<n>
.IP
Set publish hash block outbound message high water mark (default: 1000)
.HP
\fB\-zmqpubhashtx=\fR<address>
.IP
Enable publish hash transaction in <address>
.HP
\fB\-zmqpubhashtxhwm=\fR<n>
.IP
Set publish hash transaction outbound message high water mark (default:
1000)
.HP
\fB\-zmqpubrawblock=\fR<address>
.IP
Enable publish raw block in <address>
.HP
\fB\-zmqpubrawblockhwm=\fR<n>
.IP
Set publish raw block outbound message high water mark (default: 1000)
.HP
\fB\-zmqpubrawtx=\fR<address>
.IP
Enable publish raw transaction in <address>
.HP
\fB\-zmqpubrawtxhwm=\fR<n>
.IP
Set publish raw transaction outbound message high water mark (default:
1000)
.PP
Debugging/Testing options:
.HP
@ -484,136 +464,6 @@ Append comment to the user agent string
.PP
Chain selection options:
.HP
\fB\-bech32_hrp\fR
.IP
The human\-readable part of the chain's bech32 encoding. (default: bc)
.HP
\fB\-blech32_hrp\fR
.IP
The human\-readable part of the chain's blech32 encoding. Used in
confidential addresses.(default: )
.HP
\fB\-chain=\fR<chain>
.IP
Use the chain <chain> (default: main). Reserved values: main, test,
regtest
.HP
\fB\-con_blockheightinheader\fR
.IP
Whether the chain includes the block height directly in the header, for
easier validation of block height in low\-resource environments.
(default: true)
.HP
\fB\-con_has_parent_chain\fR
.IP
Whether or not there is a parent chain.
.HP
\fB\-con_max_block_sig_size\fR
.IP
Max allowed witness data for the signed block header.
.HP
\fB\-con_parent_chain_signblockscript\fR
.IP
Whether parent chain uses pow or signed blocks. If the parent chain uses
signed blocks, the challenge (scriptPubKey) script. If not, an
empty string. (default: empty script [ie parent uses pow])
.HP
\fB\-con_parent_pegged_asset=\fR<hex>
.IP
Asset ID (hex) for pegged asset for when parent chain has CA. (default:
0x00)
.HP
\fB\-con_parentpowlimit\fR
.IP
The proof\-of\-work limit value for the parent chain.
.HP
\fB\-con_signed_blocks\fR
.IP
Signed blockchain. Uses input of `\-signblockscript` to define what
signatures are necessary to solve it.
.HP
\fB\-ct_bits\fR
.IP
The default number of hiding bits in a rangeproof. Will be exceeded to
cover amounts exceeding the maximum hiding value. (default: 36)
.HP
\fB\-ct_exponent\fR
.IP
The hiding exponent. (default: 0)
.HP
\fB\-extprvkeyprefix\fR
.IP
The 4\-byte prefix, in hex, of the chain's base58 extended private key
encoding. (default: 0488ade4)
.HP
\fB\-extpubkeyprefix\fR
.IP
The 4\-byte prefix, in hex, of the chain's base58 extended public key
encoding. (default: 0488b21e)
.HP
\fB\-fedpegscript\fR
.IP
The script for the federated peg.
.HP
\fB\-feeasset=\fR<hex>
.IP
Asset ID (hex) for mempool/relay fees (default:
0000000000000000000000000000000000000000000000000000000000000000)
.HP
\fB\-initialreissuancetokens=\fR<n>
.IP
The amount of reissuance tokens created in the genesis block. (default:
0)
.HP
\fB\-parent_bech32_hrp\fR
.IP
The human\-readable part of the parent chain's bech32 encoding. (default:
bc)
.HP
\fB\-parent_blech32_hrp\fR
.IP
The human\-readable part of the parent chain's blech32 encoding.
(default: bc)
.HP
\fB\-parentgenesisblockhash\fR
.IP
The genesis blockhash of the parent chain.
.HP
\fB\-parentpubkeyprefix\fR
.IP
The byte prefix, in decimal, of the parent chain's base58 pubkey
address. (default: 111)
.HP
\fB\-parentscriptprefix\fR
.IP
The byte prefix, in decimal, of the parent chain's base58 script
address. (default: 196)
.HP
\fB\-pubkeyprefix\fR
.IP
The byte prefix, in decimal, of the chain's base58 pubkey address.
(default: 0)
.HP
\fB\-scriptprefix\fR
.IP
The byte prefix, in decimal, of the chain's base58 script address.
(default: 5)
.HP
\fB\-secretprefix\fR
.IP
The byte prefix, in decimal, of the chain's base58 secret key encoding.
(default: 128)
.HP
\fB\-signblockscript\fR
.IP
Signed blockchain enumberance. Only active when `\-con_signed_blocks` set
to true.
.HP
\fB\-subsidyasset=\fR<hex>
.IP
Asset ID (hex) for the block subsidy (default:
0000000000000000000000000000000000000000000000000000000000000000)
.HP
\fB\-testnet\fR
.IP
Use the test chain
@ -634,7 +484,6 @@ Relay and mine data carrier transactions (default: 1)
Maximum size of data in data carrier transactions we relay and mine
(default: 83)
.HP
.HP
\fB\-minrelaytxfee=\fR<amt>
.IP
Fees (in BTC/kB) smaller than this are considered zero fee for relaying,
@ -722,122 +571,10 @@ Username for JSON\-RPC connections
\fB\-server\fR
.IP
Accept command line and JSON\-RPC commands
.PP
Elements Options:
.HP
\fB\-assetdir\fR
.IP
Entries of pet names of assets, in this format:asset=<hex>:<label>.
There can be any number of entries.
.HP
\fB\-blindedaddresses\fR
.IP
Give blind addresses by default via getnewaddress and
getrawchangeaddress. (default: \fB\-con_elementsmode\fR value)
.HP
\fB\-blindedprefix\fR
.IP
The byte prefix, in decimal, of blinded addresses. (default: 4)
.HP
\fB\-con_blocksubsidy\fR
.IP
Defines the amount of block subsidy to start with, at genesis block, in
satoshis.
.HP
\fB\-con_connect_coinbase\fR
.IP
Connect outputs in genesis block to utxo database.
.HP
\fB\-con_csv_deploy_start\fR
.IP
Starting height for CSV deployment. (default: \fB\-1\fR, which means ACTIVE
from genesis)
.HP
\fB\-con_elementsmode\fR
.TP
Use Elements\-like instead of Core\-like witness encoding.
This is
.IP
required for CA/CT. (default: true)
.HP
\fB\-con_mandatorycoinbase\fR
.IP
All non\-zero valued coinbase outputs must go to this scriptPubKey, if
set.
.HP
\fB\-defaultpeggedassetname\fR
.IP
Default name of the pegged asset. (default: bitcoin)
.HP
\fB\-enforce_pak\fR
.IP
Causes standardness checks to enforce Pegout Authorization Key(PAK)
validation, and miner to include PAK commitments when configured.
Can not be set when acceptnonstdtx is set to true.
.HP
\fB\-mainchainrpccookiefile=\fR<file>
.IP
The bitcoind cookie auth path which the daemon will use to connect to
the trusted mainchain daemon to validate peg\-ins. (default:
`<datadir>/regtest/.cookie`)
.HP
\fB\-mainchainrpchost=\fR<host>
.IP
The address which the daemon will try to connect to the trusted
mainchain daemon to validate peg\-ins, if enabled. (default:
127.0.0.1)
.HP
\fB\-mainchainrpcpassword=\fR<pwd>
.IP
The rpc password which the daemon will use to connect to the trusted
mainchain daemon to validate peg\-ins, if enabled. (default:
cookie auth)
.HP
\fB\-mainchainrpcport=\fR<n>
.IP
The port which the daemon will try to connect to the trusted mainchain
daemon to validate peg\-ins, if enabled. (default: 18332)
.HP
\fB\-mainchainrpctimeout=\fR<n>
.IP
Timeout in seconds during mainchain RPC requests, or 0 for no timeout.
(default: 900)
.HP
\fB\-mainchainrpcuser=\fR<user>
.IP
The rpc username that the daemon will use to connect to the trusted
mainchain daemon to validate peg\-ins, if enabled. (default:
cookie auth)
.HP
\fB\-multi_data_permitted\fR
.IP
Allow relay of multiple OP_RETURN outputs. (default: true)
.HP
\fB\-pak\fR
.IP
Entries in the PAK list. Order of entries matter.
.HP
\fB\-peginconfirmationdepth=\fR<n>
.IP
Pegin claims must be this deep to be considered valid. (default: 8)
.HP
\fB\-recheckpeginblockinterval=\fR<n>
.IP
The interval in seconds at which a peg\-in witness failing block is
re\-evaluated in case of intermittent peg\-in witness failure. 0
means never. (default: 120)
.HP
\fB\-validatepegin\fR
.IP
Validate peg\-in claims. An RPC connection will be attempted to the
trusted mainchain daemon using the `mainchain*` settings below.
All functionaries must run this enabled. (default: true if chain
has federated peg)
.SH COPYRIGHT
Copyright (C) 2009-2019 The Elements Project developers
Copyright (C) 2009-2019 The Bitcoin Core developers
Please contribute if you find Elements Core useful. Visit
Please contribute if you find Bitcoin Core useful. Visit
<https://bitcoincore.org> for further information about the software.
The source code is available from <https://github.com/bitcoin/bitcoin>.

View file

@ -0,0 +1,34 @@
P2P and network changes
-----------------------
#### Removal of reject network messages from Bitcoin Core (BIP61)
The command line option to enable BIP61 (`-enablebip61`) has been removed.
This feature has been disabled by default since Bitcoin Core version 0.18.0.
Nodes on the network can not generally be trusted to send valid ("reject")
messages, so this should only ever be used when connected to a trusted node.
Please use the recommended alternatives if you rely on this deprecated feature:
* Testing or debugging of implementations of the Bitcoin P2P network protocol
should be done by inspecting the log messages that are produced by a recent
version of Bitcoin Core. Bitcoin Core logs debug messages
(`-debug=<category>`) to a stream (`-printtoconsole`) or to a file
(`-debuglogfile=<debug.log>`).
* Testing the validity of a block can be achieved by specific RPCs:
- `submitblock`
- `getblocktemplate` with `'mode'` set to `'proposal'` for blocks with
potentially invalid POW
* Testing the validity of a transaction can be achieved by specific RPCs:
- `sendrawtransaction`
- `testmempoolaccept`
* Wallets should not use the absence of "reject" messages to indicate a
transaction has propagated the network, nor should wallets use "reject"
messages to set transaction fees. Wallets should rather use fee estimation
to determine transaction fees and set replace-by-fee if desired. Thus, they
could wait until the transaction has confirmed (taking into account the fee
target they set (compare the RPC `estimatesmartfee`)) or listen for the
transaction announcement by other network peers to check for propagation.

View file

@ -412,7 +412,6 @@ void SetupServerArgs()
gArgs.AddArg("-discover", "Discover own IP addresses (default: 1 when listening and no -externalip or -proxy)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
gArgs.AddArg("-dns", strprintf("Allow DNS lookups for -addnode, -seednode and -connect (default: %u)", DEFAULT_NAME_LOOKUP), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
gArgs.AddArg("-dnsseed", "Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect used)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
gArgs.AddArg("-enablebip61", strprintf("Send reject messages per BIP61 (default: %u)", DEFAULT_ENABLE_BIP61), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
gArgs.AddArg("-externalip=<ip>", "Specify your own public address", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
gArgs.AddArg("-forcednsseed", strprintf("Always query for peer addresses via DNS lookup (default: %u)", DEFAULT_FORCEDNSSEED), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
gArgs.AddArg("-listen", "Accept connections from outside (default: 1 if no -proxy or -connect)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
@ -1375,7 +1374,7 @@ bool AppInitMain(InitInterfaces& interfaces)
assert(!g_connman);
g_connman = std::unique_ptr<CConnman>(new CConnman(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max())));
peerLogic.reset(new PeerLogicValidation(g_connman.get(), g_banman.get(), scheduler, gArgs.GetBoolArg("-enablebip61", DEFAULT_ENABLE_BIP61)));
peerLogic.reset(new PeerLogicValidation(g_connman.get(), g_banman.get(), scheduler));
RegisterValidationInterface(peerLogic.get());
// sanitize comments per BIP-0014, format user agent and check total size

View file

@ -193,12 +193,6 @@ namespace {
} // namespace
namespace {
struct CBlockReject {
unsigned char chRejectCode;
std::string strRejectReason;
uint256 hashBlock;
};
/**
* Maintain validation-specific state about nodes, protected by cs_main, instead
* by CNode's own locks. This simplifies asynchronous operation, where
@ -216,8 +210,6 @@ struct CNodeState {
bool fShouldBan;
//! String name of this peer (debugging/logging purposes).
const std::string name;
//! List of asynchronously-determined block rejections to notify this peer about.
std::vector<CBlockReject> rejects;
//! The best known block we know this peer has announced.
const CBlockIndex *pindexBestKnownBlock;
//! The hash of the last unknown block this peer has announced.
@ -1093,8 +1085,9 @@ static bool BlockRequestAllowed(const CBlockIndex* pindex, const Consensus::Para
(GetBlockProofEquivalentTime(*pindexBestHeader, *pindex, *pindexBestHeader, consensusParams) < STALE_RELAY_AGE_LIMIT);
}
PeerLogicValidation::PeerLogicValidation(CConnman* connmanIn, BanMan* banman, CScheduler &scheduler, bool enable_bip61)
: connman(connmanIn), m_banman(banman), m_stale_tip_check_time(0), m_enable_bip61(enable_bip61) {
PeerLogicValidation::PeerLogicValidation(CConnman* connmanIn, BanMan* banman, CScheduler& scheduler)
: connman(connmanIn), m_banman(banman), m_stale_tip_check_time(0)
{
// Initialize global variables that cannot be constructed at startup.
recentRejects.reset(new CRollingBloomFilter(120000, 0.000001));
@ -1244,8 +1237,6 @@ void PeerLogicValidation::BlockChecked(const CBlock& block, const CValidationSta
if (state.IsInvalid()) {
// Don't send reject message with code 0 or an internal reject code.
if (it != mapBlockSource.end() && State(it->second.first) && state.GetRejectCode() > 0 && state.GetRejectCode() < REJECT_INTERNAL) {
CBlockReject reject = {(unsigned char)state.GetRejectCode(), state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), hash};
State(it->second.first)->rejects.push_back(reject);
MaybePunishNode(/*nodeid=*/ it->second.first, state, /*via_compact_block=*/ !it->second.second);
}
}
@ -1859,7 +1850,7 @@ void static ProcessOrphanTx(CConnman* connman, std::set<uint256>& orphan_work_se
}
}
bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, int64_t nTimeReceived, const CChainParams& chainparams, CConnman* connman, const std::atomic<bool>& interruptMsgProc, bool enable_bip61)
bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, int64_t nTimeReceived, const CChainParams& chainparams, CConnman* connman, const std::atomic<bool>& interruptMsgProc)
{
LogPrint(BCLog::NET, "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->GetId());
if (gArgs.IsArgSet("-dropmessagestest") && GetRand(gArgs.GetArg("-dropmessagestest", 0)) == 0)
@ -1883,38 +1874,10 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
}
}
if (strCommand == NetMsgType::REJECT)
{
if (LogAcceptCategory(BCLog::NET)) {
try {
std::string strMsg; unsigned char ccode; std::string strReason;
vRecv >> LIMITED_STRING(strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING(strReason, MAX_REJECT_MESSAGE_LENGTH);
std::ostringstream ss;
ss << strMsg << " code " << itostr(ccode) << ": " << strReason;
if (strMsg == NetMsgType::BLOCK || strMsg == NetMsgType::TX)
{
uint256 hash;
vRecv >> hash;
ss << ": hash " << hash.ToString();
}
LogPrint(BCLog::NET, "Reject %s\n", SanitizeString(ss.str()));
} catch (const std::ios_base::failure&) {
// Avoid feedback loops by preventing reject messages from triggering a new reject message.
LogPrint(BCLog::NET, "Unparseable reject message received\n");
}
}
return true;
}
if (strCommand == NetMsgType::VERSION) {
// Each connection can only send one version message
if (pfrom->nVersion != 0)
{
if (enable_bip61) {
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_DUPLICATE, std::string("Duplicate version message")));
}
LOCK(cs_main);
Misbehaving(pfrom->GetId(), 1);
return false;
@ -1942,10 +1905,6 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
if (!pfrom->fInbound && !pfrom->fFeeler && !pfrom->m_manual_connection && !HasAllDesirableServiceFlags(nServices))
{
LogPrint(BCLog::NET, "peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n", pfrom->GetId(), nServices, GetDesirableServiceFlags(nServices));
if (enable_bip61) {
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_NONSTANDARD,
strprintf("Expected to offer services %08x", GetDesirableServiceFlags(nServices))));
}
pfrom->fDisconnect = true;
return false;
}
@ -1953,10 +1912,6 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
if (nVersion < MIN_PEER_PROTO_VERSION) {
// disconnect from peers older than this proto version
LogPrint(BCLog::NET, "peer=%d using obsolete version %i; disconnecting\n", pfrom->GetId(), nVersion);
if (enable_bip61) {
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION)));
}
pfrom->fDisconnect = true;
return false;
}
@ -2628,10 +2583,6 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
LogPrint(BCLog::MEMPOOLREJ, "%s from peer=%d was not accepted: %s\n", tx.GetHash().ToString(),
pfrom->GetId(),
FormatStateMessage(state));
if (enable_bip61 && state.GetRejectCode() > 0 && state.GetRejectCode() < REJECT_INTERNAL) { // Never send AcceptToMemoryPool's internal codes over P2P
connman->PushMessage(pfrom, msgMaker.Make(NetMsgType::REJECT, strCommand, (unsigned char)state.GetRejectCode(),
state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), inv.hash));
}
MaybePunishNode(pfrom->GetId(), state, /*via_compact_block*/ false);
}
return true;
@ -2811,7 +2762,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
} // cs_main
if (fProcessBLOCKTXN)
return ProcessMessage(pfrom, NetMsgType::BLOCKTXN, blockTxnMsg, nTimeReceived, chainparams, connman, interruptMsgProc, enable_bip61);
return ProcessMessage(pfrom, NetMsgType::BLOCKTXN, blockTxnMsg, nTimeReceived, chainparams, connman, interruptMsgProc);
if (fRevertToHeaderProcessing) {
// Headers received from HB compact block peers are permitted to be
@ -3238,18 +3189,11 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
return true;
}
bool PeerLogicValidation::SendRejectsAndCheckIfBanned(CNode* pnode, bool enable_bip61) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
bool PeerLogicValidation::CheckIfBanned(CNode* pnode)
{
AssertLockHeld(cs_main);
CNodeState &state = *State(pnode->GetId());
if (enable_bip61) {
for (const CBlockReject& reject : state.rejects) {
connman->PushMessage(pnode, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, std::string(NetMsgType::BLOCK), reject.chRejectCode, reject.strRejectReason, reject.hashBlock));
}
}
state.rejects.clear();
if (state.fShouldBan) {
state.fShouldBan = false;
if (pnode->HasPermission(PF_NOBAN))
@ -3358,7 +3302,7 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
bool fRet = false;
try
{
fRet = ProcessMessage(pfrom, strCommand, vRecv, msg.nTime, chainparams, connman, interruptMsgProc, m_enable_bip61);
fRet = ProcessMessage(pfrom, strCommand, vRecv, msg.nTime, chainparams, connman, interruptMsgProc);
if (interruptMsgProc)
return false;
if (!pfrom->vRecvGetData.empty())
@ -3366,9 +3310,6 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
}
catch (const std::ios_base::failure& e)
{
if (m_enable_bip61) {
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_MALFORMED, std::string("error parsing message")));
}
if (strstr(e.what(), "end of data")) {
// Allow exceptions from under-length message on vRecv
LogPrint(BCLog::NET, "%s(%s, %u bytes): Exception '%s' caught, normally caused by a message being shorter than its stated length\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
@ -3399,7 +3340,7 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
}
LOCK(cs_main);
SendRejectsAndCheckIfBanned(pfrom, m_enable_bip61);
CheckIfBanned(pfrom);
return fMoreWork;
}
@ -3598,11 +3539,12 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
}
}
TRY_LOCK(cs_main, lockMain); // Acquire cs_main for IsInitialBlockDownload() and CNodeState()
TRY_LOCK(cs_main, lockMain);
if (!lockMain)
return true;
if (SendRejectsAndCheckIfBanned(pto, m_enable_bip61)) return true;
if (CheckIfBanned(pto)) return true;
CNodeState &state = *State(pto->GetId());
// Address refresh broadcast

View file

@ -17,8 +17,6 @@ extern CCriticalSection cs_main;
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
/** Default number of orphan+recently-replaced txn to keep around for block reconstruction */
static const unsigned int DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN = 100;
/** Default for BIP61 (sending reject messages) */
static constexpr bool DEFAULT_ENABLE_BIP61{false};
static const bool DEFAULT_PEERBLOOMFILTERS = false;
class PeerLogicValidation final : public CValidationInterface, public NetEventsInterface {
@ -26,9 +24,10 @@ private:
CConnman* const connman;
BanMan* const m_banman;
bool SendRejectsAndCheckIfBanned(CNode* pnode, bool enable_bip61) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
bool CheckIfBanned(CNode* pnode) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
public:
PeerLogicValidation(CConnman* connman, BanMan* banman, CScheduler &scheduler, bool enable_bip61);
PeerLogicValidation(CConnman* connman, BanMan* banman, CScheduler& scheduler);
/**
* Overridden from CValidationInterface.
@ -75,9 +74,6 @@ public:
private:
int64_t m_stale_tip_check_time; //!< Next time to check for stale tip
/** Enable BIP61 (sending reject messages) */
const bool m_enable_bip61;
};
struct CNodeStateStats {

View file

@ -34,7 +34,6 @@ const char *NOTFOUND="notfound";
const char *FILTERLOAD="filterload";
const char *FILTERADD="filteradd";
const char *FILTERCLEAR="filterclear";
const char *REJECT="reject";
const char *SENDHEADERS="sendheaders";
const char *FEEFILTER="feefilter";
const char *SENDCMPCT="sendcmpct";
@ -66,7 +65,6 @@ const static std::string allNetMessageTypes[] = {
NetMsgType::FILTERLOAD,
NetMsgType::FILTERADD,
NetMsgType::FILTERCLEAR,
NetMsgType::REJECT,
NetMsgType::SENDHEADERS,
NetMsgType::FEEFILTER,
NetMsgType::SENDCMPCT,

View file

@ -192,13 +192,6 @@ extern const char *FILTERADD;
* @see https://bitcoin.org/en/developer-reference#filterclear
*/
extern const char *FILTERCLEAR;
/**
* The reject message informs the receiving node that one of its previous
* messages has been rejected.
* @since protocol version 70002 as described by BIP61.
* @see https://bitcoin.org/en/developer-reference#reject
*/
extern const char *REJECT;
/**
* Indicates that a node prefers to receive new block announcements via a
* "headers" message rather than an "inv".

View file

@ -78,7 +78,7 @@ BOOST_FIXTURE_TEST_SUITE(denialofservice_tests, TestingSetup)
BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
{
auto connman = MakeUnique<CConnman>(0x1337, 0x1337);
auto peerLogic = MakeUnique<PeerLogicValidation>(connman.get(), nullptr, scheduler, false);
auto peerLogic = MakeUnique<PeerLogicValidation>(connman.get(), nullptr, scheduler);
// Mock an outbound peer
CAddress addr1(ip(0xa0b0c001), NODE_NONE);
@ -148,7 +148,7 @@ static void AddRandomOutboundPeer(std::vector<CNode *> &vNodes, PeerLogicValidat
BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
{
auto connman = MakeUnique<CConnmanTest>(0x1337, 0x1337);
auto peerLogic = MakeUnique<PeerLogicValidation>(connman.get(), nullptr, scheduler, false);
auto peerLogic = MakeUnique<PeerLogicValidation>(connman.get(), nullptr, scheduler);
const Consensus::Params& consensusParams = Params().GetConsensus();
constexpr int max_outbound_full_relay = 8;
@ -221,7 +221,7 @@ BOOST_AUTO_TEST_CASE(DoS_banning)
{
auto banman = MakeUnique<BanMan>(GetDataDir() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
auto connman = MakeUnique<CConnman>(0x1337, 0x1337);
auto peerLogic = MakeUnique<PeerLogicValidation>(connman.get(), banman.get(), scheduler, false);
auto peerLogic = MakeUnique<PeerLogicValidation>(connman.get(), banman.get(), scheduler);
banman->ClearBanned();
CAddress addr1(ip(0xa0b0c001), NODE_NONE);
@ -276,7 +276,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore)
{
auto banman = MakeUnique<BanMan>(GetDataDir() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
auto connman = MakeUnique<CConnman>(0x1337, 0x1337);
auto peerLogic = MakeUnique<PeerLogicValidation>(connman.get(), banman.get(), scheduler, false);
auto peerLogic = MakeUnique<PeerLogicValidation>(connman.get(), banman.get(), scheduler);
banman->ClearBanned();
gArgs.ForceSetArg("-banscore", "111"); // because 11 is my favorite number
@ -323,7 +323,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
{
auto banman = MakeUnique<BanMan>(GetDataDir() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
auto connman = MakeUnique<CConnman>(0x1337, 0x1337);
auto peerLogic = MakeUnique<PeerLogicValidation>(connman.get(), banman.get(), scheduler, false);
auto peerLogic = MakeUnique<PeerLogicValidation>(connman.get(), banman.get(), scheduler);
banman->ClearBanned();
int64_t nStartTime = GetTime();

View file

@ -107,8 +107,6 @@ static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024;
static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60;
/** Time to wait (in seconds) between flushing chainstate to disk. */
static const unsigned int DATABASE_FLUSH_INTERVAL = 24 * 60 * 60;
/** Maximum length of reject messages. */
static const unsigned int MAX_REJECT_MESSAGE_LENGTH = 111;
/** Block download timeout base, expressed in millionths of the block interval (i.e. 10 min) */
static const int64_t BLOCK_DOWNLOAD_TIMEOUT_BASE = 1000000;
/** Additional block download timeout per parallel downloading peer (i.e. 5 min) */

View file

@ -22,9 +22,6 @@ from io import BytesIO
CLTV_HEIGHT = 1351
# Reject codes that we might receive in this test
REJECT_INVALID = 16
REJECT_NONSTANDARD = 64
def cltv_invalidate(tx):
'''Modify the signature in vin 0 of the tx to fail CLTV

View file

@ -9,19 +9,15 @@ Test that the DERSIG soft-fork activates at (regtest) height 1251.
from test_framework.blocktools import create_coinbase, create_block, create_transaction
from test_framework.messages import msg_block
from test_framework.mininode import mininode_lock, P2PInterface
from test_framework.mininode import P2PInterface
from test_framework.script import CScript
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
wait_until,
)
DERSIG_HEIGHT = 1251
# Reject codes that we might receive in this test
REJECT_INVALID = 16
REJECT_NONSTANDARD = 64
# A canonical signature consists of:
# <30> <total len> <02> <len R> <R> <02> <len S> <S> <hashtype>
@ -44,7 +40,7 @@ def unDERify(tx):
class BIP66Test(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.extra_args = [['-whitelist=127.0.0.1', '-par=1', '-enablebip61']] # Use only one script thread to get the exact reject reason for testing
self.extra_args = [['-whitelist=127.0.0.1', '-par=1']] # Use only one script thread to get the exact log msg for testing
self.setup_clean_chain = True
self.rpc_timeout = 120
@ -131,12 +127,6 @@ class BIP66Test(BitcoinTestFramework):
assert_equal(int(self.nodes[0].getbestblockhash(), 16), tip)
self.nodes[0].p2p.sync_with_ping()
wait_until(lambda: "reject" in self.nodes[0].p2p.last_message.keys(), lock=mininode_lock)
with mininode_lock:
assert self.nodes[0].p2p.last_message["reject"].code in [REJECT_INVALID, REJECT_NONSTANDARD]
assert_equal(self.nodes[0].p2p.last_message["reject"].data, block.sha256)
assert b'Non-canonical DER signature' in self.nodes[0].p2p.last_message["reject"].reason
self.log.info("Test that a version 3 block with a DERSIG-compliant transaction is accepted")
coinbase_value = self.nodes[0].decoderawtransaction(self.nodes[0].gettransaction(self.coinbase_txids[1])["hex"])["vout"][0]["value"]
block.vtx[1] = create_transaction(self.nodes[0], self.coinbase_txids[1], self.nodeaddress, amount=1.0, fee=coinbase_value-1)

View file

@ -1760,38 +1760,6 @@ class msg_headers:
return "msg_headers(headers=%s)" % repr(self.headers)
class msg_reject:
__slots__ = ("code", "data", "message", "reason")
command = b"reject"
REJECT_MALFORMED = 1
def __init__(self):
self.message = b""
self.code = 0
self.reason = b""
self.data = 0
def deserialize(self, f):
self.message = deser_string(f)
self.code = struct.unpack("<B", f.read(1))[0]
self.reason = deser_string(f)
if (self.code != self.REJECT_MALFORMED and
(self.message == b"block" or self.message == b"tx")):
self.data = deser_uint256(f)
def serialize(self):
r = ser_string(self.message)
r += struct.pack("<B", self.code)
r += ser_string(self.reason)
if (self.code != self.REJECT_MALFORMED and
(self.message == b"block" or self.message == b"tx")):
r += ser_uint256(self.data)
return r
def __repr__(self):
return "msg_reject: %s %d %s [%064x]" \
% (self.message, self.code, self.reason, self.data)
class msg_feefilter:
__slots__ = ("feerate",)

View file

@ -41,7 +41,6 @@ from test_framework.messages import (
msg_notfound,
msg_ping,
msg_pong,
msg_reject,
msg_sendcmpct,
msg_sendheaders,
msg_tx,
@ -74,7 +73,6 @@ MESSAGEMAP = {
b"notfound": msg_notfound,
b"ping": msg_ping,
b"pong": msg_pong,
b"reject": msg_reject,
b"sendcmpct": msg_sendcmpct,
b"sendheaders": msg_sendheaders,
b"tx": msg_tx,