mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 17:31:03 +00:00
[Feature] XCM-Emulator (#2447)
* [Feature] XCM-Emulator * ".git/.scripts/commands/fmt/fmt.sh" * rename * readme * more rename * rename directory * implement AssetTransactor * Update xcm/xcm-emulator/README.md Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com> * address review comments (#2502) * Update xcm/xcm-emulator/example/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update xcm/xcm-emulator/README.md * Use 2d weights. * Point out nearer the failure why it should fail * Move test-runtime to under examples * Walk through how to use it * proof needs to be non-zero * Apply suggestions from code review * Update xcm/xcm-emulator/README.md Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Improve xcm emulator (#2593) * folder restructutre * common created * make macros repetitions * messenger traits for relay and para * default Messenger impls * messenger traits refactor * declared two networks * init network approach works * queues use HashMap but relay block number * init and reset refactor * messengers trait name changed * relay block number suboptimal * fix reset hashmap keys * genesis added * test ext added for parachains * genesis added relay chains * genesis to storage * new_ext replaced by on_init * new relay block number approach * ext_wrapper added * added types to Parachain trait * relay chain with types * restructure * para_ids working * replace para_id getter * replace para_id getter 2 * tests restructure + common variables * added sovereign and balances helpers * more helpers + tess pass * expected events macro added * added events trait method * expect_events macro improve * expect_events macro done * network traits added * reserve_transfer test added * para & relay macro inputs redefined * added collectives & BH paras * test restructure * statemine removed * nitpick * rename test folder + events logs * clean * weight threshold helper * update readme * remove cumulus-test-service dependancy * fmt * comment docs * update e2e tests to xcm v3 * clippy + runtime-benchmark + clean docs --------- Co-authored-by: command-bot <> Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com> Co-authored-by: Squirrel <gilescope@gmail.com> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: Ignacio Palacios <ignacio.palacios.santos@gmail.com>
This commit is contained in:
@@ -0,0 +1,154 @@
|
||||
---
|
||||
settings:
|
||||
chains:
|
||||
relay_chain: &relay_chain
|
||||
wsPort: 9900
|
||||
assets_parachain: &assets_parachain
|
||||
wsPort: 9910
|
||||
paraId: &ap_id 1000
|
||||
penpal_parachain: &penpal_parachain
|
||||
wsPort: 9920
|
||||
paraId: &pp_id 2000
|
||||
variables:
|
||||
common:
|
||||
xcm_version: &xcm_version '3'
|
||||
require_weight_at_most: &weight_at_most {refTime: 1000000000, proofSize: 200000}
|
||||
chains:
|
||||
relay_chain:
|
||||
signer: &rc_signer //Alice
|
||||
assets_parachain_destination: &ap_dest { v3: { 0, interior: { x1: { parachain: *ap_id }}}}
|
||||
penpal_parachain:
|
||||
signer: &pp_signer //Alice
|
||||
decodedCalls:
|
||||
ap_force_xcm_version:
|
||||
chain: *assets_parachain
|
||||
pallet: polkadotXcm
|
||||
call: forceXcmVersion
|
||||
args: [
|
||||
{ # location
|
||||
parents: 1,
|
||||
interior: Here
|
||||
},
|
||||
*xcm_version # xcmVersion
|
||||
]
|
||||
|
||||
tests:
|
||||
- name: Initialize Chains
|
||||
its:
|
||||
- name: XCM supported versions between chains
|
||||
actions:
|
||||
- extrinsics: # Relay Chain sets supported version for Asset Parachain
|
||||
- chain: *relay_chain
|
||||
sudo: true
|
||||
signer: *rc_signer
|
||||
pallet: xcmPallet
|
||||
call: forceXcmVersion
|
||||
args: [
|
||||
{ # location
|
||||
parents: 0,
|
||||
interior: {
|
||||
X1: {
|
||||
Parachain: *ap_id
|
||||
}
|
||||
}
|
||||
},
|
||||
*xcm_version # xcmVersion
|
||||
]
|
||||
events:
|
||||
- name: sudo.Sudid
|
||||
attributes:
|
||||
- type: Result<Null, SpRuntimeDispatchError>
|
||||
value: Ok
|
||||
- name: xcmPallet.SupportedVersionChanged
|
||||
attributes:
|
||||
- type: u32
|
||||
value: *xcm_version
|
||||
- extrinsics: # Relay Chain sets supported version for Penpal Parachain
|
||||
- chain: *relay_chain
|
||||
sudo: true
|
||||
signer: *rc_signer
|
||||
pallet: xcmPallet
|
||||
call: forceXcmVersion
|
||||
args: [
|
||||
{ # location
|
||||
parents: 0,
|
||||
interior: {
|
||||
X1: {
|
||||
Parachain: *pp_id
|
||||
}
|
||||
}
|
||||
},
|
||||
*xcm_version # xcmVersion
|
||||
]
|
||||
events:
|
||||
- name: sudo.Sudid
|
||||
attributes:
|
||||
- type: Result<Null, SpRuntimeDispatchError>
|
||||
value: Ok
|
||||
- name: xcmPallet.SupportedVersionChanged
|
||||
attributes:
|
||||
- type: u32
|
||||
value: *xcm_version
|
||||
- extrinsics: # Asset Parachain sets supported version for Relay Chain through it
|
||||
- chain: *relay_chain
|
||||
signer: *rc_signer
|
||||
sudo: true
|
||||
pallet: xcmPallet
|
||||
call: send
|
||||
args: [
|
||||
*ap_dest, # destination
|
||||
{
|
||||
v3: [ #message
|
||||
{
|
||||
UnpaidExecution: {
|
||||
weightLimit: {
|
||||
limited: {
|
||||
refTime: 2200000000,
|
||||
proofSize: 200000
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
Transact: {
|
||||
originKind: Superuser,
|
||||
requireWeightAtMost: *weight_at_most,
|
||||
call: $ap_force_xcm_version
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
events:
|
||||
- name: sudo.Sudid
|
||||
attributes:
|
||||
- type: Result<Null, SpRuntimeDispatchError>
|
||||
value: Ok
|
||||
- name: xcmPallet.Sent
|
||||
- name: polkadotXcm.SupportedVersionChanged
|
||||
chain: *assets_parachain
|
||||
attributes:
|
||||
- type: u32
|
||||
value: *xcm_version
|
||||
- extrinsics: # Penpal Parachain sets supported version for Relay Chain
|
||||
- chain: *penpal_parachain
|
||||
signer: *pp_signer
|
||||
sudo: true
|
||||
pallet: polkadotXcm
|
||||
call: forceXcmVersion
|
||||
args: [
|
||||
{ # location
|
||||
parents: 1,
|
||||
interior: Here
|
||||
},
|
||||
*xcm_version # xcmVersion
|
||||
]
|
||||
events:
|
||||
- name: sudo.Sudid
|
||||
attributes:
|
||||
- type: Result<Null, SpRuntimeDispatchError>
|
||||
value: Ok
|
||||
- name: polkadotXcm.SupportedVersionChanged
|
||||
attributes:
|
||||
- type: u32
|
||||
value: *xcm_version
|
||||
@@ -0,0 +1,267 @@
|
||||
---
|
||||
settings:
|
||||
chains:
|
||||
relay_chain: &relay_chain
|
||||
wsPort: 9900
|
||||
assets_parachain: &assets_parachain
|
||||
wsPort: 9910
|
||||
paraId: &ap_id 1000
|
||||
variables:
|
||||
relay_chain:
|
||||
signer: &rc_signer //Alice
|
||||
wallet: &rc_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F
|
||||
assets_parachain_destination: &ap_dest { v3: { parents: 0, interior: { x1: { parachain: *ap_id }}}}
|
||||
assets_parachain_account: &ap_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'
|
||||
assets_parachain_beneficiary: &ap_benf {v3: { parents: 0, interior: { x1: { accountId32: { id: *ap_acc }}}}}
|
||||
ksm: &rc_ksm { concrete: { parents: 0, interior: { here: true }}}
|
||||
amount: &amount 1000000000000
|
||||
ksm_fungible: &rc_ksm_fungible { id: *rc_ksm, fun: { fungible: *amount }}
|
||||
require_weight_at_most: &rc_weight_at_most {refTime: 1000000000, proofSize: 200000}
|
||||
assets_parachain_account:
|
||||
wallet: &ap_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F
|
||||
asset_id: &asset_id 1
|
||||
asset_min_balance: &asset_ed 1000
|
||||
decodedCalls:
|
||||
force_create_asset:
|
||||
chain: *assets_parachain
|
||||
pallet: assets
|
||||
call: forceCreate
|
||||
args: [
|
||||
*asset_id,
|
||||
{ Id: *ap_wallet }, # owner
|
||||
true, # isSufficient
|
||||
*asset_ed # minBalance
|
||||
]
|
||||
|
||||
tests:
|
||||
- name: DMP
|
||||
its: []
|
||||
describes:
|
||||
- name: xcmPallet.limitedTeleportAssets
|
||||
before: &before_get_balances
|
||||
- name: Get the balances of the Relay Chain's sender & Assets Parachain's receiver
|
||||
actions:
|
||||
- queries:
|
||||
balance_rc_sender_before:
|
||||
chain: *relay_chain
|
||||
pallet: system
|
||||
call: account
|
||||
args: [ *rc_wallet ]
|
||||
balance_ap_receiver_before:
|
||||
chain: *assets_parachain
|
||||
pallet: system
|
||||
call: account
|
||||
args: [ *ap_wallet ]
|
||||
its:
|
||||
- name: Should teleport native assets from the Relay Chain to the Assets Parachain
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *relay_chain
|
||||
signer: *rc_signer
|
||||
pallet: xcmPallet
|
||||
call: limitedTeleportAssets
|
||||
args: [
|
||||
*ap_dest, # destination
|
||||
*ap_benf, # beneficiary
|
||||
{ v3: [ *rc_ksm_fungible ] },
|
||||
0, # feeAssetItem
|
||||
{ unlimited: true } # weightLimit
|
||||
]
|
||||
events:
|
||||
- name: xcmPallet.Attempted
|
||||
attributes:
|
||||
- type: XcmV3TraitsOutcome
|
||||
xcmOutcome: Complete
|
||||
- name: dmpQueue.ExecutedDownward
|
||||
chain: *assets_parachain
|
||||
attributes:
|
||||
- type: XcmV3TraitsOutcome
|
||||
xcmOutcome: Complete
|
||||
threshold: [10, 10]
|
||||
value: {"refTime":"162,379,000","proofSize":"0"}
|
||||
- queries:
|
||||
balance_rc_sender_after:
|
||||
chain: *relay_chain
|
||||
pallet: system
|
||||
call: account
|
||||
args: [ *rc_wallet ]
|
||||
balance_ap_receiver_after:
|
||||
chain: *assets_parachain
|
||||
pallet: system
|
||||
call: account
|
||||
args: [ *ap_wallet ]
|
||||
|
||||
- name: Should reduce the balance of the sender
|
||||
actions:
|
||||
- asserts:
|
||||
balanceDecreased:
|
||||
args: [
|
||||
{
|
||||
balances: {
|
||||
before: $balance_rc_sender_before,
|
||||
after: $balance_rc_sender_after,
|
||||
},
|
||||
amount: *amount
|
||||
}
|
||||
]
|
||||
|
||||
- name: Should increase the balance of the receiver
|
||||
actions:
|
||||
- asserts:
|
||||
balanceIncreased:
|
||||
args: [
|
||||
{
|
||||
balances: {
|
||||
before: $balance_ap_receiver_before,
|
||||
after: $balance_ap_receiver_after,
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
- name: xcmPallet.send | Superuser - Transact(assets.forceCreate)
|
||||
its:
|
||||
- name: Relay Chain Superuser account SHOULD be able to execute a XCM Transact instruction in the Assets Parachain
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *relay_chain
|
||||
signer: *rc_signer
|
||||
sudo: true
|
||||
pallet: xcmPallet
|
||||
call: send
|
||||
args: [
|
||||
*ap_dest, # destination
|
||||
{
|
||||
v3: [ #message
|
||||
{
|
||||
UnpaidExecution: {
|
||||
weightLimit: Unlimited
|
||||
}
|
||||
},
|
||||
{
|
||||
Transact: {
|
||||
originKind: Superuser,
|
||||
requireWeightAtMost: *rc_weight_at_most,
|
||||
call: $force_create_asset
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
events:
|
||||
- name: xcmPallet.Sent
|
||||
- name: dmpQueue.ExecutedDownward
|
||||
chain: *assets_parachain
|
||||
attributes:
|
||||
- type: XcmV3TraitsOutcome
|
||||
xcmOutcome: Complete
|
||||
threshold: [10, 10]
|
||||
value: {"refTime":"1,014,103,000","proofSize":"200,000"}
|
||||
- queries:
|
||||
forced_created_asset:
|
||||
chain: *assets_parachain
|
||||
pallet: assets
|
||||
call: asset
|
||||
args: [ *asset_id ]
|
||||
- asserts:
|
||||
isSome:
|
||||
args: [ $forced_created_asset ]
|
||||
|
||||
- name: xcmPallet.send | Native - Transact(assets.forceCreate)
|
||||
its:
|
||||
- name: Relay Chain Native account SHOULD NOT be able to execute a XCM Transact instruction in the Assets Parachain
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *relay_chain
|
||||
signer: *rc_signer
|
||||
pallet: xcmPallet
|
||||
call: send
|
||||
args: [
|
||||
*ap_dest, # destination
|
||||
{
|
||||
v3: [ #message
|
||||
{
|
||||
UnpaidExecution: {
|
||||
weightLimit: Unlimited
|
||||
}
|
||||
},
|
||||
{
|
||||
Transact: {
|
||||
originKind: Native,
|
||||
requireWeightAtMost: *rc_weight_at_most,
|
||||
call: $force_create_asset
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
events:
|
||||
- name: system.ExtrinsicFailed
|
||||
attributes:
|
||||
- type: SpRuntimeDispatchError
|
||||
value: BadOrigin
|
||||
|
||||
- name: xcmPallet.limitedReserveTransferAssets
|
||||
before: *before_get_balances
|
||||
its:
|
||||
- name: SHOULD NOT reserved transfer native assets from the Relay Chain to the Assets Parachain
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *relay_chain
|
||||
signer: *rc_signer
|
||||
pallet: xcmPallet
|
||||
call: limitedReserveTransferAssets
|
||||
args: [
|
||||
*ap_dest, # destination
|
||||
*ap_benf, # beneficiary
|
||||
{ v3: [ *rc_ksm_fungible ] }, # assets
|
||||
0, # feeAssetItem
|
||||
{ unlimited: true } # weightLimit
|
||||
]
|
||||
events:
|
||||
- name: xcmPallet.Attempted
|
||||
attributes:
|
||||
- type: XcmV3TraitsOutcome
|
||||
xcmOutcome: Complete
|
||||
threshold: [10, 10]
|
||||
value: {"refTime":"750,645,000","proofSize":"0"}
|
||||
- name: dmpQueue.ExecutedDownward
|
||||
chain: *assets_parachain
|
||||
attributes:
|
||||
- type: XcmV3TraitsOutcome
|
||||
xcmOutcome: Incomplete
|
||||
value: [{"refTime":"1,000,000,000","proofSize":"0"},"UntrustedReserveLocation"]
|
||||
- queries:
|
||||
balance_rc_sender_after:
|
||||
chain: *relay_chain
|
||||
pallet: system
|
||||
call: account
|
||||
args: [ *rc_wallet ]
|
||||
balance_ap_receiver_after:
|
||||
chain: *assets_parachain
|
||||
pallet: system
|
||||
call: account
|
||||
args: [ *ap_wallet ]
|
||||
|
||||
- name: Should reduce the balance of the sender
|
||||
actions:
|
||||
- asserts:
|
||||
balanceDecreased:
|
||||
args: [
|
||||
{
|
||||
balances: {
|
||||
before: $balance_rc_sender_before,
|
||||
after: $balance_rc_sender_after,
|
||||
},
|
||||
amount: *amount
|
||||
}
|
||||
]
|
||||
|
||||
- name: Should keep the balance of the receiver
|
||||
actions:
|
||||
- asserts:
|
||||
equal:
|
||||
args:
|
||||
[
|
||||
$balance_ap_receiver_before,
|
||||
$balance_ap_receiver_after
|
||||
]
|
||||
@@ -0,0 +1,206 @@
|
||||
---
|
||||
settings:
|
||||
chains:
|
||||
relay_chain: &relay_chain
|
||||
wsPort: 9900
|
||||
assets_parachain: &assets_parachain
|
||||
wsPort: 9910
|
||||
paraId: &ap_id 1000
|
||||
variables:
|
||||
common:
|
||||
amount: &amount 1000000000000
|
||||
require_weight_at_most: &weight_at_most {refTime: 1000000000, proofSize: 0}
|
||||
relay_chain:
|
||||
signer: &rc_signer //Alice
|
||||
wallet: &rc_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F #Alice
|
||||
assets_parachain_destination: &ap_dest { v3: { 0, interior: { x1: { parachain: *ap_id }}}}
|
||||
assets_parachain_account: &ap_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'
|
||||
assets_parachain_beneficiary: &ap_benf {v3: { parents: 0, interior: { x1: { accountId32: { id: *ap_acc }}}}}
|
||||
ksm: &rc_ksm { concrete: { 0, interior: { here: true }}}
|
||||
ksm_fungible: &rc_ksm_fungible { id: *rc_ksm, fun: { fungible: *amount }}
|
||||
assets_parachain_account:
|
||||
signer: &ap_signer //Alice
|
||||
wallet: &ap_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F
|
||||
relay_chain_destination: &rc_dest { v3: { parents: 1, interior: { here: true }}}
|
||||
assets_parachain_account: &rc_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' #Alice
|
||||
relay_chain_beneficiary: &rc_benf {v3: { parents: 0, interior: { x1: { accountId32: { id: *rc_acc }}}}}
|
||||
ksm: &ap_ksm { concrete: { parents: 1, interior: { here: true }}}
|
||||
ksm_fungible: &ap_ksm_fungible { id: *ap_ksm, fun: { fungible: *amount }}
|
||||
decodedCalls:
|
||||
system_remark:
|
||||
chain: *relay_chain
|
||||
pallet: system
|
||||
call: remark
|
||||
args: [ 0x0011 ]
|
||||
|
||||
tests:
|
||||
- name: UMP
|
||||
describes:
|
||||
- name: polkadotXcm.limitedTeleportAssets
|
||||
before:
|
||||
- name: DEPENDENCY | Do a 'limitedTeleportAssets' from the Relay Chain to the Assets Parachain to have funds to send them back
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *relay_chain
|
||||
signer: *rc_signer
|
||||
pallet: xcmPallet
|
||||
call: limitedTeleportAssets
|
||||
args: [
|
||||
*ap_dest, # destination
|
||||
*ap_benf, # beneficiary
|
||||
{ v3: [ *rc_ksm_fungible ] }, # assets
|
||||
0, # feeAssetItem
|
||||
{ unlimited: true } # weightLimit
|
||||
]
|
||||
events:
|
||||
- name: xcmPallet.Attempted
|
||||
attributes:
|
||||
- type: XcmV3TraitsOutcome
|
||||
xcmOutcome: Complete
|
||||
threshold: [10, 10]
|
||||
value: {"refTime":"761,173,000","proofSize":"0"}
|
||||
- name: dmpQueue.ExecutedDownward
|
||||
chain: *assets_parachain
|
||||
attributes:
|
||||
- type: XcmV3TraitsOutcome
|
||||
xcmOutcome: Complete
|
||||
threshold: [10, 10]
|
||||
value: {"refTime":"162,379,000","proofSize":"0"}
|
||||
|
||||
- name: Get the balances of the Assets Parachain's sender & Relay Chain's receiver
|
||||
actions:
|
||||
- queries:
|
||||
balance_ap_sender_before:
|
||||
chain: *assets_parachain
|
||||
pallet: system
|
||||
call: account
|
||||
args: [ *ap_wallet ]
|
||||
balance_rc_receiver_before:
|
||||
chain: *relay_chain
|
||||
pallet: system
|
||||
call: account
|
||||
args: [ *rc_wallet ]
|
||||
its:
|
||||
- name: Should teleport native assets back from Assets Parachain to the Relay Chain
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *assets_parachain
|
||||
signer: *ap_signer
|
||||
pallet: polkadotXcm
|
||||
call: limitedTeleportAssets
|
||||
args: [
|
||||
*rc_dest, # destination
|
||||
*rc_benf, # beneficiary
|
||||
{ v3: [ *ap_ksm_fungible ] }, # assets
|
||||
0, # feeAssetItem
|
||||
{ unlimited: true } # weightLimit
|
||||
]
|
||||
events:
|
||||
- name: polkadotXcm.Attempted
|
||||
attributes:
|
||||
- type: XcmV3TraitsOutcome
|
||||
xcmOutcome: Complete
|
||||
threshold: [10, 10]
|
||||
value: {"refTime":"539,494,000","proofSize":"7,133"}
|
||||
- name: ump.ExecutedUpward
|
||||
chain: *relay_chain
|
||||
attributes:
|
||||
- type: XcmV3TraitsOutcome
|
||||
xcmOutcome: Complete
|
||||
threshold: [10, 10]
|
||||
value: {"refTime":"298,716,000","proofSize":"0"}
|
||||
- queries:
|
||||
balance_ap_sender_after:
|
||||
chain: *assets_parachain
|
||||
pallet: system
|
||||
call: account
|
||||
args: [ *ap_wallet ]
|
||||
balance_rc_receiver_after:
|
||||
chain: *relay_chain
|
||||
pallet: system
|
||||
call: account
|
||||
args: [ *rc_wallet ]
|
||||
|
||||
- name: Should reduce the balance of the sender
|
||||
actions:
|
||||
- asserts:
|
||||
balanceDecreased:
|
||||
args: [
|
||||
{
|
||||
balances: {
|
||||
before: $balance_ap_sender_before,
|
||||
after: $balance_ap_sender_after,
|
||||
},
|
||||
amount: *amount
|
||||
}
|
||||
]
|
||||
|
||||
- name: Should increase the balance of the receiver
|
||||
actions:
|
||||
- asserts:
|
||||
balanceIncreased:
|
||||
args: [
|
||||
{
|
||||
balances: {
|
||||
before: $balance_rc_receiver_before,
|
||||
after: $balance_rc_receiver_after,
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
- name: polkadotXcm.send | Native - Transact(system.remark)
|
||||
its:
|
||||
- name: Assets Parachain SHOULD NOT be able to dispatch 'send' call
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *assets_parachain
|
||||
signer: *ap_signer
|
||||
pallet: polkadotXcm
|
||||
call: send
|
||||
args: [
|
||||
*rc_dest, # destination
|
||||
{
|
||||
v3: [ #message
|
||||
{
|
||||
UnpaidExecution: {
|
||||
weightLimit: Unlimited
|
||||
}
|
||||
},
|
||||
{
|
||||
Transact: {
|
||||
originKind: Native,
|
||||
requireWeightAtMost: *weight_at_most,
|
||||
call: $system_remark
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
events:
|
||||
- name: system.ExtrinsicFailed
|
||||
attributes:
|
||||
- type: SpRuntimeDispatchError
|
||||
value: BadOrigin
|
||||
|
||||
- name: polkadotXcm.limitedReserveTransferAssets
|
||||
its:
|
||||
- name: Should NOT be able to reserve transfer native assets from the Assets Parachain to the Relay Chain
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *assets_parachain
|
||||
signer: *ap_signer
|
||||
pallet: polkadotXcm
|
||||
call: limitedReserveTransferAssets
|
||||
args: [
|
||||
*rc_dest, # destination
|
||||
*rc_benf, # beneficiary
|
||||
{ v3: [ *ap_ksm_fungible ] }, # assets
|
||||
0, # feeAssetItem
|
||||
{ unlimited: true } # weightLimit
|
||||
]
|
||||
events:
|
||||
- name: polkadotXcm.Attempted
|
||||
attributes:
|
||||
- type: XcmV3TraitsOutcome
|
||||
xcmOutcome: Error
|
||||
value: Barrier
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
---
|
||||
settings:
|
||||
chains:
|
||||
relay_chain: &relay_chain
|
||||
wsPort: 9900
|
||||
assets_parachain: &assets_parachain
|
||||
wsPort: 9910
|
||||
paraId: &ap_id 1000
|
||||
penpal_parachain: &penpal_parachain
|
||||
wsPort: 9920
|
||||
paraId: &pp_id 2000
|
||||
variables:
|
||||
common:
|
||||
amount: &amount 2000000000000
|
||||
require_weight_at_most: &weight_at_most {refTime: 1000000000, proofSize: 20000}
|
||||
hrmp_channels:
|
||||
proposed_max_capacity: &max_capacity 8
|
||||
proposed_max_message_size: &max_message_size 8192
|
||||
channel: &channel {
|
||||
maxCapacity: 8,
|
||||
maxTotalSize: 8192,
|
||||
maxMessageSize: 8192,
|
||||
msgCount: 0,
|
||||
totalSize: 0,
|
||||
mqcHead: null,
|
||||
senderDeposit: 0,
|
||||
recipientDeposit: 0
|
||||
}
|
||||
chains:
|
||||
relay_chain:
|
||||
signer: &rc_signer //Alice
|
||||
assets_parachain_destination: &ap_dest { v3: { 0, interior: { x1: { parachain: *ap_id }}}}
|
||||
assets_parachain_account: &ap_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'
|
||||
assets_parachain_beneficiary: &ap_benf {v3: { parents: 0, interior: { x1: { accountId32: { id: *ap_acc }}}}}
|
||||
ksm: &rc_ksm { concrete: { 0, interior: { here: true }}}
|
||||
ksm_fungible: &rc_ksm_fungible { id: *rc_ksm, fun: { fungible: *amount }}
|
||||
assets_parachain_account:
|
||||
sovereign_account: &ap_sovereign F7fq1jSNVTPfJmaHaXCMtatT1EZefCUsa7rRiQVNR5efcah
|
||||
relay_chain_destination: &rc_dest { v3: { parents: 1, interior: { here: true }}}
|
||||
penpal_parachain:
|
||||
sovereign_account: &pp_sovereign F7fq1jMZkfuCuoMTyiEVAP2DMpMt18WopgBqTJznLihLNbZ
|
||||
signer: &pp_signer //Alice
|
||||
|
||||
tests:
|
||||
- name: HRMP
|
||||
beforeEach:
|
||||
- name: DEPENDENCY | Penpal Parachain Sovereign account in the Relay Chain needs to be funded
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *relay_chain
|
||||
signer: *rc_signer
|
||||
pallet: balances
|
||||
call: transfer
|
||||
args: [
|
||||
*pp_sovereign, # destination
|
||||
*amount, # value
|
||||
]
|
||||
events:
|
||||
- name: balances.Transfer
|
||||
|
||||
- name: DEPENDENCY | Assets Parachain Sovereign account in the Relay Chain needs to be funded
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *relay_chain
|
||||
signer: *rc_signer
|
||||
pallet: balances
|
||||
call: transfer
|
||||
args: [
|
||||
*ap_sovereign, # destination
|
||||
*amount, # value
|
||||
]
|
||||
events:
|
||||
- name: balances.Transfer
|
||||
describes:
|
||||
- name: hrmp.hrmpInitOpenChannel (Penpal Parachain → Assets Parachain)
|
||||
its:
|
||||
- name: Open Penpal Parachain to Assets Parachain
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *relay_chain
|
||||
signer: *rc_signer
|
||||
sudo: true
|
||||
pallet: hrmp
|
||||
call: forceOpenHrmpChannel
|
||||
args: [
|
||||
2000,
|
||||
1000,
|
||||
8,
|
||||
8192
|
||||
]
|
||||
events:
|
||||
- name: sudo.Sudid
|
||||
attributes:
|
||||
- type: Result<Null, SpRuntimeDispatchError>
|
||||
value: Ok
|
||||
- name: hrmp.HrmpChannelForceOpened
|
||||
- name: hrmp.hrmpInitOpenChannel (Assets Parachain → PenPal Parachain)
|
||||
its:
|
||||
- name: Open Assets Parachain to PenPal Parachain
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *relay_chain
|
||||
signer: *rc_signer
|
||||
sudo: true
|
||||
pallet: hrmp
|
||||
call: forceOpenHrmpChannel
|
||||
args: [
|
||||
1000,
|
||||
2000,
|
||||
8,
|
||||
8192
|
||||
]
|
||||
events:
|
||||
- name: sudo.Sudid
|
||||
attributes:
|
||||
- type: Result<Null, SpRuntimeDispatchError>
|
||||
value: Ok
|
||||
- name: hrmp.HrmpChannelForceOpened
|
||||
- name: hrmp.forceProcessHrmpOpen (make sure all the channels are open)
|
||||
its:
|
||||
- name: Make sure all the pending channels are open
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *relay_chain
|
||||
signer: *rc_signer
|
||||
sudo: true
|
||||
pallet: hrmp
|
||||
call: forceProcessHrmpOpen
|
||||
args: [ 2 ]
|
||||
events:
|
||||
- name: sudo.Sudid
|
||||
attributes:
|
||||
- type: Result<Null, SpRuntimeDispatchError>
|
||||
value: Ok
|
||||
@@ -0,0 +1,403 @@
|
||||
---
|
||||
# Note: This tests depends on the 3_hrmp-open-channels.yml for opening channels, otherwise teleports aren't going to
|
||||
# work.
|
||||
settings:
|
||||
chains:
|
||||
relay_chain: &relay_chain
|
||||
wsPort: 9900
|
||||
assets_parachain: &assets_parachain
|
||||
wsPort: 9910
|
||||
paraId: &ap_id 1000
|
||||
penpal_parachain: &penpal_parachain
|
||||
wsPort: 9920
|
||||
paraId: &pp_id 2000
|
||||
variables:
|
||||
common:
|
||||
mint_amount: &mint_amount 1000000000000
|
||||
amount: &amount 100000000000
|
||||
require_weight_at_most: &weight_at_most {refTime: 1200000000, proofSize: 20000}
|
||||
amount_to_send: &amount_to_send 500000000000
|
||||
chains:
|
||||
relay_chain:
|
||||
signer: &rc_signer //Alice
|
||||
assets_parachain_destination: &ap_dest { v3: { 0, interior: { x1: { parachain: *ap_id }}}}
|
||||
assets_parachain_dest_routed: &ap_dest_routed { v3: { parents: 1, interior: { x1: { parachain: *ap_id } }}}
|
||||
assets_parachain_account:
|
||||
signer: &ap_signer //Alice
|
||||
wallet: &ap_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F
|
||||
asset_id: &asset_id 2
|
||||
assets_pallet_id: &assets_pallet_id 50
|
||||
asset_min_balance: &asset_ed 1000
|
||||
penpal_parachain_destination: &pp_dest { v3: { parents: 1, interior: { x1: { parachain: *pp_id } }}}
|
||||
ksm: &ap_ksm { concrete: { parents: 1, interior: { here: true }}}
|
||||
ksm_fungible: &ap_ksm_fungible { id: *ap_ksm, fun: { fungible: *amount }}
|
||||
suff_asset: &suff_asset { concrete: { parents: 0, interior: { x2: [ { PalletInstance: *assets_pallet_id }, { GeneralIndex: *asset_id } ] }}}
|
||||
suff_asset_fail: &suff_asset_fail { concrete: { parents: 0, interior: { x2: [ { PalletInstance: *assets_pallet_id }, { GeneralIndex: 3 } ] }}}
|
||||
suff_asset_fungible_fail: &ap_suff_asset_fungible_fail { id: *suff_asset_fail, fun: { fungible: 200000000000 }}
|
||||
penpal_parachain:
|
||||
sovereign_account: &pp_sovereign_sibl FBeL7EAeUroLWXW1yfKboiqTqVfbRBcsUKd6QqVf4kGBySS
|
||||
signer: &pp_signer //Alice
|
||||
penpal_parachain_account: &pp_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'
|
||||
decodedCalls:
|
||||
force_create_asset:
|
||||
chain: *assets_parachain
|
||||
pallet: assets
|
||||
call: forceCreate
|
||||
args: [
|
||||
*asset_id,
|
||||
{ Id: *ap_wallet }, # owner
|
||||
true, # isSufficient
|
||||
*asset_ed # minBalance
|
||||
]
|
||||
force_create_asset2:
|
||||
chain: *assets_parachain
|
||||
pallet: assets
|
||||
call: forceCreate
|
||||
args: [
|
||||
*asset_id,
|
||||
{ Id: *ap_wallet }, # owner
|
||||
true, # isSufficient
|
||||
*asset_ed # minBalance
|
||||
]
|
||||
|
||||
tests:
|
||||
- name: HRMP
|
||||
describes:
|
||||
- name: polkadotXcm.limitedReserveTransferAssets (Asset) | Assets Parachain -> Penpal Parachain
|
||||
before:
|
||||
- name: DEPENDENCY | A sufficient Asset should exist in the Assets Parachain
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *relay_chain
|
||||
signer: *rc_signer
|
||||
sudo: true
|
||||
pallet: xcmPallet
|
||||
call: send
|
||||
args: [
|
||||
*ap_dest, # destination
|
||||
{
|
||||
v3: [ #message
|
||||
{
|
||||
UnpaidExecution: {
|
||||
weightLimit: Unlimited
|
||||
}
|
||||
},
|
||||
{
|
||||
SetTopic: "0x0123456789012345678901234567891201234567890123456789012345678912"
|
||||
},
|
||||
{
|
||||
Transact: {
|
||||
originKind: Superuser,
|
||||
requireWeightAtMost: *weight_at_most,
|
||||
call: $force_create_asset
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
events:
|
||||
- name: xcmPallet.Sent
|
||||
- name: dmpQueue.ExecutedDownward
|
||||
chain: *assets_parachain
|
||||
attributes:
|
||||
- type: XcmV3TraitsOutcome
|
||||
xcmOutcome: Complete
|
||||
threshold: [10, 10]
|
||||
value: {"refTime":"1,216,703,000","proofSize":"20,000"}
|
||||
- queries:
|
||||
forced_created_asset:
|
||||
chain: *assets_parachain
|
||||
pallet: assets
|
||||
call: asset
|
||||
args: [ *asset_id ]
|
||||
- asserts:
|
||||
isSome:
|
||||
args: [ $forced_created_asset ]
|
||||
|
||||
- name: DEPENDENCY | Some Assets should be minted for the sender
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *assets_parachain
|
||||
signer: *ap_signer
|
||||
pallet: assets
|
||||
call: mint
|
||||
args: [
|
||||
*asset_id,
|
||||
*ap_wallet,
|
||||
*mint_amount
|
||||
]
|
||||
events:
|
||||
- name: assets.Issued
|
||||
|
||||
its:
|
||||
- name: Assets Parachain should be able to reserve transfer an Asset to Penpal Parachain
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *assets_parachain
|
||||
signer: *ap_signer
|
||||
pallet: polkadotXcm
|
||||
call: limitedReserveTransferAssets
|
||||
args: [
|
||||
*pp_dest, # destination
|
||||
{ # beneficiary
|
||||
V3: {
|
||||
parents: 0,
|
||||
interior: {
|
||||
X1: {
|
||||
AccountId32: {
|
||||
id: *pp_acc
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{ # assets
|
||||
V3: [
|
||||
{
|
||||
id: {
|
||||
Concrete: {
|
||||
parents: 0,
|
||||
interior: {
|
||||
X2: [
|
||||
{
|
||||
PalletInstance: *assets_pallet_id
|
||||
},
|
||||
{
|
||||
GeneralIndex: *asset_id
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
fun: {
|
||||
Fungible: *amount_to_send
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
0, # feeAssetItem
|
||||
Unlimited # weightLimit
|
||||
]
|
||||
events:
|
||||
- name: polkadotXcm.Attempted
|
||||
attributes:
|
||||
- type: XcmV3TraitsOutcome
|
||||
xcmOutcome: Complete
|
||||
threshold: [10, 10]
|
||||
value: {"refTime":"679,150,000","proofSize":"6,196"}
|
||||
- name: assets.Transferred
|
||||
attributes:
|
||||
- type: AccountId32
|
||||
value: *pp_sovereign_sibl
|
||||
- name: assets.Transferred
|
||||
attributes:
|
||||
- type: u128
|
||||
value: *amount_to_send
|
||||
|
||||
- name: polkadotXcm.limitedReserveTransferAssets (KSM) | Assets Parachain -> Penpal Parachain
|
||||
its:
|
||||
- name: Assets Parachain should be able to reserve transfer KSM to Penpal Parachain
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *assets_parachain
|
||||
signer: *ap_signer
|
||||
pallet: polkadotXcm
|
||||
call: limitedReserveTransferAssets
|
||||
args: [
|
||||
*pp_dest, # destination
|
||||
{ # beneficiary
|
||||
V3: {
|
||||
parents: 0,
|
||||
interior: {
|
||||
X1: {
|
||||
AccountId32: {
|
||||
id: *pp_acc
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{ # assets
|
||||
V3: [
|
||||
*ap_ksm_fungible
|
||||
]
|
||||
},
|
||||
0, # feeAssetItem
|
||||
Unlimited # weightLimit
|
||||
]
|
||||
events:
|
||||
- name: polkadotXcm.Attempted
|
||||
attributes:
|
||||
- type: XcmV3TraitsOutcome
|
||||
xcmOutcome: Complete
|
||||
threshold: [10, 10]
|
||||
value: {"refTime":"679,150,000","proofSize":"6,196"}
|
||||
- name: balances.Endowed
|
||||
attributes:
|
||||
- type: AccountId32
|
||||
value: *pp_sovereign_sibl
|
||||
- name: balances.Endowed
|
||||
attributes:
|
||||
- type: u128
|
||||
value: *amount
|
||||
|
||||
- name: polkadotXcm.send( assets.forceCreateAsset ) | Penpal Parachain -> Assets Parachain
|
||||
before:
|
||||
- name: Get the asset balance of the Penpal Parachain Sovereign account in Assets Parachain
|
||||
actions:
|
||||
- queries:
|
||||
assets_balance_pp_sovereign_before:
|
||||
chain: *assets_parachain
|
||||
pallet: assets
|
||||
call: account
|
||||
args: [
|
||||
*asset_id,
|
||||
*pp_sovereign_sibl
|
||||
]
|
||||
its:
|
||||
- name: Penpal Parachain should be able to send XCM message paying its fee with sufficient asset in Assets Parachain
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *penpal_parachain
|
||||
signer: *pp_signer
|
||||
sudo: true
|
||||
pallet: polkadotXcm
|
||||
call: send
|
||||
args: [
|
||||
*ap_dest_routed, # destination
|
||||
{
|
||||
v3: [ #message
|
||||
{
|
||||
WithdrawAsset: [
|
||||
{
|
||||
id: {
|
||||
concrete: {
|
||||
parents: 0,
|
||||
interior: {
|
||||
X2: [
|
||||
{ PalletInstance: *assets_pallet_id },
|
||||
{ GeneralIndex: *asset_id }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
fun: { fungible: *amount }}
|
||||
]
|
||||
},
|
||||
{
|
||||
BuyExecution: {
|
||||
fees: { id: *suff_asset, fun: { fungible: *amount }},
|
||||
weightLimit: Unlimited
|
||||
}
|
||||
},
|
||||
{
|
||||
Transact: {
|
||||
originKind: SovereignAccount,
|
||||
requireWeightAtMost: *weight_at_most,
|
||||
call: $force_create_asset2
|
||||
}
|
||||
},
|
||||
{
|
||||
RefundSurplus
|
||||
},
|
||||
{
|
||||
DepositAsset: {
|
||||
assets: { Wild: All },
|
||||
beneficiary: {
|
||||
parents: 0,
|
||||
interior: {
|
||||
X1: {
|
||||
AccountId32: {
|
||||
network: , # None
|
||||
id: *pp_acc
|
||||
}
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
events:
|
||||
- name: sudo.Sudid
|
||||
attributes:
|
||||
- type: Result<Null, SpRuntimeDispatchError>
|
||||
value: Ok
|
||||
- name: polkadotXcm.Sent
|
||||
- name: assets.Burned
|
||||
chain: *assets_parachain
|
||||
attributes:
|
||||
- type: AccountId32
|
||||
value: *pp_sovereign_sibl
|
||||
- name: assets.Issued
|
||||
chain: *assets_parachain
|
||||
attributes:
|
||||
- type: u32
|
||||
value: *asset_id
|
||||
- queries:
|
||||
assets_balance_pp_sovereign_after:
|
||||
chain: *assets_parachain
|
||||
pallet: assets
|
||||
call: account
|
||||
args: [
|
||||
*asset_id,
|
||||
*pp_sovereign_sibl
|
||||
]
|
||||
forced_created_asset2:
|
||||
chain: *assets_parachain
|
||||
pallet: assets
|
||||
call: asset
|
||||
args: [ 3 ]
|
||||
- asserts:
|
||||
isSome:
|
||||
args: [ $forced_created_asset2 ]
|
||||
- name: Should reduce the assets balance of the Penpal Parachain's SovereignAccount in the Assets Parachain
|
||||
actions:
|
||||
- asserts:
|
||||
assetsDecreased:
|
||||
args: [
|
||||
{
|
||||
balances: {
|
||||
before: $assets_balance_pp_sovereign_before,
|
||||
after: $assets_balance_pp_sovereign_after,
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
- name: Penpal Parachain SHOULD NOT be able to send XCM message paying its fee with sufficient assets if not enough balance
|
||||
actions:
|
||||
- extrinsics:
|
||||
- chain: *penpal_parachain
|
||||
signer: *pp_signer
|
||||
sudo: true
|
||||
pallet: polkadotXcm
|
||||
call: send
|
||||
args: [
|
||||
*ap_dest_routed, # destination
|
||||
{
|
||||
v3: [ #message
|
||||
{
|
||||
WithdrawAsset: [*ap_suff_asset_fungible_fail]
|
||||
},
|
||||
{
|
||||
BuyExecution: {
|
||||
fees: *ap_suff_asset_fungible_fail,
|
||||
weightLimit: Unlimited
|
||||
}
|
||||
},
|
||||
{
|
||||
Transact: {
|
||||
originKind: SovereignAccount,
|
||||
requireWeightAtMost: *weight_at_most,
|
||||
call: $force_create_asset2
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
events:
|
||||
- name: xcmpQueue.Fail
|
||||
chain: *assets_parachain
|
||||
attributes:
|
||||
- type: XcmV3TraitsError
|
||||
value: FailedToTransactAsset
|
||||
@@ -0,0 +1,70 @@
|
||||
[relaychain]
|
||||
default_command = "./bin/polkadot"
|
||||
default_args = [ "-lparachain=debug", "-lxcm=trace" ]
|
||||
chain = "kusama-local"
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "alice"
|
||||
ws_port = 9900
|
||||
validator = true
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "bob"
|
||||
ws_port = 9901
|
||||
validator = true
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "charlie"
|
||||
ws_port = 9902
|
||||
validator = true
|
||||
|
||||
[[relaychain.nodes]]
|
||||
name = "dave"
|
||||
ws_port = 9903
|
||||
validator = true
|
||||
|
||||
[[parachains]]
|
||||
id = 1000
|
||||
chain = "statemine-local"
|
||||
cumulus_based = true
|
||||
|
||||
[[parachains.collators]]
|
||||
name = "collator1"
|
||||
ws_port = 9910
|
||||
command = "./bin/polkadot-parachain"
|
||||
args = [ "-lxcm=trace" ]
|
||||
|
||||
[[parachains.collators]]
|
||||
name = "collator2"
|
||||
ws_port = 9911
|
||||
command = "./bin/polkadot-parachain"
|
||||
args = [ "-lxcm=trace" ]
|
||||
|
||||
[[parachains]]
|
||||
id = 2000
|
||||
chain = "penpal-kusama-2000"
|
||||
cumulus_based = true
|
||||
|
||||
[[parachains.collators]]
|
||||
name = "collator3"
|
||||
ws_port = 9920
|
||||
command = "./bin/polkadot-parachain"
|
||||
args = [ "-lxcm=trace" ]
|
||||
|
||||
[[parachains.collators]]
|
||||
name = "collator4"
|
||||
ws_port = 9921
|
||||
command = "./bin/polkadot-parachain"
|
||||
args = [ "-lxcm=trace" ]
|
||||
|
||||
# [[hrmpChannels]]
|
||||
# sender = 1000
|
||||
# recipient = 2000
|
||||
# maxCapacity = 8
|
||||
# maxMessageSize = 8192
|
||||
|
||||
# [[hrmpChannels]]
|
||||
# sender = 2000
|
||||
# recipient = 1000
|
||||
# maxCapacity = 8
|
||||
# maxMessageSize = 8192
|
||||
Reference in New Issue
Block a user