Skip to content

Conversation

louisinger
Copy link
Collaborator

@louisinger louisinger commented Aug 19, 2025

it closes #690

@Kukks please review

Summary by CodeRabbit

  • Refactor

    • Streamlined offchain transaction handling by removing per-input checkpoint script fields; inputs now use revealed tapscripts only. Core transaction flow preserved with simpler input format.
  • Tests

    • Updated end-to-end tests to match the streamlined flow. Test signing now uses the main offchain transaction as primary and augments checkpoint transactions with a condition witness before finalizing.

Copy link

coderabbitai bot commented Aug 19, 2025

Walkthrough

Removed the custom CheckpointTapscript and its per-input override. VtxoInput now carries only Outpoint, Tapscript, RevealedTapscripts, and Amount; checkpoint construction uses the main Tapscript.RevealedScript. SubmitOffchainTx and E2E tests updated accordingly.

Changes

Cohort / File(s) Summary
Core service: SubmitOffchainTx
internal/core/application/service.go
Removed creation/attachment of CheckpointTapscript when assembling VtxoInput; inputs now include Outpoint, Tapscript, RevealedTapscripts, Amount only.
Offchain lib: VtxoInput & checkpoint build
pkg/ark-lib/offchain/tx.go
Removed VtxoInput.CheckpointTapscript field; buildCheckpointTx now derives checkpoint leaf from vtxo.Tapscript.RevealedScript and encodes RevealedTapscripts from that source.
E2E tests: multisig closure path
test/e2e/e2e_test.go
Deleted checkpoint-specific variables/wiring and removed use of per-input checkpoint tapscript; updated BuildTxs usage to return arkPtx and added condition witness augmentation steps for ark and checkpoint PSBTs.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User
    participant Service as SubmitOffchainTx
    participant Offchain as Tx Builder
    participant Signer as Sign/Encode
    note right of Offchain: VtxoInput contains Tapscript + RevealedTapscripts only

    User->>Service: SubmitOffchainTx(request)
    Service->>Offchain: Build VtxoInputs(Outpoint, Tapscript, RevealedTapscripts, Amount)
    Offchain->>Offchain: buildCheckpointTx using Tapscript.RevealedScript
    Offchain->>Signer: return arkPtx + checkpoint PSBTs
    Signer->>Signer: AddConditionWitness(arkPtx / checkpoints)
    Signer-->>Service: encoded/signed transactions
    Service-->>User: Submission result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Assessment against linked issues

