-
Notifications
You must be signed in to change notification settings - Fork 2
feat(btc-server): add GetPublicKeyById gRPC for multi-key support #1036
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
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughA new RPC endpoint Changes
Sequence DiagramsequenceDiagram
participant Client
participant BtcServerClient
participant BtcServer
participant App
participant Database
Client->>BtcServerClient: get_public_key_by_id(multisig_id)
BtcServerClient->>BtcServer: tonic::Request<GetPublicKeyByIdRequest>
BtcServer->>App: get_public_key_by_id(req)
App->>Database: fetch public key package by multisig_id
Database-->>App: public key package
App->>App: serialize to hex string
App-->>BtcServer: GetPublicKeyByIdResponse (publickey, multisig_id)
BtcServer-->>BtcServerClient: tonic::Response<GetPublicKeyByIdResponse>
BtcServerClient-->>Client: (publickey, multisig_id)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
d3d73c0 to
654440b
Compare
There was a problem hiding this 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)
bin/btc-server/src/bin/main.rs (1)
1879-1898: Public key handlers correctly share logic and preserve legacy behavior
get_public_keynow delegates toload_public_key(LEGACY_MULTISIG_ID)andget_public_key_by_idsimply threads through the requested id, which keeps error behavior consistent and avoids duplication. You might optionally add a small test thatget_public_key_by_idwith a non‑existentmultisig_idreturns the expectedInvalidArgument/Missing key packageerror, mirroring the existingget_public_keynegative test.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
bin/btc-server/client/src/btc_server.rs(2 hunks)bin/btc-server/proto/btc_server.proto(2 hunks)bin/btc-server/src/bin/main.rs(4 hunks)bin/btc-server/src/rpc/btc_server.rs(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
bin/btc-server/client/src/btc_server.rs (2)
bin/btc-server/src/bin/main.rs (4)
get_public_key_by_id(1889-1898)req(788-817)req(1080-1090)new(351-560)bin/btc-server/src/rpc/btc_server.rs (2)
get_public_key_by_id(393-399)new(520-522)
bin/btc-server/src/rpc/btc_server.rs (2)
bin/btc-server/client/src/btc_server.rs (2)
get_public_key_by_id(551-574)new(372-375)bin/btc-server/src/bin/main.rs (4)
get_public_key_by_id(1889-1898)new(351-560)req(788-817)req(1080-1090)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build
🔇 Additional comments (5)
bin/btc-server/proto/btc_server.proto (1)
20-21: Proto definition for GetPublicKeyById is consistent and well-scopedRPC signature and request/response messages line up cleanly with existing
GetPublicKeyand the Rust types used downstream (u32 id, hex-encoded key). No issues from a schema or compatibility standpoint.Also applies to: 185-193
bin/btc-server/client/src/btc_server.rs (1)
159-171: Client wiring for GetPublicKeyById matches proto and existing patternsThe new request/response types and
get_public_key_by_idclient method follow the established tonic/prost pattern and use the correct service path. Nothing to change here.Also applies to: 551-574
bin/btc-server/src/bin/main.rs (2)
26-26: Centralized load_public_key helper is good; confirm DB multi-key migration semanticsThe
load_public_keyhelper cleanly encapsulates lookup-by-id plus hex serialization and reuses the existingToStatusflow andbadarg!("Missing key package")semantics. The only thing to double‑check is that the DB layer guaranteesget_public_key_package_by_id(LEGACY_MULTISIG_ID)is populated whenever DKG completes (e.g., viaset_pubkey_packageand/ormigrate_legacy_key_package), so legacy flows still see the aggregated key via the new helper.Also applies to: 676-685
2657-2677: New test_get_public_key_by_id_success accurately exercises the happy pathThe test seeds a pubkey package under a specific
multisig_idand verifies both the id echo and the hex‑encoded key match the stored package, which is exactly what this endpoint promises.bin/btc-server/src/rpc/btc_server.rs (1)
159-171: Server-side GetPublicKeyById wiring is consistent with existing RPCsThe new messages, trait method, and
/btc_server.BtcServer/GetPublicKeyByIdroute follow the established tonic server patterns and match the proto/client definitions; no issues spotted.Also applies to: 393-399, 809-854
Issue being fixed or feature implemented
What was done?
How Has This Been Tested?
Breaking Changes
Checklist
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.