Skip to content

Commit

Permalink
Merge #6099: backport: Merge bitcoin#22507, 21464, 23050, 24367
Browse files Browse the repository at this point in the history
7972af9 (partial) Merge bitcoin#24367: User-facing content and codebase doc fixups from transifex translator feedback (laanwj)
b8951fe Merge bitcoin#23050: log: change an incorrect fee to fee rate, and vice-versa (merge-script)
10dd79c Merge bitcoin#21464: Mempool Update Cut-Through Optimization (fanquake)
5b369a1 Merge bitcoin#22507: doc: Adjust commit message template for the guix.sigs repo (W. J. van der Laan)

Pull request description:

  bitcoin backports

ACKs for top commit:
  UdjinM6:
    utACK 7972af9
  PastaPastaPasta:
    utACK 7972af9

Tree-SHA512: a362bbe9a0dd3dbaa82ead5a74edf30b4336967b0c5e3a7fb310588f6148f023ee07351c429a4cc86cb3f206aef4c50cdaa99dd7cd2f8beb2c722de7091ee10e
  • Loading branch information
PastaPastaPasta committed Jan 15, 2025
2 parents e7cac98 + 7972af9 commit ce8dffc
Show file tree
Hide file tree
Showing 23 changed files with 98 additions and 58 deletions.
2 changes: 1 addition & 1 deletion contrib/guix/guix-build
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ fi

