use MAX_HEADERS_UNCOMPRESSED_RESULT not MAX_HEADERS_UNCOMPRESSED_RESULTS ; use MAX_HEADERS_UNCOMPRESSED_RESULT in RPC to avoid breaking changes

This commit is contained in:
pasta 2024-09-06 15:13:47 -05:00
parent b137280df4
commit 07876b2c4a
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984
6 changed files with 13 additions and 13 deletions

View File

@ -1044,7 +1044,7 @@ static uint16_t GetHeadersLimit(const CNode& pfrom, const std::string& msg_type)
if (pfrom.GetCommonVersion() >= INCREASE_MAX_HEADERS2_VERSION && msg_type == NetMsgType::GETHEADERS2) {
return MAX_HEADERS_COMPRESSED_RESULT;
}
return MAX_HEADERS_UNCOMPRESSED_RESULTS;
return MAX_HEADERS_UNCOMPRESSED_RESULT;
}
static void PushInv(Peer& peer, const CInv& inv)

View File

@ -996,7 +996,7 @@ static RPCHelpMan getblockheaders()
"If verbose is true, each item is an Object with information about a single blockheader.\n",
{
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
{"count", RPCArg::Type::NUM, /* default */ strprintf("%s", MAX_HEADERS_COMPRESSED_RESULT), ""},
{"count", RPCArg::Type::NUM, /* default */ strprintf("%s", MAX_HEADERS_UNCOMPRESSED_RESULT), ""},
{"verbose", RPCArg::Type::BOOL, /* default */ "true", "true for a json object, false for the hex-encoded data"},
},
{
@ -1054,11 +1054,11 @@ static RPCHelpMan getblockheaders()
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
}
int nCount = MAX_HEADERS_COMPRESSED_RESULT;
int nCount = MAX_HEADERS_UNCOMPRESSED_RESULT;
if (!request.params[1].isNull())
nCount = request.params[1].get_int();
if (nCount <= 0 || nCount > (int)MAX_HEADERS_COMPRESSED_RESULT)
if (nCount <= 0 || nCount > (int)MAX_HEADERS_UNCOMPRESSED_RESULT)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Count is out of range");
bool fVerbose = true;
@ -1134,7 +1134,7 @@ static RPCHelpMan getmerkleblocks()
{
{"filter", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex-encoded bloom filter"},
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
{"count", RPCArg::Type::NUM, /* default */ strprintf("%s", MAX_HEADERS_COMPRESSED_RESULT), ""},
{"count", RPCArg::Type::NUM, /* default */ strprintf("%s", MAX_HEADERS_UNCOMPRESSED_RESULT), ""},
},
RPCResult{
RPCResult::Type::ARR, "", "",
@ -1163,11 +1163,11 @@ static RPCHelpMan getmerkleblocks()
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
}
int nCount = MAX_HEADERS_COMPRESSED_RESULT;
int nCount = MAX_HEADERS_UNCOMPRESSED_RESULT;
if (!request.params[2].isNull())
nCount = request.params[2].get_int();
if (nCount <= 0 || nCount > (int)MAX_HEADERS_COMPRESSED_RESULT) {
if (nCount <= 0 || nCount > (int)MAX_HEADERS_UNCOMPRESSED_RESULT) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Count is out of range");
}

View File

@ -85,7 +85,7 @@ static const int MAX_SCRIPTCHECK_THREADS = 15;
static const int DEFAULT_SCRIPTCHECK_THREADS = 0;
/** Number of headers sent in one getheaders result. We rely on the assumption that if a peer sends
* less than this number, we reached its tip. Changing this value is a protocol upgrade. */
static const unsigned int MAX_HEADERS_UNCOMPRESSED_RESULTS = 2000;
static const unsigned int MAX_HEADERS_UNCOMPRESSED_RESULT = 2000;
static const unsigned int MAX_HEADERS_COMPRESSED_RESULT = 8000;
static const int64_t DEFAULT_MAX_TIP_AGE = 6 * 60 * 60; // ~144 blocks behind -> 2 x fork detection time, was 24 * 60 * 60 in bitcoin

View File

@ -10,7 +10,7 @@ from test_framework.messages import (
CInv,
msg_ping,
ser_string,
MAX_HEADERS_UNCOMPRESSED_RESULTS,
MAX_HEADERS_UNCOMPRESSED_RESULT,
MAX_HEADERS_COMPRESSED_RESULT,
MAX_INV_SIZE,
MAX_PROTOCOL_MESSAGE_LENGTH,
@ -154,7 +154,7 @@ class InvalidMessagesTest(BitcoinTestFramework):
self.test_oversized_msg(msg_getdata([CInv(MSG_TX, 1)] * size), size)
def test_oversized_headers_msg(self):
size = MAX_HEADERS_UNCOMPRESSED_RESULTS + 1
size = MAX_HEADERS_UNCOMPRESSED_RESULT + 1
self.test_oversized_msg(msg_headers([CBlockHeader()] * size), size)
def test_oversized_headers2_msg(self):

View File

@ -42,7 +42,7 @@ MAX_MONEY = 21000000 * COIN
BIP125_SEQUENCE_NUMBER = 0xfffffffd # Sequence number that is BIP 125 opt-in and BIP 68-opt-out
MAX_PROTOCOL_MESSAGE_LENGTH = 3 * 1024 * 1024 # Maximum length of incoming protocol messages
MAX_HEADERS_UNCOMPRESSED_RESULTS = 2000 # Number of headers sent in one getheaders result
MAX_HEADERS_UNCOMPRESSED_RESULT = 2000 # Number of headers sent in one getheaders result
MAX_HEADERS_COMPRESSED_RESULT = 8000 # Number of headers2 sent in one getheaders2 result
MAX_INV_SIZE = 50000 # Maximum number of entries in an 'inv' protocol message

View File

@ -31,7 +31,7 @@ import threading
from test_framework.messages import (
CBlockHeader,
CompressibleBlockHeader,
MAX_HEADERS_UNCOMPRESSED_RESULTS,
MAX_HEADERS_UNCOMPRESSED_RESULT,
MAX_HEADERS_COMPRESSED_RESULT,
NODE_HEADERS_COMPRESSED,
msg_addr,
@ -734,7 +734,7 @@ class P2PDataStore(P2PInterface):
break
# Truncate the list if there are too many headers
max_results = MAX_HEADERS_COMPRESSED_RESULT if use_headers2 else MAX_HEADERS_UNCOMPRESSED_RESULTS
max_results = MAX_HEADERS_COMPRESSED_RESULT if use_headers2 else MAX_HEADERS_UNCOMPRESSED_RESULT
headers_list = headers_list[:-max_results - 1:-1]
return headers_list