Skip to content

Commit

Permalink
Merge branch 'bitcoin:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
soldate authored Jan 9, 2025
2 parents df36730 + 66aa6a4 commit e48a9a0
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 96 deletions.
1 change: 1 addition & 0 deletions src/arith_uint256.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class base_uint
protected:
static_assert(BITS / 32 > 0 && BITS % 32 == 0, "Template parameter BITS must be a positive multiple of 32.");
static constexpr int WIDTH = BITS / 32;
/** Big integer represented with 32-bit digits, least-significant first. */
uint32_t pn[WIDTH];
public:

Expand Down
1 change: 1 addition & 0 deletions src/node/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
}

++nPackagesSelected;
pblocktemplate->m_package_feerates.emplace_back(packageFees, static_cast<int32_t>(packageSize));

// Update transactions that depend on each of these
nDescendantsUpdated += UpdatePackagesForAdded(mempool, ancestors, mapModifiedTx);
Expand Down
4 changes: 4 additions & 0 deletions src/node/miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <policy/policy.h>
#include <primitives/block.h>
#include <txmempool.h>
#include <util/feefrac.h>

#include <memory>
#include <optional>
Expand Down Expand Up @@ -39,6 +40,9 @@ struct CBlockTemplate
std::vector<CAmount> vTxFees;
std::vector<int64_t> vTxSigOpsCost;
std::vector<unsigned char> vchCoinbaseCommitment;
/* A vector of package fee rates, ordered by the sequence in which
* packages are selected for inclusion in the block template.*/
std::vector<FeeFrac> m_package_feerates;
};

// Container for tracking updates to ancestor feerate as we include (parent)
Expand Down
5 changes: 3 additions & 2 deletions src/policy/packages.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ bool IsChildWithParents(const Package& package);
*/
bool IsChildWithParentsTree(const Package& package);

/** Get the hash of these transactions' wtxids, concatenated in lexicographical order (treating the
* wtxids as little endian encoded uint256, smallest to largest). */
/** Get the hash of the concatenated wtxids of transactions, with wtxids
* treated as a little-endian numbers and sorted in ascending numeric order.
*/
uint256 GetPackageHash(const std::vector<CTransactionRef>& transactions);

#endif // BITCOIN_POLICY_PACKAGES_H
4 changes: 2 additions & 2 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,8 @@ static RPCHelpMan getblocktemplate()
{RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR_HEX, "data", "transaction data encoded in hexadecimal (byte-for-byte)"},
{RPCResult::Type::STR_HEX, "txid", "transaction id encoded in little-endian hexadecimal"},
{RPCResult::Type::STR_HEX, "hash", "hash encoded in little-endian hexadecimal (including witness data)"},
{RPCResult::Type::STR_HEX, "txid", "transaction hash excluding witness data, shown in byte-reversed hex"},
{RPCResult::Type::STR_HEX, "hash", "transaction hash including witness data, shown in byte-reversed hex"},
{RPCResult::Type::ARR, "depends", "array of numbers",
{
{RPCResult::Type::NUM, "", "transactions before this one (by 1-based index in 'transactions' list) that must be present in the final block if this one is"},
Expand Down
4 changes: 2 additions & 2 deletions src/support/allocators/secure.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2021 The Bitcoin Core developers
// Copyright (c) 2009-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand Down Expand Up @@ -74,7 +74,7 @@ secure_unique_ptr<T> make_secure_unique(Args&&... as)

// initialize in place, and return as secure_unique_ptr
try {
return secure_unique_ptr<T>(new (p) T(std::forward(as)...));
return secure_unique_ptr<T>(new (p) T(std::forward<Args>(as)...));
} catch (...) {
secure_allocator<T>().deallocate(p, 1);
throw;
Expand Down
223 changes: 142 additions & 81 deletions src/test/miner_tests.cpp

Large diffs are not rendered by default.

29 changes: 20 additions & 9 deletions src/uint256.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,27 @@ class base_blob

/** @name Hex representation
*
* The reverse-byte hex representation is a convenient way to view the blob
* as a number, because it is consistent with the way the base_uint class
* converts blobs to numbers.
* The hex representation used by GetHex(), ToString(), FromHex() and
* SetHexDeprecated() is unusual, since it shows bytes of the base_blob in
* reverse order. For example, a 4-byte blob {0x12, 0x34, 0x56, 0x78} is
* represented as "78563412" instead of the more typical "12345678"
* representation that would be shown in a hex editor or used by typical
* byte-array / hex conversion functions like python's bytes.hex() and
* bytes.fromhex().
*
* The nice thing about the reverse-byte representation, even though it is
* unusual, is that if a blob contains an arithmetic number in little endian
* format (with least significant bytes first, and most significant bytes
* last), the GetHex() output will match the way the number would normally
* be written in base-16 (with most significant digits first and least
* significant digits last).
*
* This means, for example, that ArithToUint256(num).GetHex() can be used to
* display an arith_uint256 num value as a number, because
* ArithToUint256() converts the number to a blob in little-endian format,
* so the arith_uint256 class doesn't need to have its own number parsing
* and formatting functions.
*
* @note base_uint treats the blob as an array of bytes with the numerically
* least significant byte first and the most significant byte last. Because
* numbers are typically written with the most significant digit first and
* the least significant digit last, the reverse hex display of the blob
* corresponds to the same numeric value that base_uint interprets from the
* blob.
* @{*/
std::string GetHex() const;
/** Unlike FromHex this accepts any invalid input, thus it is fragile and deprecated!
Expand Down

0 comments on commit e48a9a0

Please sign in to comment.