Skip to content

Migrate to vultisig go#67

Merged
neavra merged 5 commits intomasterfrom
migrate-to-vultisig-go
Aug 18, 2025
Merged

Migrate to vultisig go#67
neavra merged 5 commits intomasterfrom
migrate-to-vultisig-go

Conversation

@neavra
Copy link
Contributor

@neavra neavra commented Aug 17, 2025

Overview

This PR removes duplicated code from the recipes repository and migrates to use the new vultisig-go shared library for address derivation, vault encryption, common utilities, and type definitions.

Note: This change is part of a larger effort to move these packages into a common repo (vultisig-go). Since both verifier and plugin currently has code affected by the change imported from recipes, recipes need to be merged first, followed by verifier and then plugin (see draft pr below). After this PR is merged, the recipes version need to be bumped in both verifier and plugin, before those changes can be merged.

📋 Changes

Removed Packages

  • recipes/address/ - Migrated to vultisig-go/address
  • recipes/common/ - Migrated to vultisig-go/common and vultisig-go/crypto
  • recipes/types/vault.go - Migrated to vultisig-go/types

Updated Imports

Before:

import (
    rcommon "github.com/vultisig/recipes/common"
    "github.com/vultisig/recipes/address"
    rtypes "github.com/vultisig/recipes/types"
)

After:

import (
    "github.com/vultisig/vultisig-go/common"
    "github.com/vultisig/vultisig-go/address"
    "github.com/vultisig/vultisig-go/types"
)

🔗 Related PRs

  • vultisig-go: #3Add shared address, crypto, common, and types packages
  • verifier: #316 Migrate verifier to use vultisig-go shared library (draft)
  • plugin: #157 Migrate to vultisig go (draft)

Summary by CodeRabbit

  • Refactor
    • Migrated to a new core library for chain and address handling, removing built-in address derivation and chain utilities.
  • Chores
    • Updated dependencies and module mappings to align with the new core.
  • Tests
    • Removed legacy address/chain tests and updated test imports to the new core.
  • Notes
    • No changes to CLI behavior or evaluation features; functionality remains the same for end-users.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 17, 2025

Walkthrough

This change removes the entire address derivation layer and related tests, deletes core common types and utilities, updates imports to use github.com/vultisig/vultisig-go/common, and restructures dependencies in go.mod. No new features were added; primary modifications are deletions and module import/path updates.

Changes

