From 2e3c910bbf821f7bfeb37e3b4e0181ea480acca4 Mon Sep 17 00:00:00 2001 From: valentinfernandez1 <33705477+valentinfernandez1@users.noreply.github.com> Date: Tue, 6 Jun 2023 05:31:36 -0300 Subject: [PATCH] [Backport] #206 Trappist node and #207 workspace refactor to v0.9.40 (#209) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * cherry-picked changes * WIP fixing node service¨ * Upgrade fixes, missing stout trait bound error * workspace refactor * added dex to stout * fmt --------- Co-authored-by: Hector Bulgarini --- .github/workflows/check.yml | 6 +- .gitignore | 1 - Cargo.lock | 482 +++++------ Cargo.toml | 172 ++++ README.md | 8 +- docker/scripts/inject_bootnodes.sh | 4 +- docker/trappist-parachain.dockerfile | 8 +- node/Cargo.toml | 130 ++- node/build.rs | 22 + node/cli/Cargo.toml | 97 --- node/cli/build.rs | 7 - node/cli/src/lib.rs | 17 - node/service/Cargo.toml | 122 --- node/service/src/chain_spec/mod.rs | 5 - node/service/src/lib.rs | 654 --------------- node/src/chain_spec/mod.rs | 68 ++ node/{service => }/src/chain_spec/stout.rs | 115 +-- node/{service => }/src/chain_spec/trappist.rs | 64 +- node/{cli => }/src/cli.rs | 12 +- node/{cli => }/src/command.rs | 415 ++++++++-- node/src/main.rs | 11 +- rpc/src/lib.rs => node/src/rpc.rs | 33 +- node/src/service.rs | 754 ++++++++++++++++++ node/tests/benchmark_storage_works.rs | 44 + node/tests/common.rs | 136 ++++ node/tests/polkadot_argument_parsing.rs | 39 + node/tests/polkadot_mdns_issue.rs | 33 + node/tests/purge_chain_works.rs | 53 ++ node/tests/running_the_node_and_interrupt.rs | 33 + pallets/asset-registry/Cargo.toml | 64 +- pallets/benchmarks/Cargo.toml | 22 +- pallets/benchmarks/src/lib.rs | 2 +- pallets/lockdown-mode/Cargo.toml | 71 +- primitives/xcm/Cargo.toml | 11 +- rpc/Cargo.toml | 32 - runtime/stout/Cargo.toml | 153 ++-- runtime/stout/src/lib.rs | 54 +- runtime/trappist/Cargo.toml | 166 ++-- runtime/trappist/src/lib.rs | 2 +- scripts/build_runtimes.sh | 2 - zombienet/full_network.toml | 8 +- zombienet/stout_rococo.toml | 4 +- zombienet/trappist_rococo.toml | 4 +- 43 files changed, 2343 insertions(+), 1797 deletions(-) create mode 100644 node/build.rs delete mode 100644 node/cli/Cargo.toml delete mode 100644 node/cli/build.rs delete mode 100644 node/cli/src/lib.rs delete mode 100644 node/service/Cargo.toml delete mode 100644 node/service/src/chain_spec/mod.rs delete mode 100644 node/service/src/lib.rs create mode 100644 node/src/chain_spec/mod.rs rename node/{service => }/src/chain_spec/stout.rs (54%) rename node/{service => }/src/chain_spec/trappist.rs (81%) rename node/{cli => }/src/cli.rs (92%) rename node/{cli => }/src/command.rs (50%) rename rpc/src/lib.rs => node/src/rpc.rs (79%) create mode 100644 node/src/service.rs create mode 100644 node/tests/benchmark_storage_works.rs create mode 100644 node/tests/common.rs create mode 100644 node/tests/polkadot_argument_parsing.rs create mode 100644 node/tests/polkadot_mdns_issue.rs create mode 100644 node/tests/purge_chain_works.rs create mode 100644 node/tests/running_the_node_and_interrupt.rs delete mode 100644 rpc/Cargo.toml delete mode 100755 scripts/build_runtimes.sh diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 8f85f325..49fec85c 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -46,11 +46,7 @@ jobs: - name: Check Build Trappist Runtime run: | - SKIP_WASM_BUILD=1 cargo check --release --locked --features with-trappist-runtime - - - name: Check Build Stout Runtime - run: | - SKIP_WASM_BUILD=1 cargo check --release --locked --no-default-features --features with-stout-runtime + SKIP_WASM_BUILD=1 cargo check --release test: needs: lint diff --git a/.gitignore b/.gitignore index d3504092..5e577212 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ # Generated by Cargo # will have compiled files and executables **/target/ -**/target_stout/ # These are backup files generated by rustfmt **/*.rs.bk diff --git a/Cargo.lock b/Cargo.lock index bdf116e2..a08e7d74 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -194,6 +194,12 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4436e0292ab1bb631b42973c61205e704475fe8126af845c8d923c0996328127" +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -913,13 +919,13 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.24" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" dependencies = [ + "android-tzdata", "iana-time-zone", "js-sys", - "num-integer", "num-traits", "time 0.1.45", "wasm-bindgen", @@ -1059,9 +1065,9 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "comfy-table" -version = "6.1.4" +version = "6.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e7b787b0dc42e8111badfdbe4c3059158ccb2db8780352fa1b01e8ccf45cc4d" +checksum = "7e959d788268e3bf9d35ace83e81b124190378e4c91c9067524675e33394b8ba" dependencies = [ "strum", "strum_macros", @@ -1429,7 +1435,7 @@ dependencies = [ "cumulus-client-consensus-common", "cumulus-client-network", "cumulus-primitives-core", - "futures 0.3.28", + "futures", "parity-scale-codec", "parking_lot 0.12.1", "polkadot-node-primitives", @@ -1452,7 +1458,7 @@ dependencies = [ "async-trait", "cumulus-client-consensus-common", "cumulus-primitives-core", - "futures 0.3.28", + "futures", "parity-scale-codec", "sc-client-api", "sc-consensus", @@ -1483,7 +1489,7 @@ dependencies = [ "cumulus-primitives-core", "cumulus-relay-chain-interface", "dyn-clone", - "futures 0.3.28", + "futures", "log", "parity-scale-codec", "polkadot-primitives", @@ -1506,7 +1512,7 @@ dependencies = [ "cumulus-client-consensus-common", "cumulus-primitives-core", "cumulus-relay-chain-interface", - "futures 0.3.28", + "futures", "parking_lot 0.12.1", "sc-consensus", "sp-api", @@ -1527,7 +1533,7 @@ source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.40#e05c dependencies = [ "async-trait", "cumulus-relay-chain-interface", - "futures 0.3.28", + "futures", "futures-timer", "parity-scale-codec", "parking_lot 0.12.1", @@ -1551,7 +1557,7 @@ dependencies = [ "async-trait", "cumulus-primitives-core", "cumulus-relay-chain-interface", - "futures 0.3.28", + "futures", "futures-timer", "parity-scale-codec", "polkadot-node-primitives", @@ -1581,7 +1587,7 @@ dependencies = [ "cumulus-relay-chain-inprocess-interface", "cumulus-relay-chain-interface", "cumulus-relay-chain-minimal-node", - "futures 0.3.28", + "futures", "polkadot-primitives", "sc-client-api", "sc-consensus", @@ -1787,7 +1793,7 @@ version = "0.1.0" source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.40#e05c8d7f71734ed71188337c6cb0d30715f6320f" dependencies = [ "cumulus-primitives-core", - "futures 0.3.28", + "futures", "parity-scale-codec", "sp-inherents", "sp-std", @@ -1820,7 +1826,7 @@ dependencies = [ "async-trait", "cumulus-primitives-core", "cumulus-relay-chain-interface", - "futures 0.3.28", + "futures", "futures-timer", "polkadot-cli", "polkadot-client", @@ -1844,7 +1850,7 @@ source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.40#e05c dependencies = [ "async-trait", "cumulus-primitives-core", - "futures 0.3.28", + "futures", "jsonrpsee-core", "parity-scale-codec", "polkadot-overseer", @@ -1865,7 +1871,7 @@ dependencies = [ "cumulus-primitives-core", "cumulus-relay-chain-interface", "cumulus-relay-chain-rpc-interface", - "futures 0.3.28", + "futures", "lru 0.9.0", "polkadot-core-primitives", "polkadot-network-bridge", @@ -1897,7 +1903,7 @@ dependencies = [ "async-trait", "cumulus-primitives-core", "cumulus-relay-chain-interface", - "futures 0.3.28", + "futures", "futures-timer", "jsonrpsee", "lru 0.9.0", @@ -2505,7 +2511,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5" dependencies = [ - "futures 0.3.28", + "futures", ] [[package]] @@ -2646,7 +2652,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36530797b9bf31cd4ff126dcfee8170f86b00cfdcea3269d73133cc0415945c3" dependencies = [ "either", - "futures 0.3.28", + "futures", "futures-timer", "log", "num-traits", @@ -2856,7 +2862,7 @@ name = "frame-remote-externalities" version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ - "futures 0.3.28", + "futures", "log", "parity-scale-codec", "serde", @@ -3023,12 +3029,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" -[[package]] -name = "futures" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" - [[package]] name = "futures" version = "0.3.28" @@ -3139,7 +3139,6 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ - "futures 0.1.31", "futures-channel", "futures-core", "futures-io", @@ -3601,7 +3600,7 @@ dependencies = [ "async-io", "core-foundation", "fnv", - "futures 0.3.28", + "futures", "if-addrs", "ipnet", "log", @@ -4126,7 +4125,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c7b0104790be871edcf97db9bd2356604984e623a08d825c3f27852290266b8" dependencies = [ "bytes", - "futures 0.3.28", + "futures", "futures-timer", "getrandom 0.2.9", "instant", @@ -4164,7 +4163,7 @@ dependencies = [ "ed25519-dalek", "either", "fnv", - "futures 0.3.28", + "futures", "futures-timer", "instant", "log", @@ -4195,7 +4194,7 @@ checksum = "3c1df63c0b582aa434fb09b2d86897fa2b419ffeccf934b36f87fcedc8e835c2" dependencies = [ "either", "fnv", - "futures 0.3.28", + "futures", "futures-timer", "instant", "libp2p-identity", @@ -4221,7 +4220,7 @@ version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e42a271c1b49f789b92f7fc87749fa79ce5c7bdc88cbdfacb818a4bca47fec5" dependencies = [ - "futures 0.3.28", + "futures", "libp2p-core 0.38.0", "log", "parking_lot 0.12.1", @@ -4236,7 +4235,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c052d0026f4817b44869bfb6810f4e1112f43aec8553f2cb38881c524b563abf" dependencies = [ "asynchronous-codec", - "futures 0.3.28", + "futures", "futures-timer", "libp2p-core 0.38.0", "libp2p-swarm", @@ -4279,7 +4278,7 @@ dependencies = [ "bytes", "either", "fnv", - "futures 0.3.28", + "futures", "futures-timer", "instant", "libp2p-core 0.38.0", @@ -4303,7 +4302,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04f378264aade9872d6ccd315c0accc18be3a35d15fc1b9c36e5b6f983b62b5b" dependencies = [ "data-encoding", - "futures 0.3.28", + "futures", "if-watch", "libp2p-core 0.38.0", "libp2p-swarm", @@ -4338,7 +4337,7 @@ checksum = "03805b44107aa013e7cbbfa5627b31c36cbedfdfb00603c0311998882bc4bace" dependencies = [ "asynchronous-codec", "bytes", - "futures 0.3.28", + "futures", "libp2p-core 0.38.0", "log", "nohash-hasher", @@ -4356,7 +4355,7 @@ checksum = "a978cb57efe82e892ec6f348a536bfbd9fee677adbe5689d7a93ad3a9bffbf2e" dependencies = [ "bytes", "curve25519-dalek 3.2.0", - "futures 0.3.28", + "futures", "libp2p-core 0.38.0", "log", "once_cell", @@ -4377,7 +4376,7 @@ version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "929fcace45a112536e22b3dcfd4db538723ef9c3cb79f672b98be2cc8e25f37f" dependencies = [ - "futures 0.3.28", + "futures", "futures-timer", "instant", "libp2p-core 0.38.0", @@ -4394,7 +4393,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01e7c867e95c8130667b24409d236d37598270e6da69b3baf54213ba31ffca59" dependencies = [ "bytes", - "futures 0.3.28", + "futures", "futures-timer", "if-watch", "libp2p-core 0.38.0", @@ -4416,7 +4415,7 @@ checksum = "3236168796727bfcf4927f766393415361e2c644b08bedb6a6b13d957c9a4884" dependencies = [ "async-trait", "bytes", - "futures 0.3.28", + "futures", "instant", "libp2p-core 0.38.0", "libp2p-swarm", @@ -4434,7 +4433,7 @@ checksum = "b2a35472fe3276b3855c00f1c032ea8413615e030256429ad5349cdf67c6e1a0" dependencies = [ "either", "fnv", - "futures 0.3.28", + "futures", "futures-timer", "instant", "libp2p-core 0.38.0", @@ -4465,7 +4464,7 @@ version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4b257baf6df8f2df39678b86c578961d48cc8b68642a12f0f763f56c8e5858d" dependencies = [ - "futures 0.3.28", + "futures", "futures-timer", "if-watch", "libc", @@ -4481,7 +4480,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" dependencies = [ - "futures 0.3.28", + "futures", "futures-rustls", "libp2p-core 0.39.2", "libp2p-identity", @@ -4500,7 +4499,7 @@ version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bb1a35299860e0d4b3c02a3e74e3b293ad35ae0cee8a056363b0c862d082069" dependencies = [ - "futures 0.3.28", + "futures", "js-sys", "libp2p-core 0.38.0", "parity-send-wrapper", @@ -4517,7 +4516,7 @@ dependencies = [ "async-trait", "asynchronous-codec", "bytes", - "futures 0.3.28", + "futures", "futures-timer", "hex", "if-watch", @@ -4546,7 +4545,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d705506030d5c0aaf2882437c70dab437605f21c5f9811978f694e6917a3b54" dependencies = [ "either", - "futures 0.3.28", + "futures", "futures-rustls", "libp2p-core 0.38.0", "log", @@ -4564,7 +4563,7 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f63594a0aa818642d9d4915c791945053877253f08a3626f13416b5cd928a29" dependencies = [ - "futures 0.3.28", + "futures", "libp2p-core 0.38.0", "log", "parking_lot 0.12.1", @@ -4703,12 +4702,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" [[package]] name = "lru" @@ -4881,7 +4877,7 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69672161530e8aeca1d1400fbf3f1a1747ff60ea604265a4e906c2442df20532" dependencies = [ - "futures 0.3.28", + "futures", "rand 0.8.5", "thrift", ] @@ -4912,14 +4908,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.6" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -4927,7 +4923,7 @@ name = "mmr-gadget" version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ - "futures 0.3.28", + "futures", "log", "parity-scale-codec", "sc-client-api", @@ -5087,7 +5083,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" dependencies = [ "bytes", - "futures 0.3.28", + "futures", "log", "pin-project", "smallvec", @@ -5181,7 +5177,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65b4b14489ab424703c092062176d52ba55485a89c076b4f9db05092b7223aa6" dependencies = [ "bytes", - "futures 0.3.28", + "futures", "log", "netlink-packet-core", "netlink-sys", @@ -5196,7 +5192,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6471bf08e7ac0135876a9581bf3217ef0333c191c128d34878079f42ee150411" dependencies = [ "bytes", - "futures 0.3.28", + "futures", "libc", "log", "tokio", @@ -5204,12 +5200,11 @@ dependencies = [ [[package]] name = "nix" -version = "0.23.2" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ "bitflags", - "cc", "cfg-if", "libc", "memoffset 0.6.5", @@ -5217,14 +5212,16 @@ dependencies = [ [[package]] name = "nix" -version = "0.24.3" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" dependencies = [ + "autocfg", "bitflags", "cfg-if", "libc", "memoffset 0.6.5", + "pin-utils", ] [[package]] @@ -5361,9 +5358,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.1" +version = "1.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" [[package]] name = "opaque-debug" @@ -5391,7 +5388,7 @@ checksum = "2b0766f60d83cac01c6e3f3bc36aaa9056e48bea0deddb98a8c74de6021f3061" dependencies = [ "async-trait", "dyn-clonable", - "futures 0.3.28", + "futures", "futures-timer", "orchestra-proc-macro", "pin-project", @@ -7018,7 +7015,7 @@ name = "polkadot-approval-distribution" version = "0.9.40" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe4c8862810bffd68343231a517e62689c05c0" dependencies = [ - "futures 0.3.28", + "futures", "polkadot-node-metrics", "polkadot-node-network-protocol", "polkadot-node-primitives", @@ -7033,7 +7030,7 @@ name = "polkadot-availability-bitfield-distribution" version = "0.9.40" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe4c8862810bffd68343231a517e62689c05c0" dependencies = [ - "futures 0.3.28", + "futures", "polkadot-node-network-protocol", "polkadot-node-subsystem", "polkadot-node-subsystem-util", @@ -7049,7 +7046,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe dependencies = [ "derive_more", "fatality", - "futures 0.3.28", + "futures", "lru 0.9.0", "parity-scale-codec", "polkadot-erasure-coding", @@ -7071,7 +7068,7 @@ version = "0.9.40" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe4c8862810bffd68343231a517e62689c05c0" dependencies = [ "fatality", - "futures 0.3.28", + "futures", "lru 0.9.0", "parity-scale-codec", "polkadot-erasure-coding", @@ -7093,7 +7090,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe dependencies = [ "clap", "frame-benchmarking-cli", - "futures 0.3.28", + "futures", "log", "polkadot-client", "polkadot-node-core-pvf", @@ -7124,7 +7121,7 @@ dependencies = [ "frame-benchmarking-cli", "frame-system", "frame-system-rpc-runtime-api", - "futures 0.3.28", + "futures", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "polkadot-core-primitives", @@ -7165,7 +7162,7 @@ dependencies = [ "always-assert", "bitvec", "fatality", - "futures 0.3.28", + "futures", "futures-timer", "polkadot-node-network-protocol", "polkadot-node-primitives", @@ -7198,7 +7195,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe dependencies = [ "derive_more", "fatality", - "futures 0.3.28", + "futures", "futures-timer", "indexmap", "lru 0.9.0", @@ -7235,7 +7232,7 @@ name = "polkadot-gossip-support" version = "0.9.40" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe4c8862810bffd68343231a517e62689c05c0" dependencies = [ - "futures 0.3.28", + "futures", "futures-timer", "polkadot-node-network-protocol", "polkadot-node-subsystem", @@ -7259,7 +7256,7 @@ dependencies = [ "async-trait", "bytes", "fatality", - "futures 0.3.28", + "futures", "parity-scale-codec", "parking_lot 0.12.1", "polkadot-node-metrics", @@ -7278,7 +7275,7 @@ name = "polkadot-node-collation-generation" version = "0.9.40" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe4c8862810bffd68343231a517e62689c05c0" dependencies = [ - "futures 0.3.28", + "futures", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-primitives", @@ -7298,7 +7295,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe dependencies = [ "bitvec", "derive_more", - "futures 0.3.28", + "futures", "futures-timer", "kvdb", "lru 0.9.0", @@ -7326,7 +7323,7 @@ version = "0.9.40" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe4c8862810bffd68343231a517e62689c05c0" dependencies = [ "bitvec", - "futures 0.3.28", + "futures", "futures-timer", "kvdb", "parity-scale-codec", @@ -7348,7 +7345,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe dependencies = [ "bitvec", "fatality", - "futures 0.3.28", + "futures", "polkadot-erasure-coding", "polkadot-node-primitives", "polkadot-node-subsystem", @@ -7365,7 +7362,7 @@ name = "polkadot-node-core-bitfield-signing" version = "0.9.40" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe4c8862810bffd68343231a517e62689c05c0" dependencies = [ - "futures 0.3.28", + "futures", "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", @@ -7381,7 +7378,7 @@ version = "0.9.40" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe4c8862810bffd68343231a517e62689c05c0" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "futures-timer", "parity-scale-codec", "polkadot-node-core-pvf", @@ -7400,7 +7397,7 @@ name = "polkadot-node-core-chain-api" version = "0.9.40" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe4c8862810bffd68343231a517e62689c05c0" dependencies = [ - "futures 0.3.28", + "futures", "polkadot-node-metrics", "polkadot-node-subsystem", "polkadot-primitives", @@ -7415,7 +7412,7 @@ name = "polkadot-node-core-chain-selection" version = "0.9.40" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe4c8862810bffd68343231a517e62689c05c0" dependencies = [ - "futures 0.3.28", + "futures", "futures-timer", "kvdb", "parity-scale-codec", @@ -7433,7 +7430,7 @@ version = "0.9.40" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe4c8862810bffd68343231a517e62689c05c0" dependencies = [ "fatality", - "futures 0.3.28", + "futures", "kvdb", "lru 0.9.0", "parity-scale-codec", @@ -7452,7 +7449,7 @@ version = "0.9.40" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe4c8862810bffd68343231a517e62689c05c0" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "futures-timer", "polkadot-node-subsystem", "polkadot-overseer", @@ -7470,7 +7467,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe dependencies = [ "bitvec", "fatality", - "futures 0.3.28", + "futures", "futures-timer", "polkadot-node-primitives", "polkadot-node-subsystem", @@ -7489,7 +7486,7 @@ dependencies = [ "always-assert", "assert_matches", "cpu-time", - "futures 0.3.28", + "futures", "futures-timer", "libc", "parity-scale-codec", @@ -7522,7 +7519,7 @@ name = "polkadot-node-core-pvf-checker" version = "0.9.40" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe4c8862810bffd68343231a517e62689c05c0" dependencies = [ - "futures 0.3.28", + "futures", "polkadot-node-primitives", "polkadot-node-subsystem", "polkadot-node-subsystem-util", @@ -7538,7 +7535,7 @@ name = "polkadot-node-core-runtime-api" version = "0.9.40" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe4c8862810bffd68343231a517e62689c05c0" dependencies = [ - "futures 0.3.28", + "futures", "lru 0.9.0", "polkadot-node-metrics", "polkadot-node-subsystem", @@ -7572,7 +7569,7 @@ version = "0.9.40" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe4c8862810bffd68343231a517e62689c05c0" dependencies = [ "bs58", - "futures 0.3.28", + "futures", "futures-timer", "log", "parity-scale-codec", @@ -7593,7 +7590,7 @@ dependencies = [ "async-trait", "derive_more", "fatality", - "futures 0.3.28", + "futures", "hex", "parity-scale-codec", "polkadot-node-jaeger", @@ -7613,7 +7610,7 @@ version = "0.9.40" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe4c8862810bffd68343231a517e62689c05c0" dependencies = [ "bounded-vec", - "futures 0.3.28", + "futures", "parity-scale-codec", "polkadot-parachain", "polkadot-primitives", @@ -7647,7 +7644,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe dependencies = [ "async-trait", "derive_more", - "futures 0.3.28", + "futures", "orchestra", "polkadot-node-jaeger", "polkadot-node-network-protocol", @@ -7671,7 +7668,7 @@ dependencies = [ "async-trait", "derive_more", "fatality", - "futures 0.3.28", + "futures", "futures-channel", "itertools", "kvdb", @@ -7702,7 +7699,7 @@ version = "0.9.40" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe4c8862810bffd68343231a517e62689c05c0" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "futures-timer", "lru 0.9.0", "orchestra", @@ -8025,7 +8022,7 @@ dependencies = [ "frame-benchmarking-cli", "frame-support", "frame-system-rpc-runtime-api", - "futures 0.3.28", + "futures", "hex-literal", "kusama-runtime", "kvdb", @@ -8133,7 +8130,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.40#95fe dependencies = [ "arrayvec 0.5.2", "fatality", - "futures 0.3.28", + "futures", "indexmap", "parity-scale-codec", "polkadot-node-network-protocol", @@ -8289,7 +8286,7 @@ dependencies = [ "coarsetime", "crossbeam-queue", "derive_more", - "futures 0.3.28", + "futures", "futures-timer", "nanorand", "thiserror", @@ -8936,7 +8933,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "322c53fd76a18698f1c27381d58091de3a043d356aa5bd0d510608b565f469a0" dependencies = [ - "futures 0.3.28", + "futures", "log", "netlink-packet-route", "netlink-proto", @@ -9100,7 +9097,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" dependencies = [ - "futures 0.3.28", + "futures", "pin-project", "static_assertions", ] @@ -9155,7 +9152,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "futures-timer", "ip_network", "libp2p", @@ -9182,7 +9179,7 @@ name = "sc-basic-authorship" version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ - "futures 0.3.28", + "futures", "futures-timer", "log", "parity-scale-codec", @@ -9254,7 +9251,7 @@ dependencies = [ "chrono", "clap", "fdlimit", - "futures 0.3.28", + "futures", "libp2p", "log", "names", @@ -9291,7 +9288,7 @@ version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "fnv", - "futures 0.3.28", + "futures", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -9343,7 +9340,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "futures-timer", "libp2p", "log", @@ -9368,7 +9365,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "log", "parity-scale-codec", "sc-block-builder", @@ -9398,7 +9395,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98 dependencies = [ "async-trait", "fork-tree", - "futures 0.3.28", + "futures", "log", "merlin", "num-bigint", @@ -9435,7 +9432,7 @@ name = "sc-consensus-babe-rpc" version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ - "futures 0.3.28", + "futures", "jsonrpsee", "sc-consensus-babe", "sc-consensus-epochs", @@ -9460,7 +9457,7 @@ dependencies = [ "array-bytes 4.2.0", "async-trait", "fnv", - "futures 0.3.28", + "futures", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -9492,7 +9489,7 @@ name = "sc-consensus-beefy-rpc" version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ - "futures 0.3.28", + "futures", "jsonrpsee", "log", "parity-scale-codec", @@ -9530,7 +9527,7 @@ dependencies = [ "dyn-clone", "finality-grandpa", "fork-tree", - "futures 0.3.28", + "futures", "futures-timer", "log", "parity-scale-codec", @@ -9565,7 +9562,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "finality-grandpa", - "futures 0.3.28", + "futures", "jsonrpsee", "log", "parity-scale-codec", @@ -9579,47 +9576,13 @@ dependencies = [ "thiserror", ] -[[package]] -name = "sc-consensus-manual-seal" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" -dependencies = [ - "assert_matches", - "async-trait", - "futures 0.3.28", - "jsonrpsee", - "log", - "parity-scale-codec", - "sc-client-api", - "sc-consensus", - "sc-consensus-aura", - "sc-consensus-babe", - "sc-consensus-epochs", - "sc-transaction-pool", - "sc-transaction-pool-api", - "serde", - "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-consensus-aura", - "sp-consensus-babe", - "sp-consensus-slots", - "sp-core", - "sp-inherents", - "sp-keystore", - "sp-runtime", - "sp-timestamp", - "substrate-prometheus-endpoint", - "thiserror", -] - [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "futures-timer", "log", "parity-scale-codec", @@ -9710,7 +9673,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "ansi_term", - "futures 0.3.28", + "futures", "futures-timer", "log", "sc-client-api", @@ -9747,7 +9710,7 @@ dependencies = [ "bytes", "either", "fnv", - "futures 0.3.28", + "futures", "futures-timer", "ip_network", "libp2p", @@ -9785,7 +9748,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "cid", - "futures 0.3.28", + "futures", "libp2p", "log", "prost", @@ -9808,7 +9771,7 @@ dependencies = [ "async-trait", "bitflags", "bytes", - "futures 0.3.28", + "futures", "futures-timer", "libp2p", "parity-scale-codec", @@ -9833,7 +9796,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "ahash 0.8.3", - "futures 0.3.28", + "futures", "futures-timer", "libp2p", "log", @@ -9852,7 +9815,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "array-bytes 4.2.0", - "futures 0.3.28", + "futures", "libp2p", "log", "parity-scale-codec", @@ -9876,7 +9839,7 @@ dependencies = [ "array-bytes 4.2.0", "async-trait", "fork-tree", - "futures 0.3.28", + "futures", "futures-timer", "libp2p", "log", @@ -9908,7 +9871,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "array-bytes 4.2.0", - "futures 0.3.28", + "futures", "libp2p", "log", "parity-scale-codec", @@ -9930,7 +9893,7 @@ dependencies = [ "array-bytes 4.2.0", "bytes", "fnv", - "futures 0.3.28", + "futures", "futures-timer", "hyper", "hyper-rustls", @@ -9958,7 +9921,7 @@ name = "sc-peerset" version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ - "futures 0.3.28", + "futures", "libp2p", "log", "sc-utils", @@ -9980,7 +9943,7 @@ name = "sc-rpc" version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ - "futures 0.3.28", + "futures", "jsonrpsee", "log", "parity-scale-codec", @@ -10045,7 +10008,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "array-bytes 4.2.0", - "futures 0.3.28", + "futures", "futures-util", "hex", "jsonrpsee", @@ -10073,7 +10036,7 @@ dependencies = [ "async-trait", "directories", "exit-future", - "futures 0.3.28", + "futures", "futures-timer", "jsonrpsee", "log", @@ -10149,7 +10112,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98 dependencies = [ "clap", "fs4", - "futures 0.3.28", + "futures", "log", "sc-client-db", "sc-utils", @@ -10182,7 +10145,7 @@ name = "sc-sysinfo" version = "6.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ - "futures 0.3.28", + "futures", "libc", "log", "rand 0.8.5", @@ -10202,7 +10165,7 @@ version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "chrono", - "futures 0.3.28", + "futures", "libp2p", "log", "parking_lot 0.12.1", @@ -10263,7 +10226,7 @@ version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "futures-timer", "linked-hash-map", "log", @@ -10290,7 +10253,7 @@ version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "log", "serde", "sp-blockchain", @@ -10304,7 +10267,7 @@ version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "async-channel", - "futures 0.3.28", + "futures", "futures-timer", "lazy_static", "log", @@ -10756,7 +10719,7 @@ dependencies = [ "base64 0.13.1", "bytes", "flate2", - "futures 0.3.28", + "futures", "http", "httparse", "log", @@ -10853,7 +10816,7 @@ name = "sp-blockchain" version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ - "futures 0.3.28", + "futures", "log", "lru 0.8.1", "parity-scale-codec", @@ -10872,7 +10835,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "log", "sp-core", "sp-inherents", @@ -10996,7 +10959,7 @@ dependencies = [ "bounded-collections", "dyn-clonable", "ed25519-zebra", - "futures 0.3.28", + "futures", "hash-db", "hash256-std-hasher", "impl-serde", @@ -11105,7 +11068,7 @@ dependencies = [ "bytes", "ed25519", "ed25519-dalek", - "futures 0.3.28", + "futures", "libsecp256k1", "log", "parity-scale-codec", @@ -11139,7 +11102,7 @@ version = "0.13.0" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "merlin", "parity-scale-codec", "parking_lot 0.12.1", @@ -11273,6 +11236,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "sp-serializer" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "sp-session" version = "4.0.0-dev" @@ -11619,6 +11591,7 @@ dependencies = [ "pallet-uniques", "pallet-utility", "pallet-xcm", + "pallet-xcm-benchmarks", "parachain-info", "parachains-common", "parity-scale-codec", @@ -11721,7 +11694,7 @@ version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "frame-system-rpc-runtime-api", - "futures 0.3.28", + "futures", "jsonrpsee", "log", "parity-scale-codec", @@ -12315,22 +12288,6 @@ dependencies = [ [[package]] name = "trappist" version = "1.0.0" -dependencies = [ - "assert_cmd", - "async-trait", - "clap", - "futures 0.3.28", - "log", - "nix 0.23.2", - "substrate-build-script-utils", - "tempfile", - "trappist-cli", - "trappist-service", -] - -[[package]] -name = "trappist-cli" -version = "1.0.0" dependencies = [ "assert_cmd", "async-trait", @@ -12344,54 +12301,62 @@ dependencies = [ "cumulus-primitives-core", "cumulus-primitives-parachain-inherent", "cumulus-relay-chain-interface", + "frame-benchmarking", "frame-benchmarking-cli", - "futures 0.3.28", + "futures", + "hex-literal", "jsonrpsee", "log", - "nix 0.23.2", + "nix 0.25.1", + "pallet-dex-rpc", + "pallet-transaction-payment-rpc", "parachains-common", "parity-scale-codec", "polkadot-cli", - "polkadot-parachain", "polkadot-primitives", "polkadot-service", + "sc-basic-authorship", + "sc-chain-spec", "sc-cli", + "sc-client-api", + "sc-consensus", + "sc-executor", + "sc-network", + "sc-network-common", + "sc-network-sync", + "sc-rpc", "sc-service", "sc-sysinfo", "sc-telemetry", "sc-tracing", + "sc-transaction-pool", + "sc-transaction-pool-api", "serde", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-consensus-aura", "sp-core", + "sp-io", + "sp-keystore", + "sp-offchain", "sp-runtime", + "sp-serializer", + "sp-session", + "sp-timestamp", + "sp-transaction-pool", "stout-runtime", "substrate-build-script-utils", + "substrate-frame-rpc-system", + "substrate-prometheus-endpoint", + "substrate-state-trie-migration-rpc", "tempfile", + "tokio", "trappist-runtime", - "trappist-service", "try-runtime-cli", -] - -[[package]] -name = "trappist-rpc" -version = "1.0.0" -dependencies = [ - "futures 0.3.28", - "jsonrpsee", - "pallet-dex-rpc", - "pallet-transaction-payment-rpc", - "parachains-common", - "parity-scale-codec", - "sc-client-api", - "sc-consensus-manual-seal", - "sc-rpc", - "sc-rpc-api", - "sc-transaction-pool-api", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-runtime", - "substrate-frame-rpc-system", - "trappist-runtime", + "wait-timeout", + "xcm", ] [[package]] @@ -12493,79 +12458,6 @@ dependencies = [ "xcm-executor", ] -[[package]] -name = "trappist-service" -version = "1.0.0" -dependencies = [ - "assert_cmd", - "async-trait", - "clap", - "cumulus-client-cli", - "cumulus-client-consensus-aura", - "cumulus-client-consensus-common", - "cumulus-client-network", - "cumulus-client-service", - "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", - "cumulus-relay-chain-interface", - "frame-benchmarking", - "frame-benchmarking-cli", - "futures 0.3.28", - "hex-literal", - "jsonrpsee", - "log", - "nix 0.23.2", - "pallet-dex-rpc", - "pallet-transaction-payment-rpc", - "parachains-common", - "parity-scale-codec", - "polkadot-cli", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-service", - "sc-basic-authorship", - "sc-chain-spec", - "sc-cli", - "sc-client-api", - "sc-consensus", - "sc-executor", - "sc-keystore", - "sc-network", - "sc-network-sync", - "sc-rpc", - "sc-rpc-api", - "sc-service", - "sc-sysinfo", - "sc-telemetry", - "sc-tracing", - "sc-transaction-pool", - "sc-transaction-pool-api", - "serde", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-aura", - "sp-core", - "sp-inherents", - "sp-io", - "sp-keystore", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-timestamp", - "sp-transaction-pool", - "stout-runtime", - "substrate-build-script-utils", - "substrate-frame-rpc-system", - "substrate-prometheus-endpoint", - "tempfile", - "trappist-rpc", - "trappist-runtime", - "try-runtime-cli", - "xcm", -] - [[package]] name = "trie-db" version = "0.27.1" @@ -12690,7 +12582,7 @@ checksum = "4712ee30d123ec7ae26d1e1b218395a16c87cdbaf4b3925d170d684af62ea5e8" dependencies = [ "async-trait", "base64 0.13.1", - "futures 0.3.28", + "futures", "log", "md-5", "rand 0.8.5", @@ -13051,7 +12943,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" dependencies = [ - "futures 0.3.28", + "futures", "js-sys", "parking_lot 0.11.2", "pin-utils", @@ -14120,7 +14012,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5d9ba232399af1783a58d8eb26f6b5006fbefe2dc9ef36bd283324792d03ea5" dependencies = [ - "futures 0.3.28", + "futures", "log", "nohash-hasher", "parking_lot 0.12.1", diff --git a/Cargo.toml b/Cargo.toml index d2f8fb93..b4d1d5a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,3 +17,175 @@ panic = "unwind" inherits = "release" lto = true codegen-units = 1 + +[workspace.package] +authors = ["Trappist Network "] +homepage = "https://trappist.io" +repository = "https://github.com/TrappistNetwork/trappist" +edition = "2021" +license = "Apache License v2" + + +[workspace.dependencies] + +# common +async-trait = "0.1.57" +clap = { version = "4.0.32" } +parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] } +futures = { version = "0.3.25"} +hex-literal = { version = "0.3.4"} +log = { version = "0.4.17"} +serde = { version = "1.0.152" } +scale-info = { version = "2.3.1", default-features = false, features = ["derive"] } +smallvec = "1.9.0" + +# Local dependencies +trappist-runtime = { path = "runtime/trappist"} +stout-runtime = { path = "runtime/stout" } +jsonrpsee = { version = "0.16.2" } + +# External Dependencies +pallet-dex-rpc = { version = "0.0.1", git = "https://github.com/paritytech/substrate-dex.git", default-features = false, branch = "polkadot-v0.9.40" } +pallet-dex = { version = "0.0.1", git = "https://github.com/paritytech/substrate-dex.git", default-features = false, branch = "polkadot-v0.9.40" } +pallet-dex-rpc-runtime-api = { version = "0.0.1", git = "https://github.com/paritytech/substrate-dex.git", default-features = false, branch = "polkadot-v0.9.40" } +pallet-chess = { git = "https://github.com/SubstrateChess/pallet-chess.git", default-features = false, branch = "polkadot-v0.9.40" } + +# Trappist Pallets +pallet-asset-registry = { default-features = false, path = "pallets/asset-registry" } +trappist-runtime-benchmarks = { default-features = false, path = "pallets/benchmarks" } +pallet-lockdown-mode = { version = "0.1.0", default-features = false, path = "pallets/lockdown-mode" } + +# Substrate std +try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40"} +frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sc-network-common = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sc-network-sync = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sp-serializer = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40"} +substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +substrate-state-trie-migration-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40"} + +# Substrate non-std +frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +sp-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } + + +# Substrate Runtime +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } +sp-inherents = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } + +# Build Dependencies +substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } + +## Substrate FRAME Dependencies +frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } + +## Substrate Pallet Dependencies +pallet-assets = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-asset-tx-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-contracts = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-democracy = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-identity = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-preimage = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-insecure-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-scheduler = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-uniques = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } + +# Cumulus client dependencies +cumulus-client-cli ={ git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } +cumulus-client-consensus-aura = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } +cumulus-client-consensus-relay-chain = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } +cumulus-client-consensus-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } +cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } +cumulus-client-network = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } +cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } +cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } + +# Cumulus runtime dependencies +cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } +cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } +cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } +cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } +cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } +cumulus-ping = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } +cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } +cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } +cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } +pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } +parachains-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } +parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } +cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false, version = "3.0.0" } + +# Polkadot +polkadot-cli = { git = "https://github.com/paritytech/polkadot", features = ["rococo-native"], branch = "release-v0.9.40" } +polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.40" } +polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.40" } +polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } + +# Polkadot Dependencies +kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +xcm-primitives = { path = "primitives/xcm", default-features = false } +xcm-simulator = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +pallet-xcm-benchmarks = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } + +# Dev dependencies +assert_cmd = "2.0" +nix = "0.25" +tempfile = "3.3.0" +tokio = { version = "1.24.1", features = ["macros", "time", "parking_lot"] } +wait-timeout = "0.2" +pallet-remark = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } diff --git a/README.md b/README.md index d5e21c8f..88d20fdf 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,7 @@ First, complete the [basic Rust setup instructions](./docs/rust-setup.md). Use the following command to build the Trappist collator binary: ```bash -cargo b -r --features with-trappist-runtime -cargo b -r --no-default-features --features with-stout-runtime --target-dir target_stout -``` - -Alternatively, run: -```bash -./scripts/build_runtimes.sh +cargo build --release ``` ### XCM Playground via Zombienet diff --git a/docker/scripts/inject_bootnodes.sh b/docker/scripts/inject_bootnodes.sh index b2779bf9..7b28daa0 100755 --- a/docker/scripts/inject_bootnodes.sh +++ b/docker/scripts/inject_bootnodes.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# this script runs the trappist-collator after fetching +# this script runs the trappist-node after fetching # appropriate bootnode IDs # # this is _not_ a general-purpose script; it is closely tied to the @@ -8,7 +8,7 @@ set -e -o pipefail -ctpc="/usr/bin/trappist-collator" +ctpc="/usr/bin/trappist-node" if [ ! -x "$ctpc" ]; then echo "FATAL: $ctpc does not exist or is not executable" diff --git a/docker/trappist-parachain.dockerfile b/docker/trappist-parachain.dockerfile index 33f846cd..ce6ae076 100644 --- a/docker/trappist-parachain.dockerfile +++ b/docker/trappist-parachain.dockerfile @@ -4,7 +4,7 @@ FROM docker.io/paritytech/ci-linux:production as builder WORKDIR /trappist COPY . /trappist -RUN cargo b -r --features with-trappist-runtime +RUN cargo build --release # the collator stage is normally built once, cached, and then ignored, but can # be specified with the --target build flag. This adds some extra tooling to the @@ -23,7 +23,7 @@ RUN apt-get update && apt-get install jq curl bash -y && \ npm install --global yarn && \ yarn global add @polkadot/api-cli@0.10.0-beta.14 COPY --from=builder \ - /trappist/target/release/trappist-collator /usr/bin + /trappist/target/release/trappist-node /usr/bin COPY ./docker/scripts/inject_bootnodes.sh /usr/bin CMD ["/usr/bin/inject_bootnodes.sh"] COPY ./docker/scripts/healthcheck.sh /usr/bin/ @@ -41,6 +41,6 @@ CMD ["cp", "-v", "/var/opt/trappist_runtime.wasm", "/runtime/"] FROM debian:buster-slim COPY --from=builder \ - /trappist/target/release/trappist-collator /usr/bin + /trappist/target/release/trappist-node /usr/bin -CMD ["/usr/bin/trappist-collator"] +CMD ["/usr/bin/trappist-node"] diff --git a/node/Cargo.toml b/node/Cargo.toml index 46705961..a253252d 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -1,54 +1,116 @@ [package] name = "trappist" version = "1.0.0" -authors = ["Trappist Network "] description = "A versatile Proof-of-Authority (PoA) Blockchain network." -license = "Unlicense" -homepage = "https://trappist.io" -repository = "https://github.com/TrappistNetwork/trappist" -edition = "2021" -default-run = "trappist-collator" +authors = { workspace = true } +license = { workspace = true } +homepage = { workspace = true } +repository = { workspace = true } +edition = { workspace = true } +default-run = "trappist-node" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] -[build-dependencies] -substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } - [[bin]] -required-features = ["with-trappist-runtime"] -name = "trappist-collator" +name = "trappist-node" path = "src/main.rs" +[dependencies] +async-trait = { workspace = true } +clap = { workspace = true } +parity-scale-codec = { workspace = true } +futures = { workspace = true } +hex-literal = { workspace = true } +log = { workspace = true } +serde = { workspace = true } -[[bin]] -required-features = ["with-stout-runtime"] -name = "stout-collator" -path = "src/main.rs" +# Local Dependencies +trappist-runtime = { workspace = true } +stout-runtime = { workspace = true } +jsonrpsee = { workspace = true, features = ["server"] } -[dependencies] -async-trait = "0.1.57" -clap = { version = "4.0.32", features = ["derive"] } -log = "0.4.17" -futures = { version = "0.3.1", features = ["compat"] } -trappist-cli = { path = "cli" } -trappist-service = { path = "service" } +# External Dependencies +pallet-dex-rpc = { workspace = true } + +# Substrate +frame-benchmarking = { workspace = true, features = [ "std" ] } +frame-benchmarking-cli = { workspace = true } +sp-runtime = { workspace = true } +sp-io = { workspace = true, features = [ "std" ] } +sp-core = { workspace = true, features = [ "std" ] } +sp-consensus = { workspace = true } +sp-session = { workspace = true, features = [ "std" ] } +sc-consensus = { workspace = true } +sc-cli = { workspace = true } +sc-client-api = { workspace = true } +sc-executor = { workspace = true } +sc-service = { workspace = true } +sc-telemetry = { workspace = true } +sc-transaction-pool = { workspace = true } +sp-transaction-pool = { workspace = true, features = [ "std" ] } +sc-network = { workspace = true } +sc-network-common = { workspace = true } +sc-basic-authorship = { workspace = true } +sp-timestamp = { workspace = true, features = [ "std" ] } +sp-blockchain = { workspace = true } +sp-block-builder = { workspace = true, features = [ "std" ] } +sp-keystore = { workspace = true, features = [ "std" ] } +sc-chain-spec = { workspace = true } +sc-rpc = { workspace = true } +sc-tracing = { workspace = true } +sc-network-sync = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +sp-offchain = { workspace = true, features = [ "std" ] } +sp-api = { workspace = true, features = [ "std" ] } +sp-consensus-aura = { workspace = true, features = [ "std" ] } +sc-sysinfo = { workspace = true } +sp-serializer = { workspace = true } +substrate-prometheus-endpoint = { workspace = true } +try-runtime-cli = { workspace = true, optional = true } +sc-transaction-pool-api = { workspace = true } +frame-rpc-system = { workspace = true } +pallet-transaction-payment-rpc = { workspace = true } +substrate-state-trie-migration-rpc = { workspace = true } + +# Polkadot +polkadot-cli = { workspace = true } +polkadot-primitives = { workspace = true } +polkadot-service = { workspace = true } +xcm = { workspace = true, features = [ "std" ] } + +# Cumulus +cumulus-client-cli ={ workspace = true } +cumulus-client-consensus-aura = { workspace = true } +cumulus-client-consensus-relay-chain = { workspace = true } +cumulus-client-consensus-common = { workspace = true } +cumulus-client-service = { workspace = true } +cumulus-client-network = { workspace = true } +cumulus-primitives-core = { workspace = true, features = [ "std" ] } +cumulus-primitives-parachain-inherent = { workspace = true } +cumulus-relay-chain-interface = { workspace = true } + +parachains-common = { workspace = true } + +[build-dependencies] +substrate-build-script-utils = { workspace = true } [dev-dependencies] -assert_cmd = "2.0" -nix = "0.23" -tempfile = "3.2.0" +assert_cmd = { workspace = true } +nix = { workspace = true } +tempfile = "3.3.0" +tokio = { workspace = true } +wait-timeout = { workspace = true } +# purge_chain_works works with rococo-local and needs to allow this +polkadot-cli = { workspace = true } [features] -default = ["with-trappist-runtime"] +default = [] runtime-benchmarks = [ - "trappist-cli/runtime-benchmarks" -] -with-trappist-runtime = [ - "trappist-service/with-trappist-runtime", - "trappist-cli/with-trappist-runtime", + "trappist-runtime/runtime-benchmarks", + "stout-runtime/runtime-benchmarks", + "polkadot-cli/runtime-benchmarks" ] -with-stout-runtime = [ - "trappist-service/with-stout-runtime", - "trappist-cli/with-stout-runtime", +try-runtime = [ + "trappist-runtime/try-runtime", + "stout-runtime/try-runtime" ] diff --git a/node/build.rs b/node/build.rs new file mode 100644 index 00000000..ae164d6c --- /dev/null +++ b/node/build.rs @@ -0,0 +1,22 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Substrate 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. + +// Substrate 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 Cumulus. If not, see . + +use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed}; + +fn main() { + generate_cargo_keys(); + rerun_if_git_head_changed(); +} diff --git a/node/cli/Cargo.toml b/node/cli/Cargo.toml deleted file mode 100644 index c12e1ad6..00000000 --- a/node/cli/Cargo.toml +++ /dev/null @@ -1,97 +0,0 @@ -[package] -name = "trappist-cli" -version = "1.0.0" -authors = ["Trappist Network "] -description = "A versatile Proof-of-Authority (PoA) Blockchain network." -license = "Unlicense" -homepage = "https://trappist.io" -repository = "https://github.com/TrappistNetwork/trappist" -edition = "2021" -build = "build.rs" - -[package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] - -[build-dependencies] -substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } - -[dependencies] -async-trait = "0.1.57" -clap = { version = "4.0.32", features = ["derive"] } -log = "0.4.17" -codec = { package = "parity-scale-codec", version = "3.0.0" } -serde = { version = "1.0.152", features = ["derive"] } -futures = { version = "0.3.1", features = ["compat"] } - -# RPC related Dependencies -jsonrpsee = { version = "0.16.2", features = ["server"] } - -# Local Dependencies -trappist-runtime = { path = "../../runtime/trappist" } -stout-runtime = { path = "../../runtime/stout" } - -# Substrate Dependencies -frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", optional = true } -try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", optional = true } - -## Substrate Client Dependencies -sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", optional = true} -sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", optional = true } -sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } - -## Substrate Primitive Dependencies -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" , optional = true} -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } - -# Cumulus dependencies -cumulus-client-cli = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } -cumulus-client-consensus-aura = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } -cumulus-client-consensus-relay-chain = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } -cumulus-client-consensus-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } -cumulus-client-network = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } -cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } -cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } -cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } -cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } - -parachains-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } - -# Polkadot dependencies -polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.40", features = [ "rococo-native" ] } -polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.40" } -polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.40" } -polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.40" } - -service = { package = "trappist-service", path = "../service", default-features = false, optional = true } - -[dev-dependencies] -assert_cmd = "2.0" -nix = "0.23" -tempfile = "3.2.0" - -[features] -default = [ "cli" ] -cli = [ - "service", - "sp-core", - "sc-cli", - "sc-service", - "frame-benchmarking-cli", - "try-runtime-cli", -] -runtime-benchmarks = [ - "polkadot-cli/runtime-benchmarks", - "trappist-runtime/runtime-benchmarks", - "stout-runtime/runtime-benchmarks" -] -try-runtime = [ - "service/try-runtime" -] -with-trappist-runtime = [ - "service/with-trappist-runtime", -] -with-stout-runtime = [ - "service/with-stout-runtime", -] diff --git a/node/cli/build.rs b/node/cli/build.rs deleted file mode 100644 index e3bfe311..00000000 --- a/node/cli/build.rs +++ /dev/null @@ -1,7 +0,0 @@ -use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed}; - -fn main() { - generate_cargo_keys(); - - rerun_if_git_head_changed(); -} diff --git a/node/cli/src/lib.rs b/node/cli/src/lib.rs deleted file mode 100644 index 89e28302..00000000 --- a/node/cli/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -// TODO: Write missing docs. -//#![warn(missing_docs)] -#![warn(unused_extern_crates)] - -#[cfg(feature = "cli")] -mod cli; -#[cfg(feature = "cli")] -mod command; - -#[cfg(feature = "cli")] -pub use cli::*; - -#[cfg(feature = "cli")] -pub use command::*; - -#[cfg(feature = "cli")] -pub use sc_cli::{Error, Result}; diff --git a/node/service/Cargo.toml b/node/service/Cargo.toml deleted file mode 100644 index 07db6b18..00000000 --- a/node/service/Cargo.toml +++ /dev/null @@ -1,122 +0,0 @@ -[package] -name = "trappist-service" -version = "1.0.0" -authors = ["Trappist Network "] -description = "A versatile Proof-of-Authority (PoA) Blockchain network." -license = "Unlicense" -homepage = "https://trappist.io" -repository = "https://github.com/TrappistNetwork/trappist" -edition = "2021" - -[package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] - -[build-dependencies] -substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } - -[dependencies] -async-trait = "0.1.57" -clap = { version = "4.0.32", features = ["derive"] } -log = "0.4.17" -codec = { package = "parity-scale-codec", version = "3.0.0" } -serde = { version = "1.0.152", features = ["derive"] } -futures = { version = "0.3.1", features = ["compat"] } -hex-literal = "0.3.4" - -# RPC related Dependencies -jsonrpsee = { version = "0.16.2", features = ["server"] } - -# Local Dependencies -trappist-runtime = { path = "../../runtime/trappist", optional = true } -trappist-rpc = { path = "../../rpc" } -stout-runtime = { path = "../../runtime/stout", optional = true } - -# Substrate Dependencies -frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } - -pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } - -substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } - -## Substrate Client Dependencies -sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } - -## Substrate Primitive Dependencies -sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-network-sync = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } - -# Cumulus dependencies -cumulus-client-cli = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } -cumulus-client-consensus-aura = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } -cumulus-client-consensus-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } -cumulus-client-network = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } -cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } -cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } -cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } -cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" } - -parachains-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } - -# Polkadot dependencies -polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.40" } -polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.40" } -polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.40" } -polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.40" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } - -# External Dependencies -pallet-dex-rpc = { version = "0.0.1", git = "https://github.com/paritytech/substrate-dex.git", default-features = false, branch = "polkadot-v0.9.40"} - -[dev-dependencies] -assert_cmd = "2.0" -nix = "0.23" -tempfile = "3.2.0" - -[features] -default = [ "std" ] -std = [] -runtime-benchmarks = [ - "trappist-runtime/runtime-benchmarks", - "stout-runtime/runtime-benchmarks" -] -try-runtime = [ - "trappist-runtime/try-runtime" -] -with-stout-runtime = [ - "stout-runtime", -] -with-trappist-runtime = [ - "trappist-runtime", -] - diff --git a/node/service/src/chain_spec/mod.rs b/node/service/src/chain_spec/mod.rs deleted file mode 100644 index c71d9824..00000000 --- a/node/service/src/chain_spec/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[cfg(feature = "with-stout-runtime")] -pub mod stout; - -#[cfg(feature = "with-trappist-runtime")] -pub mod trappist; diff --git a/node/service/src/lib.rs b/node/service/src/lib.rs deleted file mode 100644 index daa504af..00000000 --- a/node/service/src/lib.rs +++ /dev/null @@ -1,654 +0,0 @@ -//! Service and ServiceFactory implementation. Specialized wrapper over substrate service. - -// std -use std::{sync::Arc, time::Duration}; - -// Common Runtime Types -pub use parachains_common::{Block, Hash}; - -// Cumulus Imports -use cumulus_client_cli::CollatorOptions; -use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion}; -use cumulus_client_consensus_common::{ - ParachainBlockImport as TParachainBlockImport, ParachainConsensus, -}; -use cumulus_client_service::{ - build_network, build_relay_chain_interface, prepare_node_config, start_collator, - start_full_node, BuildNetworkParams, StartCollatorParams, StartFullNodeParams, -}; -use cumulus_primitives_core::ParaId; -use cumulus_relay_chain_interface::RelayChainInterface; -use sc_consensus::ImportQueue; - -use sc_executor::NativeElseWasmExecutor; -use sc_network::NetworkBlock; -use sc_network_sync::SyncingService; -use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager}; -use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; -use sp_keystore::SyncCryptoStorePtr; -use substrate_prometheus_endpoint::Registry; - -pub mod chain_spec; - -#[cfg(all(feature = "with-trappist-runtime", feature = "with-stout-runtime"))] -compile_error!("features `with-trappist-runtime` and `with-stout-runtime` are mutually exclusive"); - -#[cfg(feature = "with-stout-runtime")] -pub mod stout_executor { - pub use stout_runtime; - pub struct NativeExecutor; - impl sc_executor::NativeExecutionDispatch for NativeExecutor { - type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; - - fn dispatch(method: &str, data: &[u8]) -> Option> { - stout_runtime::api::dispatch(method, data) - } - - fn native_version() -> sc_executor::NativeVersion { - stout_runtime::native_version() - } - } -} -#[cfg(feature = "with-trappist-runtime")] -pub mod trappist_executor { - pub use trappist_runtime; - - pub struct NativeExecutor; - impl sc_executor::NativeExecutionDispatch for NativeExecutor { - type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; - - fn dispatch(method: &str, data: &[u8]) -> Option> { - trappist_runtime::api::dispatch(method, data) - } - - fn native_version() -> sc_executor::NativeVersion { - trappist_runtime::native_version() - } - } -} - -#[cfg(feature = "with-stout-runtime")] -pub use stout_executor::*; - -#[cfg(feature = "with-trappist-runtime")] -pub use trappist_executor::*; - -#[cfg(feature = "with-trappist-runtime")] -pub type RuntimeApi = trappist_runtime::RuntimeApi; - -#[cfg(feature = "with-stout-runtime")] -pub type RuntimeApi = stout_runtime::RuntimeApi; - -type ParachainExecutor = NativeElseWasmExecutor; - -type ParachainClient = TFullClient; - -type ParachainBackend = TFullBackend; - -type ParachainBlockImport = TParachainBlockImport, ParachainBackend>; - -/// Starts a `ServiceBuilder` for a full service. -/// -/// Use this macro if you don't actually need the full service, but just the builder in order to -/// be able to perform chain operations. -pub fn new_partial( - config: &Configuration, -) -> Result< - PartialComponents< - ParachainClient, - ParachainBackend, - (), - sc_consensus::DefaultImportQueue, - sc_transaction_pool::FullPool, - (ParachainBlockImport, Option, Option), - >, - sc_service::Error, -> { - let telemetry = config - .telemetry_endpoints - .clone() - .filter(|x| !x.is_empty()) - .map(|endpoints| -> Result<_, sc_telemetry::Error> { - let worker = TelemetryWorker::new(16)?; - let telemetry = worker.handle().new_telemetry(endpoints); - Ok((worker, telemetry)) - }) - .transpose()?; - - let executor = ParachainExecutor::new( - config.wasm_method, - config.default_heap_pages, - config.max_runtime_instances, - config.runtime_cache_size, - ); - - let (client, backend, keystore_container, task_manager) = - sc_service::new_full_parts::( - config, - telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), - executor, - )?; - let client = Arc::new(client); - - let telemetry_worker_handle = telemetry.as_ref().map(|(worker, _)| worker.handle()); - - let telemetry = telemetry.map(|(worker, telemetry)| { - task_manager.spawn_handle().spawn("telemetry", None, worker.run()); - telemetry - }); - - let transaction_pool = sc_transaction_pool::BasicPool::new_full( - config.transaction_pool.clone(), - config.role.is_authority().into(), - config.prometheus_registry(), - task_manager.spawn_essential_handle(), - client.clone(), - ); - - let block_import = ParachainBlockImport::new(client.clone(), backend.clone()); - - let import_queue = build_import_queue( - client.clone(), - block_import.clone(), - config, - telemetry.as_ref().map(|telemetry| telemetry.handle()), - &task_manager, - )?; - - Ok(PartialComponents { - backend, - client, - import_queue, - keystore_container, - task_manager, - transaction_pool, - select_chain: (), - other: (block_import, telemetry, telemetry_worker_handle), - }) -} - -/// Start a node with the given parachain `Configuration` and relay chain `Configuration`. -/// -/// This is the actual implementation that is abstract over the executor and the runtime api. -#[cfg(feature = "with-trappist-runtime")] -#[sc_tracing::logging::prefix_logs_with("Parachain")] -async fn start_node_impl( - parachain_config: Configuration, - polkadot_config: Configuration, - collator_options: CollatorOptions, - para_id: ParaId, - hwbench: Option, -) -> sc_service::error::Result<(TaskManager, Arc)> { - use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE; - - let parachain_config = prepare_node_config(parachain_config); - - let params = new_partial(¶chain_config)?; - let (block_import, mut telemetry, telemetry_worker_handle) = params.other; - - let client = params.client.clone(); - let backend = params.backend.clone(); - - let mut task_manager = params.task_manager; - let (relay_chain_interface, collator_key) = build_relay_chain_interface( - polkadot_config, - ¶chain_config, - telemetry_worker_handle, - &mut task_manager, - collator_options.clone(), - hwbench.clone(), - ) - .await - .map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?; - - let force_authoring = parachain_config.force_authoring; - let validator = parachain_config.role.is_authority(); - let prometheus_registry = parachain_config.prometheus_registry().cloned(); - let transaction_pool = params.transaction_pool.clone(); - let import_queue_service = params.import_queue.service(); - let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) = - build_network(BuildNetworkParams { - parachain_config: ¶chain_config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - para_id, - spawn_handle: task_manager.spawn_handle(), - relay_chain_interface: relay_chain_interface.clone(), - import_queue: params.import_queue, - }) - .await?; - - if parachain_config.offchain_worker.enabled { - sc_service::build_offchain_workers( - ¶chain_config, - task_manager.spawn_handle(), - client.clone(), - network.clone(), - ); - } - - let rpc_builder = { - let client = client.clone(); - let transaction_pool = transaction_pool.clone(); - - Box::new(move |deny_unsafe, _| { - let deps = trappist_rpc::FullDeps { - client: client.clone(), - pool: transaction_pool.clone(), - deny_unsafe, - }; - - trappist_rpc::trappist_create_full(deps).map_err(Into::into) - }) - }; - - if parachain_config.offchain_worker.enabled { - sc_service::build_offchain_workers( - ¶chain_config, - task_manager.spawn_handle(), - client.clone(), - network.clone(), - ); - } - - sc_service::spawn_tasks(sc_service::SpawnTasksParams { - rpc_builder, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - task_manager: &mut task_manager, - config: parachain_config, - keystore: params.keystore_container.sync_keystore(), - backend, - network: network.clone(), - system_rpc_tx, - tx_handler_controller, - telemetry: telemetry.as_mut(), - sync_service: sync_service.clone(), - })?; - - if let Some(hwbench) = hwbench { - sc_sysinfo::print_hwbench(&hwbench); - - //Check whether the hardware meets your chains' requirements. The - // requirements for a para-chain are dictated by its relay-chain. - if !SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench) && validator { - log::warn!( - "⚠️ The hardware does not meet the minimal requirements for role 'Authority'." - ); - } - - if let Some(ref mut telemetry) = telemetry { - let telemetry_handle = telemetry.handle(); - task_manager.spawn_handle().spawn( - "telemetry_hwbench", - None, - sc_sysinfo::initialize_hwbench_telemetry(telemetry_handle, hwbench), - ); - } - } - - let announce_block = { - let sync_service = sync_service.clone(); - Arc::new(move |hash, data| sync_service.announce_block(hash, data)) - }; - - let relay_chain_slot_duration = Duration::from_secs(6); - - let overseer_handle = relay_chain_interface - .overseer_handle() - .map_err(|e| sc_service::Error::Application(Box::new(e)))?; - - if validator { - let parachain_consensus = build_consensus( - client.clone(), - block_import, - prometheus_registry.as_ref(), - telemetry.as_ref().map(|t| t.handle()), - &task_manager, - relay_chain_interface.clone(), - transaction_pool, - sync_service, - params.keystore_container.sync_keystore(), - force_authoring, - para_id, - )?; - - let spawner = task_manager.spawn_handle(); - let params = StartCollatorParams { - para_id, - block_status: client.clone(), - announce_block, - client: client.clone(), - task_manager: &mut task_manager, - relay_chain_interface: relay_chain_interface.clone(), - spawner, - parachain_consensus, - import_queue: import_queue_service, - collator_key: collator_key.expect("Command line arguments do not allow this. qed"), - relay_chain_slot_duration, - recovery_handle: Box::new(overseer_handle), - }; - - start_collator(params).await?; - } else { - let params = StartFullNodeParams { - client: client.clone(), - announce_block, - task_manager: &mut task_manager, - para_id, - relay_chain_interface, - relay_chain_slot_duration, - import_queue: import_queue_service, - recovery_handle: Box::new(overseer_handle), - }; - - start_full_node(params)?; - } - - start_network.start_network(); - - Ok((task_manager, client)) -} - -// TODO: how to avoid having two of these huge functions? -/// Start a node with the given parachain `Configuration` and relay chain `Configuration`. -/// -/// This is the actual implementation that is abstract over the executor and the runtime api. -#[cfg(feature = "with-stout-runtime")] -#[sc_tracing::logging::prefix_logs_with("Parachain")] -async fn start_node_impl( - parachain_config: Configuration, - polkadot_config: Configuration, - collator_options: CollatorOptions, - para_id: ParaId, - hwbench: Option, -) -> sc_service::error::Result<(TaskManager, Arc)> { - use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE; - - let parachain_config = prepare_node_config(parachain_config); - - let params = new_partial(¶chain_config)?; - let (block_import, mut telemetry, telemetry_worker_handle) = params.other; - - let client = params.client.clone(); - let backend = params.backend.clone(); - - let mut task_manager = params.task_manager; - let (relay_chain_interface, collator_key) = build_relay_chain_interface( - polkadot_config, - ¶chain_config, - telemetry_worker_handle, - &mut task_manager, - collator_options.clone(), - hwbench.clone(), - ) - .await - .map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?; - - let force_authoring = parachain_config.force_authoring; - let validator = parachain_config.role.is_authority(); - let prometheus_registry = parachain_config.prometheus_registry().cloned(); - let transaction_pool = params.transaction_pool.clone(); - let import_queue_service = params.import_queue.service(); - let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) = - build_network(BuildNetworkParams { - parachain_config: ¶chain_config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - para_id, - spawn_handle: task_manager.spawn_handle(), - relay_chain_interface: relay_chain_interface.clone(), - import_queue: params.import_queue, - }) - .await?; - - if parachain_config.offchain_worker.enabled { - sc_service::build_offchain_workers( - ¶chain_config, - task_manager.spawn_handle(), - client.clone(), - network.clone(), - ); - } - - let rpc_builder = { - let client = client.clone(); - let transaction_pool = transaction_pool.clone(); - - Box::new(move |deny_unsafe, _| { - let deps = trappist_rpc::FullDeps { - client: client.clone(), - pool: transaction_pool.clone(), - deny_unsafe, - }; - - trappist_rpc::stout_create_full(deps).map_err(Into::into) - }) - }; - - if parachain_config.offchain_worker.enabled { - sc_service::build_offchain_workers( - ¶chain_config, - task_manager.spawn_handle(), - client.clone(), - network.clone(), - ); - } - - sc_service::spawn_tasks(sc_service::SpawnTasksParams { - rpc_builder, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - task_manager: &mut task_manager, - config: parachain_config, - keystore: params.keystore_container.sync_keystore(), - backend, - network: network.clone(), - system_rpc_tx, - tx_handler_controller, - telemetry: telemetry.as_mut(), - sync_service: sync_service.clone(), - })?; - - if let Some(hwbench) = hwbench { - sc_sysinfo::print_hwbench(&hwbench); - - //Check whether the hardware meets your chains' requirements. The - // requirements for a para-chain are dictated by its relay-chain. - if !SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench) && validator { - log::warn!( - "⚠️ The hardware does not meet the minimal requirements for role 'Authority'." - ); - } - - if let Some(ref mut telemetry) = telemetry { - let telemetry_handle = telemetry.handle(); - task_manager.spawn_handle().spawn( - "telemetry_hwbench", - None, - sc_sysinfo::initialize_hwbench_telemetry(telemetry_handle, hwbench), - ); - } - } - - let announce_block = { - let sync_service = sync_service.clone(); - Arc::new(move |hash, data| sync_service.announce_block(hash, data)) - }; - - let overseer_handle = relay_chain_interface - .overseer_handle() - .map_err(|e| sc_service::Error::Application(Box::new(e)))?; - - let relay_chain_slot_duration = Duration::from_secs(6); - - if validator { - let parachain_consensus = build_consensus( - client.clone(), - block_import, - prometheus_registry.as_ref(), - telemetry.as_ref().map(|t| t.handle()), - &task_manager, - relay_chain_interface.clone(), - transaction_pool, - sync_service, - params.keystore_container.sync_keystore(), - force_authoring, - para_id, - )?; - - let spawner = task_manager.spawn_handle(); - - let params = StartCollatorParams { - para_id, - block_status: client.clone(), - announce_block, - client: client.clone(), - task_manager: &mut task_manager, - relay_chain_interface: relay_chain_interface.clone(), - spawner, - parachain_consensus, - import_queue: import_queue_service, - collator_key: collator_key.expect("Command line arguments do not allow this. qed"), - relay_chain_slot_duration, - recovery_handle: Box::new(overseer_handle), - }; - - start_collator(params).await?; - } else { - let params = StartFullNodeParams { - client: client.clone(), - announce_block, - task_manager: &mut task_manager, - para_id, - relay_chain_interface, - relay_chain_slot_duration, - import_queue: import_queue_service, - recovery_handle: Box::new(overseer_handle), - }; - - start_full_node(params)?; - } - - start_network.start_network(); - - Ok((task_manager, client)) -} - -/// Build the import queue for the rococo parachain runtime. -fn build_import_queue( - client: Arc, - block_import: ParachainBlockImport, - config: &Configuration, - telemetry: Option, - task_manager: &TaskManager, -) -> Result, sc_service::Error> { - let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; - - cumulus_client_consensus_aura::import_queue::< - sp_consensus_aura::sr25519::AuthorityPair, - _, - _, - _, - _, - _, - >(cumulus_client_consensus_aura::ImportQueueParams { - block_import, - client, - create_inherent_data_providers: move |_, _| async move { - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - - let slot = - sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *timestamp, - slot_duration, - ); - - Ok((slot, timestamp)) - }, - registry: config.prometheus_registry(), - spawner: &task_manager.spawn_essential_handle(), - telemetry, - }) - .map_err(Into::into) -} - -fn build_consensus( - client: Arc, - block_import: ParachainBlockImport, - prometheus_registry: Option<&Registry>, - telemetry: Option, - task_manager: &TaskManager, - relay_chain_interface: Arc, - transaction_pool: Arc>, - sync_oracle: Arc>, - keystore: SyncCryptoStorePtr, - force_authoring: bool, - para_id: ParaId, -) -> Result>, sc_service::Error> { - let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; - - let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording( - task_manager.spawn_handle(), - client.clone(), - transaction_pool, - prometheus_registry, - telemetry.clone(), - ); - - let params = BuildAuraConsensusParams { - proposer_factory, - create_inherent_data_providers: move |_, (relay_parent, validation_data)| { - let relay_chain_interface = relay_chain_interface.clone(); - async move { - let parachain_inherent = - cumulus_primitives_parachain_inherent::ParachainInherentData::create_at( - relay_parent, - &relay_chain_interface, - &validation_data, - para_id, - ) - .await; - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - - let slot = - sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *timestamp, - slot_duration, - ); - - let parachain_inherent = parachain_inherent.ok_or_else(|| { - Box::::from( - "Failed to create parachain inherent", - ) - })?; - Ok((slot, timestamp, parachain_inherent)) - } - }, - block_import, - para_client: client, - backoff_authoring_blocks: Option::<()>::None, - sync_oracle, - keystore, - force_authoring, - slot_duration, - // We got around 500ms for proposing - block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32), - // And a maximum of 750ms if slots are skipped - max_block_proposal_slot_portion: Some(SlotProportion::new(1f32 / 16f32)), - telemetry, - }; - - Ok(AuraConsensus::build::(params)) -} - -/// Start a parachain node. -pub async fn start_parachain_node( - parachain_config: Configuration, - polkadot_config: Configuration, - collator_options: CollatorOptions, - para_id: ParaId, - hwbench: Option, -) -> sc_service::error::Result<(TaskManager, Arc)> { - start_node_impl(parachain_config, polkadot_config, collator_options, para_id, hwbench).await -} diff --git a/node/src/chain_spec/mod.rs b/node/src/chain_spec/mod.rs new file mode 100644 index 00000000..36b1b67a --- /dev/null +++ b/node/src/chain_spec/mod.rs @@ -0,0 +1,68 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . + +use parachains_common::{AccountId, Signature}; +use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; +use serde::{Deserialize, Serialize}; +use sp_core::{Pair, Public}; +use sp_runtime::traits::{IdentifyAccount, Verify}; + +pub mod stout; +pub mod trappist; + +/// The default XCM version to set in genesis config. +const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; + +/// Generic extensions for Parachain ChainSpecs. +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)] +#[serde(deny_unknown_fields)] +pub struct Extensions { + /// The relay chain of the Parachain. + pub relay_chain: String, + /// The id of the Parachain. + pub para_id: u32, +} + +impl Extensions { + /// Try to get the extension from the given `ChainSpec`. + pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> { + sc_chain_spec::get_extension(chain_spec.extensions()) + } +} + +/// Helper function to generate a crypto pair from seed +pub fn get_public_from_seed(seed: &str) -> ::Public { + TPublic::Pair::from_string(&format!("//{}", seed), None) + .expect("static values are valid; qed") + .public() +} + +type AccountPublic = ::Signer; + +/// Helper function to generate an account ID from seed +pub fn get_account_id_from_seed(seed: &str) -> AccountId +where + AccountPublic: From<::Public>, +{ + AccountPublic::from(get_public_from_seed::(seed)).into_account() +} + +/// Generate collator keys from seed. +/// +/// This function's return type must always match the session keys of the chain in tuple format. +pub fn get_collator_keys_from_seed(seed: &str) -> ::Public { + get_public_from_seed::(seed) +} diff --git a/node/service/src/chain_spec/stout.rs b/node/src/chain_spec/stout.rs similarity index 54% rename from node/service/src/chain_spec/stout.rs rename to node/src/chain_spec/stout.rs index dbc7e7e5..e7cfda94 100644 --- a/node/service/src/chain_spec/stout.rs +++ b/node/src/chain_spec/stout.rs @@ -1,12 +1,14 @@ +use crate::chain_spec::{ + get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION, +}; use cumulus_primitives_core::ParaId; -use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; + use sc_service::ChainType; -use serde::{Deserialize, Serialize}; -use sp_core::{sr25519, Pair, Public}; -use sp_runtime::traits::{IdentifyAccount, Verify}; + +use sp_core::sr25519; use stout_runtime::{ constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AssetsConfig, AuraId, BalancesConfig, - CouncilConfig, GenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, + CouncilConfig, GenesisConfig, SessionConfig, SessionKeys, SudoConfig, SystemConfig, }; const DEFAULT_PROTOCOL_ID: &str = "stout"; @@ -14,52 +16,8 @@ const DEFAULT_PROTOCOL_ID: &str = "stout"; /// Specialized `ChainSpec` for the normal parachain runtime. pub type ChainSpec = sc_service::GenericChainSpec; -/// The default XCM version to set in genesis config. -const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; - const STOUT_PARA_ID: u32 = 3000; -/// Helper function to generate a crypto pair from seed -pub fn get_public_from_seed(seed: &str) -> ::Public { - TPublic::Pair::from_string(&format!("//{}", seed), None) - .expect("static values are valid; qed") - .public() -} - -/// The extensions for the [`ChainSpec`]. -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)] -#[serde(deny_unknown_fields)] -pub struct Extensions { - /// The relay chain of the Parachain. - pub relay_chain: String, - /// The id of the Parachain. - pub para_id: u32, -} - -impl Extensions { - /// Try to get the extension from the given `ChainSpec`. - pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> { - sc_chain_spec::get_extension(chain_spec.extensions()) - } -} - -type AccountPublic = ::Signer; - -/// Generate collator keys from seed. -/// -/// This function's return type must always match the session keys of the chain in tuple format. -pub fn get_collator_keys_from_seed(seed: &str) -> AuraId { - get_public_from_seed::(seed) -} - -/// Helper function to generate an account ID from seed -pub fn get_account_id_from_seed(seed: &str) -> AccountId -where - AccountPublic: From<::Public>, -{ - AccountPublic::from(get_public_from_seed::(seed)).into_account() -} - /// Generate the session keys from individual elements. /// /// The input must be a tuple of individual keys (a single arg for now since we have just one key). @@ -67,60 +25,6 @@ fn session_keys(aura: AuraId) -> SessionKeys { SessionKeys { aura } } -pub fn development_config() -> ChainSpec { - // Give your stout currency a unit name and decimal places - let mut properties = sc_chain_spec::Properties::new(); - properties.insert("tokenSymbol".into(), "STOUT".into()); - properties.insert("tokenDecimals".into(), 12.into()); - properties.insert("ss58Format".into(), 42.into()); - - ChainSpec::from_genesis( - // Name - "Stout Development", - // ID - "stout_dev", - ChainType::Development, - move || { - testnet_genesis( - // Initial collators. - vec![ - ( - get_account_id_from_seed::("Alice"), - get_collator_keys_from_seed("Alice"), - ), - ( - get_account_id_from_seed::("Bob"), - get_collator_keys_from_seed("Bob"), - ), - ], - // Sudo account - get_account_id_from_seed::("Alice"), - // Pre-funded accounts - vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Charlie"), - ], - STOUT_PARA_ID.into(), - ) - }, - // Bootnodes - vec![], - // Telemetry - None, - // Protocol ID - Some(DEFAULT_PROTOCOL_ID), - None, - // Properties - Some(properties), - // Extensions - Extensions { - relay_chain: "rococo-local".into(), // You MUST set this to the correct network! - para_id: STOUT_PARA_ID, - }, - ) -} - pub fn stout_local_testnet_config() -> ChainSpec { // Give your stout currency a unit name and decimal places let mut properties = sc_chain_spec::Properties::new(); @@ -140,11 +44,11 @@ pub fn stout_local_testnet_config() -> ChainSpec { vec![ ( get_account_id_from_seed::("Alice"), - get_collator_keys_from_seed("Alice"), + get_collator_keys_from_seed::("Alice"), ), ( get_account_id_from_seed::("Bob"), - get_collator_keys_from_seed("Bob"), + get_collator_keys_from_seed::("Bob"), ), ], // Sudo account @@ -228,5 +132,6 @@ fn testnet_genesis( members: invulnerables.iter().map(|x| x.0.clone()).collect::>(), phantom: Default::default(), }, + dex: Default::default(), } } diff --git a/node/service/src/chain_spec/trappist.rs b/node/src/chain_spec/trappist.rs similarity index 81% rename from node/service/src/chain_spec/trappist.rs rename to node/src/chain_spec/trappist.rs index 5d9fa82c..81c1d6e2 100644 --- a/node/service/src/chain_spec/trappist.rs +++ b/node/src/chain_spec/trappist.rs @@ -1,13 +1,13 @@ +use crate::chain_spec::{ + get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION, +}; use cumulus_primitives_core::ParaId; use hex_literal::hex; -use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; use sc_service::ChainType; -use serde::{Deserialize, Serialize}; -use sp_core::{crypto::UncheckedInto, sr25519, Pair, Public}; -use sp_runtime::traits::{IdentifyAccount, Verify}; +use sp_core::{crypto::UncheckedInto, sr25519}; use trappist_runtime::{ constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AssetsConfig, AuraId, BalancesConfig, - CouncilConfig, GenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, + CouncilConfig, GenesisConfig, SessionConfig, SessionKeys, SudoConfig, SystemConfig, }; const DEFAULT_PROTOCOL_ID: &str = "hop"; @@ -15,52 +15,8 @@ const DEFAULT_PROTOCOL_ID: &str = "hop"; /// Specialized `ChainSpec` for the normal parachain runtime. pub type ChainSpec = sc_service::GenericChainSpec; -/// The default XCM version to set in genesis config. -const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; - const TRAPPIST_PARA_ID: u32 = 1836; -/// Helper function to generate a crypto pair from seed -pub fn get_public_from_seed(seed: &str) -> ::Public { - TPublic::Pair::from_string(&format!("//{}", seed), None) - .expect("static values are valid; qed") - .public() -} - -/// The extensions for the [`ChainSpec`]. -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)] -#[serde(deny_unknown_fields)] -pub struct Extensions { - /// The relay chain of the Parachain. - pub relay_chain: String, - /// The id of the Parachain. - pub para_id: u32, -} - -impl Extensions { - /// Try to get the extension from the given `ChainSpec`. - pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> { - sc_chain_spec::get_extension(chain_spec.extensions()) - } -} - -type AccountPublic = ::Signer; - -/// Generate collator keys from seed. -/// -/// This function's return type must always match the session keys of the chain in tuple format. -pub fn get_collator_keys_from_seed(seed: &str) -> AuraId { - get_public_from_seed::(seed) -} - -/// Helper function to generate an account ID from seed -pub fn get_account_id_from_seed(seed: &str) -> AccountId -where - AccountPublic: From<::Public>, -{ - AccountPublic::from(get_public_from_seed::(seed)).into_account() -} - /// Generate the session keys from individual elements. /// /// The input must be a tuple of individual keys (a single arg for now since we have just one key). @@ -87,11 +43,11 @@ pub fn development_config() -> ChainSpec { vec![ ( get_account_id_from_seed::("Alice"), - get_collator_keys_from_seed("Alice"), + get_collator_keys_from_seed::("Alice"), ), ( get_account_id_from_seed::("Bob"), - get_collator_keys_from_seed("Bob"), + get_collator_keys_from_seed::("Bob"), ), ], // Sudo account @@ -141,11 +97,11 @@ pub fn trappist_local_testnet_config() -> ChainSpec { vec![ ( get_account_id_from_seed::("Alice"), - get_collator_keys_from_seed("Alice"), + get_collator_keys_from_seed::("Alice"), ), ( get_account_id_from_seed::("Bob"), - get_collator_keys_from_seed("Bob"), + get_collator_keys_from_seed::("Bob"), ), ], // Sudo account @@ -180,7 +136,7 @@ pub fn trappist_local_testnet_config() -> ChainSpec { } /// Configure initial storage state for FRAME modules. -fn testnet_genesis( +pub fn testnet_genesis( invulnerables: Vec<(AccountId, AuraId)>, root_key: AccountId, endowed_accounts: Vec, diff --git a/node/cli/src/cli.rs b/node/src/cli.rs similarity index 92% rename from node/cli/src/cli.rs rename to node/src/cli.rs index 2a7615e4..90460095 100644 --- a/node/cli/src/cli.rs +++ b/node/src/cli.rs @@ -14,15 +14,15 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . -#[cfg(feature = "with-stout-runtime")] -use service::chain_spec::stout::Extensions; -#[cfg(feature = "with-trappist-runtime")] -use service::chain_spec::trappist::Extensions; use std::path::PathBuf; /// Sub-commands supported by the collator. #[derive(Debug, clap::Subcommand)] pub enum Subcommand { + /// Key management CLI utilities + #[command(subcommand)] + Key(sc_cli::KeySubcommand), + /// Build a chain specification. BuildSpec(sc_cli::BuildSpecCmd), @@ -89,7 +89,7 @@ pub struct Cli { /// Relay chain arguments #[arg(raw = true)] - pub relay_chain_args: Vec, + pub relaychain_args: Vec, } #[derive(Debug)] @@ -110,7 +110,7 @@ impl RelayChainCli { para_config: &sc_service::Configuration, relay_chain_args: impl Iterator, ) -> Self { - let extension = Extensions::try_get(&*para_config.chain_spec); + let extension = crate::chain_spec::Extensions::try_get(&*para_config.chain_spec); let chain_id = extension.map(|e| e.relay_chain.clone()); let base_path = para_config.base_path.as_ref().map(|x| x.path().join("polkadot")); Self { base_path, chain_id, base: clap::Parser::parse_from(relay_chain_args) } diff --git a/node/cli/src/command.rs b/node/src/command.rs similarity index 50% rename from node/cli/src/command.rs rename to node/src/command.rs index 6f50ea8a..e5d6f6c5 100644 --- a/node/cli/src/command.rs +++ b/node/src/command.rs @@ -1,10 +1,30 @@ -use std::net::SocketAddr; - -use codec::Encode; +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . + +use crate::{ + chain_spec, + cli::{Cli, RelayChainCli, Subcommand}, + service::{new_partial, Block, StoutRuntimeExecutor, TrappistRuntimeExecutor}, +}; use cumulus_client_cli::generate_genesis_block; use cumulus_primitives_core::ParaId; use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE}; use log::{info, warn}; +use parachains_common::AuraId; +use parity_scale_codec::Encode; use sc_cli::{ ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli, @@ -12,28 +32,80 @@ use sc_cli::{ use sc_service::config::{BasePath, PrometheusConfig}; use sp_core::hexdisplay::HexDisplay; use sp_runtime::traits::{AccountIdConversion, Block as BlockT}; +use std::{net::SocketAddr, path::PathBuf}; + +/// Helper enum that is used for better distinction of different parachain/runtime configuration +/// (it is based/calculated on ChainSpec's ID attribute) +#[derive(Debug, PartialEq, Default)] +enum Runtime { + /// This is the default runtime (actually based on rococo) + #[default] + Default, + Trappist, + Stout, +} -#[cfg(feature = "with-stout-runtime")] -use stout_runtime::Block; -#[cfg(feature = "with-trappist-runtime")] -use trappist_runtime::Block; +trait RuntimeResolver { + fn runtime(&self) -> Runtime; +} -use crate::cli::{Cli, RelayChainCli, Subcommand}; -use service::{new_partial, NativeExecutor}; +impl RuntimeResolver for dyn ChainSpec { + fn runtime(&self) -> Runtime { + runtime(self.id()) + } +} -#[cfg(feature = "with-stout-runtime")] -use service::chain_spec::stout::{ - development_config, stout_local_testnet_config, ChainSpec as ServiceChainSpec, Extensions, -}; -#[cfg(feature = "with-trappist-runtime")] -use service::chain_spec::trappist::{ - development_config, trappist_live_config, trappist_local_testnet_config, - ChainSpec as ServiceChainSpec, Extensions, -}; +/// Implementation, that can resolve [`Runtime`] from any json configuration file +impl RuntimeResolver for PathBuf { + fn runtime(&self) -> Runtime { + #[derive(Debug, serde::Deserialize)] + struct EmptyChainSpecWithId { + id: String, + } + + let file = std::fs::File::open(self).expect("Failed to open file"); + let reader = std::io::BufReader::new(file); + let chain_spec: EmptyChainSpecWithId = sp_serializer::from_reader(reader) + .expect("Failed to read 'json' file with ChainSpec configuration"); + + runtime(&chain_spec.id) + } +} + +fn runtime(id: &str) -> Runtime { + let id = id.replace("_", "-"); + if id.starts_with("trappist") { + Runtime::Trappist + } else if id.starts_with("stout") { + Runtime::Stout + } else { + log::warn!("No specific runtime was recognized for ChainSpec's id: '{}', so Runtime::default() will be used", id); + Runtime::default() + } +} + +fn load_spec(id: &str) -> std::result::Result, String> { + Ok(match id { + "dev" => Box::new(chain_spec::trappist::development_config()), + "trappist-local" => Box::new(chain_spec::trappist::trappist_local_testnet_config()), + "stout-local" => Box::new(chain_spec::stout::stout_local_testnet_config()), + // Live chain spec for Rococo - Trappist] + "trappist-rococo" => Box::new(chain_spec::trappist::trappist_live_config()), + // -- Loading a specific spec from disk + path => { + let path: PathBuf = path.into(); + match path.runtime() { + Runtime::Stout => Box::new(chain_spec::stout::ChainSpec::from_json_file(path)?), + Runtime::Default | Runtime::Trappist => + Box::new(chain_spec::trappist::ChainSpec::from_json_file(path)?), + } + }, + }) +} impl SubstrateCli for Cli { fn impl_name() -> String { - "Trappist Collator".into() + "Trappist Node".into() } fn impl_version() -> String { @@ -62,30 +134,21 @@ impl SubstrateCli for Cli { 2021 } - fn load_spec(&self, id: &str) -> std::result::Result, String> { - Ok(match id { - // -- Trappist - "dev" | "trappist_dev" => Box::new(development_config()), - #[cfg(feature = "with-trappist-runtime")] - "trappist-local" => Box::new(trappist_local_testnet_config()), - #[cfg(feature = "with-stout-runtime")] - "stout-local" => Box::new(stout_local_testnet_config()), - // Live chain spec for Rococo - Trappist - #[cfg(feature = "with-trappist-runtime")] - "trappist-rococo" => Box::new(trappist_live_config()), - // -- Loading a specific spec from disk - path => Box::new(ServiceChainSpec::from_json_file(std::path::PathBuf::from(path))?), - }) + fn load_spec(&self, id: &str) -> std::result::Result, String> { + load_spec(id) } - fn native_runtime_version(_: &Box) -> &'static RuntimeVersion { - &trappist_runtime::VERSION + fn native_runtime_version(chain_spec: &Box) -> &'static RuntimeVersion { + match chain_spec.runtime() { + Runtime::Default | Runtime::Trappist => &trappist_runtime::VERSION, + Runtime::Stout => &trappist_runtime::VERSION, + } } } impl SubstrateCli for RelayChainCli { fn impl_name() -> String { - "Trappist Collator".into() + "Trappist node".into() } fn impl_version() -> String { @@ -111,10 +174,10 @@ impl SubstrateCli for RelayChainCli { } fn copyright_start_year() -> i32 { - 2023 + 2021 } - fn load_spec(&self, id: &str) -> std::result::Result, String> { + fn load_spec(&self, id: &str) -> std::result::Result, String> { polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id) } @@ -123,14 +186,54 @@ impl SubstrateCli for RelayChainCli { } } +/// Creates partial components for the runtimes that are supported by the benchmarks. +macro_rules! construct_benchmark_partials { + ($config:expr, |$partials:ident| $code:expr) => { + match $config.chain_spec.runtime() { + Runtime::Trappist => { + let $partials = new_partial::( + &$config, + crate::service::aura_build_import_queue::<_, AuraId>, + )?; + $code + }, + Runtime::Stout => { + let $partials = new_partial::( + &$config, + crate::service::aura_build_import_queue::<_, AuraId>, + )?; + $code + }, + _ => Err("The chain is not supported".into()), + } + }; +} + macro_rules! construct_async_run { (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{ let runner = $cli.create_runner($cmd)?; - runner.async_run(|$config| { - let $components = new_partial(&$config)?; - let task_manager = $components.task_manager; - { $( $code )* }.map(|v| (v, task_manager)) - }) + match runner.config().chain_spec.runtime() { + Runtime::Default | Runtime::Trappist => { + runner.async_run(|$config| { + let $components = new_partial::( + &$config, + crate::service::aura_build_import_queue::<_, AuraId>, + )?; + let task_manager = $components.task_manager; + { $( $code )* }.map(|v| (v, task_manager)) + }) + }, + Runtime::Stout => { + runner.async_run(|$config| { + let $components = new_partial::( + &$config, + crate::service::aura_build_import_queue::<_, AuraId>, + )?; + let task_manager = $components.task_manager; + { $( $code )* }.map(|v| (v, task_manager)) + }) + } + } }} } @@ -163,18 +266,16 @@ pub fn run() -> Result<()> { Ok(cmd.run(components.client, components.import_queue)) }) }, - Some(Subcommand::Revert(cmd)) => { - construct_async_run!(|components, cli, cmd, config| { - Ok(cmd.run(components.client, components.backend, None)) - }) - }, + Some(Subcommand::Revert(cmd)) => construct_async_run!(|components, cli, cmd, config| { + Ok(cmd.run(components.client, components.backend, None)) + }), Some(Subcommand::PurgeChain(cmd)) => { let runner = cli.create_runner(cmd)?; runner.sync_run(|config| { let polkadot_cli = RelayChainCli::new( &config, - [RelayChainCli::executable_name()].iter().chain(cli.relay_chain_args.iter()), + [RelayChainCli::executable_name()].iter().chain(cli.relaychain_args.iter()), ); let polkadot_config = SubstrateCli::create_configuration( @@ -192,7 +293,7 @@ pub fn run() -> Result<()> { runner.sync_run(|_config| { let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?; let state_version = Cli::native_runtime_version(&spec).state_version(); - cmd.run::(&*spec, state_version) + cmd.run::(&*spec, state_version) }) }, Some(Subcommand::ExportGenesisWasm(cmd)) => { @@ -204,19 +305,27 @@ pub fn run() -> Result<()> { }, Some(Subcommand::Benchmark(cmd)) => { let runner = cli.create_runner(cmd)?; + // Switch on the concrete benchmark sub-command- match cmd { BenchmarkCmd::Pallet(cmd) => if cfg!(feature = "runtime-benchmarks") { - runner.sync_run(|config| cmd.run::(config)) + runner.sync_run(|config| match config.chain_spec.runtime() { + Runtime::Trappist => cmd.run::(config), + Runtime::Stout => cmd.run::(config), + _ => Err(format!( + "Chain '{:?}' doesn't support benchmarking", + config.chain_spec.runtime() + ) + .into()), + }) } else { Err("Benchmarking wasn't enabled when building the node. \ - You can enable it with `--features runtime-benchmarks`." + You can enable it with `--features runtime-benchmarks`." .into()) }, BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { - let partials = new_partial(&config)?; - cmd.run(partials.client) + construct_benchmark_partials!(config, |partials| cmd.run(partials.client)) }), #[cfg(not(feature = "runtime-benchmarks"))] BenchmarkCmd::Storage(_) => @@ -228,10 +337,12 @@ pub fn run() -> Result<()> { .into()), #[cfg(feature = "runtime-benchmarks")] BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| { - let partials = new_partial(&config)?; - let db = partials.backend.expose_db(); - let storage = partials.backend.expose_storage(); - cmd.run(config, partials.client.clone(), db, storage) + construct_benchmark_partials!(config, |partials| { + let db = partials.backend.expose_db(); + let storage = partials.backend.expose_storage(); + + cmd.run(config, partials.client.clone(), db, storage) + }) }), BenchmarkCmd::Machine(cmd) => runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())), @@ -243,28 +354,33 @@ pub fn run() -> Result<()> { }, #[cfg(feature = "try-runtime")] Some(Subcommand::TryRuntime(cmd)) => { + // grab the task manager. let runner = cli.create_runner(cmd)?; - + let registry = &runner.config().prometheus_config.as_ref().map(|cfg| &cfg.registry); + let task_manager = + sc_service::TaskManager::new(runner.config().tokio_handle.clone(), *registry) + .map_err(|e| format!("Error: {:?}", e))?; use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch}; type HostFunctionsOf = ExtendedHostFunctions< sp_io::SubstrateHostFunctions, ::ExtendHostFunctions, >; - // grab the task manager. - let registry = &runner.config().prometheus_config.as_ref().map(|cfg| &cfg.registry); - let task_manager = - sc_service::TaskManager::new(runner.config().tokio_handle.clone(), *registry) - .map_err(|e| format!("Error: {:?}", e))?; - - runner.async_run(|_| { - Ok((cmd.run::>(), task_manager)) - }) + match runner.config().chain_spec.runtime() { + Runtime::Trappist => runner.async_run(|_| { + Ok((cmd.run::>(), task_manager)) + }), + Runtime::Stout => runner.async_run(|_| { + Ok((cmd.run::>(), task_manager)) + }), + _ => Err("Chain doesn't support try-runtime".into()), + } }, #[cfg(not(feature = "try-runtime"))] Some(Subcommand::TryRuntime) => Err("Try-runtime was not enabled when building the node. \ You can enable it with `--features try-runtime`." .into()), + Some(Subcommand::Key(cmd)) => Ok(cmd.run(&cli)?), None => { let runner = cli.create_runner(&cli.run.normalize())?; let collator_options = cli.run.collator_options(); @@ -279,13 +395,13 @@ pub fn run() -> Result<()> { None }; - let para_id = Extensions::try_get(&*config.chain_spec) + let para_id = chain_spec::Extensions::try_get(&*config.chain_spec) .map(|e| e.para_id) - .ok_or_else(|| "Could not find parachain ID in chain-spec.")?; + .ok_or_else(|| "Could not find parachain extension in chain-spec.")?; let polkadot_cli = RelayChainCli::new( &config, - [RelayChainCli::executable_name()].iter().chain(cli.relay_chain_args.iter()), + [RelayChainCli::executable_name()].iter().chain(cli.relaychain_args.iter()), ); let id = ParaId::from(para_id); @@ -294,8 +410,10 @@ pub fn run() -> Result<()> { AccountIdConversion::::into_account_truncating(&id); let state_version = Cli::native_runtime_version(&config.chain_spec).state_version(); - let block: Block = generate_genesis_block(&*config.chain_spec, state_version) - .map_err(|e| format!("{:?}", e))?; + + let block: crate::service::Block = + generate_genesis_block(&*config.chain_spec, state_version) + .map_err(|e| format!("{:?}", e))?; let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode())); let tokio_handle = config.tokio_handle.clone(); @@ -308,20 +426,31 @@ pub fn run() -> Result<()> { info!("Parachain genesis state: {}", genesis_state); info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" }); - if !collator_options.relay_chain_rpc_urls.is_empty() && cli.relay_chain_args.len() > 0 { + if !collator_options.relay_chain_rpc_urls.is_empty() && cli.relaychain_args.len() > 0 { warn!("Detected relay chain node arguments together with --relay-chain-rpc-url. This command starts a minimal Polkadot node that only uses a network-related subset of all relay chain CLI options."); } - service::start_parachain_node( - config, - polkadot_config, - collator_options, - id, - hwbench, - ) - .await - .map(|r| r.0) - .map_err(Into::into) + match config.chain_spec.runtime() { + Runtime::Trappist => crate::service::start_aura_node::< + trappist_runtime::RuntimeApi, + AuraId, + >(config, polkadot_config, collator_options, id, hwbench) + .await + .map(|r| r.0) + .map_err(Into::into), + Runtime::Stout => crate::service::start_aura_node::< + stout_runtime::RuntimeApi, + AuraId, + >(config, polkadot_config, collator_options, id, hwbench) + .await + .map(|r| r.0) + .map_err(Into::into), + _ => Err(format!( + "Chain '{:?}' doesn't support benchmarking", + config.chain_spec.runtime() + ) + .into()), + } }) }, } @@ -416,6 +545,10 @@ impl CliConfiguration for RelayChainCli { self.base.base.transaction_pool(is_dev) } + fn trie_cache_maximum_size(&self) -> Result> { + self.base.base.trie_cache_maximum_size() + } + fn rpc_methods(&self) -> Result { self.base.base.rpc_methods() } @@ -459,3 +592,117 @@ impl CliConfiguration for RelayChainCli { self.base.base.node_name() } } + +#[cfg(test)] +mod tests { + use crate::{ + chain_spec::{get_account_id_from_seed, get_collator_keys_from_seed}, + command::{Runtime, RuntimeResolver}, + }; + use parachains_common::AuraId; + use sc_chain_spec::{ChainSpec, ChainSpecExtension, ChainSpecGroup, ChainType, Extension}; + use serde::{Deserialize, Serialize}; + use sp_core::sr25519; + use std::path::PathBuf; + use tempfile::TempDir; + #[derive( + Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension, Default, + )] + #[serde(deny_unknown_fields)] + pub struct Extensions1 { + pub attribute1: String, + pub attribute2: u32, + } + + #[derive( + Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension, Default, + )] + #[serde(deny_unknown_fields)] + pub struct Extensions2 { + pub attribute_x: String, + pub attribute_y: String, + pub attribute_z: u32, + } + + fn store_configuration(dir: &TempDir, spec: Box) -> PathBuf { + let raw_output = true; + let json = sc_service::chain_ops::build_spec(&*spec, raw_output) + .expect("Failed to build json string"); + let mut cfg_file_path = dir.path().to_path_buf(); + cfg_file_path.push(spec.id()); + cfg_file_path.set_extension("json"); + std::fs::write(&cfg_file_path, json).expect("Failed to write to json file"); + cfg_file_path + } + + pub type DummyChainSpec = sc_service::GenericChainSpec; + + pub fn create_default_with_extensions( + id: &str, + extension: E, + ) -> DummyChainSpec { + DummyChainSpec::from_genesis( + "Dummy local testnet", + id, + ChainType::Local, + move || { + crate::chain_spec::trappist::testnet_genesis( + vec![ + ( + get_account_id_from_seed::("Alice"), + get_collator_keys_from_seed::("Alice"), + ), + ( + get_account_id_from_seed::("Bob"), + get_collator_keys_from_seed::("Bob"), + ), + ], + get_account_id_from_seed::("Alice"), + vec![get_account_id_from_seed::("Alice")], + 1000.into(), + ) + }, + Vec::new(), + None, + None, + None, + None, + extension, + ) + } + + #[test] + fn test_resolve_runtime_for_different_configuration_files() { + let temp_dir = tempfile::tempdir().expect("Failed to access tempdir"); + + let path = store_configuration( + &temp_dir, + Box::new(create_default_with_extensions("trappist-1", Extensions1::default())), + ); + assert_eq!(Runtime::Trappist, path.runtime()); + + let path = store_configuration( + &temp_dir, + Box::new(create_default_with_extensions("trappist-2", Extensions2::default())), + ); + assert_eq!(Runtime::Trappist, path.runtime()); + + let path = store_configuration( + &temp_dir, + Box::new(create_default_with_extensions("stout-1", Extensions1::default())), + ); + assert_eq!(Runtime::Stout, path.runtime()); + + let path = store_configuration( + &temp_dir, + Box::new(create_default_with_extensions("stout-2", Extensions2::default())), + ); + assert_eq!(Runtime::Stout, path.runtime()); + + let path = store_configuration( + &temp_dir, + Box::new(crate::chain_spec::trappist::trappist_local_testnet_config()), + ); + assert_eq!(Runtime::Trappist, path.runtime()); + } +} diff --git a/node/src/main.rs b/node/src/main.rs index c39414b3..d114d2f5 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -19,6 +19,13 @@ #![warn(missing_docs)] #![warn(unused_extern_crates)] -fn main() -> trappist_cli::Result<()> { - trappist_cli::run() +mod chain_spec; +#[macro_use] +mod service; +mod cli; +mod command; +mod rpc; + +fn main() -> sc_cli::Result<()> { + command::run() } diff --git a/rpc/src/lib.rs b/node/src/rpc.rs similarity index 79% rename from rpc/src/lib.rs rename to node/src/rpc.rs index 17b3154c..af794765 100644 --- a/rpc/src/lib.rs +++ b/node/src/rpc.rs @@ -41,41 +41,43 @@ pub struct FullDeps { pub deny_unsafe: DenyUnsafe, } -/// Instantiate all RPCs we want at the canvas-kusama chain. -pub fn trappist_create_full( +/// Instantiate all RPC extensions. +pub fn create_full( deps: FullDeps, + backend: Arc, ) -> Result> where C: ProvideRuntimeApi - + sc_client_api::BlockBackend + HeaderBackend + AuxStore + HeaderMetadata + Send + Sync + 'static, - C::Api: substrate_frame_rpc_system::AccountNonceApi, + C::Api: frame_rpc_system::AccountNonceApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, + C::Api: BlockBuilder, C::Api: pallet_dex_rpc::DexRuntimeApi< trappist_runtime::opaque::Block, trappist_runtime::AssetIdForTrustBackedAssets, trappist_runtime::Balance, trappist_runtime::AssetBalance, >, - C::Api: BlockBuilder, P: TransactionPool + Sync + Send + 'static, + B: sc_client_api::Backend + Send + Sync + 'static, + B::State: sc_client_api::backend::StateBackend>, { + use frame_rpc_system::{System, SystemApiServer}; use pallet_dex_rpc::{Dex, DexApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; - use sc_rpc::dev::{Dev, DevApiServer}; - use substrate_frame_rpc_system::{System, SystemApiServer}; + use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer}; let mut module = RpcExtension::new(()); let FullDeps { client, pool, deny_unsafe } = deps; - module.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?; + module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; module.merge(TransactionPayment::new(client.clone()).into_rpc())?; - module.merge(Dev::new(client.clone(), deny_unsafe).into_rpc())?; + module.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?; module.merge(Dex::new(client).into_rpc())?; // Extend this RPC with a custom API by using the following syntax. @@ -86,6 +88,7 @@ where Ok(module) } +/// This function will be removed during the node refactor. /// Instantiate all RPCs we want at the canvas-kusama chain. pub fn stout_create_full( deps: FullDeps, @@ -99,14 +102,21 @@ where + Send + Sync + 'static, - C::Api: substrate_frame_rpc_system::AccountNonceApi, + C::Api: frame_rpc_system::AccountNonceApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, + C::Api: pallet_dex_rpc::DexRuntimeApi< + trappist_runtime::opaque::Block, + trappist_runtime::AssetIdForTrustBackedAssets, + trappist_runtime::Balance, + trappist_runtime::AssetBalance, + >, C::Api: BlockBuilder, P: TransactionPool + Sync + Send + 'static, { + use frame_rpc_system::{System, SystemApiServer}; + use pallet_dex_rpc::{Dex, DexApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use sc_rpc::dev::{Dev, DevApiServer}; - use substrate_frame_rpc_system::{System, SystemApiServer}; let mut module = RpcExtension::new(()); let FullDeps { client, pool, deny_unsafe } = deps; @@ -114,6 +124,7 @@ where module.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?; module.merge(TransactionPayment::new(client.clone()).into_rpc())?; module.merge(Dev::new(client.clone(), deny_unsafe).into_rpc())?; + module.merge(Dex::new(client).into_rpc())?; // Extend this RPC with a custom API by using the following syntax. // `YourRpcStruct` should have a reference to a client, which is needed diff --git a/node/src/service.rs b/node/src/service.rs new file mode 100644 index 00000000..a5fbf28a --- /dev/null +++ b/node/src/service.rs @@ -0,0 +1,754 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . + +use cumulus_client_cli::CollatorOptions; +use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion}; +use cumulus_client_consensus_common::{ + ParachainBlockImport as TParachainBlockImport, ParachainCandidate, ParachainConsensus, +}; +use cumulus_client_service::{ + build_network, build_relay_chain_interface, prepare_node_config, start_collator, + start_full_node, BuildNetworkParams, StartCollatorParams, StartFullNodeParams, +}; +use cumulus_primitives_core::{relay_chain::Hash as PHash, ParaId, PersistedValidationData}; +use cumulus_relay_chain_interface::RelayChainInterface; +use parity_scale_codec::Codec; +use sp_core::Pair; + +use jsonrpsee::RpcModule; + +use crate::rpc; +pub use parachains_common::{ + AccountId, AssetIdForTrustBackedAssets, Balance, Block, BlockNumber, Hash, Header, + Index as Nonce, +}; + +use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier; +use futures::lock::Mutex; +use sc_consensus::{ + import_queue::{BasicQueue, Verifier as VerifierT}, + BlockImportParams, ImportQueue, +}; +use sc_executor::WasmExecutor; +use sc_network::NetworkBlock; +use sc_network_sync::SyncingService; +use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager}; +use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; +use sp_api::{ApiExt, ConstructRuntimeApi}; +use sp_consensus_aura::AuraApi; +use sp_keystore::SyncCryptoStorePtr; +use sp_runtime::{ + app_crypto::AppKey, + traits::{BlakeTwo256, Header as HeaderT}, +}; +use std::{marker::PhantomData, sync::Arc, time::Duration}; +use substrate_prometheus_endpoint::Registry; + +#[cfg(not(feature = "runtime-benchmarks"))] +type HostFunctions = sp_io::SubstrateHostFunctions; + +#[cfg(feature = "runtime-benchmarks")] +type HostFunctions = + (sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions); + +type ParachainClient = TFullClient>; + +type ParachainBackend = TFullBackend; + +type ParachainBlockImport = + TParachainBlockImport>, ParachainBackend>; + +/// Native Stout executor instance. +pub struct StoutRuntimeExecutor; + +impl sc_executor::NativeExecutionDispatch for StoutRuntimeExecutor { + type ExtendHostFunctions = (); + + fn dispatch(method: &str, data: &[u8]) -> Option> { + stout_runtime::api::dispatch(method, data) + } + + fn native_version() -> sc_executor::NativeVersion { + stout_runtime::native_version() + } +} + +// Native Trappist executor instance. +pub struct TrappistRuntimeExecutor; + +impl sc_executor::NativeExecutionDispatch for TrappistRuntimeExecutor { + type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; + + fn dispatch(method: &str, data: &[u8]) -> Option> { + trappist_runtime::api::dispatch(method, data) + } + + fn native_version() -> sc_executor::NativeVersion { + trappist_runtime::native_version() + } +} + +/// Starts a `ServiceBuilder` for a full service. +/// +/// Use this macro if you don't actually need the full service, but just the builder in order to +/// be able to perform chain operations. +pub fn new_partial( + config: &Configuration, + build_import_queue: BIQ, +) -> Result< + PartialComponents< + ParachainClient, + ParachainBackend, + (), + sc_consensus::DefaultImportQueue>, + sc_transaction_pool::FullPool>, + (ParachainBlockImport, Option, Option), + >, + sc_service::Error, +> +where + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, + RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue + + sp_api::Metadata + + sp_session::SessionKeys + + sp_api::ApiExt< + Block, + StateBackend = sc_client_api::StateBackendFor, + > + sp_offchain::OffchainWorkerApi + + pallet_dex_rpc::DexRuntimeApi + + sp_block_builder::BlockBuilder, + sc_client_api::StateBackendFor: sp_api::StateBackend, + BIQ: FnOnce( + Arc>, + ParachainBlockImport, + &Configuration, + Option, + &TaskManager, + ) -> Result< + sc_consensus::DefaultImportQueue>, + sc_service::Error, + >, +{ + let telemetry = config + .telemetry_endpoints + .clone() + .filter(|x| !x.is_empty()) + .map(|endpoints| -> Result<_, sc_telemetry::Error> { + let worker = TelemetryWorker::new(16)?; + let telemetry = worker.handle().new_telemetry(endpoints); + Ok((worker, telemetry)) + }) + .transpose()?; + + let executor = sc_executor::WasmExecutor::::new( + config.wasm_method, + config.default_heap_pages, + config.max_runtime_instances, + None, + config.runtime_cache_size, + ); + + let (client, backend, keystore_container, task_manager) = + sc_service::new_full_parts::( + config, + telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), + executor, + )?; + let client = Arc::new(client); + + let telemetry_worker_handle = telemetry.as_ref().map(|(worker, _)| worker.handle()); + + let telemetry = telemetry.map(|(worker, telemetry)| { + task_manager.spawn_handle().spawn("telemetry", None, worker.run()); + telemetry + }); + + let transaction_pool = sc_transaction_pool::BasicPool::new_full( + config.transaction_pool.clone(), + config.role.is_authority().into(), + config.prometheus_registry(), + task_manager.spawn_essential_handle(), + client.clone(), + ); + + let block_import = ParachainBlockImport::new(client.clone(), backend.clone()); + + let import_queue = build_import_queue( + client.clone(), + block_import.clone(), + config, + telemetry.as_ref().map(|telemetry| telemetry.handle()), + &task_manager, + )?; + + let params = PartialComponents { + backend, + client, + import_queue, + keystore_container, + task_manager, + transaction_pool, + select_chain: (), + other: (block_import, telemetry, telemetry_worker_handle), + }; + + Ok(params) +} + +/// Start a node with the given parachain `Configuration` and relay chain `Configuration`. +/// +/// This is the actual implementation that is abstract over the executor and the runtime api. +#[sc_tracing::logging::prefix_logs_with("Parachain")] +async fn start_node_impl( + parachain_config: Configuration, + polkadot_config: Configuration, + collator_options: CollatorOptions, + para_id: ParaId, + _rpc_ext_builder: RB, + build_import_queue: BIQ, + build_consensus: BIC, + hwbench: Option, +) -> sc_service::error::Result<(TaskManager, Arc>)> +where + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, + RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue + + sp_api::Metadata + + sp_session::SessionKeys + + sp_api::ApiExt< + Block, + StateBackend = sc_client_api::StateBackendFor, + > + sp_offchain::OffchainWorkerApi + + sp_block_builder::BlockBuilder + + cumulus_primitives_core::CollectCollationInfo + + frame_rpc_system::AccountNonceApi + + pallet_dex_rpc::DexRuntimeApi + + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, + sc_client_api::StateBackendFor: sp_api::StateBackend, + RB: Fn(Arc>) -> Result, sc_service::Error>, + BIQ: FnOnce( + Arc>, + ParachainBlockImport, + &Configuration, + Option, + &TaskManager, + ) -> Result< + sc_consensus::DefaultImportQueue>, + sc_service::Error, + >, + BIC: FnOnce( + Arc>, + ParachainBlockImport, + Option<&Registry>, + Option, + &TaskManager, + Arc, + Arc>>, + Arc>, + SyncCryptoStorePtr, + bool, + ) -> Result>, sc_service::Error>, +{ + use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE; + + let parachain_config = prepare_node_config(parachain_config); + + let params = new_partial::(¶chain_config, build_import_queue)?; + let (block_import, mut telemetry, telemetry_worker_handle) = params.other; + + let client = params.client.clone(); + let backend = params.backend.clone(); + + let mut task_manager = params.task_manager; + let (relay_chain_interface, collator_key) = build_relay_chain_interface( + polkadot_config, + ¶chain_config, + telemetry_worker_handle, + &mut task_manager, + collator_options.clone(), + hwbench.clone(), + ) + .await + .map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?; + + let force_authoring = parachain_config.force_authoring; + let validator = parachain_config.role.is_authority(); + let prometheus_registry = parachain_config.prometheus_registry().cloned(); + let transaction_pool = params.transaction_pool.clone(); + let import_queue_service = params.import_queue.service(); + + let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) = + build_network(BuildNetworkParams { + parachain_config: ¶chain_config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + para_id, + spawn_handle: task_manager.spawn_handle(), + relay_chain_interface: relay_chain_interface.clone(), + import_queue: params.import_queue, + }) + .await?; + + let rpc_builder = { + let client = client.clone(); + let transaction_pool = transaction_pool.clone(); + + let backend_for_rpc = backend.clone(); + Box::new(move |deny_unsafe, _| { + let deps = rpc::FullDeps { + client: client.clone(), + pool: transaction_pool.clone(), + deny_unsafe, + }; + + rpc::create_full(deps, backend_for_rpc.clone()).map_err(Into::into) + }) + }; + + sc_service::spawn_tasks(sc_service::SpawnTasksParams { + rpc_builder, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + task_manager: &mut task_manager, + config: parachain_config, + keystore: params.keystore_container.sync_keystore(), + backend: backend.clone(), + network: network.clone(), + system_rpc_tx, + tx_handler_controller, + telemetry: telemetry.as_mut(), + sync_service: sync_service.clone(), + })?; + + if let Some(hwbench) = hwbench { + sc_sysinfo::print_hwbench(&hwbench); + + //Check whether the hardware meets your chains' requirements. The + // requirements for a para-chain are dictated by its relay-chain. + if !SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench) && validator { + log::warn!( + "⚠️ The hardware does not meet the minimal requirements for role 'Authority'." + ); + } + + if let Some(ref mut telemetry) = telemetry { + let telemetry_handle = telemetry.handle(); + task_manager.spawn_handle().spawn( + "telemetry_hwbench", + None, + sc_sysinfo::initialize_hwbench_telemetry(telemetry_handle, hwbench), + ); + } + } + + let announce_block = { + let sync_service = sync_service.clone(); + Arc::new(move |hash, data| sync_service.announce_block(hash, data)) + }; + + let relay_chain_slot_duration = Duration::from_secs(6); + + let overseer_handle = relay_chain_interface + .overseer_handle() + .map_err(|e| sc_service::Error::Application(Box::new(e)))?; + + if validator { + let parachain_consensus = build_consensus( + client.clone(), + block_import, + prometheus_registry.as_ref(), + telemetry.as_ref().map(|t| t.handle()), + &task_manager, + relay_chain_interface.clone(), + transaction_pool, + sync_service, + params.keystore_container.sync_keystore(), + force_authoring, + )?; + + let spawner = task_manager.spawn_handle(); + + let params = StartCollatorParams { + para_id, + block_status: client.clone(), + announce_block, + client: client.clone(), + task_manager: &mut task_manager, + relay_chain_interface: relay_chain_interface.clone(), + spawner, + parachain_consensus, + import_queue: import_queue_service, + collator_key: collator_key.expect("Command line arguments do not allow this. qed"), + relay_chain_slot_duration, + recovery_handle: Box::new(overseer_handle), + }; + + start_collator(params).await?; + } else { + let params = StartFullNodeParams { + client: client.clone(), + announce_block, + task_manager: &mut task_manager, + para_id, + relay_chain_interface, + relay_chain_slot_duration, + import_queue: import_queue_service, + recovery_handle: Box::new(overseer_handle), + }; + + start_full_node(params)?; + } + + start_network.start_network(); + + Ok((task_manager, client)) +} + +enum BuildOnAccess { + Uninitialized(Option R + Send + Sync>>), + Initialized(R), +} + +impl BuildOnAccess { + fn get_mut(&mut self) -> &mut R { + loop { + match self { + Self::Uninitialized(f) => { + *self = Self::Initialized((f.take().unwrap())()); + }, + Self::Initialized(ref mut r) => return r, + } + } + } +} + +/// Special [`ParachainConsensus`] implementation that waits for the upgrade from +/// shell to a parachain runtime that implements Aura. +struct WaitForAuraConsensus { + client: Arc, + aura_consensus: Arc>>>>, + relay_chain_consensus: Arc>>>, + _phantom: PhantomData, +} + +impl Clone for WaitForAuraConsensus { + fn clone(&self) -> Self { + Self { + client: self.client.clone(), + aura_consensus: self.aura_consensus.clone(), + relay_chain_consensus: self.relay_chain_consensus.clone(), + _phantom: PhantomData, + } + } +} + +#[async_trait::async_trait] +impl ParachainConsensus for WaitForAuraConsensus +where + Client: sp_api::ProvideRuntimeApi + Send + Sync, + Client::Api: AuraApi, + AuraId: Send + Codec + Sync, +{ + async fn produce_candidate( + &mut self, + parent: &Header, + relay_parent: PHash, + validation_data: &PersistedValidationData, + ) -> Option> { + if self + .client + .runtime_api() + .has_api::>(parent.hash()) + .unwrap_or(false) + { + self.aura_consensus + .lock() + .await + .get_mut() + .produce_candidate(parent, relay_parent, validation_data) + .await + } else { + self.relay_chain_consensus + .lock() + .await + .produce_candidate(parent, relay_parent, validation_data) + .await + } + } +} + +struct Verifier { + client: Arc, + aura_verifier: BuildOnAccess>>, + relay_chain_verifier: Box>, + _phantom: PhantomData, +} + +#[async_trait::async_trait] +impl VerifierT for Verifier +where + Client: sp_api::ProvideRuntimeApi + Send + Sync, + Client::Api: AuraApi, + AuraId: Send + Sync + Codec, +{ + async fn verify( + &mut self, + block_import: BlockImportParams, + ) -> Result, String> { + if self + .client + .runtime_api() + .has_api::>(*block_import.header.parent_hash()) + .unwrap_or(false) + { + self.aura_verifier.get_mut().verify(block_import).await + } else { + self.relay_chain_verifier.verify(block_import).await + } + } +} + +/// Start an aura powered parachain node. +/// (collective-polkadot and statemine/t use this) +pub async fn start_aura_node( + parachain_config: Configuration, + polkadot_config: Configuration, + collator_options: CollatorOptions, + para_id: ParaId, + hwbench: Option, +) -> sc_service::error::Result<(TaskManager, Arc>)> +where + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, + RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue + + sp_api::Metadata + + sp_session::SessionKeys + + sp_api::ApiExt< + Block, + StateBackend = sc_client_api::StateBackendFor, + > + sp_offchain::OffchainWorkerApi + + sp_block_builder::BlockBuilder + + cumulus_primitives_core::CollectCollationInfo + + sp_consensus_aura::AuraApi::Pair as Pair>::Public> + + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + + pallet_dex_rpc::DexRuntimeApi + + frame_rpc_system::AccountNonceApi, + sc_client_api::StateBackendFor: sp_api::StateBackend, + <::Pair as Pair>::Signature: + TryFrom> + std::hash::Hash + sp_runtime::traits::Member + Codec, +{ + start_node_impl::( + parachain_config, + polkadot_config, + collator_options, + para_id, + |_| Ok(RpcModule::new(())), + aura_build_import_queue::<_, AuraId>, + |client, + block_import, + prometheus_registry, + telemetry, + task_manager, + relay_chain_interface, + transaction_pool, + sync_oracle, + keystore, + force_authoring| { + let spawn_handle = task_manager.spawn_handle(); + let client2 = client.clone(); + let block_import2 = block_import.clone(); + let transaction_pool2 = transaction_pool.clone(); + let telemetry2 = telemetry.clone(); + let prometheus_registry2 = prometheus_registry.map(|r| (*r).clone()); + let relay_chain_for_aura = relay_chain_interface.clone(); + + let aura_consensus = BuildOnAccess::Uninitialized(Some(Box::new(move || { + let slot_duration = + cumulus_client_consensus_aura::slot_duration(&*client2).unwrap(); + + let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording( + spawn_handle, + client2.clone(), + transaction_pool2, + prometheus_registry2.as_ref(), + telemetry2.clone(), + ); + + AuraConsensus::build::<::Pair, _, _, _, _, _, _>( + BuildAuraConsensusParams { + proposer_factory, + create_inherent_data_providers: + move |_, (relay_parent, validation_data)| { + let relay_chain_for_aura = relay_chain_for_aura.clone(); + async move { + let parachain_inherent = + cumulus_primitives_parachain_inherent::ParachainInherentData::create_at( + relay_parent, + &relay_chain_for_aura, + &validation_data, + para_id, + ).await; + + let timestamp = + sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = + sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( + *timestamp, + slot_duration, + ); + + let parachain_inherent = + parachain_inherent.ok_or_else(|| { + Box::::from( + "Failed to create parachain inherent", + ) + })?; + + Ok((slot, timestamp, parachain_inherent)) + } + }, + block_import: block_import2, + para_client: client2, + backoff_authoring_blocks: Option::<()>::None, + sync_oracle, + keystore, + force_authoring, + slot_duration, + // We got around 500ms for proposing + block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32), + // And a maximum of 750ms if slots are skipped + max_block_proposal_slot_portion: Some(SlotProportion::new(1f32 / 16f32)), + telemetry: telemetry2, + }, + ) + }))); + + let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording( + task_manager.spawn_handle(), + client.clone(), + transaction_pool, + prometheus_registry, + telemetry, + ); + + let relay_chain_consensus = + cumulus_client_consensus_relay_chain::build_relay_chain_consensus( + cumulus_client_consensus_relay_chain::BuildRelayChainConsensusParams { + para_id, + proposer_factory, + block_import, + relay_chain_interface: relay_chain_interface.clone(), + create_inherent_data_providers: + move |_, (relay_parent, validation_data)| { + let relay_chain_interface = relay_chain_interface.clone(); + async move { + let parachain_inherent = + cumulus_primitives_parachain_inherent::ParachainInherentData::create_at( + relay_parent, + &relay_chain_interface, + &validation_data, + para_id, + ).await; + let parachain_inherent = + parachain_inherent.ok_or_else(|| { + Box::::from( + "Failed to create parachain inherent", + ) + })?; + Ok(parachain_inherent) + } + }, + }, + ); + + let parachain_consensus = Box::new(WaitForAuraConsensus { + client, + aura_consensus: Arc::new(Mutex::new(aura_consensus)), + relay_chain_consensus: Arc::new(Mutex::new(relay_chain_consensus)), + _phantom: PhantomData, + }); + + Ok(parachain_consensus) + }, + hwbench, + ) + .await +} + +/// Build the import queue for Aura-based parachains. +pub fn aura_build_import_queue( + client: Arc>, + block_import: ParachainBlockImport, + config: &Configuration, + telemetry_handle: Option, + task_manager: &TaskManager, +) -> Result>, sc_service::Error> +where + RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, + RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue + + sp_api::Metadata + + sp_session::SessionKeys + + sp_api::ApiExt< + Block, + StateBackend = sc_client_api::StateBackendFor, + > + sp_offchain::OffchainWorkerApi + + sp_block_builder::BlockBuilder + + pallet_dex_rpc::DexRuntimeApi + + sp_consensus_aura::AuraApi::Pair as Pair>::Public>, + sc_client_api::StateBackendFor: sp_api::StateBackend, + <::Pair as Pair>::Signature: + TryFrom> + std::hash::Hash + sp_runtime::traits::Member + Codec, +{ + let client2 = client.clone(); + + let aura_verifier = move || { + let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client2).unwrap(); + + Box::new( + cumulus_client_consensus_aura::build_verifier::<::Pair, _, _, _>( + cumulus_client_consensus_aura::BuildVerifierParams { + client: client2.clone(), + create_inherent_data_providers: move |_, _| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = + sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( + *timestamp, + slot_duration, + ); + + Ok((slot, timestamp)) + }, + telemetry: telemetry_handle, + }, + ), + ) as Box<_> + }; + + let relay_chain_verifier = + Box::new(RelayChainVerifier::new(client.clone(), |_, _| async { Ok(()) })) as Box<_>; + + let verifier = Verifier { + client: client.clone(), + relay_chain_verifier, + aura_verifier: BuildOnAccess::Uninitialized(Some(Box::new(aura_verifier))), + _phantom: PhantomData, + }; + + let registry = config.prometheus_registry(); + let spawner = task_manager.spawn_essential_handle(); + + Ok(BasicQueue::new(verifier, Box::new(block_import), None, &spawner, registry)) +} diff --git a/node/tests/benchmark_storage_works.rs b/node/tests/benchmark_storage_works.rs new file mode 100644 index 00000000..916d65c0 --- /dev/null +++ b/node/tests/benchmark_storage_works.rs @@ -0,0 +1,44 @@ +#![cfg(feature = "runtime-benchmarks")] + +use assert_cmd::cargo::cargo_bin; +use std::{ + path::Path, + process::{Command, ExitStatus}, +}; +use tempfile::tempdir; + +/// The runtimes that this command supports. +static RUNTIMES: [&'static str; 3] = ["westmint", "statemine", "statemint"]; + +/// The `benchmark storage` command works for the dev runtimes. +#[test] +#[ignore] +fn benchmark_storage_works() { + for runtime in RUNTIMES { + let tmp_dir = tempdir().expect("could not create a temp dir"); + let base_path = tmp_dir.path(); + let runtime = format!("{}-dev", runtime); + + // Benchmarking the storage works and creates the weight file. + assert!(benchmark_storage("rocksdb", &runtime, base_path).success()); + assert!(base_path.join("rocksdb_weights.rs").exists()); + + assert!(benchmark_storage("paritydb", &runtime, base_path).success()); + assert!(base_path.join("paritydb_weights.rs").exists()); + } +} + +/// Invoke the `benchmark storage` sub-command for the given database and runtime. +fn benchmark_storage(db: &str, runtime: &str, base_path: &Path) -> ExitStatus { + Command::new(cargo_bin("polkadot-parachain")) + .args(&["benchmark", "storage", "--chain", runtime]) + .arg("--db") + .arg(db) + .arg("--weight-path") + .arg(base_path) + .args(["--state-version", "0"]) + .args(["--warmups", "0"]) + .args(["--add", "100", "--mul", "1.2", "--metric", "p75"]) + .status() + .unwrap() +} diff --git a/node/tests/common.rs b/node/tests/common.rs new file mode 100644 index 00000000..1d3d710c --- /dev/null +++ b/node/tests/common.rs @@ -0,0 +1,136 @@ +// Copyright 2020-2021 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate 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. + +// Substrate 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 Substrate. If not, see . + +#![cfg(unix)] + +use assert_cmd::cargo::cargo_bin; +use nix::{ + sys::signal::{kill, Signal}, + unistd::Pid, +}; +use std::{ + io::{BufRead, BufReader, Read}, + ops::{Deref, DerefMut}, + path::Path, + process::{self, Child, Command, ExitStatus}, +}; +use tokio::time::{sleep, Duration}; + +/// Wait for the given `child` the given number of `secs`. +/// +/// Returns the `Some(exit status)` or `None` if the process did not finish in the given time. +pub fn wait_for(child: &mut Child, secs: u64) -> Result { + let result = wait_timeout::ChildExt::wait_timeout(child, Duration::from_secs(5.min(secs))) + .map_err(|_| ())?; + if let Some(exit_status) = result { + Ok(exit_status) + } else { + if secs > 5 { + eprintln!("Child process taking over 5 seconds to exit gracefully"); + let result = wait_timeout::ChildExt::wait_timeout(child, Duration::from_secs(secs - 5)) + .map_err(|_| ())?; + if let Some(exit_status) = result { + return Ok(exit_status) + } + } + eprintln!("Took too long to exit (> {} seconds). Killing...", secs); + let _ = child.kill(); + child.wait().unwrap(); + Err(()) + } +} + +/// Run the node for a while (till the RPC is up + 30 secs) +/// TODO: needs to be revisited to hit the RPC +pub async fn run_node_for_a_while(base_path: &Path, args: &[&str], signal: Signal) { + let mut cmd = Command::new(cargo_bin("polkadot-parachain")) + .stdout(process::Stdio::piped()) + .stderr(process::Stdio::piped()) + .arg("-d") + .arg(base_path) + .args(args) + .spawn() + .unwrap(); + + let stderr = cmd.stderr.take().unwrap(); + + let mut child = KillChildOnDrop(cmd); + // TODO: use this instead of the timeout going forward? + let (_, _) = find_ws_url_from_output(stderr); + + // TODO: Revisit this to find a better approach for collators + sleep(Duration::from_secs(120)).await; + + assert!(child.try_wait().unwrap().is_none(), "the process should still be running"); + + // Stop the process + kill(Pid::from_raw(child.id().try_into().unwrap()), signal).unwrap(); + assert!(wait_for(&mut child, 40).map(|x| x.success()).unwrap()); +} + +pub struct KillChildOnDrop(pub Child); + +impl Drop for KillChildOnDrop { + fn drop(&mut self) { + let _ = self.0.kill(); + } +} + +impl Deref for KillChildOnDrop { + type Target = Child; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl DerefMut for KillChildOnDrop { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + +/// Read the WS address from the output. +/// +/// This is hack to get the actual bound sockaddr because +/// substrate assigns a random port if the specified port was already bound. +pub fn find_ws_url_from_output(read: impl Read + Send) -> (String, String) { + let mut data = String::new(); + + let ws_url = BufReader::new(read) + .lines() + .find_map(|line| { + let line = + line.expect("failed to obtain next line from stdout for WS address discovery"); + + data.push_str(&line); + data.push_str("\n"); + + // does the line contain our port (we expect this specific output from substrate). + let sock_addr = match line.split_once("Running JSON-RPC WS server: addr=") { + None => return None, + Some((_, after)) => after.split_once(",").unwrap().0, + }; + + Some(format!("ws://{}", sock_addr)) + }) + .unwrap_or_else(|| { + eprintln!("Output:\n{}", data); + panic!("We should get a WebSocket address") + }); + + (ws_url, data) +} diff --git a/node/tests/polkadot_argument_parsing.rs b/node/tests/polkadot_argument_parsing.rs new file mode 100644 index 00000000..ad91ce0e --- /dev/null +++ b/node/tests/polkadot_argument_parsing.rs @@ -0,0 +1,39 @@ +// Copyright 2020-2021 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate 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. + +// Substrate 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 Substrate. If not, see . + +use tempfile::tempdir; + +mod common; + +#[tokio::test] +#[cfg(unix)] +#[ignore] +async fn polkadot_argument_parsing() { + use nix::sys::signal::Signal::{SIGINT, SIGTERM}; + let base_dir = tempdir().expect("could not create a temp dir"); + + let args = &[ + "--", + "--dev", + "--bootnodes", + "/ip4/127.0.0.1/tcp/30333/p2p/Qmbx43psh7LVkrYTRXisUpzCubbgYojkejzAgj5mteDnxy", + "--bootnodes", + "/ip4/127.0.0.1/tcp/50500/p2p/Qma6SpS7tzfCrhtgEVKR9Uhjmuv55ovC3kY6y6rPBxpWde", + ]; + + common::run_node_for_a_while(base_dir.path(), args, SIGINT).await; + common::run_node_for_a_while(base_dir.path(), args, SIGTERM).await; +} diff --git a/node/tests/polkadot_mdns_issue.rs b/node/tests/polkadot_mdns_issue.rs new file mode 100644 index 00000000..bb492a31 --- /dev/null +++ b/node/tests/polkadot_mdns_issue.rs @@ -0,0 +1,33 @@ +// Copyright 2020-2021 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate 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. + +// Substrate 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 Substrate. If not, see . + +use tempfile::tempdir; + +mod common; + +#[tokio::test] +#[cfg(unix)] +#[ignore] +async fn interrupt_polkadot_mdns_issue_test() { + use nix::sys::signal::Signal::{SIGINT, SIGTERM}; + + let base_dir = tempdir().expect("could not create a temp dir"); + + let args = &["--", "--dev"]; + + common::run_node_for_a_while(base_dir.path(), args, SIGINT).await; + common::run_node_for_a_while(base_dir.path(), args, SIGTERM).await; +} diff --git a/node/tests/purge_chain_works.rs b/node/tests/purge_chain_works.rs new file mode 100644 index 00000000..34a51dcf --- /dev/null +++ b/node/tests/purge_chain_works.rs @@ -0,0 +1,53 @@ +// Copyright 2020-2021 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate 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. + +// Substrate 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 Substrate. If not, see . + +use assert_cmd::cargo::cargo_bin; +use nix::sys::signal::SIGINT; +use std::process::Command; +use tempfile::tempdir; + +mod common; + +#[tokio::test] +#[cfg(unix)] +#[ignore] +async fn purge_chain_works() { + // Check that both databases are deleted + + let base_dir = tempdir().expect("could not create a temp dir"); + let base_dir_path = format!("{}/polkadot", base_dir.path().display()); + + let args = &["--", "--dev", "-d", &base_dir_path]; + + common::run_node_for_a_while(base_dir.path(), args, SIGINT).await; + + assert!(base_dir.path().join("chains/local_testnet/db/full").exists()); + assert!(base_dir.path().join("polkadot/chains/dev/db/full").exists()); + + let status = Command::new(cargo_bin("polkadot-parachain")) + .args(&["purge-chain", "-d"]) + .arg(base_dir.path()) + .arg("-y") + .status() + .unwrap(); + assert!(status.success()); + + // Make sure that the `parachain_local_testnet` chain folder exists, but the `db` is deleted. + assert!(base_dir.path().join("chains/local_testnet").exists()); + assert!(!base_dir.path().join("chains/local_testnet/db/full").exists()); + // assert!(base_path.path().join("polkadot/chains/dev").exists()); + // assert!(!base_path.path().join("polkadot/chains/dev/db").exists()); +} diff --git a/node/tests/running_the_node_and_interrupt.rs b/node/tests/running_the_node_and_interrupt.rs new file mode 100644 index 00000000..6ffa39bd --- /dev/null +++ b/node/tests/running_the_node_and_interrupt.rs @@ -0,0 +1,33 @@ +// Copyright 2020-2021 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate 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. + +// Substrate 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 Substrate. If not, see . + +use tempfile::tempdir; + +mod common; + +#[tokio::test] +#[cfg(unix)] +#[ignore] +async fn running_the_node_works_and_can_be_interrupted() { + use nix::sys::signal::Signal::{SIGINT, SIGTERM}; + + let base_dir = tempdir().expect("could not create a temp dir"); + + let args = &["--", "--dev"]; + + common::run_node_for_a_while(base_dir.path(), args, SIGINT).await; + common::run_node_for_a_while(base_dir.path(), args, SIGTERM).await; +} diff --git a/pallets/asset-registry/Cargo.toml b/pallets/asset-registry/Cargo.toml index c8e3b794..f2d8a1c3 100644 --- a/pallets/asset-registry/Cargo.toml +++ b/pallets/asset-registry/Cargo.toml @@ -2,53 +2,55 @@ name = "pallet-asset-registry" version = "0.0.1" description = "Trappist pallet for XCM Asset Registry." -edition = "2021" -license = "Apache-2.0" -repository = "https://github.com/paritytech/trappist" +authors = { workspace = true } +license = { workspace = true } +homepage = { workspace = true } +repository = { workspace = true } +edition = { workspace = true } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive",] } -scale-info = { version = "2.3.1", default-features = false, features = ["derive"] } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } -pallet-assets = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } -pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } +parity-scale-codec = { workspace = true, features = [ "derive" ] } +scale-info = { workspace = true } +sp-runtime = { workspace = true } +sp-std = { workspace = true } +frame-benchmarking = { workspace = true } +frame-support = { workspace = true } +frame-system = { workspace = true } +pallet-assets = { workspace = true } +pallet-balances = { workspace = true } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +xcm = { workspace = true } -xcm-primitives = { path = "../../primitives/xcm", default-features = false } +xcm-primitives = { workspace = true } [dev-dependencies] -sp-core = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } -sp-io = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } -sp-runtime = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } +sp-core = { workspace = true } +sp-io = { workspace = true } +sp-runtime = { workspace = true } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -xcm-simulator = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +xcm = { workspace = true } +xcm-simulator = { workspace = true } +xcm-executor = { workspace = true } +xcm-builder = { workspace = true } +pallet-xcm = { workspace = true } +polkadot-core-primitives = { workspace = true } +polkadot-runtime-parachains = { workspace = true } +polkadot-parachain = { workspace = true } -parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -parachains-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } +parachain-info = { workspace = true } +parachains-common = { workspace = true } +cumulus-pallet-dmp-queue = { workspace = true } +cumulus-pallet-xcmp-queue = { workspace = true } +cumulus-primitives-core = { workspace = true } [features] default = ["std"] std = [ - "codec/std", + "parity-scale-codec/std", "sp-runtime/std", "sp-std/std", "pallet-assets/std", diff --git a/pallets/benchmarks/Cargo.toml b/pallets/benchmarks/Cargo.toml index 37a06362..c6fceec1 100644 --- a/pallets/benchmarks/Cargo.toml +++ b/pallets/benchmarks/Cargo.toml @@ -7,24 +7,24 @@ edition = "2021" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", ] } -scale-info = { version = "2.3.1", default-features = false, features = ["derive"] } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } +parity-scale-codec = { workspace = true, features = [ "derive" ] } +scale-info = { workspace = true } +sp-runtime = { workspace = true } +sp-std = { workspace = true } +frame-benchmarking = { workspace = true } +frame-support = { workspace = true } +frame-system = { workspace = true } -xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.40" } -xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.40" } +xcm = { workspace = true } +xcm-executor= { workspace = true } [dev-dependencies] -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } +sp-core = { workspace = true } [features] default = ["std"] std = [ - "codec/std", + "parity-scale-codec/std", "frame-benchmarking/std", "frame-support/std", "frame-system/std", diff --git a/pallets/benchmarks/src/lib.rs b/pallets/benchmarks/src/lib.rs index 34427034..b8cb90e1 100644 --- a/pallets/benchmarks/src/lib.rs +++ b/pallets/benchmarks/src/lib.rs @@ -2,8 +2,8 @@ #![cfg_attr(not(feature = "std"), no_std)] -use codec::Codec; use frame_support::{pallet_prelude::*, traits::tokens::AssetId}; +use parity_scale_codec::Codec; use sp_runtime::traits::AtLeast32BitUnsigned; use xcm::prelude::*; use xcm_executor::traits::DropAssets; diff --git a/pallets/lockdown-mode/Cargo.toml b/pallets/lockdown-mode/Cargo.toml index 14746944..18bc4207 100644 --- a/pallets/lockdown-mode/Cargo.toml +++ b/pallets/lockdown-mode/Cargo.toml @@ -2,55 +2,58 @@ name = "pallet-lockdown-mode" version = "0.1.0" description = "Trappist pallet for setting lockdown mode." -edition = "2021" -license = "Apache-2.0" -repository = "https://github.com/paritytech/trappist" +authors = { workspace = true } +license = { workspace = true } +homepage = { workspace = true } +repository = { workspace = true } +edition = { workspace = true } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive",] } -scale-info = { version = "2.3.1", default-features = false, features = ["derive"] } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } -cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -pallet-assets = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } -pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } -log = "0.4.17" -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +parity-scale-codec = { workspace = true, features = [ "derive" ] } +scale-info = { workspace = true } +sp-runtime = { workspace = true } +sp-std = { workspace = true } +frame-benchmarking = { workspace = true } +frame-support = { workspace = true } +frame-system = { workspace = true } -xcm-primitives = { path = "../../primitives/xcm", default-features = false } +cumulus-primitives-core = { workspace = true } +pallet-assets = { workspace = true } +pallet-balances = { workspace = true } +log = { workspace = true } +xcm = { workspace = true } + +xcm-primitives = { workspace = true } [dev-dependencies] -sp-core = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } -sp-io = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } -sp-runtime = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } -pallet-remark = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.40" } +sp-core = { workspace = true } +sp-io = { workspace = true } +sp-runtime = { workspace = true } +pallet-remark = { workspace = true } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -xcm-simulator = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } +xcm = { workspace = true } +xcm-simulator = { workspace = true } +xcm-executor = { workspace = true } +xcm-builder = { workspace = true } +pallet-xcm = { workspace = true } +polkadot-core-primitives = { workspace = true } +polkadot-runtime-parachains = { workspace = true } +polkadot-parachain = { workspace = true } -parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -parachains-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } +parachain-info = { workspace = true } +parachains-common = { workspace = true } +cumulus-pallet-dmp-queue = { workspace = true } +cumulus-pallet-xcmp-queue = { workspace = true } +cumulus-primitives-core = { workspace = true } [features] default = ["std"] std = [ - "codec/std", + "parity-scale-codec/std", "sp-runtime/std", "sp-std/std", "pallet-assets/std", diff --git a/primitives/xcm/Cargo.toml b/primitives/xcm/Cargo.toml index 391b973a..39fa7270 100644 --- a/primitives/xcm/Cargo.toml +++ b/primitives/xcm/Cargo.toml @@ -4,12 +4,13 @@ version = "0.0.1" edition = "2021" [dependencies] -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40", default-features = false } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +sp-std = { workspace = true } +frame-support = { workspace = true } +sp-runtime = { workspace = true } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } + +xcm = { workspace = true } +xcm-executor = { workspace = true } [features] default = [ "std" ] diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml deleted file mode 100644 index e81a0182..00000000 --- a/rpc/Cargo.toml +++ /dev/null @@ -1,32 +0,0 @@ -[package] -name = "trappist-rpc" -version = "1.0.0" -authors = ["Trappist Network "] -description = "A versatile Proof-of-Authority (PoA) Blockchain network." -license = "Unlicense" -homepage = "https://trappist.io" -repository = "https://github.com/TrappistNetwork/trappist" -edition = "2021" - -[dependencies] -futures = "0.3.21" -jsonrpsee = { version = "0.16.2", features = ["server"] } -codec = { package = "parity-scale-codec", version = "3.0.0" } -sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } -sc-consensus-manual-seal = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } - -parachains-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } - -# External Dependencies -pallet-dex-rpc = { version = "0.0.1", git = "https://github.com/paritytech/substrate-dex.git", default-features = false, branch = "polkadot-v0.9.40" } - -trappist-runtime = { path = "../runtime/trappist" } diff --git a/runtime/stout/Cargo.toml b/runtime/stout/Cargo.toml index 43e2e1fc..01737e6b 100644 --- a/runtime/stout/Cargo.toml +++ b/runtime/stout/Cargo.toml @@ -1,106 +1,107 @@ [package] name = "stout-runtime" version = "1.0.0" -authors = ["Trappist Network "] -license = "Unlicense" -homepage = "https://trappist.io" -repository = "https://github.com/TrappistNetwork/trappist" -edition = "2021" +authors = { workspace = true } +license = { workspace = true } +homepage = { workspace = true } +repository = { workspace = true } +edition = { workspace = true } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +substrate-wasm-builder = { workspace = true } [dependencies] -hex-literal = { version = "0.3.4", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"]} -log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.3.1", default-features = false, features = ["derive"] } -serde = { version = "1.0.152", optional = true, features = ["derive"] } -smallvec = "1.9.0" +hex-literal = { workspace = true, optional = true } +parity-scale-codec = { workspace = true, features = [ "derive" ] } +log = { workspace = true, default-features = false } +scale-info = { workspace = true } +serde = { workspace = true, optional = true } +smallvec = { workspace = true } # Substrate Dependencies ## Substrate Primitive Dependencies -sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-consensus-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-inherents = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-offchain = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-transaction-pool = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +sp-api = { workspace = true } +sp-block-builder = { workspace = true } +sp-consensus-aura = { workspace = true } +sp-core = { workspace = true } +sp-inherents = { workspace = true } +sp-io = { workspace = true } +sp-offchain = { workspace = true } +sp-runtime = { workspace = true } +sp-session = { workspace = true } +sp-std = { workspace = true } +sp-transaction-pool = { workspace = true } +sp-version = { workspace = true } ## Substrate FRAME Dependencies -frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.40" } -frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.40" } -frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.40" } -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +frame-benchmarking = { workspace = true, optional = true} +frame-try-runtime = { workspace = true, optional = true} +frame-executive = { workspace = true } +frame-support = { workspace = true } +frame-system = { workspace = true } +frame-system-benchmarking = { workspace = true, optional = true } +frame-system-rpc-runtime-api = { workspace = true } ## Substrate Pallet Dependencies -pallet-assets = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-asset-tx-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-contracts = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-identity = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-preimage = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-insecure-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-scheduler = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-uniques = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-assets = { workspace = true } +pallet-asset-tx-payment = { workspace = true } +pallet-aura = { workspace = true } +pallet-authorship = { workspace = true } +pallet-balances = { workspace = true } +pallet-collective = { workspace = true } +pallet-contracts = { workspace = true } +pallet-contracts-primitives = { workspace = true } +pallet-identity = { workspace = true } +pallet-multisig = { workspace = true } +pallet-preimage = { workspace = true } +pallet-insecure-randomness-collective-flip = { workspace = true } +pallet-session = { workspace = true } +pallet-scheduler = { workspace = true } +pallet-sudo = { workspace = true } +pallet-timestamp = { workspace = true } +pallet-transaction-payment = { workspace = true } +pallet-transaction-payment-rpc-runtime-api = { workspace = true } +pallet-uniques = { workspace = true } +pallet-utility = { workspace = true } # Cumulus dependencies -cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-ping = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -parachains-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false, version = "3.0.0"} +cumulus-pallet-aura-ext = { workspace = true } +cumulus-pallet-dmp-queue = { workspace = true } +cumulus-pallet-parachain-system = { workspace = true } +cumulus-pallet-xcm = { workspace = true } +cumulus-pallet-xcmp-queue = { workspace = true } +cumulus-ping = { workspace = true } +cumulus-primitives-core = { workspace = true } +cumulus-primitives-timestamp = { workspace = true } +cumulus-primitives-utility = { workspace = true } +pallet-collator-selection = { workspace = true } +parachains-common = { workspace = true } +parachain-info = { workspace = true } +cumulus-pallet-session-benchmarking = { workspace = true } # Polkadot Dependencies -kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -xcm-primitives = { path = "../../primitives/xcm", default-features = false } +kusama-runtime-constants = { workspace = true } +pallet-xcm = { workspace = true } +polkadot-core-primitives = { workspace = true } +polkadot-parachain = { workspace = true } +polkadot-runtime-common = { workspace = true } +xcm = { workspace = true } +xcm-builder = { workspace = true } +xcm-executor = { workspace = true } +xcm-primitives = { workspace = true } +pallet-xcm-benchmarks = { workspace = true, optional = true } # External Pallets -pallet-dex = { version = "0.0.1", git = "https://github.com/paritytech/substrate-dex.git", default-features = false, branch = "polkadot-v0.9.40" } -pallet-dex-rpc-runtime-api = { version = "0.0.1", git = "https://github.com/paritytech/substrate-dex.git", default-features = false, branch = "polkadot-v0.9.40" } +pallet-dex = { workspace = true } +pallet-dex-rpc-runtime-api = { workspace = true } [features] default = ["std"] std = [ - "codec/std", + "parity-scale-codec/std", "serde", "scale-info/std", "log/std", diff --git a/runtime/stout/src/lib.rs b/runtime/stout/src/lib.rs index 30f8dd49..8b23218d 100644 --- a/runtime/stout/src/lib.rs +++ b/runtime/stout/src/lib.rs @@ -353,7 +353,7 @@ impl pallet_assets::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Balance = AssetBalance; type AssetId = AssetIdForTrustBackedAssets; - type AssetIdParameter = codec::Compact; + type AssetIdParameter = parity_scale_codec::Compact; type Currency = Balances; type CreateOrigin = AsEnsureOriginWithArg>; type ForceOrigin = AssetsForceOrigin; @@ -476,6 +476,26 @@ impl pallet_preimage::Config for Runtime { type ByteDeposit = PreimageByteDeposit; } +parameter_types! { + pub const DexPalletId: PalletId = PalletId(*b"trap/dex"); +} + +impl pallet_dex::Config for Runtime { + type PalletId = DexPalletId; + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type AssetBalance = AssetBalance; + type AssetToCurrencyBalance = sp_runtime::traits::Identity; + type CurrencyToAssetBalance = sp_runtime::traits::Identity; + type AssetId = AssetIdForTrustBackedAssets; + type Assets = Assets; + type AssetRegistry = Assets; + type WeightInfo = pallet_dex::weights::SubstrateWeight; + type ProviderFeeNumerator = ConstU128<3>; + type ProviderFeeDenominator = ConstU128<1000>; + type MinDeposit = ConstU128<{ UNITS }>; +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where @@ -521,6 +541,7 @@ construct_runtime!( Utility: pallet_utility = 47, Preimage: pallet_preimage = 48, Multisig: pallet_multisig = 49, + Dex: pallet_dex = 50, Spambot: cumulus_ping::{Pallet, Call, Storage, Event} = 99, } @@ -544,6 +565,7 @@ mod benches { [pallet_identity, Identity] [pallet_multisig, Multisig] [pallet_uniques, Uniques] + [pallet_dex, Dex] [pallet_scheduler, Scheduler] [pallet_utility, Utility] [cumulus_pallet_xcmp_queue, XcmpQueue] @@ -630,6 +652,36 @@ impl_runtime_apis! { } } + impl pallet_dex_rpc_runtime_api::DexApi for Runtime { + fn get_currency_to_asset_output_amount( + asset_id: AssetIdForTrustBackedAssets, + currency_amount: Balance + ) -> pallet_dex_rpc_runtime_api::RpcResult { + Dex::get_currency_to_asset_output_amount(asset_id, currency_amount) + } + + fn get_currency_to_asset_input_amount( + asset_id: AssetIdForTrustBackedAssets, + token_amount: AssetBalance + ) -> pallet_dex_rpc_runtime_api::RpcResult { + Dex::get_currency_to_asset_input_amount(asset_id, token_amount) + } + + fn get_asset_to_currency_output_amount( + asset_id: AssetIdForTrustBackedAssets, + token_amount: AssetBalance + ) -> pallet_dex_rpc_runtime_api::RpcResult { + Dex::get_asset_to_currency_output_amount(asset_id, token_amount) + } + + fn get_asset_to_currency_input_amount( + asset_id: AssetIdForTrustBackedAssets, + currency_amount: Balance + ) -> pallet_dex_rpc_runtime_api::RpcResult { + Dex::get_asset_to_currency_input_amount(asset_id, currency_amount) + } + } + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { fn account_nonce(account: AccountId) -> Index { System::account_nonce(account) diff --git a/runtime/trappist/Cargo.toml b/runtime/trappist/Cargo.toml index 37a77cb3..748b0008 100644 --- a/runtime/trappist/Cargo.toml +++ b/runtime/trappist/Cargo.toml @@ -1,115 +1,115 @@ [package] name = "trappist-runtime" version = "1.0.0" -authors = ["Trappist Network "] -license = "Unlicense" -homepage = "https://trappist.io" -repository = "https://github.com/TrappistNetwork/trappist" -edition = "2021" +authors = { workspace = true } +license = { workspace = true } +homepage = { workspace = true } +repository = { workspace = true } +edition = { workspace = true } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" } +substrate-wasm-builder = { workspace = true } [dependencies] -hex-literal = { version = "0.3.4", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.3.1", default-features = false, features = ["derive"] } -serde = { version = "1.0.140", optional = true, features = ["derive"] } -smallvec = "1.9.0" +hex-literal = { workspace = true, optional = true } +parity-scale-codec = { workspace = true, features = [ "derive" ] } +log = { workspace = true, default-features = false } +scale-info = { workspace = true } +serde = { workspace = true, optional = true } +smallvec = { workspace = true } # Substrate Dependencies ## Substrate Primitive Dependencies -sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-consensus-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-inherents = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-offchain = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-transaction-pool = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +sp-api = { workspace = true } +sp-block-builder = { workspace = true } +sp-consensus-aura = { workspace = true } +sp-core = { workspace = true } +sp-inherents = { workspace = true } +sp-io = { workspace = true } +sp-offchain = { workspace = true } +sp-runtime = { workspace = true } +sp-session = { workspace = true } +sp-std = { workspace = true } +sp-transaction-pool = { workspace = true } +sp-version = { workspace = true } ## Substrate FRAME Dependencies -frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.40" } -frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.40" } -frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.40" } -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +frame-benchmarking = { workspace = true, optional = true} +frame-try-runtime = { workspace = true, optional = true} +frame-executive = { workspace = true } +frame-support = { workspace = true } +frame-system = { workspace = true } +frame-system-benchmarking = { workspace = true, optional = true } +frame-system-rpc-runtime-api = { workspace = true } ## Substrate Pallet Dependencies -pallet-assets = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-asset-tx-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-contracts = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-democracy = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-identity = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-preimage = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-insecure-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-scheduler = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-uniques = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } -pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-assets = { workspace = true } +pallet-asset-tx-payment = { workspace = true } +pallet-aura = { workspace = true } +pallet-authorship = { workspace = true } +pallet-balances = { workspace = true } +pallet-collective = { workspace = true } +pallet-contracts = { workspace = true } +pallet-contracts-primitives = { workspace = true } +pallet-democracy = { workspace = true } +pallet-identity = { workspace = true } +pallet-multisig = { workspace = true } +pallet-preimage = { workspace = true } +pallet-insecure-randomness-collective-flip = { workspace = true } +pallet-session = { workspace = true } +pallet-scheduler = { workspace = true } +pallet-sudo = { workspace = true } +pallet-timestamp = { workspace = true } +pallet-transaction-payment = { workspace = true } +pallet-transaction-payment-rpc-runtime-api = { workspace = true } +pallet-uniques = { workspace = true } +pallet-utility = { workspace = true } +pallet-treasury = { workspace = true } # Cumulus dependencies -cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-ping = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -parachains-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false } -cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40", default-features = false, version = "3.0.0"} +cumulus-pallet-aura-ext = { workspace = true } +cumulus-pallet-dmp-queue = { workspace = true } +cumulus-pallet-parachain-system = { workspace = true } +cumulus-pallet-xcm = { workspace = true } +cumulus-pallet-xcmp-queue = { workspace = true } +cumulus-ping = { workspace = true } +cumulus-primitives-core = { workspace = true } +cumulus-primitives-timestamp = { workspace = true } +cumulus-primitives-utility = { workspace = true } +pallet-collator-selection = { workspace = true } +parachains-common = { workspace = true } +parachain-info = { workspace = true } +cumulus-pallet-session-benchmarking = { workspace = true } # Polkadot Dependencies -kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.40" } -xcm-primitives = { path = "../../primitives/xcm", default-features = false } -pallet-xcm-benchmarks = { git = "https://github.com/paritytech/polkadot", default-features = false, optional = true, branch = "release-v0.9.40" } +kusama-runtime-constants = { workspace = true } +pallet-xcm = { workspace = true } +polkadot-core-primitives = { workspace = true } +polkadot-parachain = { workspace = true } +polkadot-runtime-common = { workspace = true } +xcm = { workspace = true } +xcm-builder = { workspace = true } +xcm-executor = { workspace = true } +xcm-primitives = { workspace = true } +pallet-xcm-benchmarks = { workspace = true, optional = true } # External Pallets -pallet-dex = { version = "0.0.1", git = "https://github.com/paritytech/substrate-dex.git", default-features = false, branch = "polkadot-v0.9.40" } -pallet-dex-rpc-runtime-api = { version = "0.0.1", git = "https://github.com/paritytech/substrate-dex.git", default-features = false, branch = "polkadot-v0.9.40" } -pallet-chess = { git = "https://github.com/SubstrateChess/pallet-chess.git", default-features = false, branch = "polkadot-v0.9.40" } +pallet-dex = { workspace = true } +pallet-dex-rpc-runtime-api = { workspace = true } +pallet-chess = { workspace = true } # Trappist Pallets -pallet-asset-registry = { default-features = false, path = "../../pallets/asset-registry" } -pallet-lockdown-mode = { default-features = false, path = "../../pallets/lockdown-mode" } -trappist-runtime-benchmarks = { default-features = false, path = "../../pallets/benchmarks" } +pallet-asset-registry = {workspace = true } +trappist-runtime-benchmarks = { workspace = true } +pallet-lockdown-mode = { workspace = true } [features] default = ["std"] std = [ - "codec/std", + "parity-scale-codec/std", "serde", "scale-info/std", "log/std", diff --git a/runtime/trappist/src/lib.rs b/runtime/trappist/src/lib.rs index 6b44e414..7b41e736 100644 --- a/runtime/trappist/src/lib.rs +++ b/runtime/trappist/src/lib.rs @@ -360,7 +360,7 @@ impl pallet_assets::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Balance = AssetBalance; type AssetId = AssetIdForTrustBackedAssets; - type AssetIdParameter = codec::Compact; + type AssetIdParameter = parity_scale_codec::Compact; type Currency = Balances; type CreateOrigin = AsEnsureOriginWithArg>; type ForceOrigin = AssetsForceOrigin; diff --git a/scripts/build_runtimes.sh b/scripts/build_runtimes.sh deleted file mode 100755 index 57eaa4e7..00000000 --- a/scripts/build_runtimes.sh +++ /dev/null @@ -1,2 +0,0 @@ -cargo b -r --features with-trappist-runtime -cargo b -r --no-default-features --features with-stout-runtime --target-dir target_stout diff --git a/zombienet/full_network.toml b/zombienet/full_network.toml index d2f26c16..e0ba9e2a 100644 --- a/zombienet/full_network.toml +++ b/zombienet/full_network.toml @@ -52,13 +52,13 @@ chain = "trappist-local" [[parachains.collators]] name = "trappist-collator01" - command = "./target/release/trappist-collator" + command = "./target/release/trappist-node" ws_port = 9920 args = ["--log=xcm=trace,pallet-assets=trace"] [[parachains.collators]] name = "trappist-collator02" - command = "./target/release/trappist-collator" + command = "./target/release/trappist-node" ws_port = 9921 args = ["--log=xcm=trace,pallet-assets=trace"] @@ -70,13 +70,13 @@ chain = "stout-local" [[parachains.collators]] name = "stout-collator01" - command = "./target_stout/release/stout-collator" + command = "./target/release/trappist-node" ws_port = 9930 args = ["--log=xcm=trace,pallet-assets=trace"] [[parachains.collators]] name = "stout-collator02" - command = "./target_stout/release/stout-collator" + command = "./target/release/trappist-node" ws_port = 9931 args = ["--log=xcm=trace,pallet-assets=trace"] diff --git a/zombienet/stout_rococo.toml b/zombienet/stout_rococo.toml index ab2d81db..6d14f513 100644 --- a/zombienet/stout_rococo.toml +++ b/zombienet/stout_rococo.toml @@ -52,13 +52,13 @@ chain = "stout-local" [[parachains.collators]] name = "stout-collator01" - command = "./target_stout/release/stout-collator" + command = "./target/release/trappist-node" ws_port = 9930 args = ["--log=xcm=trace,pallet-assets=trace"] [[parachains.collators]] name = "stout-collator02" - command = "./target_stout/release/stout-collator" + command = "./target/release/trappist-node" ws_port = 9931 args = ["--log=xcm=trace,pallet-assets=trace"] diff --git a/zombienet/trappist_rococo.toml b/zombienet/trappist_rococo.toml index 088a8c45..c8259240 100644 --- a/zombienet/trappist_rococo.toml +++ b/zombienet/trappist_rococo.toml @@ -52,13 +52,13 @@ chain = "trappist-local" [[parachains.collators]] name = "trappist-collator01" - command = "./target/release/trappist-collator" + command = "./target/release/trappist-node" ws_port = 9920 args = ["--log=xcm=trace,pallet-assets=trace"] [[parachains.collators]] name = "trappist-collator02" - command = "./target/release/trappist-collator" + command = "./target/release/trappist-node" ws_port = 9921 args = ["--log=xcm=trace,pallet-assets=trace"]