if ! getent services http https ftp > /dev/null 2>&1; then
cat << EOF
ERR: Your system's C library can not find service database entries for at least
ERR: Your system's C library cannot find service database entries for at least
one of the following services: http, https, ftp.
Hint: Most likely, /etc/services does not exist yet (common for docker images
Expand Down
4 changes: 2 additions & 2 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ other input.
failure, it will throw an exception, which can be caught to recover from the
error.
- For example, a nullptr dereference or any other logic bug in RPC code
means that the RPC code is faulty and can not be executed. However, the
means that the RPC code is faulty and cannot be executed. However, the
logic bug can be shown to the user and the program can continue to run.
* `Assume` should be used to document assumptions when program execution can
safely continue even if the assumption is violated. In debug builds it
Expand Down Expand Up @@ -1352,7 +1352,7 @@ A few guidelines for introducing and reviewing new RPC interfaces:

- Don't forget to fill in the argument names correctly in the RPC command table.
- *Rationale*: If not, the call can not be used with name-based arguments.
- *Rationale*: If not, the call cannot be used with name-based arguments.
- Add every non-string RPC argument `(method, idx, name)` to the table `vRPCConvertParams` in `rpc/client.cpp`.
Expand Down
2 changes: 1 addition & 1 deletion doc/release-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Commit your signature for the signed macOS/Windows binaries:
```sh
pushd ./guix.sigs
git add "${VERSION}/${SIGNER}"/all.SHA256SUMS{,.asc}
git commit -m "Add ${SIGNER} ${VERSION} signed binaries signatures"
git commit -m "Add attestations by ${SIGNER} for ${VERSION} codesigned"
git push # Assuming you can push to the guix.sigs tree
popd
```
Expand Down
2 changes: 1 addition & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5189,7 +5189,7 @@ void CaptureMessageToFile(const CAddress& addr,
// layer (processing) perspective.
auto now = GetTime<std::chrono::microseconds>();

// Windows folder names can not include a colon
// Windows folder names cannot include a colon
std::string clean_addr = addr.ToStringAddrPort();
std::replace(clean_addr.begin(), clean_addr.end(), ':', '_');

Expand Down
2 changes: 1 addition & 1 deletion src/node/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ void BlockAssembler::AddToBlock(CTxMemPool::txiter iter)

bool fPrintPriority = gArgs.GetBoolArg("-printpriority", DEFAULT_PRINTPRIORITY);
if (fPrintPriority) {
LogPrintf("fee %s txid %s\n",
LogPrintf("fee rate %s txid %s\n",
CFeeRate(iter->GetModifiedFee(), iter->GetTxSize()).ToString(),
iter->GetTx().GetHash().ToString());
}
Expand Down
2 changes: 1 addition & 1 deletion src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ int GuiMain(int argc, char* argv[])
InitError(strprintf(Untranslated("Error parsing command line arguments: %s\n"), error));
// Create a message box, because the gui has neither been created nor has subscribed to core signals
QMessageBox::critical(nullptr, PACKAGE_NAME,
// message can not be translated because translations have not been initialized
// message cannot be translated because translations have not been initialized
QString::fromStdString("Error parsing command line arguments: %1.").arg(QString::fromStdString(error)));
return EXIT_FAILURE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/qt/intro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void Intro::setStatus(int status, const QString &message, quint64 bytesAvailable

void Intro::UpdateFreeSpaceLabel()
{
QString freeString = tr("%1 GB of free space available").arg(m_bytes_available / GB_BYTES);
QString freeString = tr("%1 GB of space available").arg(m_bytes_available / GB_BYTES);
if (m_bytes_available < m_required_space_gb * GB_BYTES) {
freeString += " " + tr("(of %1 GB needed)").arg(m_required_space_gb);
ui->freeSpace->setStyleSheet(GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_ERROR));
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ static RPCHelpMan setmocktime()
RPCTypeCheck(request.params, {UniValue::VNUM});
const int64_t time{request.params[0].get_int64()};
if (time < 0) {
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Mocktime can not be negative: %s.", time));
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Mocktime cannot be negative: %s.", time));
}
SetMockTime(time);
if (auto* node_context = GetContext<NodeContext>(request.context)) {
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/txoutproof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static RPCHelpMan verifytxoutproof()
RPCResult{
RPCResult::Type::ARR, "", "",
{
{RPCResult::Type::STR_HEX, "txid", "The txid(s) which the proof commits to, or empty array if the proof can not be validated."},
{RPCResult::Type::STR_HEX, "txid", "The txid(s) which the proof commits to, or empty array if the proof cannot be validated."},
}
},
RPCExamples{
Expand Down
2 changes: 1 addition & 1 deletion src/test/util_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,7 @@ BOOST_AUTO_TEST_CASE(util_ParseMoney)
BOOST_CHECK_EQUAL(ParseMoney("0.00000001 ").value(), COIN/100000000);
BOOST_CHECK_EQUAL(ParseMoney(" 0.00000001").value(), COIN/100000000);

// Parsing amount that can not be represented should fail
// Parsing amount that cannot be represented should fail
BOOST_CHECK(!ParseMoney("100000000.00"));
BOOST_CHECK(!ParseMoney("0.000000001"));

Expand Down
2 changes: 1 addition & 1 deletion src/txdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ std::optional<bilingual_str> CheckLegacyTxindex(CBlockTreeDB& block_tree_db)
{
CBlockLocator ignored{};
if (block_tree_db.Read(DB_TXINDEX_BLOCK, ignored)) {
return _("The -txindex upgrade started by a previous version can not be completed. Restart with the previous version or run a full -reindex.");
return _("The -txindex upgrade started by a previous version cannot be completed. Restart with the previous version or run a full -reindex.");
}
bool txindex_legacy_flag{false};
block_tree_db.ReadFlag("txindex", txindex_legacy_flag);
Expand Down
34 changes: 22 additions & 12 deletions src/txmempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,9 @@ size_t CTxMemPoolEntry::GetTxSize() const
return GetVirtualTransactionSize(nTxSize, sigOpCount);
}

// Update the given tx for any in-mempool descendants.
// Assumes that CTxMemPool::m_children is correct for the given tx and all
// descendants.
void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap &cachedDescendants, const std::set<uint256> &setExclude)
void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap& cachedDescendants,
const std::set<uint256>& setExclude, std::set<uint256>& descendants_to_remove,
uint64_t ancestor_size_limit, uint64_t ancestor_count_limit)
{
CTxMemPoolEntry::Children stageEntries, descendants;
stageEntries = updateIt->GetMemPoolChildrenConst();
Expand Down Expand Up @@ -164,17 +163,18 @@ void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap &cachedDescendan
cachedDescendants[updateIt].insert(mapTx.iterator_to(descendant));
// Update ancestor state for each descendant
mapTx.modify(mapTx.iterator_to(descendant), update_ancestor_state(updateIt->GetTxSize(), updateIt->GetModifiedFee(), 1, updateIt->GetSigOpCount()));
// Don't directly remove the transaction here -- doing so would
// invalidate iterators in cachedDescendants. Mark it for removal
// by inserting into descendants_to_remove.
if (descendant.GetCountWithAncestors() > ancestor_count_limit || descendant.GetSizeWithAncestors() > ancestor_size_limit) {
descendants_to_remove.insert(descendant.GetTx().GetHash());
}
}
}
mapTx.modify(updateIt, update_descendant_state(modifySize, modifyFee, modifyCount));
}

// vHashesToUpdate is the set of transaction hashes from a disconnected block
// which has been re-added to the mempool.
// for each entry, look for descendants that are outside vHashesToUpdate, and
// add fee/size information for such descendants to the parent.
// for each such descendant, also update the ancestor state to include the parent.
void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<uint256> &vHashesToUpdate)
void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<uint256> &vHashesToUpdate, uint64_t ancestor_size_limit, uint64_t ancestor_count_limit)
{
AssertLockHeld(cs);
// For each entry in vHashesToUpdate, store the set of in-mempool, but not
Expand All @@ -186,6 +186,8 @@ void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<uint256> &vHashes
// accounted for in the state of their ancestors)
std::set<uint256> setAlreadyIncluded(vHashesToUpdate.begin(), vHashesToUpdate.end());

std::set<uint256> descendants_to_remove;

// Iterate in reverse, so that whenever we are looking at a transaction
// we are sure that all in-mempool descendants have already been processed.
// This maximizes the benefit of the descendant cache and guarantees that
Expand Down Expand Up @@ -215,7 +217,15 @@ void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<uint256> &vHashes
}
}
} // release epoch guard for UpdateForDescendants
UpdateForDescendants(it, mapMemPoolDescendantsToUpdate, setAlreadyIncluded);
UpdateForDescendants(it, mapMemPoolDescendantsToUpdate, setAlreadyIncluded, descendants_to_remove, ancestor_size_limit, ancestor_count_limit);
}

