Skip to content

Delete TxOut::NULL#3978

Merged
apoelstra merged 4 commits intorust-bitcoin:masterfrom
Kixunil:delete-txout-null
Jan 31, 2025
Merged

Delete TxOut::NULL#3978
apoelstra merged 4 commits intorust-bitcoin:masterfrom
Kixunil:delete-txout-null

Conversation

@Kixunil
Copy link
Copy Markdown
Collaborator

@Kixunil Kixunil commented Jan 29, 2025

This removes TxOut::NULL from our API and replaces the very few occurrences in our code. The PR has three commits so that the first one provably doesn't break anything, and the second one could be dropped if anyone complains about not deprecating but I really hope that won't happen.

As a side effect this also improves signing performance.

Closes #3975

@Kixunil Kixunil added bug API break This PR requires a version bump for the next release 1.0 Issues and PRs required or helping to stabilize the API perf Performance optimizations/issues labels Jan 29, 2025
@github-actions github-actions Bot added C-bitcoin PRs modifying the bitcoin crate C-primitives labels Jan 29, 2025
The `encode_signing_data_to_inner` function previously constructed a
transaction internally, requiring a bunch of allocations, which it'd
then consensus-serialize into a writer (hasher). It also used a dummy
`TxOut::NULL` value which we want to get rid of.

To get rid of both allocations and the NULL value we serialize the
transaction on-the-fly. Because the encoding doesn't involve witnesses
it's not too complicated and the consensus encoding will never change so
there are no desync bugs possible. We may later change this to an
abstract transaction though.
We want to get rid of this constant, so we replace it in tests with 0
amount, empty script. Notably, the tests were already using it as a
dummy value - the exact amount was irrelevant, so this change doesn't
break anything.
We've stopped using `TxOut::NULL` in the code and we want to restrict
`Amount` to 21M BTC, so we are now deleting this constant without
deprecation. Deprecation can be backported if needed.
tcharding
tcharding previously approved these changes Jan 29, 2025
Copy link
Copy Markdown
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

ACK 39a16a3c619be99dfe3bcacce2db7f1dbc63e7b0

@tcharding
Copy link
Copy Markdown
Member

Mad, thanks. I didn't check that the first patch passes tests leaving that to @apoelstra's CI.

@coveralls
Copy link
Copy Markdown

coveralls commented Jan 29, 2025

Pull Request Test Coverage Report for Build 13047441595

Details

  • 28 of 28 (100.0%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.009%) to 83.309%

Files with Coverage Reduction New Missed Lines %
bitcoin/src/crypto/sighash.rs 1 84.26%
Totals Coverage Status
Change from base Build 13038806089: -0.009%
Covered Lines: 21033
Relevant Lines: 25247

💛 - Coveralls

@Kixunil
Copy link
Copy Markdown
Collaborator Author

Kixunil commented Jan 29, 2025

OMG, the API shit... I guess if you rebase your PR you can just clump together the API changes and I don't have to deal with that. Otherwise you need to wait until tomorrow.

@tcharding
Copy link
Copy Markdown
Member

I did #3979 for you, @apoelstra can just merge it straight on top of this one.

@tcharding
Copy link
Copy Markdown
Member

FTR his CI does not do the API checks so this PR will still get past his CI.

@tcharding
Copy link
Copy Markdown
Member

This PR combined with #3979 is proved to work because #3794 is now on top of the two of them.

@Kixunil
Copy link
Copy Markdown
Collaborator Author

Kixunil commented Jan 30, 2025

I've cherry-picked the commit from #3979

Copy link
Copy Markdown
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

ACK 53bcdef

Copy link
Copy Markdown
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 53bcdef; successfully ran local tests; thanks!! No need to deprecate. Nobody was using this thing except maybe as a test dummy value

@apoelstra apoelstra merged commit 39e9acc into rust-bitcoin:master Jan 31, 2025
@Kixunil Kixunil deleted the delete-txout-null branch January 31, 2025 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.0 Issues and PRs required or helping to stabilize the API API break This PR requires a version bump for the next release bug C-bitcoin PRs modifying the bitcoin crate C-primitives perf Performance optimizations/issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

primitives: Remove TxOut::NULL

4 participants