Git Product home page Git Product logo

xcm-simulator's Introduction

XCM Simulator

Test kit to simulate cross-chain message passing and XCM execution.

Different level of simulation are provided: xcm-simulator and xcm-emulator.

xcm-simulator

UPDATE: xcm-simulator has been merged into Polkadot repo, and not actively maintained here anymore.

xcm-simulator uses mock relay chain and parachain runtime. It allows minimum runtime modules for XCM testing and playground, and thus has less compiling overhead depending on the specific config. Typical use case is unit tests of XCM related pallets.

xcm-emulator

xcm-emulator uses production relay chain and parachain runtime. Users could plug in Kusama, Statemine, and Karura runtime etc. With up-to-date chain specs, it's able to verify if specific XCM messages work in live networks.

Limitations

xcm-emulator emulates the delivery and execution of XCM messages, with the assumption that the message can always be delivered to and executed in destination. There are some reasons which could prevent messages being delivered or executed, such as:

  • Number of messages in one block limitation a parachain can send is reached.
  • There is no HRMP channel for messages.
  • Relay chain run out of weights reserved for UMP messages execution.
  • Parachain run out of weights reserved for XCMP/DMP messages execution.
  • ...more possible reasons.

Use cases

Typical use cases:

  • Integration tests. Karura is using xcm-emulator for cross-chain transfer, homa-lite protocol integration tests.
  • XCM message playground. Use it to verify if the message about to sent would work in live Kusama networks. Note the limitations in the above section.

xcm-simulator's People

Contributors

99kies avatar apopiak avatar cuteolaf avatar insipx avatar johnwhitton avatar mclyk avatar ntn-x2 avatar nunoalexandre avatar samelamin avatar sander2 avatar shaunxw avatar xlc avatar zjb0807 avatar zqhxuyuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

xcm-simulator's Issues

use MockXcm to simulate test

currenty xcm-simulator and xcm-emulator both use non-relayed(thread-local/memory like) to test xcm.

As cumulus aleady support inject dmp_messages and hrmp_messages into MockXcm(also aim to test) in this PR: paritytech/cumulus#876. maybe we could let xcm-simulator unchanged
but xcm-emulator intergrate this feature so that we could also test something more than just handle_messages. because current the implementation of dmp-queue and xcmp-queue has some implements detail(such as cache,status,page etc), although the testcase in the cumulus repo can make sure it all works well. but I think we may need further/deeper integration?

Question: Using a local version of Polkadot with `xcm-emulator`

Hello!!!

i would like to use a local version of Polkadot so i can log custom debug messages in the executor and builder. I tried redirecting all the polkadot pallets to my local repository but when i compile tons of errors and unmet trait bounds appear specially with the xcm-emulator. Is this possible?

`xcm-emulator` tests fail when switching `yayoi` runtime for `statemint-runtime`

I'm trying to make some reserve transfer tests using the Kusama and Statemine runtimes for XCM documentation for runtime developers. I figured swapping the yayoi runtime for statemine-runtime would be a good start (literally swapping every yayoi:: string for statemine_runtime:: and adding statemine-runtime to Config.toml), but I'm getting the following errors.

~/codebases/w3f/xcm-simulator master !3                                                                                                          
❯ RUST_BACKTRACE=1 cargo test -p xcm-emulator-example 
    Finished test [unoptimized + debuginfo] target(s) in 2.17s
     Running unittests (target/debug/deps/xcm_emulator_example-5877f358a5b09661)

running 4 tests
test tests::ump ... ok
test tests::dmp ... ok
test tests::xcmp ... FAILED
test tests::xcmp_through_a_parachain ... FAILED

failures:

---- tests::xcmp stdout ----
>>> Event::XcmpQueue(Event::Fail(Some(0xef3c53636b690c322a099df7a38f9d6ef1b67352147e0170204f58b79c4814bc), Barrier))
thread 'tests::xcmp' panicked at 'assertion failed: System::events().iter().any(|r|\n                                matches!(r.event, Event ::\n                                         System(frame_system :: Event ::\n                                                Remarked(_, _))))', xcm-emulator/example/src/lib.rs:239:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:50:5
   3: xcm_emulator_example::tests::xcmp::{{closure}}
             at ./src/lib.rs:239:4
   4: environmental::using::{{closure}}
             at /Users/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/environmental-1.1.3/src/lib.rs:125:3
   5: std::thread::local::LocalKey<T>::try_with
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/local.rs:399:16
   6: std::thread::local::LocalKey<T>::with
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/local.rs:375:9
   7: environmental::using
             at /Users/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/environmental-1.1.3/src/lib.rs:106:2
   8: sp_externalities::scope_limited::ext::using
             at /Users/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/environmental-1.1.3/src/lib.rs:252:5
   9: sp_externalities::scope_limited::set_and_run_with_externalities
             at /Users/jake/.cargo/git/checkouts/substrate-7e08433d4c370a21/57346f6/primitives/externalities/src/scope_limited.rs:31:2
  10: sp_state_machine::testing::TestExternalities<H,N>::execute_with
             at /Users/jake/.cargo/git/checkouts/substrate-7e08433d4c370a21/57346f6/primitives/state-machine/src/testing.rs:200:3
  11: <xcm_emulator_example::YayoiMushroom as xcm_emulator::TestExt>::execute_with::{{closure}}
             at /Users/jake/codebases/w3f/xcm-simulator/xcm-emulator/src/lib.rs:225:32
  12: std::thread::local::LocalKey<T>::try_with
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/local.rs:399:16
  13: std::thread::local::LocalKey<T>::with
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/local.rs:375:9
  14: <xcm_emulator_example::YayoiMushroom as xcm_emulator::TestExt>::execute_with
             at /Users/jake/codebases/w3f/xcm-simulator/xcm-emulator/src/lib.rs:225:13
  15: xcm_emulator_example::tests::xcmp
             at ./src/lib.rs:235:3
  16: xcm_emulator_example::tests::xcmp::{{closure}}
             at ./src/lib.rs:217:2
  17: core::ops::function::FnOnce::call_once
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/ops/function.rs:227:5
  18: core::ops::function::FnOnce::call_once
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

