In the functional test framework, determining a (w)txid for a CTransaction
instance is currently rather confusing and footgunny due to inconsistent naming/interfaces (see table below) and statefulness involved. This PR aims to improve that by:
- removing the (w)txid caching mechanism, in order to avoid the need to call additional rehashing functions (
.rehash()
/.calculate_sha256()
, see first two commits and #32050 (review)). This change in theory decreases the performance, as the involved serialization and hashing involved might be called more often than previously, but I couldn’t find a functional test where this leads to a measurable run-time increase on my machine. - introduce consistent naming that shows the type of the returned txid, i.e. hex string vs. test-framework-internal representation [currently integers] (see remaining commits)
Summary table showing (w)txid determaination before/after this PR:
Task | master | PR |
---|---|---|
get TXID (hex string) | .rehash() / .hash [1] |
.txid_hex |
get TXID (integer) | .sha256 [1] |
.txid_int |
get WTXID (hex string) | .getwtxid() |
.wtxid_hex |
get WTXID (integer) | .calc_sha256(True) |
.wtxid_int |
Unfortunately, most renames can’t be done with a scripted-diff, as the property names (.hash
, .sha256
) are also used for blocks and other message types. The PR is rather invasive and touches a lot of files, but I think it’s worth to do it, also to make life easier for new contributors. Future tasks like e.g. doing the same overhaul for block (header) objects or getting rid of the integer representation (see #32050) become easier should become easier after this one.
[1] = returned value might be out-of-date, if rehashing function wasn’t called after modification