refactor: Enforces Txid and Wtxid types in RelayTransaction#32104
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32104. ReviewsSee the guideline for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
There was a problem hiding this comment.
not sure. This seems like a pessimization that makes it harder to use the type-safe Txid and Wtxid in RelayTransaction
It would be better to make this code type-safe, to avoid having to touch it again in the future.
There was a problem hiding this comment.
If that is the case, shouldn't we be enforcing RelayTransaction to take Txid and Wtxid instead of uint256?
There was a problem hiding this comment.
Yes. Alternatively, at a minimum the txid and wtxid types should be adjusted here. Otherwise, this refactor may cause a silent merge conflict with the type-safety refactor.
There was a problem hiding this comment.
I've updated the approach to enforce RelayTransaction types, and extended it to all other calls to the method
4871540 to
a5ddb59
Compare
RelayTransaction expects to pass a TxId and Wtxid as arguments, but any uint256 type is really accepted. When calling RelayTransaction, most times we are already passing tx->GetHash() and tx->GetWitnessHash() to it, and their value are downcasted. Updates RelayTransaction and make sure we are consistent with its arguments
a5ddb59 to
1b58696
Compare
|
cc @marcofleon & #31001. |
|
Oh, I didn't realize Marco was already working on this. I saw this when updating the Erlay PR and thought it may be good to standalone fix. I'm happy to close it if you're planning to get it addressed @marcofleon |
|
Lgtm as a standalone change. It's the same change I implement in fa8400494e3c411a55375e71abaaa2637a22e216 as part of the complete refactor. I actually missed all the My final refactor does end up altering |
|
Closing in favor of #32189 |
RelayTransaction expects to pass a TxId and Wtxid as arguments, but any uint256 type is really accepted. When calling RelayTransaction, most times we are already passing tx->GetHash() and tx->GetWitnessHash() to it, and their value are downcasted.
Updates RelayTransaction and make sure we are consistent with its arguments