---- tests::xcmp_through_a_parachain stdout ----
>>> Event::XcmpQueue(Event::Fail(Some(0xee89f42c7f7adbb1839aa1b01ba550bab977718eb7c6fff52f378a0cf9430b4e), Barrier))
thread 'tests::xcmp_through_a_parachain' panicked at 'assertion failed: System::events().iter().any(|r|\n                                matches!(r.event, Event ::\n                                         PolkadotXcm(pallet_xcm :: Event ::\n                                                     Sent(_, _, _))))', xcm-emulator/example/src/lib.rs:279:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:50:5
   3: xcm_emulator_example::tests::xcmp_through_a_parachain::{{closure}}
             at ./src/lib.rs:279:4
   4: environmental::using::{{closure}}
             at /Users/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/environmental-1.1.3/src/lib.rs:125:3
   5: std::thread::local::LocalKey<T>::try_with
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/local.rs:399:16
   6: std::thread::local::LocalKey<T>::with
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/local.rs:375:9
   7: environmental::using
             at /Users/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/environmental-1.1.3/src/lib.rs:106:2
   8: sp_externalities::scope_limited::ext::using
             at /Users/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/environmental-1.1.3/src/lib.rs:252:5
   9: sp_externalities::scope_limited::set_and_run_with_externalities
             at /Users/jake/.cargo/git/checkouts/substrate-7e08433d4c370a21/57346f6/primitives/externalities/src/scope_limited.rs:31:2
  10: sp_state_machine::testing::TestExternalities<H,N>::execute_with
             at /Users/jake/.cargo/git/checkouts/substrate-7e08433d4c370a21/57346f6/primitives/state-machine/src/testing.rs:200:3
  11: <xcm_emulator_example::YayoiMushroom as xcm_emulator::TestExt>::execute_with::{{closure}}
             at /Users/jake/codebases/w3f/xcm-simulator/xcm-emulator/src/lib.rs:225:32
  12: std::thread::local::LocalKey<T>::try_with
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/local.rs:399:16
  13: std::thread::local::LocalKey<T>::with
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/local.rs:375:9
  14: <xcm_emulator_example::YayoiMushroom as xcm_emulator::TestExt>::execute_with
             at /Users/jake/codebases/w3f/xcm-simulator/xcm-emulator/src/lib.rs:225:13
  15: xcm_emulator_example::tests::xcmp_through_a_parachain
             at ./src/lib.rs:275:3
  16: xcm_emulator_example::tests::xcmp_through_a_parachain::{{closure}}
             at ./src/lib.rs:246:2
  17: core::ops::function::FnOnce::call_once
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/ops/function.rs:227:5
  18: core::ops::function::FnOnce::call_once
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    tests::xcmp
    tests::xcmp_through_a_parachain

test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.34s

error: test failed, to rerun pass '-p xcm-emulator-example --lib'

It appears that it's checking for the event type to have a remark or something similar, but it does not appear to exist. The relevant lines of code are https://github.com/shaunxw/xcm-simulator/blob/master/xcm-emulator/example/src/lib.rs#L239 and https://github.com/shaunxw/xcm-simulator/blob/master/xcm-emulator/example/src/lib.rs#L279

Parachain macro: Use `$crate::` dependencies in `construct_runtime!`

//TODO: Use `$crate::frame_system` etc once `construct_runtime!` supports path.
// https://github.com/paritytech/substrate/issues/8085
System: frame_system::{Pallet, Call, Storage, Config, Event<T>},
ParachainInfo: parachain_info::{Pallet, Storage, Config},
XcmHandler: cumulus_pallet_xcm_handler::{Pallet, Call, Event<T>, Origin},

depends on paritytech/substrate#8085

upgrade to polkadot v1.0.0

Upgrading to the latest version is a proactive approach to ensure that the test kit stays up-to-date with the latest developments and advancements. All the substrate dependencies need to be upgraded to the latest v1.0.0 release

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.