Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable inscription parsing on Bitcoin mainnet #3425

Merged
merged 3 commits into from
Jan 29, 2025

Conversation

lumtis
Copy link
Member

@lumtis lumtis commented Jan 28, 2025

Description

Closes #3424

Summary by CodeRabbit

  • New Features

    • Enabled inscription parsing on Bitcoin mainnet
  • Refactor

    • Simplified Bitcoin event extraction logic
    • Removed alternative method for processing Bitcoin transactions without witness data
  • Tests

    • Updated test cases to reflect changes in Bitcoin event processing function

Copy link
Contributor

coderabbitai bot commented Jan 28, 2025

📝 Walkthrough

Walkthrough

This pull request introduces a significant enhancement to Bitcoin mainnet functionality by enabling inscription parsing. The changes primarily involve modifying the Bitcoin observer's event handling mechanism in the ZetaChain node, specifically removing the GetBtcEventWithoutWitness function and updating the GetBtcEvent function to streamline Bitcoin transaction processing across different network configurations.

Changes

File Change Summary
changelog.md Added entry for enabling inscription parsing on Bitcoin mainnet
zetaclient/chains/bitcoin/observer/inbound.go - Removed GetBtcEventWithoutWitness function
- Simplified GetBtcEvent function by removing network-specific conditional logic
zetaclient/chains/bitcoin/observer/inbound_test.go - Renamed test function from TestGetBtcEventWithoutWitness to TestGetBtcEvent
- Updated function calls to use new GetBtcEvent method

Assessment against linked issues

Objective Addressed Explanation
Enable witness/inscription parsing for Bitcoin mainnet [#3424]

Possibly related PRs

Suggested labels

chain:bitcoin, no-changelog

Suggested reviewers

  • swift1337
  • kingpinXD
  • brewmaster012
  • skosito
  • fbac
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@lumtis lumtis changed the title feat: enable inscription for Bitcoin mainnet feat: enable inscription parsing on Bitcoin mainnet Jan 28, 2025
@lumtis lumtis marked this pull request as ready for review January 28, 2025 14:29
@lumtis lumtis requested a review from a team as a code owner January 28, 2025 14:29
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
changelog.md (1)

11-11: Include version context for clarity.
Adding “enable inscription parsing on Bitcoin mainnet” is informative. Consider appending a reference to the upcoming release version or date for heightened transparency.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d162dda and cd48d80.

📒 Files selected for processing (3)
  • changelog.md (1 hunks)
  • zetaclient/chains/bitcoin/observer/inbound.go (1 hunks)
  • zetaclient/chains/bitcoin/observer/inbound_test.go (16 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
zetaclient/chains/bitcoin/observer/inbound_test.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

zetaclient/chains/bitcoin/observer/inbound.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

🔇 Additional comments (17)
zetaclient/chains/bitcoin/observer/inbound.go (1)

288-288: Consider a fallback for non-witness transactions.
The updated GetBtcEvent function exclusively calls GetBtcEventWithWitness, removing any handling for non-witness data. Confirm whether legacy transactions or unupgraded nodes would fail under this approach. If necessary, implement a graceful fallback or detection mechanism for older transaction types.

zetaclient/chains/bitcoin/observer/inbound_test.go (16)

277-277: Test renaming is consistent.
Renaming the test from TestGetBtcEventWithoutWitness to TestGetBtcEvent aptly aligns with the consolidated approach in production code.


318-318: Clear function call alignment.
Switching to GetBtcEvent ensures test parity with the updated observer logic. The scenario coverage is adequately maintained.


351-351: Good insufficient fee scenario coverage.
Validating the depositor fee edge case with GetBtcEvent helps maintain confidence in the updated event extraction logic.


376-376: Proper handling of P2TR address.
Using GetBtcEvent for Taproot inputs demonstrates that the codebase now comprehensively covers witness-based transactions.


401-401: Thorough P2WSH test coverage.
Ensuring test coverage for P2WSH inputs in GetBtcEvent boosts confidence in the correctness of the new consolidated function.


426-426: P2SH sending scenario validated.
The test confirms that sending from a P2SH address remains supported under the unified event parsing flow.


451-451: P2PKH coverage is consistent.
This test demonstrates that legacy P2PKH inputs are accurately handled, even with the consolidated witness-based extraction approach.


472-472: Minimum output count check.
Skipping transactions with fewer than two outputs remains an important safeguard, ensuring only relevant inbound transactions are processed.


493-493: Rejecting non-P2WPKH outputs at vout[0].
Maintaining this check ensures transactions intended for other addresses are gracefully ignored, preventing extraneous event generation.


508-508: Extended script length tested.
Appending a byte to the script and confirming that it is rejected highlights careful boundary handling with the new function approach.


529-529: Rejecting non-TSS addresses.
Confirming that the inbound flow halts if the target address is not TSS is essential to the inbound filtering logic.


549-549: Depositor fee calculation failure scenario.
The test covers fee calculation RPC error handling, ensuring failures do not disrupt the rest of the inbound flow.


570-570: Guarding against non-OP_RETURN second outputs.
Skipping transactions lacking the second output memo logic remains a cornerstone of reliable inbound event detection.


591-591: Memo decoding failure check.
Ensuring the process discards transactions with broken memo scripts prevents potential misinterpretations or invalid event creation.


623-623: Empty sender address scenario.
The test verifies that unknown or malformed sender scripts result in a nil event, strengthening input validation.


662-662: Proper error handling for RPC failures.
Verifying that the function surfaces errors from GetRawTransaction preserves reliability for fault-tolerant inbound processing.

Copy link

codecov bot commented Jan 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.86%. Comparing base (d162dda) to head (cd48d80).
Report is 6 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3425      +/-   ##
===========================================
- Coverage    62.89%   62.86%   -0.04%     
===========================================
  Files          436      436              
  Lines        30796    30726      -70     
===========================================
- Hits         19369    19315      -54     
+ Misses       10615    10603      -12     
+ Partials       812      808       -4     
Files with missing lines Coverage Δ
zetaclient/chains/bitcoin/observer/inbound.go 21.63% <ø> (-19.38%) ⬇️

... and 1 file with indirect coverage changes

@lumtis lumtis added this pull request to the merge queue Jan 29, 2025
Merged via the queue into develop with commit 21884ab Jan 29, 2025
45 checks passed
@lumtis lumtis deleted the refactor/use-witness-bitcoin-mainnet branch January 29, 2025 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable witness/inscription parsing for Bitcoin mainnet
3 participants