Skip to content

Conversation

@lucash-dev
Copy link
Contributor

This PR is re-submission of #14156, which was automatically closed by github (glitch?)

Original description:

This PR makes explicit the now implicit conversion constructor CTransaction(const CMutableTransaction&) in transaction.h.
Minimal changes were made elsewhere to make the code compilable. I'll follow up with other PRs to address individually refactoring functions that should have a CMutableTransaction version, or where a CTransaction should be reused.

The rationale for this change is:

  • Conversion constructors should not be explicit unless there's a strong reason for it (in the opinion of, for example, https://google.github.io/styleguide/cppguide.html, and https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Ro-conversion. Let me know your take on this).
  • This particular conversion is very costly -- it implies a serialization plus hash of the transaction.
  • Even though CTransaction and CMutableTransaction represent the same data, they have very different use cases and performance properties.
  • Making it explicit allows for easier reasoning of performance trade-offs.
  • There has been previous performance issues caused by unneeded use of this implicit conversion.
  • This PR creates a map for places to look for possible refactoring and performance gains (this benefit still holds if the PR is not merged).

@lucash-dev lucash-dev changed the title Explicit c mutable transaction conversion refactor: Make explicit CMutableTransaction -> CTransaction conversion. Dec 10, 2018
@lucash-dev
Copy link
Contributor Author

The part referring to tests and benchmark changes has now a separate PR #14908

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 10, 2018

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #14978 (Factor out PSBT utilities from RPCs for use in GUI code; related refactoring. by gwillen)
  • #12911 (wallet: Show fee in results for signrawtransaction* for segwit inputs by kallewoof)

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.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you are missing a rebase.

maflcko pushed a commit that referenced this pull request Dec 12, 2018
…rom tests and benchmarks.

8db0c3d Removed implicit CTransaction conversion from benchmaks (lucash-dev)
ed61abe Removed implicit CTransaction constructor from tests (lucash-dev)

Pull request description:

  This PR was split from #14906 and is a prerequisite for it.
  It updates tests and benchmarks, removing all implicit calls to `CTransaction(CMutableTransaction&)` constructors. This will make possible making the constructor explicit in the next PR.
  The original rationale for making the constructor explicit:

   - Conversion constructors should not be explicit unless there's a strong reason for it (in the opinion of, for example, https://google.github.io/styleguide/cppguide.html, and https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Ro-conversion. Let me know your take on this).
   - This particular conversion is very costly -- it implies a serialization plus hash of the transaction.
   - Even though `CTransaction` and `CMutableTransaction` represent the same data, they have very different use cases and performance properties.
   - Making it explicit allows for easier reasoning of performance trade-offs.
   - There has been previous performance issues caused by unneeded use of this implicit conversion.
   - This PR creates a map for places to look for possible refactoring and performance gains (this benefit still holds if the PR is not merged).

Tree-SHA512: de8073aa6ff8a3153bcbe10818616677ecf9598e4978d8a0b4c39a262e71c36be5679cec08554c760d1f011ba6d37350318248eef15f6d9b86f9e4462b2de0d2
@lucash-dev
Copy link
Contributor Author

Rebased

@gwillen
Copy link
Contributor

gwillen commented Dec 17, 2018

Strong support for making constructors explicit wherever possible. This looks like a fairly minimal change in terms of total amount of stuff touched, and definitely in a positive direction. Would love to see this get in. (Consider this a utACK from me, for what my vote is worth. I'm not sure what's up with Travis but the failure doesn't look legitimate.)

(EDIT: Looks like I missed some comments / context due to the reopening as a new PR, and indeed there was already plenty of support for this to go in soon. Yay. :-) )

…action conversion.

This commit makes the minimal changes necessary to fix compilation once CTransaction(const CMutableTransaction &tx) is made explicit. In each case an explicit call `CTransaction(...)` was added. Shouldn't affect behaviour or performance.
This makes the above constructor explicit. The rationale is that this conversion has very significant performance effects. Making it explicit makes it easier to reason about these performance trade-offs, and helps identify possible functions that need a CMutableTransaction version.
@lucash-dev
Copy link
Contributor Author

