scripted-diff: Rename hash_serialized_2 to hash_serialized_3

-BEGIN VERIFY SCRIPT-
sed -i 's/hash_serialized_2/hash_serialized_3/g' $( git grep -l 'hash_serialized_2' ./src ./contrib ./test )
-END VERIFY SCRIPT-
This commit is contained in:
Fabian Jahr 2023-10-19 14:54:41 +02:00
parent 351370a1d2
commit cb0336817e
No known key found for this signature in database
GPG key ID: F13D1E9D890798CD
6 changed files with 20 additions and 20 deletions

View file

@ -34,7 +34,7 @@ ${BITCOIN_CLI_CALL} invalidateblock "${PIVOT_BLOCKHASH}"
if [[ "${OUTPUT_PATH}" = "-" ]]; then if [[ "${OUTPUT_PATH}" = "-" ]]; then
(>&2 echo "Generating txoutset info...") (>&2 echo "Generating txoutset info...")
${BITCOIN_CLI_CALL} gettxoutsetinfo | grep hash_serialized_2 | sed 's/^.*: "\(.\+\)\+",/\1/g' ${BITCOIN_CLI_CALL} gettxoutsetinfo | grep hash_serialized_3 | sed 's/^.*: "\(.\+\)\+",/\1/g'
else else
(>&2 echo "Generating UTXO snapshot...") (>&2 echo "Generating UTXO snapshot...")
${BITCOIN_CLI_CALL} dumptxoutset "${OUTPUT_PATH}" ${BITCOIN_CLI_CALL} dumptxoutset "${OUTPUT_PATH}"

View file

