Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Asset Registry #63

Merged
merged 44 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
ff6a982
bootstrap pallet_asset_registry
bernardoaraujor Sep 10, 2022
045296f
rm change_foreign_asset fn
bernardoaraujor Sep 10, 2022
c774b1d
fix AsAssetMultiLocation implementation
bernardoaraujor Sep 10, 2022
ab124a3
avoid creating/destroying assets for registry
bernardoaraujor Sep 13, 2022
bac57dd
use loose coupling with Assets pallet
bernardoaraujor Sep 14, 2022
f3d53fa
split unit tests
bernardoaraujor Sep 14, 2022
61239cd
bootstrap xcm-simulator unit tests
bernardoaraujor Sep 19, 2022
35df979
rustfmt
bernardoaraujor Sep 19, 2022
79e1c04
rm change_foreign_asset extrinsic
bernardoaraujor Sep 19, 2022
01c45dc
rename Foreign Asset -> Reserve Asset
bernardoaraujor Sep 19, 2022
88ad1ab
rm xcm-simulator from unit tests
bernardoaraujor Sep 20, 2022
d9b924a
rename ForeignFungiblesTransactor->ReservedFungiblesTransactor
bernardoaraujor Sep 21, 2022
f5a8ac7
add comments to asset-registry pallet errors
bernardoaraujor Oct 3, 2022
8e9cce1
bootstrap integration-tests
bernardoaraujor Oct 3, 2022
65f6dd3
asset-registry pallet README
bernardoaraujor Oct 3, 2022
a165b2d
zombienet with 2 collators per para
bernardoaraujor Oct 4, 2022
84a5a27
bootstrap benchmarks
bernardoaraujor Oct 4, 2022
6abf936
upgrade zombienet config camel_case
bernardoaraujor Oct 4, 2022
7ea2391
update weights with GCP c2d-highcpu-8
bernardoaraujor Oct 5, 2022
379b19a
integration test: rm XcmV1MultiLocation attribute from ReserveAssetRe…
bernardoaraujor Oct 5, 2022
c5b7078
Merge branch 'master' of ssh://github.com/paritytech/trappist into 51…
bernardoaraujor Oct 5, 2022
a7e6a04
rm unused StatemineAssetIdInfoB
bernardoaraujor Oct 5, 2022
a45b376
add WeightInfo to asset-registry mock
bernardoaraujor Oct 5, 2022
152d4cd
Run cargo fmt & clippy
Oct 6, 2022
884f089
More clippy smartness
Oct 6, 2022
6861c96
lint pallets/asset-registry/README.md
bernardoaraujor Oct 6, 2022
926bcd3
lint pallets/asset-registry/README.md
bernardoaraujor Oct 6, 2022
5b7b6f1
lint pallets/asset-registry/README.md
bernardoaraujor Oct 6, 2022
cfa494a
lint pallets/asset-registry/README.md
bernardoaraujor Oct 6, 2022
fbee91b
lint pallets/asset-registry/src/benchmarking.rs
bernardoaraujor Oct 6, 2022
f458c4e
lint pallets/asset-registry/src/tests.rs
bernardoaraujor Oct 6, 2022
3e67a7b
lint pallets/asset-registry/src/tests.rs
bernardoaraujor Oct 6, 2022
2d745e1
lint primitives/xcm/Cargo.toml
bernardoaraujor Oct 6, 2022
820537f
lint primitives/xcm/src/lib.rs
bernardoaraujor Oct 6, 2022
5442dc6
lint primitives/xcm/src/lib.rs
bernardoaraujor Oct 6, 2022
4b212d6
lint pallets/asset-registry/src/benchmarking.rs
bernardoaraujor Oct 6, 2022
4c901b5
lint pallets/asset-registry/src/lib.rs
bernardoaraujor Oct 6, 2022
27ac57a
lint pallets/asset-registry/src/lib.rs
bernardoaraujor Oct 6, 2022
9804fa4
lint pallets/asset-registry/src/tests.rs
bernardoaraujor Oct 6, 2022
fc10247
fix ReserveAssetRegistered field
bernardoaraujor Oct 6, 2022
fb5769e
add comment explaining fn asset_exists
bernardoaraujor Oct 6, 2022
410acf8
fix asset-registry pallet README
bernardoaraujor Oct 6, 2022
f3179b7
set LOCAL_ASSET_ID to 10
bernardoaraujor Oct 7, 2022
4150d78
change &trappist_asset_id on integration test
bernardoaraujor Oct 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
399 changes: 229 additions & 170 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"node",
"runtime",
"primitives/xcm",
]
exclude = [
"contracts"
Expand Down
19 changes: 19 additions & 0 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[`parachains-integration-tests`](https://github.com/paritytech/parachains-integration-tests) is a tool designed to test interactions between Substrate blockchains.

Trappist uses it to ensure the correctness of some of its features.

# Setup

Install `parachains-integration-tests` into your system:
```
$ yarn global add @parity/parachains-integration-tests
```

# Usage

Please refer to the [project's `README.md`](https://github.com/paritytech/parachains-integration-tests#how-to-use) for an extensive description of how to write YAML test files and how to execute tests.

For example, to use zombienet and perform a reserve transfer that tests the functionality of `asset-registry` pallet:
```
$ parachains-integration-tests -m zombienet-test -c xcm-playground.toml -t integration-tests/asset-registry/0_reserve_transfer.yml
```
249 changes: 249 additions & 0 deletions integration-tests/asset-registry/0_reserve_transfer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
---
settings:
chains:
relay_chain: &relay_chain
wsPort: 9900
reserve_parachain: &reserve_parachain
wsPort: 9910
paraId: &rp_id 1000
trappist_parachain: &trappist_parachain
wsPort: 9920
paraId: &tp_id 2000
variables:
common:
amount_to_mint: &amount_to_mint 100000000000000
amount_to_send: &amount_to_send 10000000000000
require_weight_at_most: &weight_at_most 1000000000
chains:
relay_chain:
signer: &rc_signer //Alice
trappist_parachain_dest_routed: &tp_dest_routed { v1: { parents: 1, interior: { x1: { parachain: *tp_id } }}}
reserve_parachain:
signer: &rp_signer //Alice
wallet: &rp_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F
bob_signer: &rp_bob_signer //Bob
bob_wallet: &rp_bob_wallet FoQJpPyadYccjavVdTWxpxU7rUEaYhfLCPwXgkfD6Zat9QP
asset_id: &reserve_asset_id 1
asset_pallet_id: &reserve_asset_pallet_id 50
asset_min_balance: &reserve_assets_min_balance 1
asset_multi_location: &reserve_asset_multi_location {
parents: 1,
interior: {
X3: [
{
Parachain: *rp_id
},
{
PalletInstance: *reserve_asset_pallet_id
},
{
GeneralIndex: *reserve_asset_id
}
]
}
}
trappist_parachain:
signer: &tp_signer //Alice
wallet: &tp_wallet 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
bob_wallet: &tp_bob_wallet 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty
asset_id: &trappist_asset_id 100 # different from reserve_asset_id, so we can test pallet-assets-registry
asset_min_balance: &trappist_assets_min_balance 1
sovereign_account: &tp_sovereign_sibl FBeL7EAeUroLWXW1yfKboiqTqVfbRBcsUKd6QqVf4kGBySS
bob_account: &tp_bob_acc '0x8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48'
decodedCalls:
force_create_asset:
chain: *reserve_parachain
pallet: assets
call: forceCreate
args: [
*reserve_asset_id,
{ id: *rp_wallet }, # owner
true, # isSufficient
*reserve_assets_min_balance # minBalance
]

tests:
- name: HRMP
describes:
- name: polkadotXcm.limitedReserveTransferAssets (Asset) | Reserve Parachain -> Trappist Parachain
before:
- name: DEPENDENCY | Create a sufficient Asset on Reserve Parachain
actions:
- extrinsics:
- chain: *relay_chain
signer: *rc_signer
sudo: true
pallet: parasSudoWrapper
call: sudoQueueDownwardXcm
args: [
*rp_id, # id
{
v2: [ # message
{
Transact: {
originType: Superuser,
requireWeightAtMost: *weight_at_most,
call: $force_create_asset
}
}
]
}
]
events:
- name: sudo.Sudid
attributes:
- type: Result<Null, SpRuntimeDispatchError>
value: Ok
- queries:
forced_created_asset:
chain: *reserve_parachain
pallet: assets
call: asset
args: [ *reserve_asset_id ]
- asserts:
isSome:
args: [ $forced_created_asset ]

- name: DEPENDENCY | Mint assets on Reserve Parachain
actions:
- extrinsics:
- chain: *reserve_parachain
signer: *rp_signer
pallet: assets
call: mint
args: [
*reserve_asset_id,
*rp_bob_wallet,
*amount_to_mint
]
events:
- name: assets.Issued

- name: DEPENDENCY | Create asset on Trappist Parachain
actions:
- extrinsics:
- chain: *trappist_parachain
signer: *tp_signer
pallet: assets
call: forceCreate
sudo: true
args: [
*trappist_asset_id,
{ id: *tp_wallet }, # owner
false, # isSufficient
*trappist_assets_min_balance #minBalance
]
events:
- name: sudo.Sudid
attributes:
- type: Result<Null, SpRuntimeDispatchError>
value: Ok
- name: assets.ForceCreated
- queries:
forced_created_asset:
chain: *trappist_parachain
pallet: assets
call: asset
args: [ *trappist_asset_id ]
- asserts:
isSome:
args: [ $forced_created_asset ]

its:
- name: Trappist Parachain has AssetId registered to Reserve Asset
actions:
- extrinsics:
- chain: *trappist_parachain
signer: *tp_signer
sudo: true
pallet: assetRegistry
call: registerReserveAsset
args: [
*trappist_asset_id,
*reserve_asset_multi_location
]
events:
- name: sudo.Sudid
attributes:
- type: Result<Null, SpRuntimeDispatchError>
value: Ok
- name: assetRegistry.ReserveAssetRegistered
attributes:
- type: u32
value: *trappist_asset_id

- name: Assets Parachain should be able to reserve transfer an asset to Trappist Parachain
actions:
- extrinsics:
- chain: *reserve_parachain
signer: *rp_bob_signer
pallet: polkadotXcm
call: limitedReserveTransferAssets
args: [
*tp_dest_routed, # destination
{ # beneficiary
v1: {
parents: 0,
interior: {
x1: {
AccountId32: {
network: null,
id: *tp_bob_acc
}
}
}
}
},
{ # assets
v1: [
{
id: {
Concrete: {
parents: 0,
interior: {
x2: [
{
PalletInstance: *reserve_asset_pallet_id
},
{
GeneralIndex: *reserve_asset_id
}
]
}
}
},
fun: {
Fungible: *amount_to_send
}
}
]
},
0, # feeAssetItem
Unlimited # weightLimit
]
events:
- name: polkadotXcm.Attempted
attributes:
- type: XcmV2TraitsOutcome
xcmOutcome: Complete
value: 1,000,000,000
- name: assets.Transferred
attributes:
- type: AccountId32
value: *tp_sovereign_sibl
- type: u128
value: *amount_to_send
- name: assets.Issued
chain: *trappist_parachain
- queries:
bob_received_asset:
chain: *trappist_parachain
pallet: assets
call: account
args: [
*trappist_asset_id,
*tp_bob_wallet
]
- asserts:
isSome:
args: [ $bob_received_asset ]
21 changes: 18 additions & 3 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use serde::{Deserialize, Serialize};
use sp_core::{sr25519, Pair, Public};
use sp_runtime::traits::{IdentifyAccount, Verify};
use trappist_runtime::{
constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AuraId, BalancesConfig, CouncilConfig,
GenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig,
constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AssetsConfig, AuraId, BalancesConfig,
CouncilConfig, GenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig,
};

const DEFAULT_PROTOCOL_ID: &str = "hop";
Expand Down Expand Up @@ -176,6 +176,8 @@ pub fn local_testnet_config() -> ChainSpec {
)
}

pub const LOCAL_ASSET_ID: u32 = 10;

/// Configure initial storage state for FRAME modules.
fn testnet_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
Expand Down Expand Up @@ -223,7 +225,20 @@ fn testnet_genesis(
// Assign network admin rights.
key: Some(root_key),
},
assets: Default::default(),
assets: AssetsConfig {
assets: vec![
// id, owner, is_sufficient, min_balance
(LOCAL_ASSET_ID, get_account_id_from_seed::<sr25519::Public>("Alice"), true, 1),
],
metadata: vec![
// id, name, symbol, decimals
(LOCAL_ASSET_ID, "txUSD".into(), "txUSD".into(), 10),
],
accounts: vec![
// id, account_id, balance
(LOCAL_ASSET_ID, get_account_id_from_seed::<sr25519::Public>("Alice"), 100),
],
},
council: CouncilConfig {
members: invulnerables.iter().map(|x| x.0.clone()).collect::<Vec<_>>(),
phantom: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayC
use cumulus_relay_chain_rpc_interface::{create_client_and_start_worker, RelayChainRpcInterface};

use sc_executor::NativeElseWasmExecutor;
use sc_network::{NetworkService, NetworkBlock};
use sc_network::{NetworkBlock, NetworkService};
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
use sp_api::ConstructRuntimeApi;
Expand Down
Loading