Skip to content

Commit 19a9b90

Browse files
committed
use version=3 instead of v3 in debug strings
Make it more clear to the user what we mean by v3.
1 parent 881fac8 commit 19a9b90

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

src/policy/truc_policy.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ std::optional<std::string> PackageTRUCChecks(const CTransactionRef& ptx, int64_t
6969
if (ptx->version == TRUC_VERSION) {
7070
// SingleTRUCChecks should have checked this already.
7171
if (!Assume(vsize <= TRUC_MAX_VSIZE)) {
72-
return strprintf("v3 tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
72+
return strprintf("version=3 tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
7373
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(), vsize, TRUC_MAX_VSIZE);
7474
}
7575

@@ -82,7 +82,7 @@ std::optional<std::string> PackageTRUCChecks(const CTransactionRef& ptx, int64_t
8282
if (has_parent) {
8383
// A TRUC child cannot be too large.
8484
if (vsize > TRUC_CHILD_MAX_VSIZE) {
85-
return strprintf("v3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
85+
return strprintf("version=3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
8686
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(),
8787
vsize, TRUC_CHILD_MAX_VSIZE);
8888
}
@@ -107,7 +107,7 @@ std::optional<std::string> PackageTRUCChecks(const CTransactionRef& ptx, int64_t
107107

108108
// If there is a parent, it must have the right version.
109109
if (parent_info.m_version != TRUC_VERSION) {
110-
return strprintf("v3 tx %s (wtxid=%s) cannot spend from non-v3 tx %s (wtxid=%s)",
110+
return strprintf("version=3 tx %s (wtxid=%s) cannot spend from non-version=3 tx %s (wtxid=%s)",
111111
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(),
112112
parent_info.m_txid.ToString(), parent_info.m_wtxid.ToString());
113113
}
@@ -143,14 +143,14 @@ std::optional<std::string> PackageTRUCChecks(const CTransactionRef& ptx, int64_t
143143
// Non-TRUC transactions cannot have TRUC parents.
144144
for (auto it : mempool_ancestors) {
145145
if (it->GetTx().version == TRUC_VERSION) {
146-
return strprintf("non-v3 tx %s (wtxid=%s) cannot spend from v3 tx %s (wtxid=%s)",
146+
return strprintf("non-version=3 tx %s (wtxid=%s) cannot spend from version=3 tx %s (wtxid=%s)",
147147
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(),
148148
it->GetSharedTx()->GetHash().ToString(), it->GetSharedTx()->GetWitnessHash().ToString());
149149
}
150150
}
151151
for (const auto& index: in_package_parents) {
152152
if (package.at(index)->version == TRUC_VERSION) {
153-
return strprintf("non-v3 tx %s (wtxid=%s) cannot spend from v3 tx %s (wtxid=%s)",
153+
return strprintf("non-version=3 tx %s (wtxid=%s) cannot spend from version=3 tx %s (wtxid=%s)",
154154
ptx->GetHash().ToString(),
155155
ptx->GetWitnessHash().ToString(),
156156
package.at(index)->GetHash().ToString(),
@@ -169,12 +169,12 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleTRUCChecks(const CT
169169
// Check TRUC and non-TRUC inheritance.
170170
for (const auto& entry : mempool_ancestors) {
171171
if (ptx->version != TRUC_VERSION && entry->GetTx().version == TRUC_VERSION) {
172-
return std::make_pair(strprintf("non-v3 tx %s (wtxid=%s) cannot spend from v3 tx %s (wtxid=%s)",
172+
return std::make_pair(strprintf("non-version=3 tx %s (wtxid=%s) cannot spend from version=3 tx %s (wtxid=%s)",
173173
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(),
174174
entry->GetSharedTx()->GetHash().ToString(), entry->GetSharedTx()->GetWitnessHash().ToString()),
175175
nullptr);
176176
} else if (ptx->version == TRUC_VERSION && entry->GetTx().version != TRUC_VERSION) {
177-
return std::make_pair(strprintf("v3 tx %s (wtxid=%s) cannot spend from non-v3 tx %s (wtxid=%s)",
177+
return std::make_pair(strprintf("version=3 tx %s (wtxid=%s) cannot spend from non-version=3 tx %s (wtxid=%s)",
178178
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(),
179179
entry->GetSharedTx()->GetHash().ToString(), entry->GetSharedTx()->GetWitnessHash().ToString()),
180180
nullptr);
@@ -189,7 +189,7 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleTRUCChecks(const CT
189189
if (ptx->version != TRUC_VERSION) return std::nullopt;
190190

191191
if (vsize > TRUC_MAX_VSIZE) {
192-
return std::make_pair(strprintf("v3 tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
192+
return std::make_pair(strprintf("version=3 tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
193193
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(), vsize, TRUC_MAX_VSIZE),
194194
nullptr);
195195
}
@@ -205,7 +205,7 @@ std::optional<std::pair<std::string, CTransactionRef>> SingleTRUCChecks(const CT
205205
if (mempool_ancestors.size() > 0) {
206206
// If this transaction spends TRUC parents, it cannot be too large.
207207
if (vsize > TRUC_CHILD_MAX_VSIZE) {
208-
return std::make_pair(strprintf("v3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
208+
return std::make_pair(strprintf("version=3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
209209
ptx->GetHash().ToString(), ptx->GetWitnessHash().ToString(), vsize, TRUC_CHILD_MAX_VSIZE),
210210
nullptr);
211211
}

src/test/txvalidation_tests.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
112112
// tx_v2_from_v3
113113
auto tx_v2_from_v3 = make_tx({COutPoint{mempool_tx_v3->GetHash(), 0}}, /*version=*/2);
114114
auto ancestors_v2_from_v3{pool.CalculateMemPoolAncestors(entry.FromTx(tx_v2_from_v3), m_limits)};
115-
const auto expected_error_str{strprintf("non-v3 tx %s (wtxid=%s) cannot spend from v3 tx %s (wtxid=%s)",
115+
const auto expected_error_str{strprintf("non-version=3 tx %s (wtxid=%s) cannot spend from version=3 tx %s (wtxid=%s)",
116116
tx_v2_from_v3->GetHash().ToString(), tx_v2_from_v3->GetWitnessHash().ToString(),
117117
mempool_tx_v3->GetHash().ToString(), mempool_tx_v3->GetWitnessHash().ToString())};
118118
auto result_v2_from_v3{SingleTRUCChecks(tx_v2_from_v3, *ancestors_v2_from_v3, empty_conflicts_set, GetVirtualTransactionSize(*tx_v2_from_v3))};
@@ -129,7 +129,7 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
129129
// tx_v2_from_v2_and_v3
130130
auto tx_v2_from_v2_and_v3 = make_tx({COutPoint{mempool_tx_v3->GetHash(), 0}, COutPoint{mempool_tx_v2->GetHash(), 0}}, /*version=*/2);
131131
auto ancestors_v2_from_both{pool.CalculateMemPoolAncestors(entry.FromTx(tx_v2_from_v2_and_v3), m_limits)};
132-
const auto expected_error_str_2{strprintf("non-v3 tx %s (wtxid=%s) cannot spend from v3 tx %s (wtxid=%s)",
132+
const auto expected_error_str_2{strprintf("non-version=3 tx %s (wtxid=%s) cannot spend from version=3 tx %s (wtxid=%s)",
133133
tx_v2_from_v2_and_v3->GetHash().ToString(), tx_v2_from_v2_and_v3->GetWitnessHash().ToString(),
134134
mempool_tx_v3->GetHash().ToString(), mempool_tx_v3->GetWitnessHash().ToString())};
135135
auto result_v2_from_both{SingleTRUCChecks(tx_v2_from_v2_and_v3, *ancestors_v2_from_both, empty_conflicts_set, GetVirtualTransactionSize(*tx_v2_from_v2_and_v3))};
@@ -147,7 +147,7 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
147147
// tx_v3_from_v2
148148
auto tx_v3_from_v2 = make_tx({COutPoint{mempool_tx_v2->GetHash(), 0}}, /*version=*/3);
149149
auto ancestors_v3_from_v2{pool.CalculateMemPoolAncestors(entry.FromTx(tx_v3_from_v2), m_limits)};
150-
const auto expected_error_str{strprintf("v3 tx %s (wtxid=%s) cannot spend from non-v3 tx %s (wtxid=%s)",
150+
const auto expected_error_str{strprintf("version=3 tx %s (wtxid=%s) cannot spend from non-version=3 tx %s (wtxid=%s)",
151151
tx_v3_from_v2->GetHash().ToString(), tx_v3_from_v2->GetWitnessHash().ToString(),
152152
mempool_tx_v2->GetHash().ToString(), mempool_tx_v2->GetWitnessHash().ToString())};
153153
auto result_v3_from_v2{SingleTRUCChecks(tx_v3_from_v2, *ancestors_v3_from_v2, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_from_v2))};
@@ -164,7 +164,7 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
164164
// tx_v3_from_v2_and_v3
165165
auto tx_v3_from_v2_and_v3 = make_tx({COutPoint{mempool_tx_v3->GetHash(), 0}, COutPoint{mempool_tx_v2->GetHash(), 0}}, /*version=*/3);
166166
auto ancestors_v3_from_both{pool.CalculateMemPoolAncestors(entry.FromTx(tx_v3_from_v2_and_v3), m_limits)};
167-
const auto expected_error_str_2{strprintf("v3 tx %s (wtxid=%s) cannot spend from non-v3 tx %s (wtxid=%s)",
167+
const auto expected_error_str_2{strprintf("version=3 tx %s (wtxid=%s) cannot spend from non-version=3 tx %s (wtxid=%s)",
168168
tx_v3_from_v2_and_v3->GetHash().ToString(), tx_v3_from_v2_and_v3->GetWitnessHash().ToString(),
169169
mempool_tx_v2->GetHash().ToString(), mempool_tx_v2->GetWitnessHash().ToString())};
170170
auto result_v3_from_both{SingleTRUCChecks(tx_v3_from_v2_and_v3, *ancestors_v3_from_both, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_from_v2_and_v3))};
@@ -262,7 +262,7 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
262262
auto tx_v3_child_big = make_tx(many_inputs, /*version=*/3);
263263
const auto vsize{GetVirtualTransactionSize(*tx_v3_child_big)};
264264
auto ancestors{pool.CalculateMemPoolAncestors(entry.FromTx(tx_v3_child_big), m_limits)};
265-
const auto expected_error_str{strprintf("v3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
265+
const auto expected_error_str{strprintf("version=3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
266266
tx_v3_child_big->GetHash().ToString(), tx_v3_child_big->GetWitnessHash().ToString(), vsize, TRUC_CHILD_MAX_VSIZE)};
267267
auto result{SingleTRUCChecks(tx_v3_child_big, *ancestors, empty_conflicts_set, GetVirtualTransactionSize(*tx_v3_child_big))};
268268
BOOST_CHECK_EQUAL(result->first, expected_error_str);
@@ -304,7 +304,7 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
304304
// Weight limit is not reached...
305305
BOOST_CHECK(SingleTRUCChecks(tx_many_sigops, *ancestors, empty_conflicts_set, bip141_vsize) == std::nullopt);
306306
// ...but sigop limit is.
307-
const auto expected_error_str{strprintf("v3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
307+
const auto expected_error_str{strprintf("version=3 child tx %s (wtxid=%s) is too big: %u > %u virtual bytes",
308308
tx_many_sigops->GetHash().ToString(), tx_many_sigops->GetWitnessHash().ToString(),
309309
total_sigops * DEFAULT_BYTES_PER_SIGOP / WITNESS_SCALE_FACTOR, TRUC_CHILD_MAX_VSIZE)};
310310
auto result{SingleTRUCChecks(tx_many_sigops, *ancestors, empty_conflicts_set,

test/functional/mempool_truc.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_truc_max_vsize(self):
5757
self.log.info("Test TRUC-specific maximum transaction vsize")
5858
tx_v3_heavy = self.wallet.create_self_transfer(target_weight=(TRUC_MAX_VSIZE + 1) * WITNESS_SCALE_FACTOR, version=3)
5959
assert_greater_than_or_equal(tx_v3_heavy["tx"].get_vsize(), TRUC_MAX_VSIZE)
60-
expected_error_heavy = f"TRUC-violation, v3 tx {tx_v3_heavy['txid']} (wtxid={tx_v3_heavy['wtxid']}) is too big"
60+
expected_error_heavy = f"TRUC-violation, version=3 tx {tx_v3_heavy['txid']} (wtxid={tx_v3_heavy['wtxid']}) is too big"
6161
assert_raises_rpc_error(-26, expected_error_heavy, node.sendrawtransaction, tx_v3_heavy["hex"])
6262
self.check_mempool([])
6363

@@ -77,7 +77,7 @@ def test_truc_acceptance(self):
7777
version=3
7878
)
7979
assert_greater_than_or_equal(tx_v3_child_heavy["tx"].get_vsize(), 1000)
80-
expected_error_child_heavy = f"TRUC-violation, v3 child tx {tx_v3_child_heavy['txid']} (wtxid={tx_v3_child_heavy['wtxid']}) is too big"
80+
expected_error_child_heavy = f"TRUC-violation, version=3 child tx {tx_v3_child_heavy['txid']} (wtxid={tx_v3_child_heavy['wtxid']}) is too big"
8181
assert_raises_rpc_error(-26, expected_error_child_heavy, node.sendrawtransaction, tx_v3_child_heavy["hex"])
8282
self.check_mempool([tx_v3_parent_normal["txid"]])
8383
# tx has no descendants
@@ -157,7 +157,7 @@ def test_truc_replacement(self):
157157
utxo_to_spend=tx_v3_parent["new_utxo"],
158158
version=2
159159
)
160-
expected_error_v2_v3 = f"TRUC-violation, non-v3 tx {tx_v3_child_rbf_v2['txid']} (wtxid={tx_v3_child_rbf_v2['wtxid']}) cannot spend from v3 tx {tx_v3_parent['txid']} (wtxid={tx_v3_parent['wtxid']})"
160+
expected_error_v2_v3 = f"TRUC-violation, non-version=3 tx {tx_v3_child_rbf_v2['txid']} (wtxid={tx_v3_child_rbf_v2['wtxid']}) cannot spend from version=3 tx {tx_v3_parent['txid']} (wtxid={tx_v3_parent['wtxid']})"
161161
assert_raises_rpc_error(-26, expected_error_v2_v3, node.sendrawtransaction, tx_v3_child_rbf_v2["hex"])
162162
self.check_mempool([tx_v3_bip125_rbf_v2["txid"], tx_v3_parent["txid"], tx_v3_child["txid"]])
163163

@@ -295,7 +295,7 @@ def test_truc_ancestors_package(self):
295295
self.check_mempool([])
296296
result = node.submitpackage([tx_v3_parent_normal["hex"], tx_v3_child_heavy["hex"]])
297297
# tx_v3_child_heavy is heavy based on weight, not sigops.
298-
assert_equal(result['package_msg'], f"TRUC-violation, v3 child tx {tx_v3_child_heavy['txid']} (wtxid={tx_v3_child_heavy['wtxid']}) is too big: {tx_v3_child_heavy['tx'].get_vsize()} > 1000 virtual bytes")
298+
assert_equal(result['package_msg'], f"TRUC-violation, version=3 child tx {tx_v3_child_heavy['txid']} (wtxid={tx_v3_child_heavy['wtxid']}) is too big: {tx_v3_child_heavy['tx'].get_vsize()} > 1000 virtual bytes")
299299
self.check_mempool([])
300300

301301
tx_v3_parent = self.wallet.create_self_transfer(version=3)
@@ -426,7 +426,7 @@ def test_truc_package_inheritance(self):
426426
)
427427
self.check_mempool([])
428428
result = node.submitpackage([tx_v3_parent["hex"], tx_v2_child["hex"]])
429-
assert_equal(result['package_msg'], f"TRUC-violation, non-v3 tx {tx_v2_child['txid']} (wtxid={tx_v2_child['wtxid']}) cannot spend from v3 tx {tx_v3_parent['txid']} (wtxid={tx_v3_parent['wtxid']})")
429+
assert_equal(result['package_msg'], f"TRUC-violation, non-version=3 tx {tx_v2_child['txid']} (wtxid={tx_v2_child['wtxid']}) cannot spend from version=3 tx {tx_v3_parent['txid']} (wtxid={tx_v3_parent['wtxid']})")
430430
self.check_mempool([])
431431

432432
@cleanup(extra_args=None)
@@ -447,11 +447,11 @@ def test_truc_in_testmempoolaccept(self):
447447
assert all([result["allowed"] for result in test_accept_v2_and_v3])
448448

449449
test_accept_v3_from_v2 = node.testmempoolaccept([tx_v2["hex"], tx_v3_from_v2["hex"]])
450-
expected_error_v3_from_v2 = f"TRUC-violation, v3 tx {tx_v3_from_v2['txid']} (wtxid={tx_v3_from_v2['wtxid']}) cannot spend from non-v3 tx {tx_v2['txid']} (wtxid={tx_v2['wtxid']})"
450+
expected_error_v3_from_v2 = f"TRUC-violation, version=3 tx {tx_v3_from_v2['txid']} (wtxid={tx_v3_from_v2['wtxid']}) cannot spend from non-version=3 tx {tx_v2['txid']} (wtxid={tx_v2['wtxid']})"
451451
assert all([result["package-error"] == expected_error_v3_from_v2 for result in test_accept_v3_from_v2])
452452

453453
test_accept_v2_from_v3 = node.testmempoolaccept([tx_v3["hex"], tx_v2_from_v3["hex"]])
454-
expected_error_v2_from_v3 = f"TRUC-violation, non-v3 tx {tx_v2_from_v3['txid']} (wtxid={tx_v2_from_v3['wtxid']}) cannot spend from v3 tx {tx_v3['txid']} (wtxid={tx_v3['wtxid']})"
454+
expected_error_v2_from_v3 = f"TRUC-violation, non-version=3 tx {tx_v2_from_v3['txid']} (wtxid={tx_v2_from_v3['wtxid']}) cannot spend from version=3 tx {tx_v3['txid']} (wtxid={tx_v3['wtxid']})"
455455
assert all([result["package-error"] == expected_error_v2_from_v3 for result in test_accept_v2_from_v3])
456456

457457
test_accept_pairs = node.testmempoolaccept([tx_v2["hex"], tx_v3["hex"], tx_v2_from_v2["hex"], tx_v3_from_v3["hex"]])

0 commit comments

Comments
 (0)