for (const auto& txid : descendants_to_remove) {
// This txid may have been removed already in a prior call to removeRecursive.
// Therefore we ensure it is not yet removed already.
if (const std::optional<txiter> txiter = GetIter(txid)) {
removeRecursive((*txiter)->GetTx(), MemPoolRemovalReason::SIZELIMIT);
}
}
}

Expand Down Expand Up @@ -1470,7 +1480,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD
++nTransactionsUpdated;
}
}
LogPrint(BCLog::MEMPOOL, "PrioritiseTransaction: %s feerate += %s\n", hash.ToString(), FormatMoney(nFeeDelta));
LogPrint(BCLog::MEMPOOL, "PrioritiseTransaction: %s fee += %s\n", hash.ToString(), FormatMoney(nFeeDelta));
}

void CTxMemPool::ApplyDelta(const uint256& hash, CAmount &nFeeDelta) const
Expand Down
68 changes: 48 additions & 20 deletions src/txmempool.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,16 +680,25 @@ class CTxMemPool
*/
void RemoveStaged(setEntries& stage, bool updateDescendants, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs);

/** When adding transactions from a disconnected block back to the mempool,
* new mempool entries may have children in the mempool (which is generally
* not the case when otherwise adding transactions).
* UpdateTransactionsFromBlock() will find child transactions and update the
* descendant state for each transaction in vHashesToUpdate (excluding any
* child transactions present in vHashesToUpdate, which are already accounted
* for). Note: vHashesToUpdate should be the set of transactions from the
* disconnected block that have been accepted back into the mempool.
/** UpdateTransactionsFromBlock is called when adding transactions from a
* disconnected block back to the mempool, new mempool entries may have
* children in the mempool (which is generally not the case when otherwise
* adding transactions).
* @post updated descendant state for descendants of each transaction in
* vHashesToUpdate (excluding any child transactions present in
* vHashesToUpdate, which are already accounted for). Updated state
* includes add fee/size information for such descendants to the
* parent and updated ancestor state to include the parent.
*
* @param[in] vHashesToUpdate The set of txids from the
* disconnected block that have been accepted back into the mempool.
* @param[in] ancestor_size_limit The maximum allowed size in virtual
* bytes of an entry and its ancestors
* @param[in] ancestor_count_limit The maximum allowed number of
* transactions including the entry and its ancestors.
*/
void UpdateTransactionsFromBlock(const std::vector<uint256>& vHashesToUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main) LOCKS_EXCLUDED(m_epoch);
void UpdateTransactionsFromBlock(const std::vector<uint256>& vHashesToUpdate,
uint64_t ancestor_size_limit, uint64_t ancestor_count_limit) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main) LOCKS_EXCLUDED(m_epoch);

