Skip to content

change(consensus): Optimize checks for coinbase transactions - #9126

Merged
mergify[bot] merged 3 commits into
mainfrom
fix-coinbase-decrypt
Jan 15, 2025
Merged

change(consensus): Optimize checks for coinbase transactions#9126
mergify[bot] merged 3 commits into
mainfrom
fix-coinbase-decrypt

Conversation

@upbqdn

@upbqdn upbqdn commented Jan 15, 2025

Copy link
Copy Markdown
Member

Motivation

The original motivation was to address #9098 (comment) and #9098 (comment). Then I noticed that the coinbase_outputs_are_decryptable fn currently converts each post-Heartwood coinbase tx to check if its shielded outputs are decryptable, even if the tx has no shielded outputs. This conversion involves a serialization and deserialization cycle. We can skip this conversion for txs with no shielded outputs.

Solution

  • Return early if the tx has no shielded outputs.
  • Return a new Transaction::NotCoinbase error if the tx is not coinbase but should be.
  • Update docs.

Tests

  • Improve tests so they check more scenarios.

PR Author's Checklist

  • The PR name will make sense to users.
  • The PR provides a CHANGELOG summary.
  • The solution is tested.
  • The documentation is up to date.
  • The PR has a priority label.

@upbqdn upbqdn added consensus Consensus-critical code: validation, cryptography, script P-Low 鉂勶笍 labels Jan 15, 2025
@upbqdn upbqdn self-assigned this Jan 15, 2025
@upbqdn
upbqdn requested a review from a team as a code owner January 15, 2025 17:36
@upbqdn
upbqdn requested review from arya2 and removed request for a team January 15, 2025 17:36

@arya2 arya2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, thank you!

@upbqdn upbqdn removed the C-trivial label Jan 15, 2025
mergify Bot added a commit that referenced this pull request Jan 15, 2025
mergify Bot added a commit that referenced this pull request Jan 15, 2025
@mergify
mergify Bot merged commit 522d955 into main Jan 15, 2025
@mergify
mergify Bot deleted the fix-coinbase-decrypt branch January 15, 2025 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

consensus Consensus-critical code: validation, cryptography, script P-Low 鉂勶笍

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants