-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Identity Deposits Relay to Parachain Migration #1814
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
20fa029
add migration extrinsics to identity
joepetrowski 7becd9e
add to runtimes
joepetrowski fd39b82
adjust trait
joepetrowski 24b9d0d
Add OnReapIdentity implementation for Relay Chain
joepetrowski 96b2add
add license
joepetrowski 54d15a1
Merge branch 'master' into joe-identity-deposit-migration
joepetrowski f9ac75e
add ability to lock and unlock pallet
joepetrowski 4f45cc8
address most of review comments
joepetrowski 64acbb9
Merge branch 'joe-identity-deposit-migration' of https://github.com/p…
joepetrowski 0b3708e
fix alliance test config
joepetrowski 7ae9df0
benchmark reap_identity properly
joepetrowski b517c91
put deposit info into separate function
joepetrowski f6e8220
merge master
joepetrowski c4b45d7
update benchmarks to v2
joepetrowski cff4f4c
Merge branch 'master' into joe-identity-deposit-migration
joepetrowski 776910c
test that correct functions get locked
joepetrowski c2eb330
Merge remote-tracking branch 'origin' into joe-identity-deposit-migra…
joepetrowski 88a9923
no need to filter with pallet lock
joepetrowski 67de971
Merge branch 'master' into joe-identity-deposit-migration
joepetrowski a46e4ef
Merge branch 'master' into joe-identity-deposit-migration
joepetrowski 390ce01
fix compile errors on merge
joepetrowski 9da0726
add poke call encoding to handler impl
joepetrowski 255893d
don't need RuntimeDebug
joepetrowski 298931a
Reduce Impact on Identity Pallet in Migration (#2088)
joepetrowski cd08c4f
Merge branch 'master' into joe-identity-deposit-migration
joepetrowski 1f03941
merge master
joepetrowski 8e70450
actually merge master
joepetrowski 4aaa862
update identity pallet
joepetrowski 70f708b
migrator updates
joepetrowski e56874c
Merge branch 'master' into joe-identity-deposit-migration
joepetrowski 180352d
reap benchmark
joepetrowski 9bf6499
remove migration benchmarks from pallet_identity
joepetrowski 48a33d6
add to define_benchmarks
joepetrowski 750c440
fix runtime errors
joepetrowski 11e2999
Merge branch 'master' into joe-identity-deposit-migration
joepetrowski 0030969
remove pallet lock leftovers
joepetrowski ed0d8e9
disable calls to identity (again)
joepetrowski cb7bda0
fix benchmark test suite
joepetrowski 76258be
make unused imports happy
joepetrowski ace6f41
correct and clarify some docs
joepetrowski de3e4e8
nits
joepetrowski be38015
add westend config
joepetrowski 1c670b7
fmt
joepetrowski 836f824
set deposits for parachains
joepetrowski d698705
replace accidentally deleted docs
joepetrowski ea5d6a3
use benchmarked weight
joepetrowski f5df158
Merge remote-tracking branch 'origin' into joe-identity-deposit-migra…
joepetrowski bf42286
new xcm errors
joepetrowski 73426e7
apply basti review
joepetrowski f18914f
Merge branch 'master' into joe-identity-deposit-migration
joepetrowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| // Copyright (C) Parity Technologies (UK) Ltd. | ||
| // This file is part of Polkadot. | ||
|
|
||
| // Polkadot is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
|
|
||
| // Polkadot is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
|
|
||
| // You should have received a copy of the GNU General Public License | ||
| // along with Polkadot. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| use crate::xcm_config; | ||
| use frame_support::pallet_prelude::DispatchResult; | ||
| use frame_system::RawOrigin; | ||
| use pallet_identity::OnReapIdentity; | ||
| use primitives::Balance; | ||
| use rococo_runtime_constants::currency::*; | ||
| use sp_std::{marker::PhantomData, prelude::*}; | ||
| use xcm::{latest::prelude::*, /* v2::OriginKind, */ VersionedMultiLocation, VersionedXcm}; | ||
| use xcm_executor::traits::TransactAsset; | ||
|
|
||
| /// Type that implements `OnReapIdentity` that will send the deposit needed to store the same | ||
| /// information on a parachain, sends the deposit there, and then updates it. | ||
| pub struct ToParachainIdentityReaper<T>(PhantomData<T>); | ||
| impl<AccountId, T> OnReapIdentity<AccountId> for ToParachainIdentityReaper<T> | ||
| where | ||
| T: frame_system::Config + pallet_xcm::Config, | ||
| AccountId: Into<[u8; 32]> + Clone, | ||
| { | ||
| fn on_reap_identity(who: &AccountId, fields: u32, subs: u32) -> DispatchResult { | ||
| // calculate deposit needed on parachains | ||
| // assume `relay_deposit / 100 + ED + buffer` | ||
| // buffer to cover tx fees on para, maybe ED | ||
| let para_basic_deposit = 1000 * CENTS / 100; | ||
| let para_field_deposit = 250 * CENTS / 100; | ||
| let para_sub_account_deposit = 200 * CENTS / 100; | ||
| let para_existential_deposit = EXISTENTIAL_DEPOSIT / 10; | ||
| let id_deposit = | ||
| para_basic_deposit.saturating_add(para_field_deposit.saturating_mul(fields as Balance)); | ||
|
|
||
| let subs_deposit = para_sub_account_deposit.saturating_mul(subs as Balance); | ||
|
|
||
| let total_to_send = id_deposit | ||
| .saturating_add(subs_deposit) | ||
| .saturating_add(para_existential_deposit.saturating_mul(2)); | ||
joepetrowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // define asset / destination from relay perspective | ||
| let roc: MultiAssets = | ||
| vec![MultiAsset { id: Concrete(Here.into_location()), fun: Fungible(total_to_send) }] | ||
| .into(); | ||
joepetrowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // todo: people chain para id | ||
| let destination: MultiLocation = MultiLocation::new(0, Parachain(1000)); | ||
|
|
||
| // Do `check_out` accounting since the XCM Executor's `InitiateTeleport` doesn't support | ||
| // unpaid teleports. | ||
|
|
||
| // check out | ||
| xcm_config::LocalAssetTransactor::can_check_out( | ||
| &destination, | ||
| &roc.inner().first().unwrap(), // <- safe unwrap since we just set `roc`. | ||
joepetrowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // not used in AssetTransactor | ||
| &XcmContext { origin: None, message_id: [0; 32], topic: None }, | ||
| ) | ||
| .map_err(|_| pallet_xcm::Error::<T>::InvalidAsset)?; | ||
| xcm_config::LocalAssetTransactor::check_out( | ||
| &destination, | ||
| &roc.inner().first().unwrap(), // <- safe unwrap since we just set `roc`. | ||
joepetrowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // not used in AssetTransactor | ||
| &XcmContext { origin: None, message_id: [0; 32], topic: None }, | ||
| ); | ||
|
|
||
| // reanchor | ||
| let roc_reanchored: MultiAssets = vec![MultiAsset { | ||
| id: Concrete(MultiLocation::new(1, Here)), | ||
| fun: Fungible(total_to_send), | ||
| }] | ||
| .into(); | ||
|
|
||
| // Actual program to execute on People Chain. | ||
| let program: Xcm<()> = Xcm(vec![ | ||
| // Unpaid as this is constructed by the system, once per user. The user shouldn't have | ||
| // their balance reduced by teleport fees for the favor of migrating. | ||
| UnpaidExecution { weight_limit: Unlimited, check_origin: None }, | ||
| // Receive the asset into holding. | ||
| ReceiveTeleportedAsset(roc_reanchored), | ||
| // Deposit into the user's account. | ||
| DepositAsset { | ||
| assets: Wild(AllCounted(1)), | ||
| beneficiary: Junction::AccountId32 { network: None, id: who.clone().into() } | ||
| .into_location() | ||
| .into(), | ||
| }, | ||
| // // Poke the deposit to reserve the appropriate amount on the parachain. | ||
| // Transact { | ||
| // origin_kind: OriginKind::Superuser, | ||
| // require_weight_at_most: Weight {ref_time: 2_000_000_000, proof_size: 16_384}, | ||
| // // Need People Chain runtime to encode call. | ||
| // call: DoubleEncoded { encoded: /* pallet_identity::poke_deposit(who) */ }, | ||
| // }, | ||
| ]); | ||
|
|
||
| // send | ||
| let _ = <pallet_xcm::Pallet<T>>::send( | ||
| RawOrigin::Root.into(), | ||
| Box::new(VersionedMultiLocation::V3(destination)), | ||
| Box::new(VersionedXcm::V3(program)), | ||
| )?; | ||
| Ok(()) | ||
| } | ||
| } | ||
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.