You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR implements filtering of safe key ceremonies based on enabled root slots returned from the WP initialization. Overall, this is a well-implemented feature with good backward compatibility and thorough testing. Here's my detailed review:
✅ Strengths
Excellent Backward Compatibility: The implementation gracefully handles older WP versions by falling back to all 4 slots when enabledRootSlots is absent (enabledRootSlots ?? allSlots)
Type Safety: Good use of TypeScript with proper type definitions and leveraging existing InitializeSafeResponse['enabledRootSlots'] type
Comprehensive Test Coverage: Tests cover all the key scenarios:
Decoding enabledRootSlots from server response
Subset filtering behavior
Threading through generateSafe chain
Error handling remains intact
Clean Architecture: The change maintains the existing ceremony structure while adding filtering capability without breaking existing patterns
Good Error Handling: Preserves existing error handling and safe archival on ceremony failures
🔍 Code Quality Observations
Interface Changes (iSafes.ts:28-35)
✅ Good documentation explaining the Flipt-based server decision model
✅ Proper optional field handling with enabledRootSlots?: InitializeSafeResponse['enabledRootSlots']
✅ Updated comments to reflect "enabled slots" vs hardcoded "4 slots"
Implementation (safes.ts:132-149)
✅ Elegant filtering logic using Set for O(1) lookups
✅ Maintains slot ordering (scheme-based) while filtering
✅ Clean ceremony mapping using Record type for better maintainability
✅ Parallel execution preserved with Promise.allSettled(slots.map(...))
Threading Logic (safes.ts:97-105)
✅ Proper data flow from initializeSafe → createSafeKeys → finalizeSafe
✅ enabledRootSlots correctly passed through the chain
📝 Minor Suggestions
Type Improvement: Consider extracting the ceremonies record type for reusability:
Code Comment: The comment on line 137 could be more explicit about the Set optimization:
// Use Set for O(1) slot filtering - older WP (pre-gating) uses all 4 slotsconstenabled=newSet(enabledRootSlots??allSlots);
🧪 Testing Assessment
The test additions are comprehensive and well-structured:
Decoding Test (safes.ts:45-60): Verifies proper parsing of enabledRootSlots
Filtering Test (safes.ts:185-203): Confirms only enabled ceremonies run and unused coins aren't instantiated
Integration Test (safes.ts:277-300): Validates end-to-end threading through generateSafe
✅ Security & Performance
No Security Issues: The filtering is based on server-provided data with proper validation
Performance Gain: Running fewer ceremonies when slots are filtered reduces overhead
Resource Optimization: Unused coin instances aren't created (keychainsByCoin.should.not.have.property('tbtc'))
📋 Final Assessment
This is a solid implementation that adds valuable functionality while maintaining backward compatibility and code quality. The PR achieves its goal of filtering safe key ceremonies based on enabled root slots with minimal risk and good performance characteristics.
Recommendation: ✅ Approve
The code follows BitGoJS patterns, includes comprehensive tests, and handles edge cases appropriately. The feature will allow more efficient safe creation by running only necessary ceremonies.
Review completed for PR #9534 on branch WCN-1658/filter-enabled-root-slots
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gate SDK safe root-key ceremonies on the slots WP returns at initialize.
enabledRootSlotsfrominitializeSafeintocreateSafeKeysandgenerateSafeTests:
enabledRootSlotson initializeenabledRootSlotsskips the other ceremoniesgenerateSafeforwardsenabledRootSlotsintocreateSafeKeysTicket: WCN-1658