Rebased on latest master. Everything worked locally. Let's see how Travis behaves.

@maflcko
Copy link
Member

maflcko commented Dec 22, 2018

utACK b301950

1 similar comment
@practicalswift
Copy link
Contributor

utACK b301950

@laanwj
Copy link
Member

laanwj commented Jan 21, 2019

utACK b301950, agree with the rationale

@laanwj laanwj merged commit b301950 into bitcoin:master Jan 21, 2019
laanwj added a commit that referenced this pull request Jan 21, 2019
…tion conversion.

b301950  Made expicit constructor CTransaction(const CMutableTransaction &tx). (lucash-dev)
faf29dd  Minimal changes to comply with explicit CMutableTransaction -> CTranaction conversion. (lucash-dev)

Pull request description:

  This PR is re-submission of #14156, which was automatically closed by github (glitch?)

  Original description:

  This PR makes explicit the now implicit conversion constructor `CTransaction(const CMutableTransaction&)` in `transaction.h`.
  Minimal changes were made elsewhere to make the code compilable. I'll follow up with other PRs to address individually refactoring functions that should have a `CMutableTransaction` version, or where a `CTransaction` should be reused.

  The rationale for this change is:

   - Conversion constructors should not be explicit unless there's a strong reason for it (in the opinion of, for example, https://google.github.io/styleguide/cppguide.html, and https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Ro-conversion. Let me know your take on this).
   - This particular conversion is very costly -- it implies a serialization plus hash of the transaction.
   - Even though `CTransaction` and `CMutableTransaction` represent the same data, they have very different use cases and performance properties.
   - Making it explicit allows for easier reasoning of performance trade-offs.
   - There has been previous performance issues caused by unneeded use of this implicit conversion.
   - This PR creates a map for places to look for possible refactoring and performance gains (this benefit still holds if the PR is not merged).

Tree-SHA512: 2427462e7211b5ffc7299dae17339d27f8c43266e0895690fda49a83c72751bd2489d4471b3993075a18f3fef25d741243e5010b2f49aeef4a9688b30b6d0631
wqking added a commit to wqking-misc/Phore that referenced this pull request Dec 25, 2019
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 16, 2020
…saction conversion.

Summary:
This PR is re-submission of #14156, which was automatically closed by github (glitch?)

Original description:

This PR makes explicit the now implicit conversion constructor CTransaction(const CMutableTransaction&) in transaction.h.
Minimal changes were made elsewhere to make the code compilable. I'll follow up with other PRs to address individually refactoring functions that should have a CMutableTransaction version, or where a CTransaction should be reused.

The rationale for this change is:

Conversion constructors should not be explicit unless there's a strong reason for it (in the opinion of, for example, https://google.github.io/styleguide/cppguide.html, and https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Ro-conversion. Let me know your take on this).
This particular conversion is very costly -- it implies a serialization plus hash of the transaction.
Even though CTransaction and CMutableTransaction represent the same data, they have very different use cases and performance properties.
Making it explicit allows for easier reasoning of performance trade-offs.
There has been previous performance issues caused by unneeded use of this implicit conversion.
This PR creates a map for places to look for possible refactoring and performance gains (this benefit still holds if the PR is not merged).

---

Depends on D6072

This is a backport of Core [[bitcoin/bitcoin#14906 | PR14906]]

Test Plan:
  ninja check-all

Reviewers: #bitcoin_abc, nakihito

Reviewed By: nakihito

Subscribers: nakihito

Differential Revision: https://reviews.bitcoinabc.org/D6073
kwvg added a commit to kwvg/dash that referenced this pull request Oct 12, 2021
UdjinM6 added a commit to dashpay/dash that referenced this pull request Oct 13, 2021
merge bitcoin bitcoin#13013, bitcoin#14908, bitcoin#14906: Make explicit CMutableTransaction -> CTransaction conversion
pravblockc pushed a commit to pravblockc/dash that referenced this pull request Nov 18, 2021
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants