-
Notifications
You must be signed in to change notification settings - Fork 261
Rework coldkey swap #2251
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
Open
l0r1s
wants to merge
57
commits into
devnet-ready
Choose a base branch
from
rework-coldkey-swap
base: devnet-ready
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Rework coldkey swap #2251
Conversation
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
59d349c to
2f1ad59
Compare
a342a4e to
4e74495
Compare
camfairchild
suggested changes
Dec 11, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #2230
Summary
This PR refactors the coldkey swap mechanism from a scheduler-based system to an announcement-based system with a configurable delay period. This change improves security, simplifies the codebase, and provides better transparency for coldkey swap operations.
Key Changes
1. New Announcement-Based Flow
announce_coldkey_swap: Users must first announce their intention to swap coldkeys by providing a hash of the new coldkeyswap_coldkey_announced: After the announcement delay period, users can execute the swap by providing the actual new coldkey2. Configuration Changes
InitialColdkeySwapScheduleDuration→InitialColdkeySwapAnnouncementDelayInitialColdkeySwapRescheduleDuration(no longer needed)ColdkeySwapScheduledmap →ColdkeySwapAnnouncementsmap3. Refactored Core Swap Logic
do_swap_coldkey: Consolidated swap logic with clearer separation of concernstransfer_subnet_ownershiptransfer_auto_stake_destinationtransfer_coldkey_staketransfer_staking_hotkeystransfer_hotkeys_ownership4. Updated
swap_coldkeyExtrinsicDispatchResultinstead ofDispatchResultWithPostInfo5. Admin Utilities
sudo_set_coldkey_swap_schedule_duration(call index 54)sudo_set_coldkey_swap_announcement_delay(call index 84)remove_coldkey_swap_announcement(call index 127) - root-only removal of announcements6. Events
ColdkeySwapScheduledColdkeySwapAnnounced- emitted when an announcement is madeColdkeySwapAnnouncementRemoved- emitted when an announcement is removedColdkeySwapAnnouncementDelaySet(renamed fromColdkeySwapScheduleDurationSet)7. Error Handling
ColdkeyIsInArbitration,SwapAlreadyScheduled,FailedToScheduleColdkeySwapAnnouncementNotFoundColdkeySwapTooEarlyColdkeySwapReannouncedTooEarlyAnnouncedColdkeyHashDoesNotMatchDeprecated(for the oldschedule_swap_coldkeycall)8. Transaction Extension
CustomTransactionError::ColdkeyInSwapSchedule→ColdkeySwapAnnounced9. Migration
migrate_coldkey_swap_scheduled_to_announcementsto migrate existing scheduled swaps to the new announcement systemscheduled_time - delayso swaps can execute at the originally scheduled timeBenefits
swap_coldkeycallBreaking Changes
schedule_swap_coldkeyextrinsic is deprecated and will return an errorMigration Path
For users with existing scheduled coldkey swaps:
swap_coldkey_announced