Objective Addressed Explanation
Remove custom CheckpointTapscript feature (#690)

Out-of-scope changes

Code Change Explanation
Added condition-witness augmentation to ark and checkpoint PSBTs (test/e2e/e2e_test.go) This introduces witness-adding steps in tests and PSBT processing not specified by issue #690 (which only required removing the custom checkpoint tapscript).

Possibly related PRs

Suggested reviewers

  • Kukks

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

Copy link

@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: 1

🧹 Nitpick comments (1)
pkg/ark-lib/offchain/tx.go (1)

25-27: Docs: Clarify what tree RevealedTapscripts represents

Nit: This comment is good; consider clarifying that these are the tap tree encodings for the input being spent by the Ark tx (i.e., the checkpoint output’s tree), not the original vtxo’s tree. This helps prevent future mix-ups in callers.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9186cfe and 4ad1af0.

📒 Files selected for processing (3)
  • internal/core/application/service.go (1 hunks)
  • pkg/ark-lib/offchain/tx.go (3 hunks)
  • test/e2e/e2e_test.go (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
pkg/ark-lib/offchain/tx.go (1)
pkg/ark-lib/script/closure.go (1)
  • DecodeClosure (31-69)
🔇 Additional comments (3)
test/e2e/e2e_test.go (1)

1659-1661: LGTM: struct literal updated to the new VtxoInput shape

The test now constructs offchain.VtxoInput without CheckpointTapscript and supplies Amount, Tapscript, RevealedTapscripts. This aligns with the library changes. No issues spotted.

pkg/ark-lib/offchain/tx.go (2)

168-176: LGTM: Collaborative closure now derived from the main tapscript

Decoding the collaborative closure from vtxo.Tapscript.RevealedScript removes the need for a separate CheckpointTapscript and ensures the checkpoint’s collaborative path matches the Ark path. This meets the PR objective of equality between checkpoint and ark tapscripts.


197-205: LGTM: Checkpoint leaf constructed from the same revealed script

Using the same revealed script to derive the tapleaf hash for the collaborative proof keeps the control block and script consistent with the checkpoint tree. Matches the new design.

Copy link

@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)
test/e2e/e2e_test.go (1)

1688-1695: Rename variable for clarity: it’s the ark PSBT, not a “virtual” tx

encodedVirtualTx here is the encoded ark PSBT. Rename for readability.

-encodedVirtualTx, err := arkPtx.B64Encode()
+encodedArkTx, err := arkPtx.B64Encode()
 require.NoError(t, err)

 signedTx, err := bobWallet.SignTransaction(
   ctx,
   explorer,
-  encodedVirtualTx,
+  encodedArkTx,
 )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4ad1af0 and 04b899c.

📒 Files selected for processing (1)
  • test/e2e/e2e_test.go (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: louisinger
PR: arkade-os/arkd#691
File: internal/core/application/service.go:557-562
Timestamp: 2025-08-19T10:58:41.013Z
Learning: In the arkd SubmitOffchainTx method, using the checkpoint PSBT input's tapscript (forfeit path) for the VtxoInput.Tapscript field is the correct behavior, not a bug as initially thought. The system correctly handles the relationship between checkpoint inputs and Ark transaction inputs.
📚 Learning: 2025-08-19T10:58:41.013Z
Learnt from: louisinger
PR: arkade-os/arkd#691
File: internal/core/application/service.go:557-562
Timestamp: 2025-08-19T10:58:41.013Z
Learning: In the arkd SubmitOffchainTx method, using the checkpoint PSBT input's tapscript (forfeit path) for the VtxoInput.Tapscript field is the correct behavior, not a bug as initially thought. The system correctly handles the relationship between checkpoint inputs and Ark transaction inputs.

Applied to files:

  • test/e2e/e2e_test.go
🧬 Code Graph Analysis (1)
test/e2e/e2e_test.go (1)
pkg/ark-lib/offchain/tx.go (2)
  • BuildTxs (31-64)
  • VtxoInput (20-28)
🔇 Additional comments (3)
test/e2e/e2e_test.go (3)

1652-1662: BuildTxs call correctly reflects removal of CheckpointTapscript; VtxoInput fields align

Good update: you pass Outpoint, Amount, Tapscript, and RevealedTapscripts only, consistent with the new VtxoInput definition. This enforces the same tapscript for both ark tx and checkpoint, aligning with the PR objective and our prior learning about using the checkpoint PSBT input’s tapscript for VtxoInput.Tapscript.


1713-1716: Condition witness on checkpoint PSBTs: good placement

Adding the preimage to the checkpoint PSBT inputs after the server returns its signatures is acceptable for tapscript (signing digest doesn’t depend on non-sig witness elements). This mirrors the ark PSBT path and enforces parity between the two spends as intended.


1684-1687: Minor nit: remove redundant slice on preimage

  • Adding the preimage witness before signing is correct.
  • Since preimage is already a []byte, using preimage[:] is redundant. You can simplify to wire.TxWitness{preimage}.

Suggested diff in test/e2e/e2e_test.go:

--- a/test/e2e/e2e_test.go
+++ b/test/e2e/e2e_test.go
@@ -1684,7 +1684,7 @@ func TestE2E(t *testing.T) {
 	// add condition witness to the ark ptx
-	err = txutils.AddConditionWitness(0, arkPtx, wire.TxWitness{preimage[:]})
+	err = txutils.AddConditionWitness(0, arkPtx, wire.TxWitness{preimage})
 	require.NoError(t, err)
 
@@ -1711,7 +1711,7 @@ func TestE2E(t *testing.T) {
 		// add condition witness to the checkpoint ptx
-		err = txutils.AddConditionWitness(0, ptx, wire.TxWitness{preimage[:]})
+		err = txutils.AddConditionWitness(0, ptx, wire.TxWitness{preimage})
 		require.NoError(t, err)
 
 		encoded, err := ptx.B64Encode()

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.

Remove custom CheckpointTapscript feature
1 participant