Skip to content

Conversation

@jnewbery
Copy link
Contributor

PrecomputedTransactionData is initialized inside CheckInputScripts(). No need to pre-initialize it before calling into CheckInputScripts().

Normally, I wouldn't bother, but we're making changes to PrecomputedTransactionData in #17977 which would break these tests without removing these constructions. Might as well get these changes out of the way here.

…che tests

PrecomputedTransactionData is initialized inside CheckInputScripts(). No need
to pre-initialize it before calling into CheckInputScripts().
@DrahtBot
Copy link
Contributor

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

Conflicts

Reviewers, 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.

@robot-visions
Copy link
Contributor

Thanks for doing this cleanup, tests passed for me!

Before I finish my review, there's something I'm hoping to understand.

The refactoring change #18401 adds the following to validation.cpp#CheckInputScripts:

if (!txdata.m_ready) {
    txdata.Init(tx);
}

However, the Schnorr/taproot/tapscript change #17977 instead does the following (no txdata.m_ready check):

txdata.Init(tx, std::move(spent_outputs));

What's the motivation for updating the tests to start with uninitialized PrecomputedTransactionData, as opposed to keeping the m_ready check in the Schnorr/taproot/tapscript change?

@jnewbery
Copy link
Contributor Author

Thanks for the review @robot-visions

What's the motivation for updating the tests to start with uninitialized PrecomputedTransactionData

Great question! I added the if (!txdata.m_ready) to CheckInputScripts() and assert(!m_ready) to PrecomputedTransactionData::Init() following the conversation here: #18401 (comment) to ensure that a PrecomputedTransactionData object is only initialized once. That means that the subsequent commits in the Taproot PR need to be changed slightly to ensure that Init() isn't called more than once. I've done that in a branch here: https://github.com/jnewbery/bitcoin/commits/pr17977.2. One of the changes needed is to not initialize these PrecomputedTransactionData objects in the tests, which is what this PR is doing.

@robot-visions
Copy link
Contributor

ACK 3718ae2

Thanks for clarifying! That makes sense—it looks like pr17977.2 includes both the if (!txdata.m_ready) check and the test update.

@sipa
Copy link
Member

sipa commented Apr 18, 2020

utACK 3718ae2

@maflcko maflcko merged commit a998c51 into bitcoin:master Apr 19, 2020
@jnewbery jnewbery deleted the 2020-04-precomputedtransactiondata-txvalidationcache branch April 19, 2020 15:09
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 20, 2020
…ta in txvalidationcache tests

3718ae2 [tests] Don't initialize PrecomputedTransactionData in txvalidationcache tests (John Newbery)

Pull request description:

  PrecomputedTransactionData is initialized inside CheckInputScripts(). No need to pre-initialize it before calling into CheckInputScripts().

  Normally, I wouldn't bother, but we're making changes to `PrecomputedTransactionData` in bitcoin#17977 which would break these tests without removing these constructions. Might as well get these changes out of the way here.

ACKs for top commit:
  robot-visions:
    ACK 3718ae2
  sipa:
    utACK 3718ae2

Tree-SHA512: bc9c095035a7072a2a91941df38cdbb969e817264efbaa6dcb88cc3ab132d9264aa0751fa588d1a5e45f37b4d2bb1903cda078765f0bbcc87d9cc47cbec5356a
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants