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

Consolidate RPC Client Interfaces #1323

Merged
merged 4 commits into from
Jan 27, 2025
Merged

Consolidate RPC Client Interfaces #1323

merged 4 commits into from
Jan 27, 2025

Conversation

ffranr
Copy link
Contributor

@ffranr ffranr commented Jan 24, 2025

This PR introduces the following changes:

  • Renamed RpcBundle to RpcClientsBundle for improved clarity and consistency.
  • Added missing RPC clients to RpcClientsBundle to ensure all required clients are included.
  • Reused the commands.RpcClientsBundle interface in the itest rpcClient struct for consistency.
  • Removed duplicate code by replacing TapdClient with commands.RpcClientsBundle in integration tests.

These changes streamline the codebase and enhance maintainability by unifying the handling of RPC clients across components.

I attempted to define RpcClientsBundle in taprpc but it leads to an import cycle with assetwalletrpc.

Simplify the file name by removing the redundant package name prefix,
making it more concise and consistent.

This is a refactor commit and is unrelated to the other changes in
this PR.
@ffranr ffranr requested review from guggero and GeorgeTsagk January 24, 2025 20:35
@ffranr ffranr self-assigned this Jan 24, 2025
@@ -58,29 +62,60 @@ func Fatal(err error) {
os.Exit(1)
}

func getClient(ctx *cli.Context) (taprpc.TaprootAssetsClient, func()) {
// RpcClientsBundle is an interface that groups all the RPC clients.
type RpcClientsBundle interface {
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should just define this in taprpc? Then that way we don't have anything importing from the cmd package, which is really just meant to be an executable.

What does the import cycle you ran into look like?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All these proto message types would need to be moved/refactored (and related golang code):

Targets
    Occurrences of 'taprpc' in Selected directories with mask '*.proto'
Found occurrences in Selected directories with mask '*.proto'  (38 usages found)
    Unclassified  (38 usages found)
        taproot-assets  (38 usages found)
            taprpc/assetwalletrpc  (14 usages found)
                assetwallet.proto  (14 usages found)
                    34 returns (taprpc.SendAssetResponse);
                    52 returns (taprpc.SendAssetResponse);
                    205 taprpc.OutPoint outpoint = 1;
                    347 repeated taprpc.OutPoint lnd_locked_utxos = 6;
                    381 repeated taprpc.OutPoint lnd_locked_utxos = 5;
                    389 taprpc.KeyDescriptor internal_key = 1;
                    397 taprpc.ScriptKey script_key = 1;
                    407 taprpc.KeyDescriptor internal_key = 1;
                    418 taprpc.ScriptKey script_key = 1;
                    426 taprpc.OutPoint outpoint = 3;
                    451 taprpc.OutPoint outpoint = 2;
                    468 taprpc.OutPoint outpoint = 1;
                    475 taprpc.ScriptKey script_key = 1;
                    479 taprpc.ScriptKey script_key = 1;
            taprpc/mintrpc  (18 usages found)
                mint.proto  (18 usages found)
                    63 taprpc.AssetVersion asset_version = 1;
                    66 taprpc.AssetType asset_type = 2;
                    75 taprpc.AssetMeta asset_meta = 4;
                    102 taprpc.KeyDescriptor group_internal_key = 9;
                    115 taprpc.ScriptKey script_key = 11;
                    123 taprpc.GroupKeyRequest group_key_request = 2;
                    126 taprpc.GroupVirtualTx group_virtual_tx = 3;
                    134 taprpc.AssetVersion asset_version = 1;
                    137 taprpc.AssetType asset_type = 2;
                    146 taprpc.AssetMeta asset_meta = 4;
                    181 taprpc.KeyDescriptor group_internal_key = 10;
                    201 taprpc.ScriptKey script_key = 12;
                    225 taprpc.ExternalKey external_group_key = 14;
                    319 taprpc.TapscriptFullTree full_tree = 3;
                    322 taprpc.TapBranch branch = 4;
                    342 repeated taprpc.GroupWitness group_witnesses = 2;
                    376 taprpc.TapscriptFullTree full_tree = 3;
                    379 taprpc.TapBranch branch = 4;
            taprpc/tapchannelrpc  (3 usages found)
                tapchannel.proto  (3 usages found)
                    215 taprpc.DecimalDisplay decimal_display = 2;
                    218 taprpc.AssetGroup asset_group = 3;
                    222 taprpc.GenesisInfo genesis_info = 4;
            taprpc/tapdevrpc  (1 usage found)
                tapdev.proto  (1 usage found)
                    101 taprpc.Addr address = 2;
            taprpc/universerpc  (2 usages found)
                universe.proto  (2 usages found)
                    323 taprpc.Asset asset = 1;
                    565 taprpc.AssetType asset_type = 5;

I think we should actually do that in the future by adding an RPC package with useful TAP primitive types.

But I'm hoping to avoid making that change right now and just get to a point where we can include tapcli minting commands in our itests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Solution proposal: #1328

@coveralls
Copy link

coveralls commented Jan 24, 2025

Pull Request Test Coverage Report for Build 12986915762

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 56 (0.0%) changed or added relevant lines in 4 files are covered.
  • 12 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.009%) to 40.719%

Changes Missing Coverage Covered Lines Changed/Added Lines %
cmd/commands/commands.go 0 1 0.0%
itest/utils.go 0 3 0.0%
itest/loadtest/utils.go 0 18 0.0%
cmd/commands/conn.go 0 34 0.0%
Files with Coverage Reduction New Missed Lines %
commitment/tap.go 4 83.64%
universe/interface.go 8 53.68%
Totals Coverage Status
Change from base Build 12934944306: 0.009%
Covered Lines: 26729
Relevant Lines: 65642

💛 - Coveralls

Copy link
Member

@guggero guggero 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
Member

@GeorgeTsagk GeorgeTsagk left a comment

Choose a reason for hiding this comment

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

LGTM ⬆️

itest/loadtest/utils.go Show resolved Hide resolved
@ffranr ffranr added this pull request to the merge queue Jan 27, 2025
@ffranr ffranr removed this pull request from the merge queue due to a manual request Jan 27, 2025
Refactors the RpcBundle to RpcClientsBundle for better clarity and
consistency. Also adds previously missing RPC clients to ensure all
required clients are included.
To ensure consistency, re-use interface command.RpcClientsBundle in
the itest rpcClient struct.
@ffranr ffranr force-pushed the rpc-clients-refactor branch from d042438 to c46c69e Compare January 27, 2025 10:27
@ffranr ffranr enabled auto-merge January 27, 2025 10:27
@ffranr ffranr added this pull request to the merge queue Jan 27, 2025
Merged via the queue into main with commit 9198330 Jan 27, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

5 participants