/** Try to calculate all in-mempool ancestors of entry.
* (these are all calculated including the tx itself)
Expand Down Expand Up @@ -836,19 +845,38 @@ class CTxMemPool
/** UpdateForDescendants is used by UpdateTransactionsFromBlock to update
* the descendants for a single transaction that has been added to the
* mempool but may have child transactions in the mempool, eg during a
* chain reorg. setExclude is the set of descendant transactions in the
* mempool that must not be accounted for (because any descendants in
* setExclude were added to the mempool after the transaction being
* updated and hence their state is already reflected in the parent
* state).
* chain reorg.
*
* @pre CTxMemPool::m_children is correct for the given tx and all
* descendants.
* @pre cachedDescendants is an accurate cache where each entry has all
* descendants of the corresponding key, including those that should
* be removed for violation of ancestor limits.
* @post if updateIt has any non-excluded descendants, cachedDescendants has
* a new cache line for updateIt.
* @post descendants_to_remove has a new entry for any descendant which exceeded
* ancestor limits relative to updateIt.
*
* cachedDescendants will be updated with the descendants of the transaction
* being updated, so that future invocations don't need to walk the
* same transaction again, if encountered in another transaction chain.
* @param[in] updateIt the entry to update for its descendants
* @param[in,out] cachedDescendants a cache where each line corresponds to all
* descendants. It will be updated with the descendants of the transaction
* being updated, so that future invocations don't need to walk the same
* transaction again, if encountered in another transaction chain.
* @param[in] setExclude the set of descendant transactions in the mempool
* that must not be accounted for (because any descendants in setExclude
* were added to the mempool after the transaction being updated and hence
* their state is already reflected in the parent state).
* @param[out] descendants_to_remove Populated with the txids of entries that
* exceed ancestor limits. It's the responsibility of the caller to
* removeRecursive them.
* @param[in] ancestor_size_limit the max number of ancestral bytes allowed
* for any descendant
* @param[in] ancestor_count_limit the max number of ancestor transactions
* allowed for any descendant
*/
void UpdateForDescendants(txiter updateIt,
cacheMap &cachedDescendants,
const std::set<uint256> &setExclude) EXCLUSIVE_LOCKS_REQUIRED(cs);
void UpdateForDescendants(txiter updateIt, cacheMap& cachedDescendants,
const std::set<uint256>& setExclude, std::set<uint256>& descendants_to_remove,
uint64_t ancestor_size_limit, uint64_t ancestor_count_limit) EXCLUSIVE_LOCKS_REQUIRED(cs);
/** Update ancestors of hash to add/remove it as a descendant transaction. */
void UpdateAncestorsOf(bool add, txiter hash, setEntries &setAncestors) EXCLUSIVE_LOCKS_REQUIRED(cs);
/** Set ancestor state for an entry */
Expand Down
4 changes: 3 additions & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,9 @@ void CChainState::MaybeUpdateMempoolForReorg(
// previously-confirmed transactions back to the mempool.
// UpdateTransactionsFromBlock finds descendants of any transactions in
// the disconnectpool that were added back and cleans up the mempool state.
m_mempool->UpdateTransactionsFromBlock(vHashUpdate);
const uint64_t ancestor_count_limit = gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT);
const uint64_t ancestor_size_limit = gArgs.GetArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT) * 1000;
m_mempool->UpdateTransactionsFromBlock(vHashUpdate, ancestor_size_limit, ancestor_count_limit);

