From 51ce1c1af3f3166b9dd59c5ec0251d6e87961199 Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Thu, 18 May 2023 14:48:07 +0530 Subject: [PATCH 01/19] feat: remove fixtures dir --- tests/xcm-simulator/fixtures/README.md | 6 - tests/xcm-simulator/fixtures/flipper.json | 243 ---------------------- tests/xcm-simulator/fixtures/flipper.wasm | Bin 1295 -> 0 bytes 3 files changed, 249 deletions(-) delete mode 100644 tests/xcm-simulator/fixtures/README.md delete mode 100644 tests/xcm-simulator/fixtures/flipper.json delete mode 100644 tests/xcm-simulator/fixtures/flipper.wasm diff --git a/tests/xcm-simulator/fixtures/README.md b/tests/xcm-simulator/fixtures/README.md deleted file mode 100644 index 6ed582ed8b..0000000000 --- a/tests/xcm-simulator/fixtures/README.md +++ /dev/null @@ -1,6 +0,0 @@ -## fixtures -This directory contains contracts which are used in experimental scenarios. - -Files in this directory are used by experimental scenarios in `src/experimental.rs`. The json -files are for informational purposes only and are not consumed by the tests. - diff --git a/tests/xcm-simulator/fixtures/flipper.json b/tests/xcm-simulator/fixtures/flipper.json deleted file mode 100644 index b3cebf039f..0000000000 --- a/tests/xcm-simulator/fixtures/flipper.json +++ /dev/null @@ -1,243 +0,0 @@ -{ - "source": { - "hash": "0xdd6430401e759bba008f829d53364435923d211c22f3aa14434d306ea0dc3cbd", - "language": "ink! 4.1.0", - "compiler": "rustc 1.68.2", - "build_info": { - "build_mode": "Release", - "cargo_contract_version": "2.0.0", - "rust_toolchain": "stable-x86_64-unknown-linux-gnu", - "wasm_opt_settings": { - "keep_debug_symbols": false, - "optimization_passes": "Z" - } - } - }, - "contract": { - "name": "flipper", - "version": "0.1.0", - "authors": [ - "[your_name] <[your_email]>" - ] - }, - "spec": { - "constructors": [ - { - "args": [ - { - "label": "init_value", - "type": { - "displayName": [ - "bool" - ], - "type": 0 - } - } - ], - "docs": [ - "Constructor that initializes the `bool` value to the given `init_value`." - ], - "label": "new", - "payable": false, - "returnType": { - "displayName": [ - "ink_primitives", - "ConstructorResult" - ], - "type": 1 - }, - "selector": "0x9bae9d5e" - } - ], - "docs": [], - "events": [], - "lang_error": { - "displayName": [ - "ink", - "LangError" - ], - "type": 3 - }, - "messages": [ - { - "args": [], - "docs": [ - " A message that can be called on instantiated contracts.", - " This one flips the value of the stored `bool` from `true`", - " to `false` and vice versa." - ], - "label": "flip", - "mutates": true, - "payable": false, - "returnType": { - "displayName": [ - "ink", - "MessageResult" - ], - "type": 1 - }, - "selector": "0x633aa551" - }, - { - "args": [], - "docs": [ - " Simply returns the current value of our `bool`." - ], - "label": "get", - "mutates": false, - "payable": false, - "returnType": { - "displayName": [ - "ink", - "MessageResult" - ], - "type": 4 - }, - "selector": "0x2f865bd9" - } - ] - }, - "storage": { - "root": { - "layout": { - "struct": { - "fields": [ - { - "layout": { - "leaf": { - "key": "0x00000000", - "ty": 0 - } - }, - "name": "value" - } - ], - "name": "Flipper" - } - }, - "root_key": "0x00000000" - } - }, - "types": [ - { - "id": 0, - "type": { - "def": { - "primitive": "bool" - } - } - }, - { - "id": 1, - "type": { - "def": { - "variant": { - "variants": [ - { - "fields": [ - { - "type": 2 - } - ], - "index": 0, - "name": "Ok" - }, - { - "fields": [ - { - "type": 3 - } - ], - "index": 1, - "name": "Err" - } - ] - } - }, - "params": [ - { - "name": "T", - "type": 2 - }, - { - "name": "E", - "type": 3 - } - ], - "path": [ - "Result" - ] - } - }, - { - "id": 2, - "type": { - "def": { - "tuple": [] - } - } - }, - { - "id": 3, - "type": { - "def": { - "variant": { - "variants": [ - { - "index": 1, - "name": "CouldNotReadInput" - } - ] - } - }, - "path": [ - "ink_primitives", - "LangError" - ] - } - }, - { - "id": 4, - "type": { - "def": { - "variant": { - "variants": [ - { - "fields": [ - { - "type": 0 - } - ], - "index": 0, - "name": "Ok" - }, - { - "fields": [ - { - "type": 3 - } - ], - "index": 1, - "name": "Err" - } - ] - } - }, - "params": [ - { - "name": "T", - "type": 0 - }, - { - "name": "E", - "type": 3 - } - ], - "path": [ - "Result" - ] - } - } - ], - "version": "4" -} \ No newline at end of file diff --git a/tests/xcm-simulator/fixtures/flipper.wasm b/tests/xcm-simulator/fixtures/flipper.wasm deleted file mode 100644 index ee816fbe7fbbcb24080be53502c64c94bd92c04b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1295 zcmZvb&1xJ+5XY;kdsZXOE^2`eLh_+^EP`|h{y3~aK6u+84Iu~nlC!kf6O-B1hi6v{ zx_DL~{0ug}8T=f61|LJnDX$Q6wf{A}HiSegrhBTZYJT;vY8p+?n230Hz=)Y^(wIIVB@M?$}ZS6GL)gG zJxO!prOK^0KlR94HQArrof&&6daM@mrs^kw`o=U!YmRN>lf)aJR7h{C9|>QAQ{bv^ zx}0U(9=QgRu4jbbFCvY+2ACh`1TYX*IX|HTgS{@Png((QOIqP^r*iCh-%uYl?3=W2 zVDvx_Nw5lV`)ntBjAC2doR91<$a;p4a^UemP)3WL6Nm&Vda zo@_!{EL*v#yx2L^(ze>oi<&qfGMr>+3(4;onlQY{$pkk=FI3lI+ z>?~z(nPoWu&{Bv46_R4<$lz@K378I|>`6E0aI@g2Jp>@LRZt4IS{XKKQAITf zgAm^T`On`mn@cq{6vdQC28r3NYPW&7rrv>6K^&`u9}Fk|Ci`EuSPMlk`VJPcWXS;Y z)*O=ox#xXU9@2T=wCu{m;V&wzR&uYvL~8YKxTw8tw|`Jk_ke~t3BU7kkGnQox*Zlv zr;qUOVVGN|&s6jbii%CgWGO`}O>DY~6+0e>5u>WNidz|>n2s>o$K%{+6tMBbjbrGf z2YS6Q9kr_NCC)Cogtw)@nB8L>+9TXWK7zIoH7Xsidc08)D(bFxQF(6`?m$!^Dv&LS RVAM9-4k^=XpuPFly04YR&td=o From a0f5cd054b65a591c3774d34f5cf69e1525933be Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Thu, 18 May 2023 20:43:27 +0530 Subject: [PATCH 02/19] feat: add utilty method to call contract method --- tests/xcm-simulator/src/mocks/mod.rs | 45 ++++++++++++++++++- tests/xcm-simulator/src/tests/experimental.rs | 23 +++------- 2 files changed, 48 insertions(+), 20 deletions(-) diff --git a/tests/xcm-simulator/src/mocks/mod.rs b/tests/xcm-simulator/src/mocks/mod.rs index 336233d592..a70b83fd05 100644 --- a/tests/xcm-simulator/src/mocks/mod.rs +++ b/tests/xcm-simulator/src/mocks/mod.rs @@ -22,7 +22,9 @@ pub(crate) mod relay_chain; use frame_support::traits::{Currency, IsType, OnFinalize, OnInitialize}; use frame_support::weights::Weight; -use pallet_contracts_primitives::Code; +use pallet_contracts::Determinism; +use pallet_contracts_primitives::{Code, ReturnFlags}; +use parity_scale_codec::Decode; use sp_runtime::traits::{Bounded, Hash, StaticLookup}; use sp_runtime::DispatchResult; use xcm::latest::prelude::*; @@ -80,7 +82,6 @@ pub type RelayChainPalletXcm = pallet_xcm::Pallet; pub type ParachainPalletXcm = pallet_xcm::Pallet; pub type ParachainAssets = pallet_assets::Pallet; pub type ParachainBalances = pallet_balances::Pallet; -pub type ParachainContracts = pallet_contracts::Pallet; pub type ParachainXtokens = orml_xtokens::Pallet; pub fn parent_account_id() -> parachain::AccountId { @@ -305,3 +306,43 @@ pub fn deploy_contract( ); (result.account_id, hash) } + +/// Call the wasm contract method and returns the decoded return +/// values along with return flags and consumed weight +pub fn call_contract_method( + origin: T::AccountId, + dest: T::AccountId, + value: ContractBalanceOf, + gas_limit: Weight, + storage_deposit_limit: Option>, + data: Vec, + debug: bool, +) -> (V, ReturnFlags, Weight) { + let outcome = pallet_contracts::Pallet::::bare_call( + origin, + dest, + value, + gas_limit, + storage_deposit_limit, + data, + debug, + Determinism::Deterministic, + ); + + if debug { + println!( + "Contract debug - {:?}", + String::from_utf8(outcome.debug_message.clone()) + ); + } + + let res = outcome.result.unwrap(); + // check for revert + assert!(!res.did_revert(), "Contract reverted!"); + + ( + V::decode(&mut res.data.as_ref()).unwrap(), + res.flags, + outcome.gas_consumed, + ) +} diff --git a/tests/xcm-simulator/src/tests/experimental.rs b/tests/xcm-simulator/src/tests/experimental.rs index 835ac7097a..e9d3885224 100644 --- a/tests/xcm-simulator/src/tests/experimental.rs +++ b/tests/xcm-simulator/src/tests/experimental.rs @@ -23,8 +23,7 @@ use crate::mocks::{ }; use frame_support::{assert_ok, weights::Weight}; -use pallet_contracts::Determinism; -use parity_scale_codec::{Decode, Encode}; +use parity_scale_codec::Encode; use sp_runtime::traits::Bounded; use xcm::{prelude::*, v3::Response}; use xcm_simulator::TestExt; @@ -183,7 +182,7 @@ fn xcm_remote_transact_contract() { ); // check for flip status - let outcome = ParachainContracts::bare_call( + let (res, _, _) = call_contract_method::>( ALICE.into(), contract_id.clone(), 0, @@ -191,14 +190,8 @@ fn xcm_remote_transact_contract() { None, SELECTOR_GET.to_vec(), true, - Determinism::Deterministic, ); - let res = outcome.result.unwrap(); - // check for revert - assert!(!res.did_revert()); - // decode the return value - let flag = Result::::decode(&mut res.data.as_ref()).unwrap(); - assert_eq!(flag, Ok(true)); + assert_eq!(res, Ok(true)); }); ParaB::execute_with(|| { @@ -235,7 +228,7 @@ fn xcm_remote_transact_contract() { // check for flip status, it should be false ParaA::execute_with(|| { - let outcome = ParachainContracts::bare_call( + let (res, _, _) = call_contract_method::>( ALICE.into(), contract_id.clone(), 0, @@ -243,13 +236,7 @@ fn xcm_remote_transact_contract() { None, SELECTOR_GET.to_vec(), true, - Determinism::Deterministic, ); - let res = outcome.result.unwrap(); - // check for revert - assert!(res.did_revert() == false); - // decode the return value, it should be false - let flag = Result::::decode(&mut res.data.as_ref()).unwrap(); - assert_eq!(flag, Ok(false)); + assert_eq!(res, Ok(false)); }); } From 60bcb336b51670d6679010869cec3de15f7d0751 Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Thu, 18 May 2023 20:44:01 +0530 Subject: [PATCH 03/19] feat: build.rs for compiling ink! contracts --- Cargo.lock | 98 +++++++++++- tests/xcm-simulator/.gitignore | 1 + tests/xcm-simulator/Cargo.toml | 9 ++ tests/xcm-simulator/build.rs | 140 ++++++++++++++++++ .../contracts/flipper/.gitignore | 9 ++ .../contracts/flipper/Cargo.toml | 24 +++ tests/xcm-simulator/contracts/flipper/lib.rs | 36 +++++ 7 files changed, 315 insertions(+), 2 deletions(-) create mode 100644 tests/xcm-simulator/.gitignore create mode 100644 tests/xcm-simulator/build.rs create mode 100755 tests/xcm-simulator/contracts/flipper/.gitignore create mode 100755 tests/xcm-simulator/contracts/flipper/Cargo.toml create mode 100755 tests/xcm-simulator/contracts/flipper/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 4a6d329249..71a856bdcf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1300,6 +1300,17 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +[[package]] +name = "colored" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" +dependencies = [ + "atty", + "lazy_static", + "winapi", +] + [[package]] name = "comfy-table" version = "6.1.4" @@ -1332,6 +1343,50 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" +[[package]] +name = "contract-build" +version = "2.2.1" +source = "git+https://github.com/ashutoshvarma/cargo-contract?branch=patch/fix-rustflags#95d1ad75886b6f73ac426765a6cbe022c7bd6a7a" +dependencies = [ + "anyhow", + "blake2", + "cargo_metadata", + "clap", + "colored", + "contract-metadata", + "heck", + "hex", + "impl-serde", + "parity-scale-codec", + "parity-wasm", + "rustc_version 0.4.0", + "semver 1.0.17", + "serde", + "serde_json", + "strum", + "tempfile", + "toml 0.7.3", + "tracing", + "url", + "walkdir", + "wasm-opt", + "which", + "zip", +] + +[[package]] +name = "contract-metadata" +version = "2.2.1" +source = "git+https://github.com/ashutoshvarma/cargo-contract?branch=patch/fix-rustflags#95d1ad75886b6f73ac426765a6cbe022c7bd6a7a" +dependencies = [ + "anyhow", + "impl-serde", + "semver 1.0.17", + "serde", + "serde_json", + "url", +] + [[package]] name = "convert_case" version = "0.4.0" @@ -11708,6 +11763,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4" +dependencies = [ + "serde", +] + [[package]] name = "sha-1" version = "0.9.8" @@ -13102,7 +13166,7 @@ dependencies = [ "sp-maybe-compressed-blob", "strum", "tempfile", - "toml", + "toml 0.5.11", "walkdir", "wasm-opt", ] @@ -13464,11 +13528,26 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b403acf6f2bb0859c93c7f0d967cb4a75a7ac552100f9322faf64dc047669b21" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + [[package]] name = "toml_datetime" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" @@ -13477,6 +13556,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" dependencies = [ "indexmap", + "serde", + "serde_spanned", "toml_datetime", "winnow", ] @@ -13895,6 +13976,7 @@ dependencies = [ "form_urlencoded", "idna 0.3.0", "percent-encoding", + "serde", ] [[package]] @@ -14263,7 +14345,7 @@ dependencies = [ "rustix 0.36.13", "serde", "sha2 0.10.6", - "toml", + "toml 0.5.11", "windows-sys 0.42.0", "zstd", ] @@ -15191,6 +15273,7 @@ dependencies = [ name = "xcm-simulator-tests" version = "0.1.0" dependencies = [ + "contract-build", "cumulus-pallet-xcm", "frame-support", "frame-system", @@ -15300,6 +15383,17 @@ dependencies = [ "syn 2.0.15", ] +[[package]] +name = "zip" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +dependencies = [ + "byteorder", + "crc32fast", + "crossbeam-utils", +] + [[package]] name = "zstd" version = "0.11.2+zstd.1.5.2" diff --git a/tests/xcm-simulator/.gitignore b/tests/xcm-simulator/.gitignore new file mode 100644 index 0000000000..116caa1278 --- /dev/null +++ b/tests/xcm-simulator/.gitignore @@ -0,0 +1 @@ +fixtures diff --git a/tests/xcm-simulator/Cargo.toml b/tests/xcm-simulator/Cargo.toml index bca9358688..7d4cdaded0 100644 --- a/tests/xcm-simulator/Cargo.toml +++ b/tests/xcm-simulator/Cargo.toml @@ -54,6 +54,15 @@ orml-traits = { workspace = true } orml-xcm-support = { workspace = true } orml-xtokens = { workspace = true } +[build-dependencies] +# Currently using patched version due to issue with `RUSTFLAGS` inside build script. +# cargo-build sets the `RUSTFLAGS` for adding linker flags which are not applied when +# invoking it inside a build script, thus contract compilation fails. +# Fix - use `CARGO_ENCODED_RUSTFLAGS` instead of `RUSTFLAGS` +# https://github.com/rust-lang/cargo/issues/10111 +# TODO: remove this once it is merged in upstream +contract-build = { git = "https://github.com/ashutoshvarma/cargo-contract", branch = "patch/fix-rustflags" } + [features] default = ["std"] std = [ diff --git a/tests/xcm-simulator/build.rs b/tests/xcm-simulator/build.rs new file mode 100644 index 0000000000..98de242590 --- /dev/null +++ b/tests/xcm-simulator/build.rs @@ -0,0 +1,140 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. If not, see . + +/// build.rs +/// Compile and copy the contract artifacts to be used as fixture +/// in tests +use std::{ + fs, + path::{Path, PathBuf}, +}; + +use contract_build::{ + BuildArtifacts, BuildMode, Features, ManifestPath, Network, OptimizationPasses, OutputType, + Target, UnstableFlags, Verbosity, +}; + +const DEFAULT_FIXTURES_DIR: &'static str = "./fixtures"; +const DEFAULT_CONTRACTS_DIR: &'static str = "./contracts"; + +/// Execute the clousre with given directory as current dir +fn with_directory T>(dir: &Path, f: F) -> T { + let curr_dir = std::env::current_dir().unwrap(); + + std::env::set_current_dir(dir).unwrap(); + let res = f(); + std::env::set_current_dir(curr_dir).unwrap(); + + res +} + +/// Build config for adjusting the ink! contract compilation +struct BuildConfig { + /// Directory where artifacts will be copied to after compilation + fixtures_dir: PathBuf, + /// Directory where individual contract are present, each on it's own sub-directory + contracts_dir: PathBuf, + is_verbose: bool, + /// Whether to build the metadata json along with WASM blob + build_metadata: bool, + /// Skip Wasm post build validation + skip_wasm_validation: bool, +} + +impl BuildConfig { + fn from_env() -> Self { + Self { + fixtures_dir: PathBuf::from( + std::env::var("CB_FIXTURES_DIR").unwrap_or(DEFAULT_FIXTURES_DIR.to_string()), + ), + contracts_dir: PathBuf::from( + std::env::var("CB_CONTRACTS_DIR").unwrap_or(DEFAULT_CONTRACTS_DIR.to_string()), + ), + is_verbose: std::env::var("CB_BUILD_VERBOSE").is_ok(), + build_metadata: std::env::var("CB_BUILD_METADATA").is_ok(), + skip_wasm_validation: std::env::var("CB_SKIP_WASM_VALIDATION").is_ok(), + } + } +} + +/// Build the contracts and copy the artifacts to fixtures dir +fn build_contracts(config: &BuildConfig, contacts: Vec<&str>) { + for contract in contacts { + let dir = &config.contracts_dir.join(contract); + println!("[build.rs] Building Contract - {contract}"); + let build = with_directory(dir, || { + let manifest_path = ManifestPath::new("Cargo.toml").unwrap(); + let verbosity = if config.is_verbose { + Verbosity::Verbose + } else { + Verbosity::Default + }; + let build_artifact = if config.build_metadata { + BuildArtifacts::All + } else { + BuildArtifacts::CodeOnly + }; + let args = contract_build::ExecuteArgs { + manifest_path, + verbosity, + build_artifact, + skip_wasm_validation: config.skip_wasm_validation, + build_mode: BuildMode::Debug, + features: Features::default(), + network: Network::Online, + unstable_flags: UnstableFlags::default(), + optimization_passes: Some(OptimizationPasses::default()), + keep_debug_symbols: true, + lint: false, + output_type: OutputType::HumanReadable, + target: Target::Wasm, + }; + contract_build::execute(args).expect(&format!("Failed to build contract at - {dir:?}")) + }); + + // copy wasm artifact + fs::copy( + build.dest_wasm.unwrap(), + config.fixtures_dir.join(format!("{contract}.wasm")), + ) + .unwrap(); + + // copy metadata + if let Some(res) = build.metadata_result { + fs::copy( + res.dest_metadata, + config.fixtures_dir.join(format!("{contract}.json")), + ) + .unwrap(); + } + } +} + +fn main() { + let config = BuildConfig::from_env(); + // create fixtures dir if not exists + fs::create_dir_all(&config.fixtures_dir).unwrap(); + + // build all the contracts + build_contracts(&config, ["flipper"].to_vec()); + + println!( + "cargo:rerun-if-changed={}", + config.contracts_dir.to_str().unwrap() + ); +} diff --git a/tests/xcm-simulator/contracts/flipper/.gitignore b/tests/xcm-simulator/contracts/flipper/.gitignore new file mode 100755 index 0000000000..8de8f877e4 --- /dev/null +++ b/tests/xcm-simulator/contracts/flipper/.gitignore @@ -0,0 +1,9 @@ +# Ignore build artifacts from the local tests sub-crate. +/target/ + +# Ignore backup files creates by cargo fmt. +**/*.rs.bk + +# Remove Cargo.lock when creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/tests/xcm-simulator/contracts/flipper/Cargo.toml b/tests/xcm-simulator/contracts/flipper/Cargo.toml new file mode 100755 index 0000000000..de1c760b79 --- /dev/null +++ b/tests/xcm-simulator/contracts/flipper/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "flipper" +version = "0.1.0" +authors = ["Ashutosh Varma "] +edition = "2021" + +[dependencies] +ink = { version = "~4.2.0", default-features = false } +scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } +scale-info = { version = "2.6", default-features = false, features = ["derive"], optional = true } + +[lib] +path = "lib.rs" + +[features] +default = ["std"] +std = [ + "ink/std", + "scale/std", + "scale-info/std", +] +ink-as-dependency = [] + +[workspace] diff --git a/tests/xcm-simulator/contracts/flipper/lib.rs b/tests/xcm-simulator/contracts/flipper/lib.rs new file mode 100755 index 0000000000..0a062a6d06 --- /dev/null +++ b/tests/xcm-simulator/contracts/flipper/lib.rs @@ -0,0 +1,36 @@ +#![cfg_attr(not(feature = "std"), no_std, no_main)] + +#[ink::contract] +mod flipper { + + /// Defines the storage of your contract. + /// Add new fields to the below struct in order + /// to add new static storage fields to your contract. + #[ink(storage)] + pub struct Flipper { + /// Stores a single `bool` value on the storage. + value: bool, + } + + impl Flipper { + /// Constructor that initializes the `bool` value to the given `init_value`. + #[ink(constructor)] + pub fn new(init_value: bool) -> Self { + Self { value: init_value } + } + + /// A message that can be called on instantiated contracts. + /// This one flips the value of the stored `bool` from `true` + /// to `false` and vice versa. + #[ink(message)] + pub fn flip(&mut self) { + self.value = !self.value; + } + + /// Simply returns the current value of our `bool`. + #[ink(message)] + pub fn get(&self) -> bool { + self.value + } + } +} From 92fa3adf05756c2bdab5030fd0f2c890c8189c73 Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Fri, 19 May 2023 09:50:28 +0530 Subject: [PATCH 04/19] fix: ci build issues --- rust-toolchain.toml | 2 +- tests/xcm-simulator/contracts/flipper/lib.rs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index e01bdaaafd..5b3d02f2f6 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] channel = "nightly-2023-01-10" -components = ["rustfmt", "clippy"] +components = ["rustfmt", "clippy", "rust-src"] targets = ["wasm32-unknown-unknown"] profile = "minimal" diff --git a/tests/xcm-simulator/contracts/flipper/lib.rs b/tests/xcm-simulator/contracts/flipper/lib.rs index 0a062a6d06..04704cc858 100755 --- a/tests/xcm-simulator/contracts/flipper/lib.rs +++ b/tests/xcm-simulator/contracts/flipper/lib.rs @@ -1,3 +1,21 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. If not, see . + #![cfg_attr(not(feature = "std"), no_std, no_main)] #[ink::contract] From 965f42a41dedd09d3c08937ee132a1cbd18eba36 Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Sat, 20 May 2023 22:48:12 +0530 Subject: [PATCH 05/19] feat: add async xcm ink! contract fixture --- tests/xcm-simulator/build.rs | 2 +- .../contracts/async-xcm-call-no-ce/.gitignore | 9 + .../contracts/async-xcm-call-no-ce/Cargo.toml | 30 +++ .../contracts/async-xcm-call-no-ce/lib.rs | 217 ++++++++++++++++++ 4 files changed, 257 insertions(+), 1 deletion(-) create mode 100755 tests/xcm-simulator/contracts/async-xcm-call-no-ce/.gitignore create mode 100755 tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml create mode 100755 tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs diff --git a/tests/xcm-simulator/build.rs b/tests/xcm-simulator/build.rs index 98de242590..7058261ac7 100644 --- a/tests/xcm-simulator/build.rs +++ b/tests/xcm-simulator/build.rs @@ -131,7 +131,7 @@ fn main() { fs::create_dir_all(&config.fixtures_dir).unwrap(); // build all the contracts - build_contracts(&config, ["flipper"].to_vec()); + build_contracts(&config, ["flipper", "async-xcm-call-no-ce"].to_vec()); println!( "cargo:rerun-if-changed={}", diff --git a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/.gitignore b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/.gitignore new file mode 100755 index 0000000000..8de8f877e4 --- /dev/null +++ b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/.gitignore @@ -0,0 +1,9 @@ +# Ignore build artifacts from the local tests sub-crate. +/target/ + +# Ignore backup files creates by cargo fmt. +**/*.rs.bk + +# Remove Cargo.lock when creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml new file mode 100755 index 0000000000..c01d259286 --- /dev/null +++ b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "contract" +version = "0.1.0" +authors = ["Ashutosh Varma "] +edition = "2021" + +[dependencies] +ink = { version = "~4.2.0", default-features = false, features = ["call-runtime"] } +scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } +scale-info = { version = "2.6", default-features = false, features = ["derive"], optional = true } +xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.39", default-features = false } + +[lib] +path = "lib.rs" + +[features] +default = ["std"] +std = [ + "ink/std", + "scale/std", + "scale-info/std", + "xcm/std", +] +ink-as-dependency = [] + + +[profile.release] +overflow-checks = false + +[workspace] diff --git a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs new file mode 100755 index 0000000000..6b7d39ed33 --- /dev/null +++ b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs @@ -0,0 +1,217 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar 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. + +// Astar 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 Astar. If not, see . + +#![cfg_attr(not(feature = "std"), no_std, no_main)] + +use async_xcm_call_no_ce::*; +use ink::codegen::Env; +use ink::prelude::{boxed::Box, vec, vec::Vec}; +use scale::{Decode, Encode}; +use xcm::{prelude::*, v3::Weight}; + +mod foreign { + use super::*; + + #[derive(scale::Encode)] + pub enum RuntimeCall { + #[codec(index = 0)] + System(SystemCall), + #[codec(index = 3)] + PolkadotXcm(PolkadotXcmCall), + } + + #[derive(scale::Encode)] + pub enum SystemCall { + #[codec(index = 7)] + RemarkWithEvent { remark: Vec }, + } + + #[derive(scale::Encode)] + pub enum PolkadotXcmCall { + #[codec(index = 0)] + Send { + dest: Box, + message: Box>, + }, + } +} + +mod here { + use super::*; + use ink::primitives::AccountId; + + #[derive(scale::Encode)] + pub enum RuntimeCall { + #[codec(index = 3)] + PolkadotXcm(PolkadotXcmCall), + #[codec(index = 12)] + Contracts(ContractsCall), + } + + #[derive(scale::Encode)] + pub enum PolkadotXcmCall { + #[codec(index = 0)] + Send { + dest: Box, + message: Box>, + }, + } + + #[derive(scale::Encode)] + pub enum ContractsCall { + #[codec(index = 6u8)] + Call { + dest: AccountId, + #[codec(compact)] + value: u128, + gas_limit: Weight, + storage_deposit_limit: Option<::Type>, + data: Vec, + }, + } +} + +#[ink::contract] +mod async_xcm_call_no_ce { + use super::*; + + #[ink(storage)] + #[derive(Default)] + pub struct AsyncCall { + pub result: Option, + pub here_para_id: u32, + } + + #[derive(Encode, Decode, Debug, Clone)] + #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] + pub struct WeightsAndFees { + pub foreign_base_fee: MultiAsset, + pub foreign_transact_weight: Weight, + pub foreign_transcat_pallet_xcm: Weight, + pub here_callback_base_fee: MultiAsset, + pub here_callback_transact_weight: Weight, + pub here_callback_contract_weight: Weight, + } + + impl AsyncCall { + #[ink(constructor, selector = 0x00001111)] + pub fn new(here_para_id: u32) -> Self { + Self { + result: None, + here_para_id, + } + } + + #[ink(message, selector = 0x00002222)] + pub fn attempt_remark_via_xcm( + &mut self, + parachain_id: u32, + remark: Vec, + weight_and_fees: WeightsAndFees, + ) -> bool { + ink::env::debug_println!("[1/2] Start of attempt_remark_via_xcm"); + + let dest: Box = + Box::new((Parent, Parachain(parachain_id)).into()); + let message: Box> = + Box::new(VersionedXcm::V3(self.build_xcm(remark, &weight_and_fees))); + + ink::env::debug_println!("[2/2] XCM Build successfully, sending..."); + + self.env() + .call_runtime(&here::RuntimeCall::PolkadotXcm( + here::PolkadotXcmCall::Send { dest, message }, + )) + .is_ok() + } + + #[ink(message, selector = 0x0000BBBB)] + pub fn handle_response(&mut self, success: bool) { + ink::env::debug_println!("[1/1] Inside handle_response..."); + + self.result = Some(success); + } + + #[ink(message, selector = 0x0000CCCC)] + pub fn result(&self) -> Option { + self.result + } + } +} + +impl AsyncCall { + fn build_callback_sequence(&self, success: bool, weight_and_fees: &WeightsAndFees) -> Xcm<()> { + let callback_xcm = Xcm(vec![ + // buy execution + WithdrawAsset(weight_and_fees.here_callback_base_fee.clone().into()), + BuyExecution { + fees: weight_and_fees.here_callback_base_fee.clone(), + weight_limit: Unlimited, + }, + // transact call to contract method + Transact { + origin_kind: OriginKind::SovereignAccount, + require_weight_at_most: weight_and_fees.here_callback_transact_weight, + call: here::RuntimeCall::Contracts(here::ContractsCall::Call { + dest: self.env().account_id(), + value: 0u128, + gas_limit: weight_and_fees.here_callback_contract_weight, + storage_deposit_limit: None, + data: [[0x00, 0x00, 0xBB, 0xBB].to_vec(), success.encode()].concat(), + }) + .encode() + .into(), + }, + ExpectTransactStatus(MaybeErrorCode::Success), + ]); + + Xcm(vec![Transact { + origin_kind: OriginKind::SovereignAccount, + require_weight_at_most: weight_and_fees.foreign_transcat_pallet_xcm, + call: foreign::RuntimeCall::PolkadotXcm(foreign::PolkadotXcmCall::Send { + dest: Box::new((Parent, Parachain(self.here_para_id)).into()), + message: Box::new(VersionedXcm::V3(callback_xcm)), + }) + .encode() + .into(), + }]) + } + + fn build_xcm(&self, remark: Vec, weight_and_fees: &WeightsAndFees) -> Xcm<()> { + Xcm(vec![ + // buy execution + WithdrawAsset(weight_and_fees.foreign_base_fee.clone().into()), + BuyExecution { + fees: weight_and_fees.foreign_base_fee.clone(), + weight_limit: Unlimited, + }, + // set on error handler + SetErrorHandler(self.build_callback_sequence(false, weight_and_fees)), + // set on success handler + SetAppendix(self.build_callback_sequence(true, weight_and_fees)), + // perform operation - remark + Transact { + origin_kind: OriginKind::SovereignAccount, + require_weight_at_most: weight_and_fees.foreign_transact_weight, + call: foreign::RuntimeCall::System(foreign::SystemCall::RemarkWithEvent { remark }) + .encode() + .into(), + }, + ]) + } +} From cc192cdc885c74102ccd20574c56c64e53f4d16c Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Sat, 20 May 2023 22:48:35 +0530 Subject: [PATCH 06/19] feat: add async xcm experimental scenario --- tests/xcm-simulator/src/mocks/mod.rs | 3 +- tests/xcm-simulator/src/mocks/parachain.rs | 4 +- tests/xcm-simulator/src/tests/experimental.rs | 127 ++++++++++++++++++ 3 files changed, 131 insertions(+), 3 deletions(-) diff --git a/tests/xcm-simulator/src/mocks/mod.rs b/tests/xcm-simulator/src/mocks/mod.rs index a70b83fd05..d9d37f83e5 100644 --- a/tests/xcm-simulator/src/mocks/mod.rs +++ b/tests/xcm-simulator/src/mocks/mod.rs @@ -331,9 +331,10 @@ pub fn call_contract_method( if debug { println!( - "Contract debug - {:?}", + "Contract debug buffer - {:?}", String::from_utf8(outcome.debug_message.clone()) ); + println!("Contract outcome - {outcome:?}"); } let res = outcome.result.unwrap(); diff --git a/tests/xcm-simulator/src/mocks/parachain.rs b/tests/xcm-simulator/src/mocks/parachain.rs index 2ab1f7eb81..4a9be33275 100644 --- a/tests/xcm-simulator/src/mocks/parachain.rs +++ b/tests/xcm-simulator/src/mocks/parachain.rs @@ -230,7 +230,7 @@ impl pallet_contracts::Config for Runtime { /// and make sure they are stable. Dispatchables exposed to contracts are not allowed to /// change because that would break already deployed contracts. The `Call` structure itself /// is not allowed to change the indices of existing pallets, too. - type CallFilter = Nothing; + type CallFilter = Everything; type DepositPerItem = DepositPerItem; type DepositPerByte = DepositPerByte; type CallStack = [pallet_contracts::Frame; 5]; @@ -244,7 +244,7 @@ impl pallet_contracts::Config for Runtime { type AddressGenerator = pallet_contracts::DefaultAddressGenerator; type MaxCodeLen = ConstU32<{ 123 * 1024 }>; type MaxStorageKeyLen = ConstU32<128>; - type UnsafeUnstableInterface = ConstBool; + type UnsafeUnstableInterface = ConstBool; type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; } diff --git a/tests/xcm-simulator/src/tests/experimental.rs b/tests/xcm-simulator/src/tests/experimental.rs index e9d3885224..8ead45be80 100644 --- a/tests/xcm-simulator/src/tests/experimental.rs +++ b/tests/xcm-simulator/src/tests/experimental.rs @@ -240,3 +240,130 @@ fn xcm_remote_transact_contract() { assert_eq!(res, Ok(false)); }); } + +#[test] +fn test_async_xcm_contract_call_no_ce() { + #[derive(Encode, Debug, Clone)] + pub struct WeightsAndFees { + pub foreign_base_fee: MultiAsset, + pub foreign_transact_weight: Weight, + pub foreign_transcat_pallet_xcm: Weight, + pub here_callback_base_fee: MultiAsset, + pub here_callback_transact_weight: Weight, + pub here_callback_contract_weight: Weight, + } + + const CONSTRUCTOR_SELECTOR: [u8; 4] = [0x00, 0x00, 0x11, 0x11]; + const ATTEMPT_REMARK_SELECTOR: [u8; 4] = [0x00, 0x00, 0x22, 0x22]; + const RESULT_REMARK_SELECTOR: [u8; 4] = [0x00, 0x00, 0xCC, 0xCC]; + + // + // Setup + // + let contract_id = ParaA::execute_with(|| { + // deploy contract + let (contract_id, _) = deploy_contract::( + "async-xcm-call-no-ce", + ALICE.into(), + 0, + GAS_LIMIT, + None, + [CONSTRUCTOR_SELECTOR.to_vec(), 1.encode()].concat(), + ); + + // topup soverigin account of contract's derieve account in ParaB + assert_ok!(ParachainBalances::set_balance( + parachain::RuntimeOrigin::root(), + sibling_para_account_account_id( + 2, + sibling_para_account_account_id(1, contract_id.clone()) + ), + INITIAL_BALANCE, + 100_000 + )); + + contract_id + }); + + ParaB::execute_with(|| { + // topup contract's ParaB derieve account + assert_ok!(ParachainBalances::set_balance( + parachain::RuntimeOrigin::root(), + sibling_para_account_account_id(1, contract_id.clone()), + INITIAL_BALANCE, + 100_000 + )); + }); + + // + // Send the XCM + // + ParaA::execute_with(|| { + assert_eq!( + call_contract_method::>( + ALICE.into(), + contract_id.clone(), + 0, + Weight::max_value(), + None, + [ + ATTEMPT_REMARK_SELECTOR.to_vec(), + 2u32.encode(), + [1u8, 2u8, 3u8].to_vec().encode(), + WeightsAndFees { + foreign_base_fee: (Here, 100_000_000_000_000_000_000_u128).into(), + foreign_transact_weight: Weight::from_parts(7_800_000, 0), + foreign_transcat_pallet_xcm: Weight::from_parts( + 2_000_000_000_000, + 3 * 1024 * 1024 + ), + here_callback_base_fee: (Here, 100_000_000_000_000_000_u128).into(), + here_callback_contract_weight: Weight::from_parts( + 400_000_000_000, + 1024 * 1024, + ), + here_callback_transact_weight: Weight::from_parts( + 500_000_000_000, + 2 * 1024 * 1024 + ), + } + .encode(), + ] + .concat(), + true, + ) + .0, + Ok(true) + ); + }); + + // check for if remark was executed in ParaB + ParaB::execute_with(|| { + use parachain::{RuntimeEvent, System}; + // check remark events + assert!(System::events().iter().any(|r| matches!( + r.event, + RuntimeEvent::System(frame_system::Event::Remarked { .. }) + ))); + + // clear the events + System::reset_events(); + }); + + // Check for contract method called + ParaA::execute_with(|| { + assert_eq!( + call_contract_method::, ()>>( + ALICE.into(), + contract_id.clone(), + 0, + GAS_LIMIT, + None, + RESULT_REMARK_SELECTOR.to_vec(), + true, + ) + .0, + Ok(Some(true)) + ); + }); +} From 45ffe6adda9d70d5b8d3a1686ba98c641133b04c Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Sun, 21 May 2023 08:48:05 +0530 Subject: [PATCH 07/19] feat: add call filter to allow `pallet_xcm:send` only --- tests/xcm-simulator/src/mocks/parachain.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/xcm-simulator/src/mocks/parachain.rs b/tests/xcm-simulator/src/mocks/parachain.rs index 4a9be33275..15e45f2139 100644 --- a/tests/xcm-simulator/src/mocks/parachain.rs +++ b/tests/xcm-simulator/src/mocks/parachain.rs @@ -23,8 +23,8 @@ use frame_support::{ dispatch::DispatchClass, match_types, parameter_types, traits::{ - AsEnsureOriginWithArg, ConstU128, ConstU32, ConstU64, Currency, Everything, Imbalance, - InstanceFilter, Nothing, OnUnbalanced, + AsEnsureOriginWithArg, ConstU128, ConstU32, ConstU64, Contains, Currency, Everything, + Imbalance, InstanceFilter, Nothing, OnUnbalanced, }, weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, WEIGHT_REF_TIME_PER_SECOND}, @@ -218,6 +218,18 @@ impl Convert for Runtime { } } +pub struct CallFilter; +impl Contains for CallFilter { + fn contains(call: &RuntimeCall) -> bool { + match call { + // allow pallet_xcm::send() + RuntimeCall::PolkadotXcm(pallet_xcm::Call::send { .. }) => true, + // no other calls allowed + _ => false, + } + } +} + impl pallet_contracts::Config for Runtime { type Time = Timestamp; type Randomness = Randomness; @@ -230,7 +242,7 @@ impl pallet_contracts::Config for Runtime { /// and make sure they are stable. Dispatchables exposed to contracts are not allowed to /// change because that would break already deployed contracts. The `Call` structure itself /// is not allowed to change the indices of existing pallets, too. - type CallFilter = Everything; + type CallFilter = CallFilter; type DepositPerItem = DepositPerItem; type DepositPerByte = DepositPerByte; type CallStack = [pallet_contracts::Frame; 5]; From d4cd4108e42bc5b3a2071f6a067a2eac245d5f59 Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Sun, 21 May 2023 08:48:43 +0530 Subject: [PATCH 08/19] docs: add comments --- .../contracts/async-xcm-call-no-ce/Cargo.toml | 1 - .../contracts/async-xcm-call-no-ce/lib.rs | 25 ++++++++++++++++--- tests/xcm-simulator/src/tests/experimental.rs | 15 +++++++++-- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml index c01d259286..c1fc125610 100755 --- a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml +++ b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml @@ -23,7 +23,6 @@ std = [ ] ink-as-dependency = [] - [profile.release] overflow-checks = false diff --git a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs index 6b7d39ed33..c2b213c4ea 100755 --- a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs +++ b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs @@ -24,6 +24,8 @@ use ink::prelude::{boxed::Box, vec, vec::Vec}; use scale::{Decode, Encode}; use xcm::{prelude::*, v3::Weight}; +/// +/// Foreign parachain types mod foreign { use super::*; @@ -51,6 +53,7 @@ mod foreign { } } +/// parachain types mod here { use super::*; use ink::primitives::AccountId; @@ -93,18 +96,32 @@ mod async_xcm_call_no_ce { #[ink(storage)] #[derive(Default)] pub struct AsyncCall { + /// store the result of async XCM operation pub result: Option, + /// Parachain's Id on which contract is deployed pub here_para_id: u32, } + + /// All the fees and weights values required for the whole + /// operation. #[derive(Encode, Decode, Debug, Clone)] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] pub struct WeightsAndFees { + /// Max fee for whole XCM operation in foreign chain + /// This includes fees for sending XCM back to original + /// chain via Transact(pallet_xcm::send). pub foreign_base_fee: MultiAsset, + /// Max weight for operation (remark) pub foreign_transact_weight: Weight, + /// Max weight for Transact(pallet_xcm::send) operation pub foreign_transcat_pallet_xcm: Weight, + /// Max fee for the callback operation + /// send by foreign chain pub here_callback_base_fee: MultiAsset, + /// Max weight for Transact(pallet_contracts::call) pub here_callback_transact_weight: Weight, + /// Max weight for contract call pub here_callback_contract_weight: Weight, } @@ -117,6 +134,8 @@ mod async_xcm_call_no_ce { } } + /// Attempt to perform remark operation on given parachain by + /// sending a XCM using `call_runtime`. #[ink(message, selector = 0x00002222)] pub fn attempt_remark_via_xcm( &mut self, @@ -140,14 +159,14 @@ mod async_xcm_call_no_ce { .is_ok() } - #[ink(message, selector = 0x0000BBBB)] + #[ink(message, selector = 0x00003333)] pub fn handle_response(&mut self, success: bool) { ink::env::debug_println!("[1/1] Inside handle_response..."); self.result = Some(success); } - #[ink(message, selector = 0x0000CCCC)] + #[ink(message, selector = 0x00004444)] pub fn result(&self) -> Option { self.result } @@ -172,7 +191,7 @@ impl AsyncCall { value: 0u128, gas_limit: weight_and_fees.here_callback_contract_weight, storage_deposit_limit: None, - data: [[0x00, 0x00, 0xBB, 0xBB].to_vec(), success.encode()].concat(), + data: [[0x00, 0x00, 0x33, 0x33].to_vec(), success.encode()].concat(), }) .encode() .into(), diff --git a/tests/xcm-simulator/src/tests/experimental.rs b/tests/xcm-simulator/src/tests/experimental.rs index 8ead45be80..66a29d5cb5 100644 --- a/tests/xcm-simulator/src/tests/experimental.rs +++ b/tests/xcm-simulator/src/tests/experimental.rs @@ -243,19 +243,30 @@ fn xcm_remote_transact_contract() { #[test] fn test_async_xcm_contract_call_no_ce() { - #[derive(Encode, Debug, Clone)] + /// All the fees and weights values required for the whole + /// operation. + #[derive(Encode)] pub struct WeightsAndFees { + /// Max fee for whole XCM operation in foreign chain + /// This includes fees for sending XCM back to original + /// chain via Transact(pallet_xcm::send). pub foreign_base_fee: MultiAsset, + /// Max weight for operation (remark) pub foreign_transact_weight: Weight, + /// Max weight for Transact(pallet_xcm::send) operation pub foreign_transcat_pallet_xcm: Weight, + /// Max fee for the callback operation + /// send by foreign chain pub here_callback_base_fee: MultiAsset, + /// Max weight for Transact(pallet_contracts::call) pub here_callback_transact_weight: Weight, + /// Max weight for contract call pub here_callback_contract_weight: Weight, } const CONSTRUCTOR_SELECTOR: [u8; 4] = [0x00, 0x00, 0x11, 0x11]; const ATTEMPT_REMARK_SELECTOR: [u8; 4] = [0x00, 0x00, 0x22, 0x22]; - const RESULT_REMARK_SELECTOR: [u8; 4] = [0x00, 0x00, 0xCC, 0xCC]; + const RESULT_REMARK_SELECTOR: [u8; 4] = [0x00, 0x00, 0x44, 0x44]; // // Setup From b5b228c6d3e5acd933ac89a9064af41cbe481c27 Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Sun, 21 May 2023 13:14:19 +0530 Subject: [PATCH 09/19] fix: make clippy happy --- tests/xcm-simulator/Cargo.toml | 1 + tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/xcm-simulator/Cargo.toml b/tests/xcm-simulator/Cargo.toml index 7d4cdaded0..90d97e304c 100644 --- a/tests/xcm-simulator/Cargo.toml +++ b/tests/xcm-simulator/Cargo.toml @@ -102,4 +102,5 @@ runtime-benchmarks = [ "xcm-executor/runtime-benchmarks", "polkadot-runtime-parachains/runtime-benchmarks", "polkadot-parachain/runtime-benchmarks", + "orml-xtokens/runtime-benchmarks" ] diff --git a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs index c2b213c4ea..1b0375d0e9 100755 --- a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs +++ b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs @@ -17,6 +17,7 @@ // along with Astar. If not, see . #![cfg_attr(not(feature = "std"), no_std, no_main)] +#![allow(clippy::large_enum_variant)] use async_xcm_call_no_ce::*; use ink::codegen::Env; From e148ddf271577b4e36662afe4b9ec820c235a384 Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Sun, 21 May 2023 21:13:15 +0530 Subject: [PATCH 10/19] fix: make clippy happy again --- tests/xcm-simulator/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/xcm-simulator/Cargo.toml b/tests/xcm-simulator/Cargo.toml index 90d97e304c..c8f0351c92 100644 --- a/tests/xcm-simulator/Cargo.toml +++ b/tests/xcm-simulator/Cargo.toml @@ -102,5 +102,5 @@ runtime-benchmarks = [ "xcm-executor/runtime-benchmarks", "polkadot-runtime-parachains/runtime-benchmarks", "polkadot-parachain/runtime-benchmarks", - "orml-xtokens/runtime-benchmarks" + "orml-xtokens/runtime-benchmarks", ] From 90b6ab76da970b0f133363e85524f3abaaf47ae0 Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Wed, 24 May 2023 08:17:47 +0530 Subject: [PATCH 11/19] feat: apply review suggestions --- .../contracts/async-xcm-call-no-ce/Cargo.toml | 2 +- .../contracts/async-xcm-call-no-ce/lib.rs | 33 +++++++++++++++++-- tests/xcm-simulator/src/tests/experimental.rs | 3 -- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml index c1fc125610..bbd39f5336 100755 --- a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml +++ b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "contract" +name = "async_xcm_call_contract" version = "0.1.0" authors = ["Ashutosh Varma "] edition = "2021" diff --git a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs index 1b0375d0e9..2323289a1c 100755 --- a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs +++ b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs @@ -16,6 +16,37 @@ // You should have received a copy of the GNU General Public License // along with Astar. If not, see . +//! Async XCM Call Contracrt +//! This PoC contract showcase the scenario of sending a XCM to another parachain +//! and get the results back of XCM execution, aka async operation. +//! - Contract will send below XCM to foreign parachain using `call_runtime` to perform +//! some operation (`Transact(Remark)`). +//! - If Error, a `Transact` instr will be used to send an XCM back to origin chain which +//! will call `handle_response(false)` contract method. +//! - If Success, same as above but call `handle_response(true)` method. +//! +//! ```rust +//! Xcm(vec![ +//! WithdrawAsset(..) +//! BuyExecution(..) +//! SetAppendix(Xcm(vec![ +//! Transcat { /* pallet_xcm::send() runtime call to call SUCCESS contract method in ParaA */ } +//! ])) +//! SetErrorHandler(Xcm(vec![ +//! Transcat { /* pallet_xcm::send() runtime call to call ERROR contract method in ParaA */ } +//! ])) +//! ... +//! ]) +//! ``` +//! +//! # Methods +//! - attempt_remark_via_xcm: This method when called will build the XCM call that +//! will be sent to given parachain. The XCM call will include necessary handler +//! to send the results back via calling the `handle_response` contract method +//! - handle_response: This method will be called with operation result initiated by +//! XCM by foreign parachain. +//! - result: This is a getter method to get current stored result. + #![cfg_attr(not(feature = "std"), no_std, no_main)] #![allow(clippy::large_enum_variant)] @@ -25,7 +56,6 @@ use ink::prelude::{boxed::Box, vec, vec::Vec}; use scale::{Decode, Encode}; use xcm::{prelude::*, v3::Weight}; -/// /// Foreign parachain types mod foreign { use super::*; @@ -103,7 +133,6 @@ mod async_xcm_call_no_ce { pub here_para_id: u32, } - /// All the fees and weights values required for the whole /// operation. #[derive(Encode, Decode, Debug, Clone)] diff --git a/tests/xcm-simulator/src/tests/experimental.rs b/tests/xcm-simulator/src/tests/experimental.rs index 66a29d5cb5..6f47ed74de 100644 --- a/tests/xcm-simulator/src/tests/experimental.rs +++ b/tests/xcm-simulator/src/tests/experimental.rs @@ -356,9 +356,6 @@ fn test_async_xcm_contract_call_no_ce() { r.event, RuntimeEvent::System(frame_system::Event::Remarked { .. }) ))); - - // clear the events - System::reset_events(); }); // Check for contract method called From 3133613ed8c6accce21b77db8dc8ac466e6e03fd Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Thu, 25 May 2023 12:40:33 +0530 Subject: [PATCH 12/19] lint: make clippy happy --- .../contracts/async-xcm-call-no-ce/lib.rs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs index 2323289a1c..c133c0b119 100755 --- a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs +++ b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs @@ -25,17 +25,17 @@ //! will call `handle_response(false)` contract method. //! - If Success, same as above but call `handle_response(true)` method. //! -//! ```rust +//! ```no_run //! Xcm(vec![ -//! WithdrawAsset(..) -//! BuyExecution(..) -//! SetAppendix(Xcm(vec![ -//! Transcat { /* pallet_xcm::send() runtime call to call SUCCESS contract method in ParaA */ } -//! ])) -//! SetErrorHandler(Xcm(vec![ -//! Transcat { /* pallet_xcm::send() runtime call to call ERROR contract method in ParaA */ } -//! ])) -//! ... +//! WithdrawAsset(..) +//! BuyExecution(..) +//! SetAppendix(Xcm(vec![ +//! Transcat { /* pallet_xcm::send() runtime call to call SUCCESS contract method in ParaA */ } +//! ])) +//! SetErrorHandler(Xcm(vec![ +//! Transcat { /* pallet_xcm::send() runtime call to call ERROR contract method in ParaA */ } +//! ])) +//! ... //! ]) //! ``` //! From 985d5bf05c50c04e0d28f8575e1731b376acb19c Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Thu, 1 Jun 2023 09:34:32 +0530 Subject: [PATCH 13/19] feat: update package meta for fixture contracts --- tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml | 4 +++- tests/xcm-simulator/contracts/flipper/Cargo.toml | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml index bbd39f5336..3bfa9274ed 100755 --- a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml +++ b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "async_xcm_call_contract" version = "0.1.0" -authors = ["Ashutosh Varma "] +authors = ["Stake Technologies "] edition = "2021" +homepage = "https://astar.network" +repository = "https://github.com/AstarNetwork/Astar" [dependencies] ink = { version = "~4.2.0", default-features = false, features = ["call-runtime"] } diff --git a/tests/xcm-simulator/contracts/flipper/Cargo.toml b/tests/xcm-simulator/contracts/flipper/Cargo.toml index de1c760b79..16cdfdfedd 100755 --- a/tests/xcm-simulator/contracts/flipper/Cargo.toml +++ b/tests/xcm-simulator/contracts/flipper/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "flipper" version = "0.1.0" -authors = ["Ashutosh Varma "] +authors = ["Stake Technologies "] edition = "2021" +homepage = "https://astar.network" +repository = "https://github.com/AstarNetwork/Astar" [dependencies] ink = { version = "~4.2.0", default-features = false } From b78d52ed43c59b2e794788c5b810a4da9f59be89 Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Thu, 1 Jun 2023 09:35:08 +0530 Subject: [PATCH 14/19] feat: move `contract-build` dep to workspace --- Cargo.toml | 7 +++++++ tests/xcm-simulator/Cargo.toml | 8 +------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bc5746b6d4..92772887b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -246,3 +246,10 @@ moonbeam-rpc-txpool = { git = "https://github.com/AstarNetwork/astar-frame", bra # Build deps substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.39" } substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.39" } +# Currently using patched version due to issue with `RUSTFLAGS` inside build script. +# cargo-build sets the `RUSTFLAGS` for adding linker flags which are not applied when +# invoking it inside a build script, thus contract compilation fails. +# Fix - use `CARGO_ENCODED_RUSTFLAGS` instead of `RUSTFLAGS` +# https://github.com/rust-lang/cargo/issues/10111 +# TODO: remove this once it is merged in upstream +contract-build = { git = "https://github.com/ashutoshvarma/cargo-contract", branch = "patch/fix-rustflags" } diff --git a/tests/xcm-simulator/Cargo.toml b/tests/xcm-simulator/Cargo.toml index c8f0351c92..ed8889eb38 100644 --- a/tests/xcm-simulator/Cargo.toml +++ b/tests/xcm-simulator/Cargo.toml @@ -55,13 +55,7 @@ orml-xcm-support = { workspace = true } orml-xtokens = { workspace = true } [build-dependencies] -# Currently using patched version due to issue with `RUSTFLAGS` inside build script. -# cargo-build sets the `RUSTFLAGS` for adding linker flags which are not applied when -# invoking it inside a build script, thus contract compilation fails. -# Fix - use `CARGO_ENCODED_RUSTFLAGS` instead of `RUSTFLAGS` -# https://github.com/rust-lang/cargo/issues/10111 -# TODO: remove this once it is merged in upstream -contract-build = { git = "https://github.com/ashutoshvarma/cargo-contract", branch = "patch/fix-rustflags" } +contract-build = { workspace = true } [features] default = ["std"] From 8b6f9b1b3d82bf599b8ef7836726463a2bd18ff5 Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Thu, 1 Jun 2023 09:57:46 +0530 Subject: [PATCH 15/19] feat: automatically pick contracts from contarcts_dir --- tests/xcm-simulator/build.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/xcm-simulator/build.rs b/tests/xcm-simulator/build.rs index 7058261ac7..c4f541ca22 100644 --- a/tests/xcm-simulator/build.rs +++ b/tests/xcm-simulator/build.rs @@ -20,7 +20,7 @@ /// Compile and copy the contract artifacts to be used as fixture /// in tests use std::{ - fs, + fs, io, path::{Path, PathBuf}, }; @@ -48,6 +48,7 @@ struct BuildConfig { /// Directory where artifacts will be copied to after compilation fixtures_dir: PathBuf, /// Directory where individual contract are present, each on it's own sub-directory + /// All the sub-folders inside this directory will be treated as ink! contracts. contracts_dir: PathBuf, is_verbose: bool, /// Whether to build the metadata json along with WASM blob @@ -73,11 +74,12 @@ impl BuildConfig { } /// Build the contracts and copy the artifacts to fixtures dir -fn build_contracts(config: &BuildConfig, contacts: Vec<&str>) { - for contract in contacts { - let dir = &config.contracts_dir.join(contract); +fn build_contracts(config: &BuildConfig) -> io::Result<()> { + for dir in config.contracts_dir.read_dir()? { + let dir = dir?; + let contract = dir.file_name().to_os_string().into_string().unwrap(); println!("[build.rs] Building Contract - {contract}"); - let build = with_directory(dir, || { + let build = with_directory(&dir.path(), || { let manifest_path = ManifestPath::new("Cargo.toml").unwrap(); let verbosity = if config.is_verbose { Verbosity::Verbose @@ -123,6 +125,8 @@ fn build_contracts(config: &BuildConfig, contacts: Vec<&str>) { .unwrap(); } } + + Ok(()) } fn main() { @@ -131,7 +135,7 @@ fn main() { fs::create_dir_all(&config.fixtures_dir).unwrap(); // build all the contracts - build_contracts(&config, ["flipper", "async-xcm-call-no-ce"].to_vec()); + build_contracts(&config).unwrap(); println!( "cargo:rerun-if-changed={}", From 657cccb9211899905b676acf90fd09a2c22dd72d Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Thu, 1 Jun 2023 10:11:13 +0530 Subject: [PATCH 16/19] refactor: move build contracts method to `BuildConfig` --- tests/xcm-simulator/build.rs | 103 ++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/tests/xcm-simulator/build.rs b/tests/xcm-simulator/build.rs index c4f541ca22..91ff14fd12 100644 --- a/tests/xcm-simulator/build.rs +++ b/tests/xcm-simulator/build.rs @@ -71,62 +71,63 @@ impl BuildConfig { skip_wasm_validation: std::env::var("CB_SKIP_WASM_VALIDATION").is_ok(), } } -} -/// Build the contracts and copy the artifacts to fixtures dir -fn build_contracts(config: &BuildConfig) -> io::Result<()> { - for dir in config.contracts_dir.read_dir()? { - let dir = dir?; - let contract = dir.file_name().to_os_string().into_string().unwrap(); - println!("[build.rs] Building Contract - {contract}"); - let build = with_directory(&dir.path(), || { - let manifest_path = ManifestPath::new("Cargo.toml").unwrap(); - let verbosity = if config.is_verbose { - Verbosity::Verbose - } else { - Verbosity::Default - }; - let build_artifact = if config.build_metadata { - BuildArtifacts::All - } else { - BuildArtifacts::CodeOnly - }; - let args = contract_build::ExecuteArgs { - manifest_path, - verbosity, - build_artifact, - skip_wasm_validation: config.skip_wasm_validation, - build_mode: BuildMode::Debug, - features: Features::default(), - network: Network::Online, - unstable_flags: UnstableFlags::default(), - optimization_passes: Some(OptimizationPasses::default()), - keep_debug_symbols: true, - lint: false, - output_type: OutputType::HumanReadable, - target: Target::Wasm, - }; - contract_build::execute(args).expect(&format!("Failed to build contract at - {dir:?}")) - }); - - // copy wasm artifact - fs::copy( - build.dest_wasm.unwrap(), - config.fixtures_dir.join(format!("{contract}.wasm")), - ) - .unwrap(); - - // copy metadata - if let Some(res) = build.metadata_result { + /// Build the contracts and copy the artifacts to fixtures dir + fn build_contracts(&self) -> io::Result<()> { + for dir in self.contracts_dir.read_dir()? { + let dir = dir?; + let contract = dir.file_name().to_os_string().into_string().unwrap(); + println!("[build.rs] Building Contract - {contract}"); + let build = with_directory(&dir.path(), || { + let manifest_path = ManifestPath::new("Cargo.toml").unwrap(); + let verbosity = if self.is_verbose { + Verbosity::Verbose + } else { + Verbosity::Default + }; + let build_artifact = if self.build_metadata { + BuildArtifacts::All + } else { + BuildArtifacts::CodeOnly + }; + let args = contract_build::ExecuteArgs { + manifest_path, + verbosity, + build_artifact, + skip_wasm_validation: self.skip_wasm_validation, + build_mode: BuildMode::Debug, + features: Features::default(), + network: Network::Online, + unstable_flags: UnstableFlags::default(), + optimization_passes: Some(OptimizationPasses::default()), + keep_debug_symbols: true, + lint: false, + output_type: OutputType::HumanReadable, + target: Target::Wasm, + }; + contract_build::execute(args) + .expect(&format!("Failed to build contract at - {dir:?}")) + }); + + // copy wasm artifact fs::copy( - res.dest_metadata, - config.fixtures_dir.join(format!("{contract}.json")), + build.dest_wasm.unwrap(), + self.fixtures_dir.join(format!("{contract}.wasm")), ) .unwrap(); + + // copy metadata + if let Some(res) = build.metadata_result { + fs::copy( + res.dest_metadata, + self.fixtures_dir.join(format!("{contract}.json")), + ) + .unwrap(); + } } - } - Ok(()) + Ok(()) + } } fn main() { @@ -135,7 +136,7 @@ fn main() { fs::create_dir_all(&config.fixtures_dir).unwrap(); // build all the contracts - build_contracts(&config).unwrap(); + config.build_contracts().unwrap(); println!( "cargo:rerun-if-changed={}", From af03b053d73a12ef0d104f635729325406f0ca25 Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Thu, 1 Jun 2023 10:24:04 +0530 Subject: [PATCH 17/19] docs: update readme for contract fixtures --- tests/xcm-simulator/src/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/xcm-simulator/src/README.md b/tests/xcm-simulator/src/README.md index 1e9fdc18ce..8de94b3f48 100644 --- a/tests/xcm-simulator/src/README.md +++ b/tests/xcm-simulator/src/README.md @@ -19,4 +19,8 @@ It's possible that in the future we decide to define a different runtime type (p Running tests is same as with any other unit tests: -`cargo test -p xcm-simulator-tests` \ No newline at end of file +`cargo test -p xcm-simulator-tests` + +# ink! Contract fixtures +All the contract used in XCM Scenarios should be placed in [contracts](../contracts/) dir. The [cargo build script](../build.rs) will pick them and build them before executing tests automatically. +Please refer the env variables used in build script to configure the contract building - [`build.rs`](../build.rs). From f9eeae02e2fa270ee6ff917d7214fc2585e7bcd1 Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Mon, 12 Jun 2023 09:02:46 +0530 Subject: [PATCH 18/19] feat: remove build script for contract compilation --- Cargo.lock | 98 +- Cargo.toml | 7 - tests/xcm-simulator/.gitignore | 1 - tests/xcm-simulator/Cargo.toml | 3 - tests/xcm-simulator/build.rs | 145 -- .../contracts/async-xcm-call-no-ce/.gitignore | 9 - .../contracts/async-xcm-call-no-ce/Cargo.toml | 31 - .../contracts/async-xcm-call-no-ce/lib.rs | 266 --- .../contracts/flipper/.gitignore | 9 - .../contracts/flipper/Cargo.toml | 26 - tests/xcm-simulator/contracts/flipper/lib.rs | 54 - tests/xcm-simulator/fixtures/README.md | 7 + .../fixtures/async-xcm-call-no-ce.json | 1509 +++++++++++++++++ .../fixtures/async-xcm-call-no-ce.wasm | Bin 0 -> 67578 bytes tests/xcm-simulator/fixtures/flipper.json | 383 +++++ tests/xcm-simulator/fixtures/flipper.wasm | Bin 0 -> 16765 bytes 16 files changed, 1901 insertions(+), 647 deletions(-) delete mode 100644 tests/xcm-simulator/.gitignore delete mode 100644 tests/xcm-simulator/build.rs delete mode 100755 tests/xcm-simulator/contracts/async-xcm-call-no-ce/.gitignore delete mode 100755 tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml delete mode 100755 tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs delete mode 100755 tests/xcm-simulator/contracts/flipper/.gitignore delete mode 100755 tests/xcm-simulator/contracts/flipper/Cargo.toml delete mode 100755 tests/xcm-simulator/contracts/flipper/lib.rs create mode 100644 tests/xcm-simulator/fixtures/README.md create mode 100644 tests/xcm-simulator/fixtures/async-xcm-call-no-ce.json create mode 100644 tests/xcm-simulator/fixtures/async-xcm-call-no-ce.wasm create mode 100644 tests/xcm-simulator/fixtures/flipper.json create mode 100644 tests/xcm-simulator/fixtures/flipper.wasm diff --git a/Cargo.lock b/Cargo.lock index 71a856bdcf..4a6d329249 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1300,17 +1300,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" -[[package]] -name = "colored" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" -dependencies = [ - "atty", - "lazy_static", - "winapi", -] - [[package]] name = "comfy-table" version = "6.1.4" @@ -1343,50 +1332,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" -[[package]] -name = "contract-build" -version = "2.2.1" -source = "git+https://github.com/ashutoshvarma/cargo-contract?branch=patch/fix-rustflags#95d1ad75886b6f73ac426765a6cbe022c7bd6a7a" -dependencies = [ - "anyhow", - "blake2", - "cargo_metadata", - "clap", - "colored", - "contract-metadata", - "heck", - "hex", - "impl-serde", - "parity-scale-codec", - "parity-wasm", - "rustc_version 0.4.0", - "semver 1.0.17", - "serde", - "serde_json", - "strum", - "tempfile", - "toml 0.7.3", - "tracing", - "url", - "walkdir", - "wasm-opt", - "which", - "zip", -] - -[[package]] -name = "contract-metadata" -version = "2.2.1" -source = "git+https://github.com/ashutoshvarma/cargo-contract?branch=patch/fix-rustflags#95d1ad75886b6f73ac426765a6cbe022c7bd6a7a" -dependencies = [ - "anyhow", - "impl-serde", - "semver 1.0.17", - "serde", - "serde_json", - "url", -] - [[package]] name = "convert_case" version = "0.4.0" @@ -11763,15 +11708,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_spanned" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4" -dependencies = [ - "serde", -] - [[package]] name = "sha-1" version = "0.9.8" @@ -13166,7 +13102,7 @@ dependencies = [ "sp-maybe-compressed-blob", "strum", "tempfile", - "toml 0.5.11", + "toml", "walkdir", "wasm-opt", ] @@ -13528,26 +13464,11 @@ dependencies = [ "serde", ] -[[package]] -name = "toml" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b403acf6f2bb0859c93c7f0d967cb4a75a7ac552100f9322faf64dc047669b21" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - [[package]] name = "toml_datetime" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" -dependencies = [ - "serde", -] [[package]] name = "toml_edit" @@ -13556,8 +13477,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" dependencies = [ "indexmap", - "serde", - "serde_spanned", "toml_datetime", "winnow", ] @@ -13976,7 +13895,6 @@ dependencies = [ "form_urlencoded", "idna 0.3.0", "percent-encoding", - "serde", ] [[package]] @@ -14345,7 +14263,7 @@ dependencies = [ "rustix 0.36.13", "serde", "sha2 0.10.6", - "toml 0.5.11", + "toml", "windows-sys 0.42.0", "zstd", ] @@ -15273,7 +15191,6 @@ dependencies = [ name = "xcm-simulator-tests" version = "0.1.0" dependencies = [ - "contract-build", "cumulus-pallet-xcm", "frame-support", "frame-system", @@ -15383,17 +15300,6 @@ dependencies = [ "syn 2.0.15", ] -[[package]] -name = "zip" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" -dependencies = [ - "byteorder", - "crc32fast", - "crossbeam-utils", -] - [[package]] name = "zstd" version = "0.11.2+zstd.1.5.2" diff --git a/Cargo.toml b/Cargo.toml index 92772887b4..bc5746b6d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -246,10 +246,3 @@ moonbeam-rpc-txpool = { git = "https://github.com/AstarNetwork/astar-frame", bra # Build deps substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.39" } substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.39" } -# Currently using patched version due to issue with `RUSTFLAGS` inside build script. -# cargo-build sets the `RUSTFLAGS` for adding linker flags which are not applied when -# invoking it inside a build script, thus contract compilation fails. -# Fix - use `CARGO_ENCODED_RUSTFLAGS` instead of `RUSTFLAGS` -# https://github.com/rust-lang/cargo/issues/10111 -# TODO: remove this once it is merged in upstream -contract-build = { git = "https://github.com/ashutoshvarma/cargo-contract", branch = "patch/fix-rustflags" } diff --git a/tests/xcm-simulator/.gitignore b/tests/xcm-simulator/.gitignore deleted file mode 100644 index 116caa1278..0000000000 --- a/tests/xcm-simulator/.gitignore +++ /dev/null @@ -1 +0,0 @@ -fixtures diff --git a/tests/xcm-simulator/Cargo.toml b/tests/xcm-simulator/Cargo.toml index ed8889eb38..6b375baefd 100644 --- a/tests/xcm-simulator/Cargo.toml +++ b/tests/xcm-simulator/Cargo.toml @@ -54,9 +54,6 @@ orml-traits = { workspace = true } orml-xcm-support = { workspace = true } orml-xtokens = { workspace = true } -[build-dependencies] -contract-build = { workspace = true } - [features] default = ["std"] std = [ diff --git a/tests/xcm-simulator/build.rs b/tests/xcm-simulator/build.rs deleted file mode 100644 index 91ff14fd12..0000000000 --- a/tests/xcm-simulator/build.rs +++ /dev/null @@ -1,145 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -/// build.rs -/// Compile and copy the contract artifacts to be used as fixture -/// in tests -use std::{ - fs, io, - path::{Path, PathBuf}, -}; - -use contract_build::{ - BuildArtifacts, BuildMode, Features, ManifestPath, Network, OptimizationPasses, OutputType, - Target, UnstableFlags, Verbosity, -}; - -const DEFAULT_FIXTURES_DIR: &'static str = "./fixtures"; -const DEFAULT_CONTRACTS_DIR: &'static str = "./contracts"; - -/// Execute the clousre with given directory as current dir -fn with_directory T>(dir: &Path, f: F) -> T { - let curr_dir = std::env::current_dir().unwrap(); - - std::env::set_current_dir(dir).unwrap(); - let res = f(); - std::env::set_current_dir(curr_dir).unwrap(); - - res -} - -/// Build config for adjusting the ink! contract compilation -struct BuildConfig { - /// Directory where artifacts will be copied to after compilation - fixtures_dir: PathBuf, - /// Directory where individual contract are present, each on it's own sub-directory - /// All the sub-folders inside this directory will be treated as ink! contracts. - contracts_dir: PathBuf, - is_verbose: bool, - /// Whether to build the metadata json along with WASM blob - build_metadata: bool, - /// Skip Wasm post build validation - skip_wasm_validation: bool, -} - -impl BuildConfig { - fn from_env() -> Self { - Self { - fixtures_dir: PathBuf::from( - std::env::var("CB_FIXTURES_DIR").unwrap_or(DEFAULT_FIXTURES_DIR.to_string()), - ), - contracts_dir: PathBuf::from( - std::env::var("CB_CONTRACTS_DIR").unwrap_or(DEFAULT_CONTRACTS_DIR.to_string()), - ), - is_verbose: std::env::var("CB_BUILD_VERBOSE").is_ok(), - build_metadata: std::env::var("CB_BUILD_METADATA").is_ok(), - skip_wasm_validation: std::env::var("CB_SKIP_WASM_VALIDATION").is_ok(), - } - } - - /// Build the contracts and copy the artifacts to fixtures dir - fn build_contracts(&self) -> io::Result<()> { - for dir in self.contracts_dir.read_dir()? { - let dir = dir?; - let contract = dir.file_name().to_os_string().into_string().unwrap(); - println!("[build.rs] Building Contract - {contract}"); - let build = with_directory(&dir.path(), || { - let manifest_path = ManifestPath::new("Cargo.toml").unwrap(); - let verbosity = if self.is_verbose { - Verbosity::Verbose - } else { - Verbosity::Default - }; - let build_artifact = if self.build_metadata { - BuildArtifacts::All - } else { - BuildArtifacts::CodeOnly - }; - let args = contract_build::ExecuteArgs { - manifest_path, - verbosity, - build_artifact, - skip_wasm_validation: self.skip_wasm_validation, - build_mode: BuildMode::Debug, - features: Features::default(), - network: Network::Online, - unstable_flags: UnstableFlags::default(), - optimization_passes: Some(OptimizationPasses::default()), - keep_debug_symbols: true, - lint: false, - output_type: OutputType::HumanReadable, - target: Target::Wasm, - }; - contract_build::execute(args) - .expect(&format!("Failed to build contract at - {dir:?}")) - }); - - // copy wasm artifact - fs::copy( - build.dest_wasm.unwrap(), - self.fixtures_dir.join(format!("{contract}.wasm")), - ) - .unwrap(); - - // copy metadata - if let Some(res) = build.metadata_result { - fs::copy( - res.dest_metadata, - self.fixtures_dir.join(format!("{contract}.json")), - ) - .unwrap(); - } - } - - Ok(()) - } -} - -fn main() { - let config = BuildConfig::from_env(); - // create fixtures dir if not exists - fs::create_dir_all(&config.fixtures_dir).unwrap(); - - // build all the contracts - config.build_contracts().unwrap(); - - println!( - "cargo:rerun-if-changed={}", - config.contracts_dir.to_str().unwrap() - ); -} diff --git a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/.gitignore b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/.gitignore deleted file mode 100755 index 8de8f877e4..0000000000 --- a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -# Ignore build artifacts from the local tests sub-crate. -/target/ - -# Ignore backup files creates by cargo fmt. -**/*.rs.bk - -# Remove Cargo.lock when creating an executable, leave it for libraries -# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock -Cargo.lock diff --git a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml deleted file mode 100755 index 3bfa9274ed..0000000000 --- a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/Cargo.toml +++ /dev/null @@ -1,31 +0,0 @@ -[package] -name = "async_xcm_call_contract" -version = "0.1.0" -authors = ["Stake Technologies "] -edition = "2021" -homepage = "https://astar.network" -repository = "https://github.com/AstarNetwork/Astar" - -[dependencies] -ink = { version = "~4.2.0", default-features = false, features = ["call-runtime"] } -scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } -scale-info = { version = "2.6", default-features = false, features = ["derive"], optional = true } -xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.39", default-features = false } - -[lib] -path = "lib.rs" - -[features] -default = ["std"] -std = [ - "ink/std", - "scale/std", - "scale-info/std", - "xcm/std", -] -ink-as-dependency = [] - -[profile.release] -overflow-checks = false - -[workspace] diff --git a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs b/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs deleted file mode 100755 index c133c0b119..0000000000 --- a/tests/xcm-simulator/contracts/async-xcm-call-no-ce/lib.rs +++ /dev/null @@ -1,266 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -//! Async XCM Call Contracrt -//! This PoC contract showcase the scenario of sending a XCM to another parachain -//! and get the results back of XCM execution, aka async operation. -//! - Contract will send below XCM to foreign parachain using `call_runtime` to perform -//! some operation (`Transact(Remark)`). -//! - If Error, a `Transact` instr will be used to send an XCM back to origin chain which -//! will call `handle_response(false)` contract method. -//! - If Success, same as above but call `handle_response(true)` method. -//! -//! ```no_run -//! Xcm(vec![ -//! WithdrawAsset(..) -//! BuyExecution(..) -//! SetAppendix(Xcm(vec![ -//! Transcat { /* pallet_xcm::send() runtime call to call SUCCESS contract method in ParaA */ } -//! ])) -//! SetErrorHandler(Xcm(vec![ -//! Transcat { /* pallet_xcm::send() runtime call to call ERROR contract method in ParaA */ } -//! ])) -//! ... -//! ]) -//! ``` -//! -//! # Methods -//! - attempt_remark_via_xcm: This method when called will build the XCM call that -//! will be sent to given parachain. The XCM call will include necessary handler -//! to send the results back via calling the `handle_response` contract method -//! - handle_response: This method will be called with operation result initiated by -//! XCM by foreign parachain. -//! - result: This is a getter method to get current stored result. - -#![cfg_attr(not(feature = "std"), no_std, no_main)] -#![allow(clippy::large_enum_variant)] - -use async_xcm_call_no_ce::*; -use ink::codegen::Env; -use ink::prelude::{boxed::Box, vec, vec::Vec}; -use scale::{Decode, Encode}; -use xcm::{prelude::*, v3::Weight}; - -/// Foreign parachain types -mod foreign { - use super::*; - - #[derive(scale::Encode)] - pub enum RuntimeCall { - #[codec(index = 0)] - System(SystemCall), - #[codec(index = 3)] - PolkadotXcm(PolkadotXcmCall), - } - - #[derive(scale::Encode)] - pub enum SystemCall { - #[codec(index = 7)] - RemarkWithEvent { remark: Vec }, - } - - #[derive(scale::Encode)] - pub enum PolkadotXcmCall { - #[codec(index = 0)] - Send { - dest: Box, - message: Box>, - }, - } -} - -/// parachain types -mod here { - use super::*; - use ink::primitives::AccountId; - - #[derive(scale::Encode)] - pub enum RuntimeCall { - #[codec(index = 3)] - PolkadotXcm(PolkadotXcmCall), - #[codec(index = 12)] - Contracts(ContractsCall), - } - - #[derive(scale::Encode)] - pub enum PolkadotXcmCall { - #[codec(index = 0)] - Send { - dest: Box, - message: Box>, - }, - } - - #[derive(scale::Encode)] - pub enum ContractsCall { - #[codec(index = 6u8)] - Call { - dest: AccountId, - #[codec(compact)] - value: u128, - gas_limit: Weight, - storage_deposit_limit: Option<::Type>, - data: Vec, - }, - } -} - -#[ink::contract] -mod async_xcm_call_no_ce { - use super::*; - - #[ink(storage)] - #[derive(Default)] - pub struct AsyncCall { - /// store the result of async XCM operation - pub result: Option, - /// Parachain's Id on which contract is deployed - pub here_para_id: u32, - } - - /// All the fees and weights values required for the whole - /// operation. - #[derive(Encode, Decode, Debug, Clone)] - #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] - pub struct WeightsAndFees { - /// Max fee for whole XCM operation in foreign chain - /// This includes fees for sending XCM back to original - /// chain via Transact(pallet_xcm::send). - pub foreign_base_fee: MultiAsset, - /// Max weight for operation (remark) - pub foreign_transact_weight: Weight, - /// Max weight for Transact(pallet_xcm::send) operation - pub foreign_transcat_pallet_xcm: Weight, - /// Max fee for the callback operation - /// send by foreign chain - pub here_callback_base_fee: MultiAsset, - /// Max weight for Transact(pallet_contracts::call) - pub here_callback_transact_weight: Weight, - /// Max weight for contract call - pub here_callback_contract_weight: Weight, - } - - impl AsyncCall { - #[ink(constructor, selector = 0x00001111)] - pub fn new(here_para_id: u32) -> Self { - Self { - result: None, - here_para_id, - } - } - - /// Attempt to perform remark operation on given parachain by - /// sending a XCM using `call_runtime`. - #[ink(message, selector = 0x00002222)] - pub fn attempt_remark_via_xcm( - &mut self, - parachain_id: u32, - remark: Vec, - weight_and_fees: WeightsAndFees, - ) -> bool { - ink::env::debug_println!("[1/2] Start of attempt_remark_via_xcm"); - - let dest: Box = - Box::new((Parent, Parachain(parachain_id)).into()); - let message: Box> = - Box::new(VersionedXcm::V3(self.build_xcm(remark, &weight_and_fees))); - - ink::env::debug_println!("[2/2] XCM Build successfully, sending..."); - - self.env() - .call_runtime(&here::RuntimeCall::PolkadotXcm( - here::PolkadotXcmCall::Send { dest, message }, - )) - .is_ok() - } - - #[ink(message, selector = 0x00003333)] - pub fn handle_response(&mut self, success: bool) { - ink::env::debug_println!("[1/1] Inside handle_response..."); - - self.result = Some(success); - } - - #[ink(message, selector = 0x00004444)] - pub fn result(&self) -> Option { - self.result - } - } -} - -impl AsyncCall { - fn build_callback_sequence(&self, success: bool, weight_and_fees: &WeightsAndFees) -> Xcm<()> { - let callback_xcm = Xcm(vec![ - // buy execution - WithdrawAsset(weight_and_fees.here_callback_base_fee.clone().into()), - BuyExecution { - fees: weight_and_fees.here_callback_base_fee.clone(), - weight_limit: Unlimited, - }, - // transact call to contract method - Transact { - origin_kind: OriginKind::SovereignAccount, - require_weight_at_most: weight_and_fees.here_callback_transact_weight, - call: here::RuntimeCall::Contracts(here::ContractsCall::Call { - dest: self.env().account_id(), - value: 0u128, - gas_limit: weight_and_fees.here_callback_contract_weight, - storage_deposit_limit: None, - data: [[0x00, 0x00, 0x33, 0x33].to_vec(), success.encode()].concat(), - }) - .encode() - .into(), - }, - ExpectTransactStatus(MaybeErrorCode::Success), - ]); - - Xcm(vec![Transact { - origin_kind: OriginKind::SovereignAccount, - require_weight_at_most: weight_and_fees.foreign_transcat_pallet_xcm, - call: foreign::RuntimeCall::PolkadotXcm(foreign::PolkadotXcmCall::Send { - dest: Box::new((Parent, Parachain(self.here_para_id)).into()), - message: Box::new(VersionedXcm::V3(callback_xcm)), - }) - .encode() - .into(), - }]) - } - - fn build_xcm(&self, remark: Vec, weight_and_fees: &WeightsAndFees) -> Xcm<()> { - Xcm(vec![ - // buy execution - WithdrawAsset(weight_and_fees.foreign_base_fee.clone().into()), - BuyExecution { - fees: weight_and_fees.foreign_base_fee.clone(), - weight_limit: Unlimited, - }, - // set on error handler - SetErrorHandler(self.build_callback_sequence(false, weight_and_fees)), - // set on success handler - SetAppendix(self.build_callback_sequence(true, weight_and_fees)), - // perform operation - remark - Transact { - origin_kind: OriginKind::SovereignAccount, - require_weight_at_most: weight_and_fees.foreign_transact_weight, - call: foreign::RuntimeCall::System(foreign::SystemCall::RemarkWithEvent { remark }) - .encode() - .into(), - }, - ]) - } -} diff --git a/tests/xcm-simulator/contracts/flipper/.gitignore b/tests/xcm-simulator/contracts/flipper/.gitignore deleted file mode 100755 index 8de8f877e4..0000000000 --- a/tests/xcm-simulator/contracts/flipper/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -# Ignore build artifacts from the local tests sub-crate. -/target/ - -# Ignore backup files creates by cargo fmt. -**/*.rs.bk - -# Remove Cargo.lock when creating an executable, leave it for libraries -# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock -Cargo.lock diff --git a/tests/xcm-simulator/contracts/flipper/Cargo.toml b/tests/xcm-simulator/contracts/flipper/Cargo.toml deleted file mode 100755 index 16cdfdfedd..0000000000 --- a/tests/xcm-simulator/contracts/flipper/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "flipper" -version = "0.1.0" -authors = ["Stake Technologies "] -edition = "2021" -homepage = "https://astar.network" -repository = "https://github.com/AstarNetwork/Astar" - -[dependencies] -ink = { version = "~4.2.0", default-features = false } -scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } -scale-info = { version = "2.6", default-features = false, features = ["derive"], optional = true } - -[lib] -path = "lib.rs" - -[features] -default = ["std"] -std = [ - "ink/std", - "scale/std", - "scale-info/std", -] -ink-as-dependency = [] - -[workspace] diff --git a/tests/xcm-simulator/contracts/flipper/lib.rs b/tests/xcm-simulator/contracts/flipper/lib.rs deleted file mode 100755 index 04704cc858..0000000000 --- a/tests/xcm-simulator/contracts/flipper/lib.rs +++ /dev/null @@ -1,54 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -#![cfg_attr(not(feature = "std"), no_std, no_main)] - -#[ink::contract] -mod flipper { - - /// Defines the storage of your contract. - /// Add new fields to the below struct in order - /// to add new static storage fields to your contract. - #[ink(storage)] - pub struct Flipper { - /// Stores a single `bool` value on the storage. - value: bool, - } - - impl Flipper { - /// Constructor that initializes the `bool` value to the given `init_value`. - #[ink(constructor)] - pub fn new(init_value: bool) -> Self { - Self { value: init_value } - } - - /// A message that can be called on instantiated contracts. - /// This one flips the value of the stored `bool` from `true` - /// to `false` and vice versa. - #[ink(message)] - pub fn flip(&mut self) { - self.value = !self.value; - } - - /// Simply returns the current value of our `bool`. - #[ink(message)] - pub fn get(&self) -> bool { - self.value - } - } -} diff --git a/tests/xcm-simulator/fixtures/README.md b/tests/xcm-simulator/fixtures/README.md new file mode 100644 index 0000000000..5c71d97488 --- /dev/null +++ b/tests/xcm-simulator/fixtures/README.md @@ -0,0 +1,7 @@ +## fixtures +This directory contains contracts which are used in experimental scenarios. + +Files in this directory are used by experimental scenarios in `src/experimental.rs`. The json +files are for informational purposes only and are not consumed by the tests. + +The source code for the contracts can be found at https://github.com/AstarNetwork/ink-test-contracts diff --git a/tests/xcm-simulator/fixtures/async-xcm-call-no-ce.json b/tests/xcm-simulator/fixtures/async-xcm-call-no-ce.json new file mode 100644 index 0000000000..cf2fc3d26f --- /dev/null +++ b/tests/xcm-simulator/fixtures/async-xcm-call-no-ce.json @@ -0,0 +1,1509 @@ +{ + "source": { + "hash": "0xea6312435caaa3765aee3a8640b33fa45317e13d097a1d51a4d211fdfe2d2088", + "language": "ink! 4.2.0", + "compiler": "rustc 1.68.0-nightly", + "build_info": { + "build_mode": "Debug", + "cargo_contract_version": "2.2.1", + "rust_toolchain": "nightly-aarch64-apple-darwin", + "wasm_opt_settings": { + "keep_debug_symbols": true, + "optimization_passes": "Z" + } + } + }, + "contract": { + "name": "async_xcm_call_contract", + "version": "0.1.0", + "authors": [ + "Stake Technologies " + ], + "repository": "https://github.com/AstarNetwork/Astar", + "homepage": "https://astar.network/" + }, + "spec": { + "constructors": [ + { + "args": [ + { + "label": "here_para_id", + "type": { + "displayName": [ + "u32" + ], + "type": 1 + } + } + ], + "default": false, + "docs": [], + "label": "new", + "payable": false, + "returnType": { + "displayName": [ + "ink_primitives", + "ConstructorResult" + ], + "type": 2 + }, + "selector": "0x00001111" + } + ], + "docs": [], + "environment": { + "accountId": { + "displayName": [ + "AccountId" + ], + "type": 33 + }, + "balance": { + "displayName": [ + "Balance" + ], + "type": 21 + }, + "blockNumber": { + "displayName": [ + "BlockNumber" + ], + "type": 1 + }, + "chainExtension": { + "displayName": [ + "ChainExtension" + ], + "type": 35 + }, + "hash": { + "displayName": [ + "Hash" + ], + "type": 34 + }, + "maxEventTopics": 4, + "timestamp": { + "displayName": [ + "Timestamp" + ], + "type": 17 + } + }, + "events": [], + "lang_error": { + "displayName": [ + "ink", + "LangError" + ], + "type": 4 + }, + "messages": [ + { + "args": [ + { + "label": "parachain_id", + "type": { + "displayName": [ + "u32" + ], + "type": 1 + } + }, + { + "label": "remark", + "type": { + "displayName": [ + "Vec" + ], + "type": 5 + } + }, + { + "label": "weight_and_fees", + "type": { + "displayName": [ + "WeightsAndFees" + ], + "type": 7 + } + } + ], + "default": false, + "docs": [ + " Attempt to perform remark operation on given parachain by", + " sending a XCM using `call_runtime`." + ], + "label": "attempt_remark_via_xcm", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 30 + }, + "selector": "0x00002222" + }, + { + "args": [ + { + "label": "success", + "type": { + "displayName": [ + "bool" + ], + "type": 0 + } + } + ], + "default": false, + "docs": [], + "label": "handle_response", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 2 + }, + "selector": "0x00003333" + }, + { + "args": [], + "default": false, + "docs": [], + "label": "result", + "mutates": false, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 31 + }, + "selector": "0x00004444" + } + ] + }, + "storage": { + "root": { + "layout": { + "struct": { + "fields": [ + { + "layout": { + "enum": { + "dispatchKey": "0x00000000", + "name": "Option", + "variants": { + "0": { + "fields": [], + "name": "None" + }, + "1": { + "fields": [ + { + "layout": { + "leaf": { + "key": "0x00000000", + "ty": 0 + } + }, + "name": "0" + } + ], + "name": "Some" + } + } + } + }, + "name": "result" + }, + { + "layout": { + "leaf": { + "key": "0x00000000", + "ty": 1 + } + }, + "name": "here_para_id" + } + ], + "name": "AsyncCall" + } + }, + "root_key": "0x00000000" + } + }, + "types": [ + { + "id": 0, + "type": { + "def": { + "primitive": "bool" + } + } + }, + { + "id": 1, + "type": { + "def": { + "primitive": "u32" + } + } + }, + { + "id": 2, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 3 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 4 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 3 + }, + { + "name": "E", + "type": 4 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 3, + "type": { + "def": { + "tuple": [] + } + } + }, + { + "id": 4, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 1, + "name": "CouldNotReadInput" + } + ] + } + }, + "path": [ + "ink_primitives", + "LangError" + ] + } + }, + { + "id": 5, + "type": { + "def": { + "sequence": { + "type": 6 + } + } + } + }, + { + "id": 6, + "type": { + "def": { + "primitive": "u8" + } + } + }, + { + "id": 7, + "type": { + "def": { + "composite": { + "fields": [ + { + "name": "foreign_base_fee", + "type": 8, + "typeName": "MultiAsset" + }, + { + "name": "foreign_transact_weight", + "type": 29, + "typeName": "Weight" + }, + { + "name": "foreign_transcat_pallet_xcm", + "type": 29, + "typeName": "Weight" + }, + { + "name": "here_callback_base_fee", + "type": 8, + "typeName": "MultiAsset" + }, + { + "name": "here_callback_transact_weight", + "type": 29, + "typeName": "Weight" + }, + { + "name": "here_callback_contract_weight", + "type": 29, + "typeName": "Weight" + } + ] + } + }, + "path": [ + "async_xcm_call_contract", + "async_xcm_call_no_ce", + "WeightsAndFees" + ] + } + }, + { + "id": 8, + "type": { + "def": { + "composite": { + "fields": [ + { + "name": "id", + "type": 9, + "typeName": "AssetId" + }, + { + "name": "fun", + "type": 25, + "typeName": "Fungibility" + } + ] + } + }, + "path": [ + "xcm", + "v3", + "multiasset", + "MultiAsset" + ] + } + }, + { + "id": 9, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 10, + "typeName": "MultiLocation" + } + ], + "index": 0, + "name": "Concrete" + }, + { + "fields": [ + { + "type": 16, + "typeName": "[u8; 32]" + } + ], + "index": 1, + "name": "Abstract" + } + ] + } + }, + "path": [ + "xcm", + "v3", + "multiasset", + "AssetId" + ] + } + }, + { + "id": 10, + "type": { + "def": { + "composite": { + "fields": [ + { + "name": "parents", + "type": 6, + "typeName": "u8" + }, + { + "name": "interior", + "type": 11, + "typeName": "Junctions" + } + ] + } + }, + "path": [ + "xcm", + "v3", + "multilocation", + "MultiLocation" + ] + } + }, + { + "id": 11, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 0, + "name": "Here" + }, + { + "fields": [ + { + "type": 12, + "typeName": "Junction" + } + ], + "index": 1, + "name": "X1" + }, + { + "fields": [ + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + } + ], + "index": 2, + "name": "X2" + }, + { + "fields": [ + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + } + ], + "index": 3, + "name": "X3" + }, + { + "fields": [ + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + } + ], + "index": 4, + "name": "X4" + }, + { + "fields": [ + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + } + ], + "index": 5, + "name": "X5" + }, + { + "fields": [ + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + } + ], + "index": 6, + "name": "X6" + }, + { + "fields": [ + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + } + ], + "index": 7, + "name": "X7" + }, + { + "fields": [ + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + }, + { + "type": 12, + "typeName": "Junction" + } + ], + "index": 8, + "name": "X8" + } + ] + } + }, + "path": [ + "xcm", + "v3", + "junctions", + "Junctions" + ] + } + }, + { + "id": 12, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 13, + "typeName": "u32" + } + ], + "index": 0, + "name": "Parachain" + }, + { + "fields": [ + { + "name": "network", + "type": 14, + "typeName": "Option" + }, + { + "name": "id", + "type": 16, + "typeName": "[u8; 32]" + } + ], + "index": 1, + "name": "AccountId32" + }, + { + "fields": [ + { + "name": "network", + "type": 14, + "typeName": "Option" + }, + { + "name": "index", + "type": 18, + "typeName": "u64" + } + ], + "index": 2, + "name": "AccountIndex64" + }, + { + "fields": [ + { + "name": "network", + "type": 14, + "typeName": "Option" + }, + { + "name": "key", + "type": 19, + "typeName": "[u8; 20]" + } + ], + "index": 3, + "name": "AccountKey20" + }, + { + "fields": [ + { + "type": 6, + "typeName": "u8" + } + ], + "index": 4, + "name": "PalletInstance" + }, + { + "fields": [ + { + "type": 20, + "typeName": "u128" + } + ], + "index": 5, + "name": "GeneralIndex" + }, + { + "fields": [ + { + "name": "length", + "type": 6, + "typeName": "u8" + }, + { + "name": "data", + "type": 16, + "typeName": "[u8; 32]" + } + ], + "index": 6, + "name": "GeneralKey" + }, + { + "index": 7, + "name": "OnlyChild" + }, + { + "fields": [ + { + "name": "id", + "type": 22, + "typeName": "BodyId" + }, + { + "name": "part", + "type": 24, + "typeName": "BodyPart" + } + ], + "index": 8, + "name": "Plurality" + }, + { + "fields": [ + { + "type": 15, + "typeName": "NetworkId" + } + ], + "index": 9, + "name": "GlobalConsensus" + } + ] + } + }, + "path": [ + "xcm", + "v3", + "junction", + "Junction" + ] + } + }, + { + "id": 13, + "type": { + "def": { + "compact": { + "type": 1 + } + } + } + }, + { + "id": 14, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 0, + "name": "None" + }, + { + "fields": [ + { + "type": 15 + } + ], + "index": 1, + "name": "Some" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 15 + } + ], + "path": [ + "Option" + ] + } + }, + { + "id": 15, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 16, + "typeName": "[u8; 32]" + } + ], + "index": 0, + "name": "ByGenesis" + }, + { + "fields": [ + { + "name": "block_number", + "type": 17, + "typeName": "u64" + }, + { + "name": "block_hash", + "type": 16, + "typeName": "[u8; 32]" + } + ], + "index": 1, + "name": "ByFork" + }, + { + "index": 2, + "name": "Polkadot" + }, + { + "index": 3, + "name": "Kusama" + }, + { + "index": 4, + "name": "Westend" + }, + { + "index": 5, + "name": "Rococo" + }, + { + "index": 6, + "name": "Wococo" + }, + { + "fields": [ + { + "name": "chain_id", + "type": 18, + "typeName": "u64" + } + ], + "index": 7, + "name": "Ethereum" + }, + { + "index": 8, + "name": "BitcoinCore" + }, + { + "index": 9, + "name": "BitcoinCash" + } + ] + } + }, + "path": [ + "xcm", + "v3", + "junction", + "NetworkId" + ] + } + }, + { + "id": 16, + "type": { + "def": { + "array": { + "len": 32, + "type": 6 + } + } + } + }, + { + "id": 17, + "type": { + "def": { + "primitive": "u64" + } + } + }, + { + "id": 18, + "type": { + "def": { + "compact": { + "type": 17 + } + } + } + }, + { + "id": 19, + "type": { + "def": { + "array": { + "len": 20, + "type": 6 + } + } + } + }, + { + "id": 20, + "type": { + "def": { + "compact": { + "type": 21 + } + } + } + }, + { + "id": 21, + "type": { + "def": { + "primitive": "u128" + } + } + }, + { + "id": 22, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 0, + "name": "Unit" + }, + { + "fields": [ + { + "type": 23, + "typeName": "[u8; 4]" + } + ], + "index": 1, + "name": "Moniker" + }, + { + "fields": [ + { + "type": 13, + "typeName": "u32" + } + ], + "index": 2, + "name": "Index" + }, + { + "index": 3, + "name": "Executive" + }, + { + "index": 4, + "name": "Technical" + }, + { + "index": 5, + "name": "Legislative" + }, + { + "index": 6, + "name": "Judicial" + }, + { + "index": 7, + "name": "Defense" + }, + { + "index": 8, + "name": "Administration" + }, + { + "index": 9, + "name": "Treasury" + } + ] + } + }, + "path": [ + "xcm", + "v3", + "junction", + "BodyId" + ] + } + }, + { + "id": 23, + "type": { + "def": { + "array": { + "len": 4, + "type": 6 + } + } + } + }, + { + "id": 24, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 0, + "name": "Voice" + }, + { + "fields": [ + { + "name": "count", + "type": 13, + "typeName": "u32" + } + ], + "index": 1, + "name": "Members" + }, + { + "fields": [ + { + "name": "nom", + "type": 13, + "typeName": "u32" + }, + { + "name": "denom", + "type": 13, + "typeName": "u32" + } + ], + "index": 2, + "name": "Fraction" + }, + { + "fields": [ + { + "name": "nom", + "type": 13, + "typeName": "u32" + }, + { + "name": "denom", + "type": 13, + "typeName": "u32" + } + ], + "index": 3, + "name": "AtLeastProportion" + }, + { + "fields": [ + { + "name": "nom", + "type": 13, + "typeName": "u32" + }, + { + "name": "denom", + "type": 13, + "typeName": "u32" + } + ], + "index": 4, + "name": "MoreThanProportion" + } + ] + } + }, + "path": [ + "xcm", + "v3", + "junction", + "BodyPart" + ] + } + }, + { + "id": 25, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 20, + "typeName": "u128" + } + ], + "index": 0, + "name": "Fungible" + }, + { + "fields": [ + { + "type": 26, + "typeName": "AssetInstance" + } + ], + "index": 1, + "name": "NonFungible" + } + ] + } + }, + "path": [ + "xcm", + "v3", + "multiasset", + "Fungibility" + ] + } + }, + { + "id": 26, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 0, + "name": "Undefined" + }, + { + "fields": [ + { + "type": 20, + "typeName": "u128" + } + ], + "index": 1, + "name": "Index" + }, + { + "fields": [ + { + "type": 23, + "typeName": "[u8; 4]" + } + ], + "index": 2, + "name": "Array4" + }, + { + "fields": [ + { + "type": 27, + "typeName": "[u8; 8]" + } + ], + "index": 3, + "name": "Array8" + }, + { + "fields": [ + { + "type": 28, + "typeName": "[u8; 16]" + } + ], + "index": 4, + "name": "Array16" + }, + { + "fields": [ + { + "type": 16, + "typeName": "[u8; 32]" + } + ], + "index": 5, + "name": "Array32" + } + ] + } + }, + "path": [ + "xcm", + "v3", + "multiasset", + "AssetInstance" + ] + } + }, + { + "id": 27, + "type": { + "def": { + "array": { + "len": 8, + "type": 6 + } + } + } + }, + { + "id": 28, + "type": { + "def": { + "array": { + "len": 16, + "type": 6 + } + } + } + }, + { + "id": 29, + "type": { + "def": { + "composite": { + "fields": [ + { + "name": "ref_time", + "type": 18, + "typeName": "u64" + }, + { + "name": "proof_size", + "type": 18, + "typeName": "u64" + } + ] + } + }, + "path": [ + "sp_weights", + "weight_v2", + "Weight" + ] + } + }, + { + "id": 30, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 0 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 4 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 0 + }, + { + "name": "E", + "type": 4 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 31, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 32 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 4 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 32 + }, + { + "name": "E", + "type": 4 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 32, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 0, + "name": "None" + }, + { + "fields": [ + { + "type": 0 + } + ], + "index": 1, + "name": "Some" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 0 + } + ], + "path": [ + "Option" + ] + } + }, + { + "id": 33, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 16, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "AccountId" + ] + } + }, + { + "id": 34, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 16, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "Hash" + ] + } + }, + { + "id": 35, + "type": { + "def": { + "variant": {} + }, + "path": [ + "ink_env", + "types", + "NoChainExtension" + ] + } + } + ], + "version": "4" +} \ No newline at end of file diff --git a/tests/xcm-simulator/fixtures/async-xcm-call-no-ce.wasm b/tests/xcm-simulator/fixtures/async-xcm-call-no-ce.wasm new file mode 100644 index 0000000000000000000000000000000000000000..b00d619810ff3dcb8a25e0a7671a515ba6567b33 GIT binary patch literal 67578 zcmeFa3z%Kib?14`xwl@rC2=JL5(vYoLO{tzrTc#1myYn|VZg>1+r*A7?h{lcRY_GP zfjk%qn-Im11SfHV6YMyN)8LNXP5KpgcRG!`=>#Y4G?{qDeAE6i^t7j&OsBtLX43sR zJ^teP{ntL{)~$zLfDQe917GQ!v!83Pwf5R;t-bcXUUTt~?|Gho^uoJ?6DPd8QzuTG z@K5NSfBiVYyE{!XA47WZv`-3n-rd22eEY7n|6p8#tn`ToAAHce+f!o?Dtp-KT8qj^ zJxD{r-}T3a7Q4-Z`OH1trTvRb^9#*;y55MT2W(Iu&g20LOYvr@disbTsh&AQIDCCPyo=j&(E)3Edz4x>JaHo6t;QVp# z=lroZ`d;K`E@-RO-^q=lsAwG4$Y-UX-1kOz-rXncvqSi`qn~}o!RMSo=XKICwzgmcV;pGtRTuU((HKTPo#pqVX)iFMgEbEUa)uh zf2HOp(^2ZkUwb4Rdw60j9HQ?Z`bWZ% znVfs4nt)lF8-dhB4C8+T=HN!u(n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4F1cj1$jqWRN zqUli7;Ggv!$&nSmHpybBAIwbB$FgYL*V}&)pmZ7#un3a25~$(63E4&4h#LkZGr&Ve za*am+XP4x3$h5%jjka{AChl90qB~*wsi(dyR2%EUbcC(+Hj|YzSO(s;cHgPzLfi|{ zVlyw)jtyeM7%(G@Sizn{x9H#`ZvHUTzWA+n1W7-ag+dG!nyfUjCb8G?67G&$Xns{Ks}7T!U`IyTnXg_vQ0F@Kl(5iTm_J}-=wPDKkBi`(cb0jJI&sM2PA8Cb-BCT_SKPp zl{;?HMK*SdDM}abRTu6V!;4FWcD65R`ux&;cVD)FGl*V{-ya3`%~H% literal 0 HcmV?d00001 diff --git a/tests/xcm-simulator/fixtures/flipper.json b/tests/xcm-simulator/fixtures/flipper.json new file mode 100644 index 0000000000..f262449163 --- /dev/null +++ b/tests/xcm-simulator/fixtures/flipper.json @@ -0,0 +1,383 @@ +{ + "source": { + "hash": "0xe8dbb2816fed4f8414c4a9fde5e9e89a00ab561c022cae1bd90c071aa0a1275a", + "language": "ink! 4.2.0", + "compiler": "rustc 1.68.0-nightly", + "build_info": { + "build_mode": "Debug", + "cargo_contract_version": "2.2.1", + "rust_toolchain": "nightly-aarch64-apple-darwin", + "wasm_opt_settings": { + "keep_debug_symbols": true, + "optimization_passes": "Z" + } + } + }, + "contract": { + "name": "flipper", + "version": "0.1.0", + "authors": [ + "Stake Technologies " + ], + "repository": "https://github.com/AstarNetwork/Astar", + "homepage": "https://astar.network/" + }, + "spec": { + "constructors": [ + { + "args": [ + { + "label": "init_value", + "type": { + "displayName": [ + "bool" + ], + "type": 0 + } + } + ], + "default": false, + "docs": [ + "Constructor that initializes the `bool` value to the given `init_value`." + ], + "label": "new", + "payable": false, + "returnType": { + "displayName": [ + "ink_primitives", + "ConstructorResult" + ], + "type": 1 + }, + "selector": "0x9bae9d5e" + } + ], + "docs": [], + "environment": { + "accountId": { + "displayName": [ + "AccountId" + ], + "type": 5 + }, + "balance": { + "displayName": [ + "Balance" + ], + "type": 8 + }, + "blockNumber": { + "displayName": [ + "BlockNumber" + ], + "type": 11 + }, + "chainExtension": { + "displayName": [ + "ChainExtension" + ], + "type": 12 + }, + "hash": { + "displayName": [ + "Hash" + ], + "type": 9 + }, + "maxEventTopics": 4, + "timestamp": { + "displayName": [ + "Timestamp" + ], + "type": 10 + } + }, + "events": [], + "lang_error": { + "displayName": [ + "ink", + "LangError" + ], + "type": 3 + }, + "messages": [ + { + "args": [], + "default": false, + "docs": [ + " A message that can be called on instantiated contracts.", + " This one flips the value of the stored `bool` from `true`", + " to `false` and vice versa." + ], + "label": "flip", + "mutates": true, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 1 + }, + "selector": "0x633aa551" + }, + { + "args": [], + "default": false, + "docs": [ + " Simply returns the current value of our `bool`." + ], + "label": "get", + "mutates": false, + "payable": false, + "returnType": { + "displayName": [ + "ink", + "MessageResult" + ], + "type": 4 + }, + "selector": "0x2f865bd9" + } + ] + }, + "storage": { + "root": { + "layout": { + "struct": { + "fields": [ + { + "layout": { + "leaf": { + "key": "0x00000000", + "ty": 0 + } + }, + "name": "value" + } + ], + "name": "Flipper" + } + }, + "root_key": "0x00000000" + } + }, + "types": [ + { + "id": 0, + "type": { + "def": { + "primitive": "bool" + } + } + }, + { + "id": 1, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 2 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 3 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 2 + }, + { + "name": "E", + "type": 3 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 2, + "type": { + "def": { + "tuple": [] + } + } + }, + { + "id": 3, + "type": { + "def": { + "variant": { + "variants": [ + { + "index": 1, + "name": "CouldNotReadInput" + } + ] + } + }, + "path": [ + "ink_primitives", + "LangError" + ] + } + }, + { + "id": 4, + "type": { + "def": { + "variant": { + "variants": [ + { + "fields": [ + { + "type": 0 + } + ], + "index": 0, + "name": "Ok" + }, + { + "fields": [ + { + "type": 3 + } + ], + "index": 1, + "name": "Err" + } + ] + } + }, + "params": [ + { + "name": "T", + "type": 0 + }, + { + "name": "E", + "type": 3 + } + ], + "path": [ + "Result" + ] + } + }, + { + "id": 5, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 6, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "AccountId" + ] + } + }, + { + "id": 6, + "type": { + "def": { + "array": { + "len": 32, + "type": 7 + } + } + } + }, + { + "id": 7, + "type": { + "def": { + "primitive": "u8" + } + } + }, + { + "id": 8, + "type": { + "def": { + "primitive": "u128" + } + } + }, + { + "id": 9, + "type": { + "def": { + "composite": { + "fields": [ + { + "type": 6, + "typeName": "[u8; 32]" + } + ] + } + }, + "path": [ + "ink_primitives", + "types", + "Hash" + ] + } + }, + { + "id": 10, + "type": { + "def": { + "primitive": "u64" + } + } + }, + { + "id": 11, + "type": { + "def": { + "primitive": "u32" + } + } + }, + { + "id": 12, + "type": { + "def": { + "variant": {} + }, + "path": [ + "ink_env", + "types", + "NoChainExtension" + ] + } + } + ], + "version": "4" +} \ No newline at end of file diff --git a/tests/xcm-simulator/fixtures/flipper.wasm b/tests/xcm-simulator/fixtures/flipper.wasm new file mode 100644 index 0000000000000000000000000000000000000000..a064cb425238c0203ef7c63675f95c460f34f9f6 GIT binary patch literal 16765 zcmc(GYm6M%mENsKKZZR+7G>I|NqSY?8e62r>8VFoRX3x=EUlYkS}RMDrFCE=XjNBL zlk@5xcK7hH@Omhj_U>xeh!uO+_O69}#DN!xlieS?zyety3ZfrIfFus$U>$5W5U>hh z1a_bwMvxy$l<&K@x;Z1#vgu?c5fUqDIrlr?IrsLANG98w5JKxNKBMpLX?xEY zd-8%CA=}~^4J{K-`BoH7KE*A5eCC-F-=UAt_VnkqN@tyq#~4#y50Lw~U~r=|-(;m_n~=x^5b}UM>qwGlU^3x>?qRDa-{S4wWh; zA&f(Ggs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WMD3jW#Ro17ygvtQvttbbK9KfjWyWJJC(i}mZ3+kvo zAG_X8!YXN+UxF&Gr>J8G#mxG3BGJil?%7E?9RzJ3*l&7wmlHuu#>xq$(g153WRBK#RaN{G*3Jbyc5WQZ2u{*U9M{L(o*T5%pbKx@bqx=s!z>HKWY9-0Nwcu! zh27w1c4R+oqe60{e&l3f7JA+AXBO2C2GJn%unBD^ZqV_%5&aYR`@&JK=37?EZ(5!K zm?!rlAhVwgIw&04KeKvHKM%n{dCPTk9Ow7DoiC|!NYRes3%Plb=h4mPlRU5{Deg{? zm57-;nMr2$`F7_MJOG*RdEOMd6yW+i0{~fG&iQo-0x9s?@K)9u4Ejzh%-Y?`eVRDZ fLv5L)o4uV8qjtRTZe3KG<58AO6K$brG~NFTwEevF literal 0 HcmV?d00001 From b7dd9cbe82fd7ea68cba69bb8c077e5b93c61817 Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Mon, 12 Jun 2023 09:08:23 +0530 Subject: [PATCH 19/19] feat: revert build script changes --- rust-toolchain.toml | 2 +- tests/xcm-simulator/src/README.md | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5b3d02f2f6..e01bdaaafd 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] channel = "nightly-2023-01-10" -components = ["rustfmt", "clippy", "rust-src"] +components = ["rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"] profile = "minimal" diff --git a/tests/xcm-simulator/src/README.md b/tests/xcm-simulator/src/README.md index 8de94b3f48..c15363a4f1 100644 --- a/tests/xcm-simulator/src/README.md +++ b/tests/xcm-simulator/src/README.md @@ -20,7 +20,3 @@ It's possible that in the future we decide to define a different runtime type (p Running tests is same as with any other unit tests: `cargo test -p xcm-simulator-tests` - -# ink! Contract fixtures -All the contract used in XCM Scenarios should be placed in [contracts](../contracts/) dir. The [cargo build script](../build.rs) will pick them and build them before executing tests automatically. -Please refer the env variables used in build script to configure the contract building - [`build.rs`](../build.rs).