Provide instructions allowing remote chains to lock/unlock local assets. This allows for the possibility of separation of system-parachains such as conviction-voting and staking from token-hosting parachains (e.g. Statemint).
The basic idea is that VotingChain (i.e. the system-parachain hosting conviction-voting) would have a remote-locks pallet. This allows locks of funds sitting on Statemint which are initiated by VotingChain to be tracked and queried synchronously. An API will be built into Conviction Voting pallet allowing for alternative means of the querying and locking of funds, allowing for funds held and locked remotely to be known and utilised.
Basic API. This works by the user issuing a lock_asset(user, dots, VotingChain) on Statemint, which then locks dots such that they're only unlockable by VotingChain. Statemint automatically sends a NoteAssetLocked(dots, user) to VotingChain, which checks that Statemint is a teleport target (it is) and registers the lock in a map in PalletXcm. The user then casts their vote on VotingChain, which is configured to check the remote locks in PalletXcm and in doing so determines that the appropriate funds were locked and the votes should be put in place. It registers with the PalletXcm the amount of the lock which is now in use so that the user cannot request that PalletXcm unlock more funds than it should.
At some point later, the user may have the Conviction-Voting pallet unlock the funds which were needed for voting according to its own logic. Instead of unlocking the balance directly, it registers with PalletXcm that (a portion of) the remote locked funds are no longer needed. This allows the user to execute a second dispatchable in PalletXcm unlock_asset with the newly unused locked funds to have VotingChain send UnlockAsset back to Statemint which unlocks the DOT.
- New dispatchable in PalletXcm
lock_asset(origin, asset: MultiAsset, unlocker: MultiLocation): Locks asset owned by origin with ID (b"xcm_lock", unlocker).encode(). Sends a NoteAssetLocked message to unlocker with asset and origin (converted to a MultiLocation). NOTE: This is a bit "dangerous" since of unlocker is not a chain which recognises the NodeAssetLocked message and allows for the sending of an UnlockAsset, then the assets may not be unlockable without governance intervention.
- New dispatchable in PalletXcm
unlock_asset(origin, asset: MultiAsset, locker: MultiLocation): Sends an UnlockAsset instruction to locker for asset IFF there is a registered remote lock for asset and it is currently unused.
NoteAssetLocked(asset, owner): Notes that owner locked asset guaranteeing that it will be held under custody at least until a corresponding call from UnlockAsset is received.
UnlockAsset(asset, owner): Unlocks asset owned by owner with ID (b"xcm_lock", origin).encode().
Provide instructions allowing remote chains to lock/unlock local assets. This allows for the possibility of separation of system-parachains such as conviction-voting and staking from token-hosting parachains (e.g. Statemint).
The basic idea is that VotingChain (i.e. the system-parachain hosting conviction-voting) would have a remote-locks pallet. This allows locks of funds sitting on
Statemintwhich are initiated by VotingChain to be tracked and queried synchronously. An API will be built into Conviction Voting pallet allowing for alternative means of the querying and locking of funds, allowing for funds held and locked remotely to be known and utilised.Basic API. This works by the user issuing a
lock_asset(user, dots, VotingChain)on Statemint, which then locksdotssuch that they're only unlockable by VotingChain. Statemint automatically sends aNoteAssetLocked(dots, user)to VotingChain, which checks that Statemint is a teleport target (it is) and registers the lock in a map inPalletXcm. The user then casts their vote on VotingChain, which is configured to check the remote locks inPalletXcmand in doing so determines that the appropriate funds were locked and the votes should be put in place. It registers with the PalletXcm the amount of the lock which is now in use so that the user cannot request that PalletXcm unlock more funds than it should.At some point later, the user may have the Conviction-Voting pallet unlock the funds which were needed for voting according to its own logic. Instead of unlocking the balance directly, it registers with PalletXcm that (a portion of) the remote locked funds are no longer needed. This allows the user to execute a second dispatchable in PalletXcm
unlock_assetwith the newly unused locked funds to have VotingChain sendUnlockAssetback to Statemint which unlocks the DOT.lock_asset(origin, asset: MultiAsset, unlocker: MultiLocation): Locksassetowned byoriginwith ID(b"xcm_lock", unlocker).encode(). Sends aNoteAssetLockedmessage tounlockerwithassetandorigin(converted to aMultiLocation). NOTE: This is a bit "dangerous" since ofunlockeris not a chain which recognises theNodeAssetLockedmessage and allows for the sending of anUnlockAsset, then the assets may not be unlockable without governance intervention.unlock_asset(origin, asset: MultiAsset, locker: MultiLocation): Sends anUnlockAssetinstruction tolockerfor asset IFF there is a registered remote lock forassetand it is currently unused.NoteAssetLocked(asset, owner): Notes thatownerlockedassetguaranteeing that it will be held under custody at least until a corresponding call fromUnlockAssetis received.UnlockAsset(asset, owner): Unlocksassetowned byownerwith ID(b"xcm_lock", origin).encode().