// Predicate to use for filtering transactions in removeForReorg.
// Checks whether the transaction is still final and, if it spends a coinbase output, mature.
Expand Down
6 changes: 3 additions & 3 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,7 @@ static RPCHelpMan walletpassphrase()
}

if (strWalletPass.empty()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "passphrase can not be empty");
throw JSONRPCError(RPC_INVALID_PARAMETER, "passphrase cannot be empty");
}

if (!pwallet->Unlock(strWalletPass, fForMixingOnly)) {
Expand Down Expand Up @@ -2087,7 +2087,7 @@ static RPCHelpMan walletpassphrasechange()
strNewWalletPass = request.params[1].get_str().c_str();

if (strOldWalletPass.empty() || strNewWalletPass.empty()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "passphrase can not be empty");
throw JSONRPCError(RPC_INVALID_PARAMETER, "passphrase cannot be empty");
}

if (!pwallet->ChangeWalletPassphrase(strOldWalletPass, strNewWalletPass)) {
Expand Down Expand Up @@ -2184,7 +2184,7 @@ static RPCHelpMan encryptwallet()
strWalletPass = request.params[0].get_str().c_str();

if (strWalletPass.empty()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "passphrase can not be empty");
throw JSONRPCError(RPC_INVALID_PARAMETER, "passphrase cannot be empty");
}

if (!pwallet->EncryptWallet(strWalletPass)) {
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/test/wallet_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ class CreateTransactionTestSetup : public TestChain100Setup
const std::string strUnableToLocateCoinJoin1 = "Unable to locate enough non-denominated funds for this transaction.";
const std::string strUnableToLocateCoinJoin2 = "Unable to locate enough mixed funds for this transaction. CoinJoin uses exact denominated amounts to send funds, you might simply need to mix some more coins.";
const std::string strTransactionTooLarge = "Transaction too large";
const std::string strChangeIndexOutOfRange = "Change index out of range";
const std::string strChangeIndexOutOfRange = "Transaction change output index out of range";
const std::string strExceededMaxTries = "Exceeded max tries.";
const std::string strMaxFeeExceeded = "Fee exceeds maximum configured by user (e.g. -maxtxfee, maxfeerate)";

Expand Down
2 changes: 1 addition & 1 deletion src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3783,7 +3783,7 @@ bool CWallet::CreateTransactionInternal(
}
else if ((unsigned int)nChangePosRequest > txNew.vout.size())
{
error = _("Change index out of range");
error = _("Transaction change output index out of range");
return false;
} else {
nChangePosInOut = nChangePosRequest;
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_txindex_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def run_test(self):

self.stop_nodes()

self.log.info("Check migrated txindex can not be read by legacy node")
self.log.info("Check migrated txindex cannot be read by legacy node")
err_msg = f": You need to rebuild the database using -reindex to change -txindex.{os.linesep}Please restart with -reindex or -reindex-chainstate to recover."
shutil.rmtree(legacy_chain_dir)
shutil.copytree(migrate_chain_dir, legacy_chain_dir)
Expand Down
2 changes: 1 addition & 1 deletion test/functional/mempool_updatefromblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class MempoolUpdateFromBlockTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.extra_args = [['-limitdescendantsize=1000', '-limitancestorsize=1000']]
self.extra_args = [['-limitdescendantsize=1000', '-limitancestorsize=1000', '-limitancestorcount=100']]

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
Expand Down
Loading

0 comments on commit ce8dffc

Please sign in to comment.