@ -820,7 +820,7 @@ static RPCHelpMan pruneblockchain()
CoinStatsHashType ParseHashType(const std::string& hash_type_input) CoinStatsHashType ParseHashType(const std::string& hash_type_input)
{ {
if (hash_type_input == "hash_serialized_2") { if (hash_type_input == "hash_serialized_3") {
return CoinStatsHashType::HASH_SERIALIZED; return CoinStatsHashType::HASH_SERIALIZED;
} else if (hash_type_input == "muhash") { } else if (hash_type_input == "muhash") {
return CoinStatsHashType::MUHASH; return CoinStatsHashType::MUHASH;
@ -867,7 +867,7 @@ static RPCHelpMan gettxoutsetinfo()
"\nReturns statistics about the unspent transaction output set.\n" "\nReturns statistics about the unspent transaction output set.\n"
"Note this call may take some time if you are not using coinstatsindex.\n", "Note this call may take some time if you are not using coinstatsindex.\n",
{ {
{"hash_type", RPCArg::Type::STR, RPCArg::Default{"hash_serialized_2"}, "Which UTXO set hash should be calculated. Options: 'hash_serialized_2' (the legacy algorithm), 'muhash', 'none'."}, {"hash_type", RPCArg::Type::STR, RPCArg::Default{"hash_serialized_3"}, "Which UTXO set hash should be calculated. Options: 'hash_serialized_3' (the legacy algorithm), 'muhash', 'none'."},
{"hash_or_height", RPCArg::Type::NUM, RPCArg::DefaultHint{"the current best block"}, "The block hash or height of the target height (only available with coinstatsindex).", {"hash_or_height", RPCArg::Type::NUM, RPCArg::DefaultHint{"the current best block"}, "The block hash or height of the target height (only available with coinstatsindex).",
RPCArgOptions{ RPCArgOptions{
.skip_type_check = true, .skip_type_check = true,
@ -882,7 +882,7 @@ static RPCHelpMan gettxoutsetinfo()
{RPCResult::Type::STR_HEX, "bestblock", "The hash of the block at which these statistics are calculated"}, {RPCResult::Type::STR_HEX, "bestblock", "The hash of the block at which these statistics are calculated"},
{RPCResult::Type::NUM, "txouts", "The number of unspent transaction outputs"}, {RPCResult::Type::NUM, "txouts", "The number of unspent transaction outputs"},
{RPCResult::Type::NUM, "bogosize", "Database-independent, meaningless metric indicating the UTXO set size"}, {RPCResult::Type::NUM, "bogosize", "Database-independent, meaningless metric indicating the UTXO set size"},
{RPCResult::Type::STR_HEX, "hash_serialized_2", /*optional=*/true, "The serialized hash (only present if 'hash_serialized_2' hash_type is chosen)"}, {RPCResult::Type::STR_HEX, "hash_serialized_3", /*optional=*/true, "The serialized hash (only present if 'hash_serialized_3' hash_type is chosen)"},
{RPCResult::Type::STR_HEX, "muhash", /*optional=*/true, "The serialized hash (only present if 'muhash' hash_type is chosen)"}, {RPCResult::Type::STR_HEX, "muhash", /*optional=*/true, "The serialized hash (only present if 'muhash' hash_type is chosen)"},
{RPCResult::Type::NUM, "transactions", /*optional=*/true, "The number of transactions with unspent outputs (not available when coinstatsindex is used)"}, {RPCResult::Type::NUM, "transactions", /*optional=*/true, "The number of transactions with unspent outputs (not available when coinstatsindex is used)"},
{RPCResult::Type::NUM, "disk_size", /*optional=*/true, "The estimated size of the chainstate on disk (not available when coinstatsindex is used)"}, {RPCResult::Type::NUM, "disk_size", /*optional=*/true, "The estimated size of the chainstate on disk (not available when coinstatsindex is used)"},
@ -942,7 +942,7 @@ static RPCHelpMan gettxoutsetinfo()
} }
if (hash_type == CoinStatsHashType::HASH_SERIALIZED) { if (hash_type == CoinStatsHashType::HASH_SERIALIZED) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "hash_serialized_2 hash type cannot be queried for a specific block"); throw JSONRPCError(RPC_INVALID_PARAMETER, "hash_serialized_3 hash type cannot be queried for a specific block");
} }
if (!index_requested) { if (!index_requested) {
@ -971,7 +971,7 @@ static RPCHelpMan gettxoutsetinfo()
ret.pushKV("txouts", (int64_t)stats.nTransactionOutputs); ret.pushKV("txouts", (int64_t)stats.nTransactionOutputs);
ret.pushKV("bogosize", (int64_t)stats.nBogoSize); ret.pushKV("bogosize", (int64_t)stats.nBogoSize);
if (hash_type == CoinStatsHashType::HASH_SERIALIZED) { if (hash_type == CoinStatsHashType::HASH_SERIALIZED) {
ret.pushKV("hash_serialized_2", stats.hashSerialized.GetHex()); ret.pushKV("hash_serialized_3", stats.hashSerialized.GetHex());
} }
if (hash_type == CoinStatsHashType::MUHASH) { if (hash_type == CoinStatsHashType::MUHASH) {
ret.pushKV("muhash", stats.hashSerialized.GetHex()); ret.pushKV("muhash", stats.hashSerialized.GetHex());

View file

@ -293,11 +293,11 @@ class CoinStatsIndexTest(BitcoinTestFramework):
def _test_index_rejects_hash_serialized(self): def _test_index_rejects_hash_serialized(self):
self.log.info("Test that the rpc raises if the legacy hash is passed with the index") self.log.info("Test that the rpc raises if the legacy hash is passed with the index")
msg = "hash_serialized_2 hash type cannot be queried for a specific block" msg = "hash_serialized_3 hash type cannot be queried for a specific block"
assert_raises_rpc_error(-8, msg, self.nodes[1].gettxoutsetinfo, hash_type='hash_serialized_2', hash_or_height=111) assert_raises_rpc_error(-8, msg, self.nodes[1].gettxoutsetinfo, hash_type='hash_serialized_3', hash_or_height=111)
for use_index in {True, False, None}: for use_index in {True, False, None}:
assert_raises_rpc_error(-8, msg, self.nodes[1].gettxoutsetinfo, hash_type='hash_serialized_2', hash_or_height=111, use_index=use_index) assert_raises_rpc_error(-8, msg, self.nodes[1].gettxoutsetinfo, hash_type='hash_serialized_3', hash_or_height=111, use_index=use_index)
def _test_init_index_after_reorg(self): def _test_init_index_after_reorg(self):
self.log.info("Test a reorg while the index is deactivated") self.log.info("Test a reorg while the index is deactivated")

View file

@ -85,7 +85,7 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
# Any of these RPC calls could throw due to node crash # Any of these RPC calls could throw due to node crash
self.start_node(node_index) self.start_node(node_index)
self.nodes[node_index].waitforblock(expected_tip) self.nodes[node_index].waitforblock(expected_tip)
utxo_hash = self.nodes[node_index].gettxoutsetinfo()['hash_serialized_2'] utxo_hash = self.nodes[node_index].gettxoutsetinfo()['hash_serialized_3']
return utxo_hash return utxo_hash
except Exception: except Exception:
# An exception here should mean the node is about to crash. # An exception here should mean the node is about to crash.
@ -130,7 +130,7 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
If any nodes crash while updating, we'll compare utxo hashes to If any nodes crash while updating, we'll compare utxo hashes to
ensure recovery was successful.""" ensure recovery was successful."""
node3_utxo_hash = self.nodes[3].gettxoutsetinfo()['hash_serialized_2'] node3_utxo_hash = self.nodes[3].gettxoutsetinfo()['hash_serialized_3']
# Retrieve all the blocks from node3 # Retrieve all the blocks from node3
blocks = [] blocks = []
@ -172,12 +172,12 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
"""Verify that the utxo hash of each node matches node3. """Verify that the utxo hash of each node matches node3.
Restart any nodes that crash while querying.""" Restart any nodes that crash while querying."""
node3_utxo_hash = self.nodes[3].gettxoutsetinfo()['hash_serialized_2'] node3_utxo_hash = self.nodes[3].gettxoutsetinfo()['hash_serialized_3']
self.log.info("Verifying utxo hash matches for all nodes") self.log.info("Verifying utxo hash matches for all nodes")
for i in range(3): for i in range(3):
try: try:
nodei_utxo_hash = self.nodes[i].gettxoutsetinfo()['hash_serialized_2'] nodei_utxo_hash = self.nodes[i].gettxoutsetinfo()['hash_serialized_3']
except OSError: except OSError:
# probably a crash on db flushing # probably a crash on db flushing
nodei_utxo_hash = self.restart_node(i, self.nodes[3].getbestblockhash()) nodei_utxo_hash = self.restart_node(i, self.nodes[3].getbestblockhash())

View file

@ -69,7 +69,7 @@ class UTXOSetHashTest(BitcoinTestFramework):
assert_equal(finalized[::-1].hex(), node_muhash) assert_equal(finalized[::-1].hex(), node_muhash)
self.log.info("Test deterministic UTXO set hash results") self.log.info("Test deterministic UTXO set hash results")
assert_equal(node.gettxoutsetinfo()['hash_serialized_2'], "d1c7fec1c0623f6793839878cbe2a531eb968b50b27edd6e2a57077a5aed6094") assert_equal(node.gettxoutsetinfo()['hash_serialized_3'], "d1c7fec1c0623f6793839878cbe2a531eb968b50b27edd6e2a57077a5aed6094")
assert_equal(node.gettxoutsetinfo("muhash")['muhash'], "d1725b2fe3ef43e55aa4907480aea98d406fc9e0bf8f60169e2305f1fbf5961b") assert_equal(node.gettxoutsetinfo("muhash")['muhash'], "d1725b2fe3ef43e55aa4907480aea98d406fc9e0bf8f60169e2305f1fbf5961b")
def run_test(self): def run_test(self):

View file

@ -340,7 +340,7 @@ class BlockchainTest(BitcoinTestFramework):
assert size > 6400 assert size > 6400
assert size < 64000 assert size < 64000
assert_equal(len(res['bestblock']), 64) assert_equal(len(res['bestblock']), 64)
assert_equal(len(res['hash_serialized_2']), 64) assert_equal(len(res['hash_serialized_3']), 64)
self.log.info("Test gettxoutsetinfo works for blockchain with just the genesis block") self.log.info("Test gettxoutsetinfo works for blockchain with just the genesis block")
b1hash = node.getblockhash(1) b1hash = node.getblockhash(1)
@ -353,7 +353,7 @@ class BlockchainTest(BitcoinTestFramework):
assert_equal(res2['txouts'], 0) assert_equal(res2['txouts'], 0)
assert_equal(res2['bogosize'], 0), assert_equal(res2['bogosize'], 0),
assert_equal(res2['bestblock'], node.getblockhash(0)) assert_equal(res2['bestblock'], node.getblockhash(0))
assert_equal(len(res2['hash_serialized_2']), 64) assert_equal(len(res2['hash_serialized_3']), 64)
self.log.info("Test gettxoutsetinfo returns the same result after invalidate/reconsider block") self.log.info("Test gettxoutsetinfo returns the same result after invalidate/reconsider block")
node.reconsiderblock(b1hash) node.reconsiderblock(b1hash)
@ -365,20 +365,20 @@ class BlockchainTest(BitcoinTestFramework):
assert_equal(res, res3) assert_equal(res, res3)
self.log.info("Test gettxoutsetinfo hash_type option") self.log.info("Test gettxoutsetinfo hash_type option")
# Adding hash_type 'hash_serialized_2', which is the default, should # Adding hash_type 'hash_serialized_3', which is the default, should
# not change the result. # not change the result.
res4 = node.gettxoutsetinfo(hash_type='hash_serialized_2') res4 = node.gettxoutsetinfo(hash_type='hash_serialized_3')
del res4['disk_size'] del res4['disk_size']
assert_equal(res, res4) assert_equal(res, res4)
# hash_type none should not return a UTXO set hash. # hash_type none should not return a UTXO set hash.
res5 = node.gettxoutsetinfo(hash_type='none') res5 = node.gettxoutsetinfo(hash_type='none')
assert 'hash_serialized_2' not in res5 assert 'hash_serialized_3' not in res5
# hash_type muhash should return a different UTXO set hash. # hash_type muhash should return a different UTXO set hash.
res6 = node.gettxoutsetinfo(hash_type='muhash') res6 = node.gettxoutsetinfo(hash_type='muhash')
assert 'muhash' in res6 assert 'muhash' in res6
assert res['hash_serialized_2'] != res6['muhash'] assert res['hash_serialized_3'] != res6['muhash']
# muhash should not be returned unless requested. # muhash should not be returned unless requested.
for r in [res, res2, res3, res4, res5]: for r in [res, res2, res3, res4, res5]: