Repository navigation
fix(registration): require the new owner's consent for a node-owner swap - #78
Open
faizsarwar wants to merge 3 commits into
Open
faizsarwar wants to merge 3 commits into
faizsarwar wants to merge 3 commits into
Conversation
…adjacent) swap_node_owner moved a node onto any account with only the current owner's signature, letting an owner park a node on a victim that never consented and blocking that victim from ever registering its own node (OwnerAlreadyRegistered), at no cost. Replace it with a consenting two-step flow: - offer_node_owner (current owner proposes, stored with an expiry) - accept_node_owner (proposed owner consents; banned / already-registered re-checked at accept time) - cancel_node_owner_offer (current owner withdraws) swap_node_owner is now root-only for operator recovery, sharing the core transfer via do_swap_node_owner. Offers expire after OwnerSwapOfferExpiry (7 days on mainnet).
accept_node_owner transferred the node from whoever currently owned it, but the pending offer only recorded the proposed new owner. If ownership changed between offer and accept -- an operator root swap, or a deregister followed by a fresh registration of the same node id -- a stale offer could still move the node away from a current owner who never offered it, defeating the consent the two-step flow exists for. Record the offering owner in PendingOwnerSwap and, at accept time, require the node to still be owned by that account; otherwise reject with OwnerSwapOfferStale and drop the stale entry.
…s or goes PendingOwnerSwap was only cleared on accept/cancel, so an offer could outlive the state it referenced: a node that was deregistered, garbage- collected, or root-swapped to another owner left a stale offer in storage (a leak, and the window the previous commit now rejects at accept time). Clear the offer at every point the node leaves its current owner: do_swap_node_owner (covers the root path and accept), the do_unregister_main_node teardown, and the on_initialize GC that prunes conflicting registrations. accept_node_owner no longer removes the entry itself -- do_swap_node_owner does it on success.
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
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 #69.
Problem
swap_node_owner(node_id, new_owner)(call 11) moved a node ontonew_ownerwithonly the current owner's signature — the new owner never consented. An owner
could call
swap_node_owner(node_id, victim)against any account with no node ofits own: the swap succeeds,
victimnow owns a node it never asked for, and fromthen on
victimcan't register its own node (every registration path fails withOwnerAlreadyRegistered).victimalso becomes a registered family for Arion'sis_registered_family. Griefing / denial-of-registration against any node-lessaccount, at no cost (
Pays::No), with no funds moved.Fix
Consenting two-step transfer, per the issue's proposed design:
offer_node_owner(node_id, new_owner)— signed by the current owner. Verifiesownership, pre-checks the target isn't banned / already registered, and stores
PendingOwnerSwap[node_id] = (new_owner, expiry).accept_node_owner(node_id)— signed by the proposed new owner. This is whereconsent happens. Re-checks
AccountBannedandOwnerAlreadyRegisteredat accepttime, rejects and cleans up expired offers, then performs the transfer.
cancel_node_owner_offer(node_id)— current owner withdraws a pending offer.swap_node_owneris now root-only, kept as an operator-recovery escape hatch.The core transfer is extracted into a private
do_swap_node_ownerso the root pathand the accept path are identical;
NodeOwnerSwappedstill fires on the actualtransfer either way.
Details
PendingOwnerSwap: node_id -> (new_owner, expiry_block)(additive —no migration needed).
OwnerSwapOfferExpiry, set to 7 days on mainnet; offerspast expiry are rejected and removed on accept.
NodeOwnerSwapOffered/NodeOwnerSwapOfferCancelled; new errorsNoPendingOwnerSwap/NotPendingNewOwner/OwnerSwapOfferExpired.swap_node_owner.Testing
cargo check -p pallet-registrationand-p hippius-mainnet-runtime: clean.Notes / for review
simpler and needs no nonce map.
OwnerSwapOfferExpiryconstant if you want a different window.swap_node_owneras root-only rather than removing it; drop it entirely ifyou'd prefer no single-signature path at all.
mock.rs/tests.rsare still the unmodifiedSubstrate template (
TemplateModule), with no workingConfig for Test. Wiring areal mock is out of scope here; happy to do it as a follow-up.