feat: refactor MPC/TSS wallet gen to use SDK callback - #260
Conversation
|
@claude review |
|
Claude finished @danielpeng1's task —— View job Code Review for MPC/TSS Wallet Generation RefactoringReview Checklist:
Overall Assessment: STRONG APPROVE ✅This is an excellent refactoring that significantly improves the codebase architecture by consolidating wallet generation logic and leveraging the SDK's standardized callback pattern. The implementation is well-structured, thoroughly tested, and follows best practices. 🏆 StrengthsArchitecture Improvements
Code Quality
🧪 Test Coverage ExcellenceThe test suite is comprehensive and well-structured:
📋 Detailed Technical ReviewECDSA MPCv2 Implementation (
|
pranavjain97
left a comment
There was a problem hiding this comment.
lgtm overall, nice work!
|
@claude review |
|
Claude finished @danielpeng1's task —— View job Code Review for MPC/TSS Wallet Generation RefactoringReview Progress:
Overall Assessment: STRONG APPROVE ✅This is an excellent refactoring that significantly improves the codebase architecture by consolidating wallet generation logic and leveraging the SDK's standardized callback pattern. The implementation is well-structured, thoroughly tested, and follows best practices. 🏆 StrengthsArchitecture Improvements
Code Quality
🧪 Test Coverage ExcellenceThe test suite is comprehensive and well-structured:
📋 Detailed Technical ReviewECDSA MPCv2 Implementation (
|
|
|
||
| const bitgo = req.bitgo; | ||
| const baseCoin = await coinFactory.getCoin(req.decoded.coin, bitgo); | ||
| const baseCoin = await coinFactory.getCoin(req.params.coin, bitgo); |
There was a problem hiding this comment.
why this change? we should use decoded values.
| ): EcdsaMPCv2KeyGenCallbacks { | ||
| // Messages the SDK never sees: user/backup broadcasts and the p2p messages they exchange. | ||
| // round-2 counterparty messages are only used within round2Callback and are locals there. | ||
| let userRound1Broadcast: DklsTypes.AuthBroadcastMessage; |
There was a problem hiding this comment.
what happens if the SDK retries this callback? the round-1 state stored in the closure would get overwritten.
There was a problem hiding this comment.
there's no retry in the sdk, createKeychainsWithExternalSigner just initializes the callback once
https://github.com/BitGo/BitGoJS/blob/40e021dfc0e8d9890f32e6a3a222d52642ba4793/modules/sdk-core/src/bitgo/utils/tss/ecdsa/ecdsaMPCv2.ts#L678
should we add a guard at the top of intitializeCallback to detect that anyways?
| }; | ||
| }, | ||
|
|
||
| finalizeCallback: async ({ |
There was a problem hiding this comment.
backup finalize reads counterpartyKeyShare produced by user finalize, so it depends on user running first. is that ordering guaranteed by the SDK contract?
There was a problem hiding this comment.
should be guaranteed by the sdk, it does run sequentially in that order
Replaces hand-rolled ECDSA MPCv2 and EdDSA MPCv1 DKG orchestrators with the SDK's
generateWalletWithExternalSignercallback pattern, consolidating onchain and TSS wallet generation into a singlehandleGenerateWallethandler.createEcdsaMPCv2KeyGenCallbacksandcreateEddsaKeyGenCallbacksfactories inwalletGenerationCallbacks.ts; each drives both the user and backup AWM. User↔backup messages are carried in the factory closure (which is the same pattern as signing). ECDSA AWM rounds 2+3 are folded intoround2Callbackbecause both their inputs arrive with BitGo's round 1 response.handleGenerateMpcWallet+orchestrateEcdsaKeyGen+orchestrateEddsaKeyGenwith a singlekeyGenCallbacks()dispatch keyed onbaseCoin.getMPCAlgorithm().walletCreationUtils.ts(unused now but we can always get it back if needed).@bitgo-beta/sdk-coreto8.2.1-beta.1928and@bitgo-beta/sdk-apito1.10.1-beta.1923, to useEcdsaMPCv2KeyGenCallbacks,EddsaKeyGenCallbacks, andgenerateWalletWithExternalSigner.Ticket: WCN-683