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

Add xcm-simulator #102

Merged
merged 16 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
79 changes: 79 additions & 0 deletions .github/workflows/simulate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: XCM Simulator

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master, xcm-simulator ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
simulate:
# The type of runner that the job will run on
runs-on: ubuntu-20.04
defaults:
run:
working-directory: xcm-simulator
env:
NIGHTLY: nightly-2022-11-02 # Fix version to prevent cache misses with nightly changes
SKIP_WASM_BUILD: '1' # Skip for all steps, so no wasm32-unknown-unknown target required

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- name: Set-Up
run: sudo apt update && sudo apt install -y git clang curl libssl-dev llvm libudev-dev cmake protobuf-compiler

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable

- name: Install Nightly
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.NIGHTLY }}
override: true

- name: Cache Build artefacts
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-test

# Install cargo-nextest, 60% faster than cargo test and support for junit output format
- name: Install cargo-nextest
run: if ! which cargo-nextest &> /dev/null; then cargo install cargo-nextest; fi

# Create profile with JUnit output enabled
- name: Configure CI
run: mkdir .config && echo -e "[profile.ci.junit]\npath = \"junit.xml\"" > .config/nextest.toml

# Run all tests in solution using CI profile created above
- name: Run tests
run: cargo nextest run "tests::" --release --profile ci

# Report test results
- name: Report test results
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: simulate
path: target/nextest/ci/junit.xml
reporter: jest-junit
working-directory: 'xcm-simulator'
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ members = [
"primitives/xcm",
]
exclude = [
"contracts"
"contracts",
"xcm-simulator"
]

[profile.release]
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ First, complete the [basic Rust setup instructions](./docs/rust-setup.md).

#### Build

Use the following command to build the Trappist collector binary:
Use the following command to build the Trappist collator binary:

When the base collator is built, rename the binary into `base-collator` and place it into the `./bin` folder.
```
Expand Down Expand Up @@ -83,6 +83,22 @@ Then, start the **Trappist** playground with:
./zombienet-linux -p native spawn xcm-playground.toml
```

### Integration Tests
[parachains-integration-tests](https://github.com/paritytech/parachains-integration-tests) is a tool meant for XCM message execution in a locally spawned network. Tests are written as YAML files and converted into [Mocha](https://mochajs.org/) tests with [Chai](https://www.chaijs.com/) assertions.

The [integration-tests](./integration-tests) directory has tests on Trappist use cases and instructions on how to run them.

### XCM Simulator
evilrobot-01 marked this conversation as resolved.
Show resolved Hide resolved
The [XCM simulator](./xcm-simulator) can be used to further explore XCM message execution across the various runtimes used by Trappist.
Each Trappist use case is written as a Rust unit test, allowing interactive debugging/exploration of message flows and instruction execution.
Each `execute_with` closure scope within a test can be considered as a block on the corresponding chain, with messages being dispatched to the destination chains via a mock message queue as the closure goes out of scope.
All XCM-specific traces from the interactions are also collected in a single place for easier inspection.

You can run all tests, including the tracing output, with:
```
cd xcm-simulator && cargo test --release tests::; cd ..
```

## License

Trappist is licensed under [Apache 2](LICENSE).
2 changes: 1 addition & 1 deletion runtime/base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

pub mod constants;
mod contracts;
mod xcm_config;
pub mod xcm_config;

use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use sp_api::impl_runtime_apis;
Expand Down
2 changes: 1 addition & 1 deletion runtime/trappist/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

pub mod constants;
mod contracts;
mod xcm_config;
pub mod xcm_config;

use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use sp_api::impl_runtime_apis;
Expand Down
49 changes: 49 additions & 0 deletions xcm-simulator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[package]
name = "xcm-simulator-trappist"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Examples of xcm-simulator usage."
edition = "2021"

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0" }
scale-info = { version = "2.1.2", features = ["derive"] }
thousands = "0.2.0"
tracing = { version = "0.1.37" }
tracing-subscriber = { version = "0.3.16", features = ["env-filter", "tracing-log"] }

frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
pallet-assets = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
pallet-asset-registry = { version = "0.0.1", path = "../pallets/asset-registry" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }

xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.30" }
xcm-simulator = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.30" }
xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.30" }
xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.30" }
pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.30" }

# Polkadot
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.30" }
polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.30" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.30" }
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.30" }

# Cumulus
cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.30" }
cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.30" }
pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.30" }
parachains-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.30" }

# Runtimes
rococo-runtime = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.30" }
rococo-runtime-constants = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.30" }
statemine-runtime = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.30" }
base-runtime = { path = "../runtime/base" }
trappist-runtime = { path = "../runtime/trappist" }
Loading