Cohort / File(s) Summary of changes
Address APIs removed
address/address.go, address/bitcoin.go, address/bch.go, address/ltc.go, address/cosmos.go, address/evm.go, address/dot.go, address/sol.go, address/sui.go, address/xrp.go, address/ss85.go
Deleted all address derivation implementations and the public GetAddress entrypoint, removing support for BTC/BCH/LTC, Cosmos bech32 variants, EVM, DOT, SOL, Sui, XRP, and SS58 encoding.
Address tests removed
address/*_test.go
Deleted all unit tests validating address derivation across chains (Bitcoin, BitcoinCash, Litecoin, Cosmos variants, EVM, Polkadot, Solana, Sui, XRP).
Common core removed
common/chain.go, common/utils.go
Removed Chain enum/constants, serialization, helpers (IsEvm, EvmID, NativeSymbol, GetDerivePath, IsEdDSA, FromString, JSON/DB methods) and a wide set of public utilities (encryption, compression, validation, misc helpers).
Import path migration
cmd/vulticheck/main.go, engine/engine.go, engine/engine_test.go, engine/evm/evm_test.go
Switched imports from github.com/vultisig/recipes/common to github.com/vultisig/vultisig-go/common; adjusted aliases. No logic changes.
Dependency graph update
go.mod
Reworked module dependencies: added github.com/vultisig/vultisig-go, updated/removed various indirects, adjusted replacements, and upgraded several packages (btcec, x/crypto, zap, etc.).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

I nibbled old roots, let forests clear,
Pruned the paths so new trails appear.
Hops made light by lighter load,
Fresh carrots packed for the road.
With modules merged and branches slim,
I thump the ground—onward, trim! 🥕🐇

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
  • Commit unit tests in branch migrate-to-vultisig-go

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.

@neavra neavra marked this pull request as ready for review August 18, 2025 13:40
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

🔭 Outside diff range comments (1)
cmd/vulticheck/main.go (1)

72-78: Fix potential nil dereference when Evaluate returns an error

If eng.Evaluate returns an error, matchingRule may be nil; dereferencing it will panic.

Apply this diff:

-    matchingRule, err := eng.Evaluate(&policy, common.Chain(*chainID), txBytes)
-    if err != nil {
-      log.Printf("Failed to evaluate transaction: %v", err)
-    }
-
-    log.Printf("Matching rule: %s", matchingRule.GetId())
+    matchingRule, err := eng.Evaluate(&policy, common.Chain(*chainID), txBytes)
+    if err != nil {
+      log.Printf("Failed to evaluate transaction: %v", err)
+    } else if matchingRule != nil {
+      log.Printf("Matching rule: %s", matchingRule.GetId())
+    } else {
+      log.Printf("No matching rule found")
+    }
🧹 Nitpick comments (9)
engine/engine.go (2)

52-59: Make chain ID comparison robust to case mismatches

To avoid subtle mismatches between resource path and chain.String(), compare case-insensitively rather than lowercasing only one side.

Apply this diff:

-    if resourcePath.ChainId != strings.ToLower(chain.String()) {
+    if !strings.EqualFold(resourcePath.ChainId, chain.String()) {
       e.logger.Printf(
         "Skipping rule %s: target chain %s is not '%s'",
         rule.GetId(),
         resourcePath.ChainId,
         chain.String(),
       )
       continue
     }

165-167: Remove unreachable branch after nil-guard

configurationData is set to a non-nil struct on Line 158 if nil, so this nil check is dead code.

Apply this diff:

-  if configurationData == nil {
-    policyJson = emptyJson
-  }
cmd/vulticheck/main.go (1)

20-21: Optional: improve UX for chain flag

Using raw ints for -chain is error-prone. Consider accepting well-known chain names (e.g., "ethereum") and mapping to common.Chain.

I can wire a small map[string]common.Chain and parse the flag accordingly if you want.

engine/evm/evm_test.go (3)

450-454: Don’t ignore error from NativeSymbol()

Assert no error to avoid masking failures if the common API changes or returns an error.

Apply this diff:

-      native, _ := vgcommon.Ethereum.NativeSymbol()
+      native, err := vgcommon.Ethereum.NativeSymbol()
+      if err != nil {
+        t.Fatalf("Failed to get native symbol: %v", err)
+      }
       evm, err := NewEvm(native)

856-860: Repeat: check error from NativeSymbol()

Mirror the earlier pattern to avoid silent failures in tests.

Apply this diff:

-      native, _ := vgcommon.Ethereum.NativeSymbol()
+      native, err := vgcommon.Ethereum.NativeSymbol()
+      if err != nil {
+        t.Fatalf("Failed to get native symbol: %v", err)
+      }
       evm, err := NewEvm(native)

1057-1063: Repeat: check error from NativeSymbol()

Keep tests consistent and fail fast on unexpected errors.

Apply this diff:

-      native, _ := vgcommon.Ethereum.NativeSymbol()
-      evm, err := NewEvm(native)
+      native, err := vgcommon.Ethereum.NativeSymbol()
+      if err != nil {
+        t.Fatalf("Failed to get native symbol: %v", err)
+      }
+      evm, err := NewEvm(native)
go.mod (3)

11-11: Dependency on vultisig-go looks aligned with the migration

Pinned to a pseudo-version which is fine for moving targets. Consider tagging a semver once stabilized for downstream consumers.


16-81: Tidy module deps after migration

There are many indirect entries and dual btcutil module paths present. Running go mod tidy after this migration will simplify the graph and reduce noise.

I can provide a one-off script to run tidy and check for unwanted replaces if your CI environment allows it.


3-3: go directive supports patch versions; no change required

The go directive in go.mod accepts full Go version strings, including patch releases (e.g., 1.24.2). Language semantics are based on the major.minor “language version” (truncating after the minor).
You can leave go 1.24.2 as-is, or—purely for consistency—opt to shorten it to go 1.24.

• Location: go.mod (line 3)
• Optional diff:

-go 1.24.2
+go 1.24

Citations:

  1. https://tip.golang.org/ref/mod
  2. https://tip.golang.org/doc/toolchain
📜 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 6e37f70 and 1f4185e.

⛔ Files ignored due to path filters (7)
  • go.sum is excluded by !**/*.sum
  • types/constraint.pb.go is excluded by !**/*.pb.go
  • types/parameter_constraint.pb.go is excluded by !**/*.pb.go
  • types/policy.pb.go is excluded by !**/*.pb.go
  • types/recipe_specification.pb.go is excluded by !**/*.pb.go
  • types/resource.pb.go is excluded by !**/*.pb.go
  • types/rule.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (28)
  • address/address.go (0 hunks)
  • address/address_test.go (0 hunks)
  • address/bch.go (0 hunks)
  • address/bch_test.go (0 hunks)
  • address/bitcoin.go (0 hunks)
  • address/bitcoin_test.go (0 hunks)
  • address/cosmos.go (0 hunks)
  • address/cosmos_test.go (0 hunks)
  • address/dot.go (0 hunks)
  • address/dot_test.go (0 hunks)
  • address/evm.go (0 hunks)
  • address/evm_test.go (0 hunks)
  • address/ltc.go (0 hunks)
  • address/ltc_test.go (0 hunks)
  • address/sol.go (0 hunks)
  • address/sol_test.go (0 hunks)
  • address/ss85.go (0 hunks)
  • address/sui.go (0 hunks)
  • address/sui_test.go (0 hunks)
  • address/xrp.go (0 hunks)
  • address/xrp_test.go (0 hunks)
  • cmd/vulticheck/main.go (1 hunks)
  • common/chain.go (0 hunks)
  • common/utils.go (0 hunks)
  • engine/engine.go (1 hunks)
  • engine/engine_test.go (1 hunks)
  • engine/evm/evm_test.go (6 hunks)
  • go.mod (1 hunks)
💤 Files with no reviewable changes (23)
  • address/evm_test.go
  • address/sol.go
  • address/sol_test.go
  • address/sui.go
  • address/ltc.go
  • address/cosmos.go
  • address/bitcoin.go
  • address/xrp_test.go
  • address/dot.go
  • address/bitcoin_test.go
  • address/ltc_test.go
  • address/bch_test.go
  • address/xrp.go
  • address/dot_test.go
  • address/ss85.go
  • address/sui_test.go
  • address/bch.go
  • address/cosmos_test.go
  • address/evm.go
  • address/address.go
  • common/utils.go
  • common/chain.go
  • address/address_test.go
🔇 Additional comments (7)
engine/engine.go (2)

15-15: Import path migration to vultisig-go/common looks correct

The switch to github.com/vultisig/vultisig-go/common is consistent with the PR objective and aligns with the rest of the repo changes.


201-208: SupportedTypes is a single enum, not a list — no change needed
The SupportedTypes field is defined as a singular ConstraintType (not repeated), and GetSupportedTypes() returns that enum value. The existing equality check correctly verifies support; a membership loop is unnecessary.

Likely an incorrect or invalid review comment.

cmd/vulticheck/main.go (1)

9-9: Import path migration to vultisig-go/common looks correct

Matches the engine changes and PR goals.

engine/engine_test.go (1)

14-14: Tests updated to new common import path — looks good

The switch to github.com/vultisig/vultisig-go/common aligns with production code.

engine/evm/evm_test.go (3)

16-16: Import alias change to vgcommon is correct

References resolve cleanly and are consistent with the migration.


474-477: LGTM: error check present here

This instance correctly checks the error from NativeSymbol().


1079-1082: LGTM: error check present here

This test also correctly checks the error from NativeSymbol().

Copy link
Contributor

@webpiratt webpiratt left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@RaghavSood RaghavSood left a comment

Choose a reason for hiding this comment

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

LGTM

Lovely go.sum

@neavra neavra merged commit db3f03c into master Aug 18, 2025
3 checks passed
@neavra neavra deleted the migrate-to-vultisig-go branch August 18, 2025 15:17
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.

3 participants