From cf680054ee03dade0a45fe1fc301ec3c0872c4cc Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Thu, 25 May 2023 10:33:10 +0200 Subject: [PATCH 01/15] WIP --- Cargo.lock | 652 ++++------------ node copy/Cargo.toml | 54 ++ {node => node copy}/cli/Cargo.toml | 0 {node => node copy}/cli/build.rs | 0 {node => node copy}/cli/src/cli.rs | 0 {node => node copy}/cli/src/command.rs | 0 {node => node copy}/cli/src/lib.rs | 0 {node => node copy}/service/Cargo.toml | 0 .../service/src/chain_spec/mod.rs | 0 .../service/src/chain_spec/stout.rs | 0 .../service/src/chain_spec/trappist.rs | 0 {node => node copy}/service/src/lib.rs | 0 node copy/src/main.rs | 24 + node/Cargo.toml | 113 ++- node/build.rs | 22 + node/src/chain_spec/mod.rs | 68 ++ node/src/chain_spec/stout.rs | 232 ++++++ node/src/chain_spec/trappist.rs | 355 +++++++++ node/src/cli.rs | 118 +++ node/src/command.rs | 709 ++++++++++++++++++ node/src/main.rs | 11 +- node/src/rpc.rs | 86 +++ node/src/service.rs | 583 ++++++++++++++ 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 + 29 files changed, 2850 insertions(+), 515 deletions(-) create mode 100644 node copy/Cargo.toml rename {node => node copy}/cli/Cargo.toml (100%) rename {node => node copy}/cli/build.rs (100%) rename {node => node copy}/cli/src/cli.rs (100%) rename {node => node copy}/cli/src/command.rs (100%) rename {node => node copy}/cli/src/lib.rs (100%) rename {node => node copy}/service/Cargo.toml (100%) rename {node => node copy}/service/src/chain_spec/mod.rs (100%) rename {node => node copy}/service/src/chain_spec/stout.rs (100%) rename {node => node copy}/service/src/chain_spec/trappist.rs (100%) rename {node => node copy}/service/src/lib.rs (100%) create mode 100644 node copy/src/main.rs create mode 100644 node/build.rs create mode 100644 node/src/chain_spec/mod.rs create mode 100644 node/src/chain_spec/stout.rs create mode 100644 node/src/chain_spec/trappist.rs create mode 100644 node/src/cli.rs create mode 100644 node/src/command.rs create mode 100644 node/src/rpc.rs 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 diff --git a/Cargo.lock b/Cargo.lock index 25891846..e2808e3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -538,7 +538,7 @@ dependencies = [ "array-bytes 4.2.0", "async-trait", "fnv", - "futures 0.3.28", + "futures", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -570,7 +570,7 @@ version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "beefy-gadget", - "futures 0.3.28", + "futures", "jsonrpsee", "log", "parity-scale-codec", @@ -1440,7 +1440,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", @@ -1463,7 +1463,7 @@ dependencies = [ "async-trait", "cumulus-client-consensus-common", "cumulus-primitives-core", - "futures 0.3.28", + "futures", "parity-scale-codec", "sc-client-api", "sc-consensus", @@ -1494,7 +1494,7 @@ dependencies = [ "cumulus-primitives-core", "cumulus-relay-chain-interface", "dyn-clone", - "futures 0.3.28", + "futures", "log", "parity-scale-codec", "polkadot-primitives", @@ -1516,7 +1516,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", @@ -1537,7 +1537,7 @@ source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.37#0941 dependencies = [ "async-trait", "cumulus-relay-chain-interface", - "futures 0.3.28", + "futures", "futures-timer", "parity-scale-codec", "parking_lot 0.12.1", @@ -1560,7 +1560,7 @@ source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.37#0941 dependencies = [ "cumulus-primitives-core", "cumulus-relay-chain-interface", - "futures 0.3.28", + "futures", "futures-timer", "parity-scale-codec", "polkadot-node-primitives", @@ -1589,7 +1589,7 @@ dependencies = [ "cumulus-relay-chain-inprocess-interface", "cumulus-relay-chain-interface", "cumulus-relay-chain-minimal-node", - "futures 0.3.28", + "futures", "parking_lot 0.12.1", "polkadot-primitives", "sc-client-api", @@ -1785,7 +1785,7 @@ version = "0.1.0" source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.37#09418fc04c2608b123f36ca80f16df3d2096753b" dependencies = [ "cumulus-primitives-core", - "futures 0.3.28", + "futures", "parity-scale-codec", "sp-inherents", "sp-std", @@ -1816,7 +1816,7 @@ dependencies = [ "async-trait", "cumulus-primitives-core", "cumulus-relay-chain-interface", - "futures 0.3.28", + "futures", "futures-timer", "polkadot-cli", "polkadot-client", @@ -1840,7 +1840,7 @@ source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.37#0941 dependencies = [ "async-trait", "cumulus-primitives-core", - "futures 0.3.28", + "futures", "jsonrpsee-core", "parity-scale-codec", "polkadot-overseer", @@ -1863,7 +1863,7 @@ dependencies = [ "cumulus-primitives-core", "cumulus-relay-chain-interface", "cumulus-relay-chain-rpc-interface", - "futures 0.3.28", + "futures", "lru", "polkadot-core-primitives", "polkadot-network-bridge", @@ -1901,7 +1901,7 @@ dependencies = [ "async-trait", "cumulus-primitives-core", "cumulus-relay-chain-interface", - "futures 0.3.28", + "futures", "futures-timer", "jsonrpsee", "lru", @@ -2508,7 +2508,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5" dependencies = [ - "futures 0.3.28", + "futures", ] [[package]] @@ -2636,7 +2636,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", @@ -2844,7 +2844,7 @@ name = "frame-remote-externalities" version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ - "futures 0.3.28", + "futures", "log", "parity-scale-codec", "serde", @@ -2999,12 +2999,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" @@ -3115,7 +3109,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", @@ -3569,7 +3562,7 @@ dependencies = [ "async-io", "core-foundation", "fnv", - "futures 0.3.28", + "futures", "if-addrs", "ipnet", "log", @@ -3914,15 +3907,12 @@ version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ "bitvec", - "frame-benchmarking", "frame-election-provider-support", "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "hex-literal", "kusama-runtime-constants", "log", "pallet-authority-discovery", @@ -3936,7 +3926,6 @@ dependencies = [ "pallet-conviction-voting", "pallet-democracy", "pallet-election-provider-multi-phase", - "pallet-election-provider-support-benchmarking", "pallet-elections-phragmen", "pallet-fast-unstake", "pallet-grandpa", @@ -3947,10 +3936,8 @@ dependencies = [ "pallet-multisig", "pallet-nis", "pallet-nomination-pools", - "pallet-nomination-pools-benchmarking", "pallet-nomination-pools-runtime-api", "pallet-offences", - "pallet-offences-benchmarking", "pallet-preimage", "pallet-proxy", "pallet-ranked-collective", @@ -3958,7 +3945,6 @@ dependencies = [ "pallet-referenda", "pallet-scheduler", "pallet-session", - "pallet-session-benchmarking", "pallet-society", "pallet-staking", "pallet-timestamp", @@ -3970,7 +3956,6 @@ dependencies = [ "pallet-vesting", "pallet-whitelist", "pallet-xcm", - "pallet-xcm-benchmarks", "parity-scale-codec", "polkadot-primitives", "polkadot-runtime-common", @@ -4099,7 +4084,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", @@ -4137,7 +4122,7 @@ dependencies = [ "ed25519-dalek", "either", "fnv", - "futures 0.3.28", + "futures", "futures-timer", "instant", "log", @@ -4168,7 +4153,7 @@ checksum = "9b7f8b7d65c070a5a1b5f8f0510648189da08f787b8963f8e21219e0710733af" dependencies = [ "either", "fnv", - "futures 0.3.28", + "futures", "futures-timer", "instant", "libp2p-identity", @@ -4194,7 +4179,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", @@ -4209,7 +4194,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", @@ -4252,7 +4237,7 @@ dependencies = [ "bytes", "either", "fnv", - "futures 0.3.28", + "futures", "futures-timer", "instant", "libp2p-core 0.38.0", @@ -4276,7 +4261,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", @@ -4311,7 +4296,7 @@ checksum = "03805b44107aa013e7cbbfa5627b31c36cbedfdfb00603c0311998882bc4bace" dependencies = [ "asynchronous-codec", "bytes", - "futures 0.3.28", + "futures", "libp2p-core 0.38.0", "log", "nohash-hasher", @@ -4329,7 +4314,7 @@ checksum = "a978cb57efe82e892ec6f348a536bfbd9fee677adbe5689d7a93ad3a9bffbf2e" dependencies = [ "bytes", "curve25519-dalek 3.2.0", - "futures 0.3.28", + "futures", "libp2p-core 0.38.0", "log", "once_cell", @@ -4350,7 +4335,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", @@ -4367,7 +4352,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", @@ -4389,7 +4374,7 @@ checksum = "3236168796727bfcf4927f766393415361e2c644b08bedb6a6b13d957c9a4884" dependencies = [ "async-trait", "bytes", - "futures 0.3.28", + "futures", "instant", "libp2p-core 0.38.0", "libp2p-swarm", @@ -4407,7 +4392,7 @@ checksum = "b2a35472fe3276b3855c00f1c032ea8413615e030256429ad5349cdf67c6e1a0" dependencies = [ "either", "fnv", - "futures 0.3.28", + "futures", "futures-timer", "instant", "libp2p-core 0.38.0", @@ -4438,7 +4423,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", @@ -4454,7 +4439,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.1", "libp2p-identity", @@ -4473,7 +4458,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", @@ -4490,7 +4475,7 @@ dependencies = [ "async-trait", "asynchronous-codec", "bytes", - "futures 0.3.28", + "futures", "futures-timer", "hex", "if-watch", @@ -4519,7 +4504,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", @@ -4537,7 +4522,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", @@ -4846,7 +4831,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", ] @@ -4883,7 +4868,7 @@ name = "mmr-gadget" version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ - "futures 0.3.28", + "futures", "log", "parity-scale-codec", "sc-client-api", @@ -5045,7 +5030,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" dependencies = [ "bytes", - "futures 0.3.28", + "futures", "log", "pin-project", "smallvec", @@ -5141,7 +5126,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", @@ -5156,7 +5141,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6471bf08e7ac0135876a9581bf3217ef0333c191c128d34878079f42ee150411" dependencies = [ "bytes", - "futures 0.3.28", + "futures", "libc", "log", "tokio", @@ -5164,12 +5149,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", @@ -5177,14 +5161,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]] @@ -5352,7 +5338,7 @@ checksum = "17e7d5b6bb115db09390bed8842c94180893dd83df3dfce7354f2a2aa090a4ee" dependencies = [ "async-trait", "dyn-clonable", - "futures 0.3.28", + "futures", "futures-timer", "orchestra-proc-macro", "pin-project", @@ -6107,26 +6093,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-nomination-pools-benchmarking" -version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" -dependencies = [ - "frame-benchmarking", - "frame-election-provider-support", - "frame-support", - "frame-system", - "pallet-bags-list", - "pallet-nomination-pools", - "pallet-staking", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-runtime-interface", - "sp-staking", - "sp-std", -] - [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" @@ -6154,29 +6120,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-offences-benchmarking" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" -dependencies = [ - "frame-benchmarking", - "frame-election-provider-support", - "frame-support", - "frame-system", - "pallet-babe", - "pallet-balances", - "pallet-grandpa", - "pallet-im-online", - "pallet-offences", - "pallet-session", - "pallet-staking", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-staking", - "sp-std", -] - [[package]] name = "pallet-preimage" version = "4.0.0-dev" @@ -6261,7 +6204,6 @@ name = "pallet-referenda" version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ - "assert_matches", "frame-benchmarking", "frame-support", "frame-system", @@ -6328,22 +6270,6 @@ dependencies = [ "sp-trie", ] -[[package]] -name = "pallet-session-benchmarking" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "pallet-session", - "pallet-staking", - "rand 0.8.5", - "sp-runtime", - "sp-session", - "sp-std", -] - [[package]] name = "pallet-society" version = "4.0.0-dev" @@ -6371,7 +6297,6 @@ dependencies = [ "pallet-authorship", "pallet-session", "parity-scale-codec", - "rand_chacha 0.2.2", "scale-info", "serde", "sp-application-crypto", @@ -6609,23 +6534,6 @@ dependencies = [ "xcm-executor", ] -[[package]] -name = "pallet-xcm-benchmarks" -version = "0.9.37" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-std", - "xcm", - "xcm-executor", -] - [[package]] name = "parachain-info" version = "0.1.0" @@ -6956,7 +6864,7 @@ name = "polkadot-approval-distribution" version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ - "futures 0.3.28", + "futures", "polkadot-node-metrics", "polkadot-node-network-protocol", "polkadot-node-primitives", @@ -6971,7 +6879,7 @@ name = "polkadot-availability-bitfield-distribution" version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ - "futures 0.3.28", + "futures", "polkadot-node-network-protocol", "polkadot-node-subsystem", "polkadot-node-subsystem-util", @@ -6987,7 +6895,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#6457 dependencies = [ "derive_more", "fatality", - "futures 0.3.28", + "futures", "lru", "parity-scale-codec", "polkadot-erasure-coding", @@ -7009,7 +6917,7 @@ version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ "fatality", - "futures 0.3.28", + "futures", "lru", "parity-scale-codec", "polkadot-erasure-coding", @@ -7031,7 +6939,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#6457 dependencies = [ "clap", "frame-benchmarking-cli", - "futures 0.3.28", + "futures", "log", "polkadot-client", "polkadot-node-core-pvf", @@ -7061,7 +6969,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", @@ -7102,7 +7010,7 @@ dependencies = [ "always-assert", "bitvec", "fatality", - "futures 0.3.28", + "futures", "futures-timer", "polkadot-node-network-protocol", "polkadot-node-primitives", @@ -7135,7 +7043,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#6457 dependencies = [ "derive_more", "fatality", - "futures 0.3.28", + "futures", "futures-timer", "indexmap", "lru", @@ -7172,7 +7080,7 @@ name = "polkadot-gossip-support" version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ - "futures 0.3.28", + "futures", "futures-timer", "polkadot-node-network-protocol", "polkadot-node-subsystem", @@ -7196,7 +7104,7 @@ dependencies = [ "async-trait", "bytes", "fatality", - "futures 0.3.28", + "futures", "parity-scale-codec", "parking_lot 0.12.1", "polkadot-node-metrics", @@ -7216,7 +7124,7 @@ name = "polkadot-node-collation-generation" version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ - "futures 0.3.28", + "futures", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-primitives", @@ -7236,7 +7144,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#6457 dependencies = [ "bitvec", "derive_more", - "futures 0.3.28", + "futures", "futures-timer", "kvdb", "lru", @@ -7264,7 +7172,7 @@ version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ "bitvec", - "futures 0.3.28", + "futures", "futures-timer", "kvdb", "parity-scale-codec", @@ -7285,7 +7193,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#6457 dependencies = [ "bitvec", "fatality", - "futures 0.3.28", + "futures", "polkadot-erasure-coding", "polkadot-node-primitives", "polkadot-node-subsystem", @@ -7302,7 +7210,7 @@ name = "polkadot-node-core-bitfield-signing" version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ - "futures 0.3.28", + "futures", "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", @@ -7318,7 +7226,7 @@ version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "futures-timer", "parity-scale-codec", "polkadot-node-core-pvf", @@ -7336,7 +7244,7 @@ name = "polkadot-node-core-chain-api" version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ - "futures 0.3.28", + "futures", "polkadot-node-metrics", "polkadot-node-subsystem", "polkadot-primitives", @@ -7351,7 +7259,7 @@ name = "polkadot-node-core-chain-selection" version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ - "futures 0.3.28", + "futures", "futures-timer", "kvdb", "parity-scale-codec", @@ -7369,7 +7277,7 @@ version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ "fatality", - "futures 0.3.28", + "futures", "kvdb", "lru", "parity-scale-codec", @@ -7388,7 +7296,7 @@ version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "futures-timer", "polkadot-node-subsystem", "polkadot-overseer", @@ -7406,7 +7314,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#6457 dependencies = [ "bitvec", "fatality", - "futures 0.3.28", + "futures", "futures-timer", "polkadot-node-primitives", "polkadot-node-subsystem", @@ -7425,7 +7333,7 @@ dependencies = [ "always-assert", "assert_matches", "cpu-time", - "futures 0.3.28", + "futures", "futures-timer", "parity-scale-codec", "pin-project", @@ -7454,7 +7362,7 @@ name = "polkadot-node-core-pvf-checker" version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ - "futures 0.3.28", + "futures", "polkadot-node-primitives", "polkadot-node-subsystem", "polkadot-node-subsystem-util", @@ -7470,7 +7378,7 @@ name = "polkadot-node-core-runtime-api" version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ - "futures 0.3.28", + "futures", "lru", "polkadot-node-metrics", "polkadot-node-subsystem", @@ -7504,7 +7412,7 @@ version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ "bs58", - "futures 0.3.28", + "futures", "futures-timer", "log", "parity-scale-codec", @@ -7525,7 +7433,7 @@ dependencies = [ "async-trait", "derive_more", "fatality", - "futures 0.3.28", + "futures", "hex", "parity-scale-codec", "polkadot-node-jaeger", @@ -7546,7 +7454,7 @@ version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ "bounded-vec", - "futures 0.3.28", + "futures", "parity-scale-codec", "polkadot-parachain", "polkadot-primitives", @@ -7579,7 +7487,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#6457 dependencies = [ "async-trait", "derive_more", - "futures 0.3.28", + "futures", "orchestra", "polkadot-node-jaeger", "polkadot-node-network-protocol", @@ -7603,7 +7511,7 @@ dependencies = [ "async-trait", "derive_more", "fatality", - "futures 0.3.28", + "futures", "futures-channel", "itertools", "kvdb", @@ -7634,7 +7542,7 @@ version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "futures-timer", "lru", "orchestra", @@ -7746,15 +7654,12 @@ version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ "bitvec", - "frame-benchmarking", "frame-election-provider-support", "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "hex-literal", "log", "pallet-authority-discovery", "pallet-authorship", @@ -7766,7 +7671,6 @@ dependencies = [ "pallet-collective", "pallet-democracy", "pallet-election-provider-multi-phase", - "pallet-election-provider-support-benchmarking", "pallet-elections-phragmen", "pallet-fast-unstake", "pallet-grandpa", @@ -7776,15 +7680,12 @@ dependencies = [ "pallet-membership", "pallet-multisig", "pallet-nomination-pools", - "pallet-nomination-pools-benchmarking", "pallet-nomination-pools-runtime-api", "pallet-offences", - "pallet-offences-benchmarking", "pallet-preimage", "pallet-proxy", "pallet-scheduler", "pallet-session", - "pallet-session-benchmarking", "pallet-staking", "pallet-staking-reward-curve", "pallet-timestamp", @@ -7835,7 +7736,6 @@ version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ "bitvec", - "frame-benchmarking", "frame-election-provider-support", "frame-support", "frame-system", @@ -7843,7 +7743,6 @@ dependencies = [ "libsecp256k1", "log", "pallet-authorship", - "pallet-babe", "pallet-bags-list", "pallet-balances", "pallet-beefy-mmr", @@ -7911,7 +7810,6 @@ dependencies = [ "bitflags", "bitvec", "derive_more", - "frame-benchmarking", "frame-support", "frame-system", "log", @@ -7932,7 +7830,6 @@ dependencies = [ "scale-info", "serde", "sp-api", - "sp-application-crypto", "sp-core", "sp-inherents", "sp-io", @@ -7941,7 +7838,6 @@ dependencies = [ "sp-session", "sp-staking", "sp-std", - "static_assertions", "xcm", "xcm-executor", ] @@ -7955,9 +7851,8 @@ dependencies = [ "beefy-gadget", "frame-support", "frame-system-rpc-runtime-api", - "futures 0.3.28", + "futures", "hex-literal", - "kusama-runtime", "kvdb", "kvdb-rocksdb", "lru", @@ -8050,7 +7945,6 @@ dependencies = [ "substrate-prometheus-endpoint", "thiserror", "tracing-gum", - "westend-runtime", ] [[package]] @@ -8060,7 +7954,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#6457 dependencies = [ "arrayvec 0.5.2", "fatality", - "futures 0.3.28", + "futures", "indexmap", "parity-scale-codec", "polkadot-node-network-protocol", @@ -8215,7 +8109,7 @@ dependencies = [ "coarsetime", "crossbeam-queue", "derive_more", - "futures 0.3.28", + "futures", "futures-timer", "nanorand", "thiserror", @@ -8738,11 +8632,9 @@ version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ "beefy-merkle-tree", - "frame-benchmarking", "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", @@ -8784,7 +8676,6 @@ dependencies = [ "pallet-utility", "pallet-vesting", "pallet-xcm", - "pallet-xcm-benchmarks", "parity-scale-codec", "polkadot-parachain", "polkadot-primitives", @@ -8860,7 +8751,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", @@ -9024,7 +8915,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", ] @@ -9070,7 +8961,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "futures-timer", "ip_network", "libp2p", @@ -9096,7 +8987,7 @@ name = "sc-basic-authorship" version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ - "futures 0.3.28", + "futures", "futures-timer", "log", "parity-scale-codec", @@ -9165,7 +9056,7 @@ dependencies = [ "chrono", "clap", "fdlimit", - "futures 0.3.28", + "futures", "libp2p", "log", "names", @@ -9202,7 +9093,7 @@ version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "fnv", - "futures 0.3.28", + "futures", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -9253,7 +9144,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "futures-timer", "libp2p", "log", @@ -9278,7 +9169,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "log", "parity-scale-codec", "sc-block-builder", @@ -9308,7 +9199,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6f dependencies = [ "async-trait", "fork-tree", - "futures 0.3.28", + "futures", "log", "merlin", "num-bigint", @@ -9344,7 +9235,7 @@ name = "sc-consensus-babe-rpc" version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ - "futures 0.3.28", + "futures", "jsonrpsee", "sc-consensus-babe", "sc-consensus-epochs", @@ -9374,47 +9265,13 @@ dependencies = [ "sp-runtime", ] -[[package]] -name = "sc-consensus-manual-seal" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" -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.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "futures-timer", "log", "parity-scale-codec", @@ -9509,7 +9366,7 @@ dependencies = [ "dyn-clone", "finality-grandpa", "fork-tree", - "futures 0.3.28", + "futures", "futures-timer", "log", "parity-scale-codec", @@ -9544,7 +9401,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "finality-grandpa", - "futures 0.3.28", + "futures", "jsonrpsee", "log", "parity-scale-codec", @@ -9564,7 +9421,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "ansi_term", - "futures 0.3.28", + "futures", "futures-timer", "log", "sc-client-api", @@ -9600,7 +9457,7 @@ dependencies = [ "bytes", "either", "fnv", - "futures 0.3.28", + "futures", "futures-timer", "ip_network", "libp2p", @@ -9636,7 +9493,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "cid", - "futures 0.3.28", + "futures", "libp2p", "log", "prost", @@ -9657,7 +9514,7 @@ dependencies = [ "async-trait", "bitflags", "bytes", - "futures 0.3.28", + "futures", "futures-timer", "libp2p", "linked_hash_set", @@ -9681,7 +9538,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "ahash", - "futures 0.3.28", + "futures", "futures-timer", "libp2p", "log", @@ -9699,7 +9556,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "array-bytes 4.2.0", - "futures 0.3.28", + "futures", "libp2p", "log", "parity-scale-codec", @@ -9722,7 +9579,7 @@ dependencies = [ "array-bytes 4.2.0", "async-trait", "fork-tree", - "futures 0.3.28", + "futures", "libp2p", "log", "lru", @@ -9752,7 +9609,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "array-bytes 4.2.0", - "futures 0.3.28", + "futures", "libp2p", "log", "parity-scale-codec", @@ -9773,7 +9630,7 @@ dependencies = [ "array-bytes 4.2.0", "bytes", "fnv", - "futures 0.3.28", + "futures", "futures-timer", "hyper", "hyper-rustls", @@ -9800,7 +9657,7 @@ name = "sc-peerset" version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ - "futures 0.3.28", + "futures", "libp2p", "log", "sc-utils", @@ -9822,7 +9679,7 @@ name = "sc-rpc" version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ - "futures 0.3.28", + "futures", "jsonrpsee", "log", "parity-scale-codec", @@ -9886,7 +9743,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "array-bytes 4.2.0", - "futures 0.3.28", + "futures", "futures-util", "hex", "jsonrpsee", @@ -9914,7 +9771,7 @@ dependencies = [ "async-trait", "directories", "exit-future", - "futures 0.3.28", + "futures", "futures-timer", "jsonrpsee", "log", @@ -10006,7 +9863,7 @@ name = "sc-sysinfo" version = "6.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ - "futures 0.3.28", + "futures", "libc", "log", "rand 0.8.5", @@ -10026,7 +9883,7 @@ version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "chrono", - "futures 0.3.28", + "futures", "libp2p", "log", "parking_lot 0.12.1", @@ -10087,7 +9944,7 @@ version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "futures-timer", "linked-hash-map", "log", @@ -10113,7 +9970,7 @@ version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "log", "serde", "sp-blockchain", @@ -10127,7 +9984,7 @@ version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "backtrace", - "futures 0.3.28", + "futures", "futures-timer", "lazy_static", "log", @@ -10566,7 +10423,7 @@ dependencies = [ "base64 0.13.1", "bytes", "flate2", - "futures 0.3.28", + "futures", "http", "httparse", "log", @@ -10690,7 +10547,7 @@ name = "sp-blockchain" version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ - "futures 0.3.28", + "futures", "log", "lru", "parity-scale-codec", @@ -10709,7 +10566,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "log", "parity-scale-codec", "sp-core", @@ -10798,7 +10655,7 @@ dependencies = [ "blake2", "dyn-clonable", "ed25519-zebra", - "futures 0.3.28", + "futures", "hash-db", "hash256-std-hasher", "impl-serde", @@ -10924,7 +10781,7 @@ dependencies = [ "bytes", "ed25519", "ed25519-dalek", - "futures 0.3.28", + "futures", "libsecp256k1", "log", "parity-scale-codec", @@ -10958,7 +10815,7 @@ version = "0.13.0" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "async-trait", - "futures 0.3.28", + "futures", "merlin", "parity-scale-codec", "parking_lot 0.12.1", @@ -11092,6 +10949,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.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "sp-session" version = "4.0.0-dev" @@ -11552,7 +11418,7 @@ version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ "frame-system-rpc-runtime-api", - "futures 0.3.28", + "futures", "jsonrpsee", "log", "parity-scale-codec", @@ -12145,22 +12011,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", @@ -12174,54 +12024,61 @@ 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-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]] @@ -12322,78 +12179,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-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.24.0" @@ -12512,7 +12297,7 @@ checksum = "4712ee30d123ec7ae26d1e1b218395a16c87cdbaf4b3925d170d684af62ea5e8" dependencies = [ "async-trait", "base64 0.13.1", - "futures 0.3.28", + "futures", "log", "md-5", "rand 0.8.5", @@ -12873,7 +12658,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", @@ -13380,110 +13165,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "westend-runtime" -version = "0.9.37" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" -dependencies = [ - "bitvec", - "frame-benchmarking", - "frame-election-provider-support", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal", - "log", - "pallet-authority-discovery", - "pallet-authorship", - "pallet-babe", - "pallet-bags-list", - "pallet-balances", - "pallet-collective", - "pallet-democracy", - "pallet-election-provider-multi-phase", - "pallet-election-provider-support-benchmarking", - "pallet-elections-phragmen", - "pallet-fast-unstake", - "pallet-grandpa", - "pallet-identity", - "pallet-im-online", - "pallet-indices", - "pallet-membership", - "pallet-multisig", - "pallet-nomination-pools", - "pallet-nomination-pools-benchmarking", - "pallet-nomination-pools-runtime-api", - "pallet-offences", - "pallet-offences-benchmarking", - "pallet-preimage", - "pallet-proxy", - "pallet-recovery", - "pallet-scheduler", - "pallet-session", - "pallet-session-benchmarking", - "pallet-society", - "pallet-staking", - "pallet-staking-reward-curve", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-treasury", - "pallet-utility", - "pallet-vesting", - "pallet-xcm", - "pallet-xcm-benchmarks", - "parity-scale-codec", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "rustc-hex", - "scale-info", - "serde", - "serde_derive", - "smallvec", - "sp-api", - "sp-authority-discovery", - "sp-beefy", - "sp-block-builder", - "sp-consensus-babe", - "sp-core", - "sp-inherents", - "sp-io", - "sp-mmr-primitives", - "sp-npos-elections", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", - "westend-runtime-constants", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "westend-runtime-constants" -version = "0.9.37" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" -dependencies = [ - "frame-support", - "polkadot-primitives", - "polkadot-runtime-common", - "smallvec", - "sp-core", - "sp-runtime", - "sp-weights", -] - [[package]] name = "which" version = "4.4.0" @@ -13899,7 +13580,6 @@ name = "xcm-executor" version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ - "frame-benchmarking", "frame-support", "impl-trait-for-tuples", "log", @@ -13957,7 +13637,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/node copy/Cargo.toml b/node copy/Cargo.toml new file mode 100644 index 00000000..d8b8ba5f --- /dev/null +++ b/node copy/Cargo.toml @@ -0,0 +1,54 @@ +[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" + +[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.37" } + +[[bin]] +required-features = ["with-trappist-runtime"] +name = "trappist-collator" +path = "src/main.rs" + + +[[bin]] +required-features = ["with-stout-runtime"] +name = "stout-collator" +path = "src/main.rs" + +[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" } + +[dev-dependencies] +assert_cmd = "2.0" +nix = "0.23" +tempfile = "3.2.0" + +[features] +default = ["with-trappist-runtime"] +runtime-benchmarks = [ + "trappist-cli/runtime-benchmarks" +] +with-trappist-runtime = [ + "trappist-service/with-trappist-runtime", + "trappist-cli/with-trappist-runtime", +] +with-stout-runtime = [ + "trappist-service/with-stout-runtime", + "trappist-cli/with-stout-runtime", +] diff --git a/node/cli/Cargo.toml b/node copy/cli/Cargo.toml similarity index 100% rename from node/cli/Cargo.toml rename to node copy/cli/Cargo.toml diff --git a/node/cli/build.rs b/node copy/cli/build.rs similarity index 100% rename from node/cli/build.rs rename to node copy/cli/build.rs diff --git a/node/cli/src/cli.rs b/node copy/cli/src/cli.rs similarity index 100% rename from node/cli/src/cli.rs rename to node copy/cli/src/cli.rs diff --git a/node/cli/src/command.rs b/node copy/cli/src/command.rs similarity index 100% rename from node/cli/src/command.rs rename to node copy/cli/src/command.rs diff --git a/node/cli/src/lib.rs b/node copy/cli/src/lib.rs similarity index 100% rename from node/cli/src/lib.rs rename to node copy/cli/src/lib.rs diff --git a/node/service/Cargo.toml b/node copy/service/Cargo.toml similarity index 100% rename from node/service/Cargo.toml rename to node copy/service/Cargo.toml diff --git a/node/service/src/chain_spec/mod.rs b/node copy/service/src/chain_spec/mod.rs similarity index 100% rename from node/service/src/chain_spec/mod.rs rename to node copy/service/src/chain_spec/mod.rs diff --git a/node/service/src/chain_spec/stout.rs b/node copy/service/src/chain_spec/stout.rs similarity index 100% rename from node/service/src/chain_spec/stout.rs rename to node copy/service/src/chain_spec/stout.rs diff --git a/node/service/src/chain_spec/trappist.rs b/node copy/service/src/chain_spec/trappist.rs similarity index 100% rename from node/service/src/chain_spec/trappist.rs rename to node copy/service/src/chain_spec/trappist.rs diff --git a/node/service/src/lib.rs b/node copy/service/src/lib.rs similarity index 100% rename from node/service/src/lib.rs rename to node copy/service/src/lib.rs diff --git a/node copy/src/main.rs b/node copy/src/main.rs new file mode 100644 index 00000000..c39414b3 --- /dev/null +++ b/node copy/src/main.rs @@ -0,0 +1,24 @@ +// 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 . + +//! Cumulus test parachain collator + +#![warn(missing_docs)] +#![warn(unused_extern_crates)] + +fn main() -> trappist_cli::Result<()> { + trappist_cli::run() +} diff --git a/node/Cargo.toml b/node/Cargo.toml index d8b8ba5f..0a41aebc 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -7,48 +7,107 @@ license = "Unlicense" homepage = "https://trappist.io" repository = "https://github.com/TrappistNetwork/trappist" edition = "2021" -default-run = "trappist-collator" +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.37" } - -[[bin]] -required-features = ["with-trappist-runtime"] -name = "trappist-collator" -path = "src/main.rs" - - [[bin]] -required-features = ["with-stout-runtime"] -name = "stout-collator" +name = "trappist-node" path = "src/main.rs" [dependencies] -async-trait = "0.1.57" +async-trait = "0.1.60" clap = { version = "4.0.32", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.0.0" } +futures = "0.3.25" +hex-literal = "0.3.4" log = "0.4.17" -futures = { version = "0.3.1", features = ["compat"] } -trappist-cli = { path = "cli" } -trappist-service = { path = "service" } +serde = { version = "1.0.152", features = ["derive"] } + +# Local Dependencies +trappist-runtime = { path = "../runtime/trappist"} +stout-runtime = { path = "../runtime/stout" } +jsonrpsee = { version = "0.16.2", features = ["server"] } + +# External Dependencies +pallet-dex-rpc = { version = "0.0.1", git = "https://github.com/paritytech/substrate-dex.git", default-features = false, branch = "polkadot-v0.9.37" } + +# Substrate +frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.37" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sc-network-common = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +sp-serializer = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +try-runtime-cli = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.37" } +sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } +substrate-state-trie-migration-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } + +# Polkadot +polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } +polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } +polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } +xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } + +# Cumulus +cumulus-client-cli ={ git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } +cumulus-client-consensus-aura = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } +cumulus-client-consensus-relay-chain = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } +cumulus-client-consensus-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } +cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } +cumulus-client-network = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } +cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } +cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } +cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } +parachains-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } + +[build-dependencies] +substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } [dev-dependencies] assert_cmd = "2.0" -nix = "0.23" -tempfile = "3.2.0" +nix = "0.25" +tempfile = "3.3.0" +tokio = { version = "1.24.1", features = ["macros", "time", "parking_lot"] } +wait-timeout = "0.2" +# purge_chain_works works with rococo-local and needs to allow this +polkadot-cli = { git = "https://github.com/paritytech/polkadot", features = ["rococo-native"] , branch = "release-v0.9.37" } [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" ] -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/src/chain_spec/mod.rs b/node/src/chain_spec/mod.rs new file mode 100644 index 00000000..48205702 --- /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_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_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_from_seed::(seed) +} diff --git a/node/src/chain_spec/stout.rs b/node/src/chain_spec/stout.rs new file mode 100644 index 00000000..dbc7e7e5 --- /dev/null +++ b/node/src/chain_spec/stout.rs @@ -0,0 +1,232 @@ +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 stout_runtime::{ + constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AssetsConfig, AuraId, BalancesConfig, + CouncilConfig, GenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, +}; + +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). +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(); + properties.insert("tokenSymbol".into(), "STOUT".into()); + properties.insert("tokenDecimals".into(), 12.into()); + properties.insert("ss58Format".into(), 42.into()); + + ChainSpec::from_genesis( + // Name + "Stout Local", + // ID + "stout_local", + ChainType::Local, + 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"), + get_account_id_from_seed::("Dave"), + get_account_id_from_seed::("Eve"), + get_account_id_from_seed::("Ferdie"), + ], + 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, + }, + ) +} + +/// Configure initial storage state for FRAME modules. +fn testnet_genesis( + invulnerables: Vec<(AccountId, AuraId)>, + root_key: AccountId, + endowed_accounts: Vec, + id: ParaId, +) -> GenesisConfig { + GenesisConfig { + system: SystemConfig { + code: stout_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + }, + balances: BalancesConfig { + // Configure endowed accounts with initial balance of 1 << 60. + balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(), + }, + parachain_info: stout_runtime::ParachainInfoConfig { parachain_id: id }, + collator_selection: stout_runtime::CollatorSelectionConfig { + invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), + candidacy_bond: EXISTENTIAL_DEPOSIT * 16, + ..Default::default() + }, + session: SessionConfig { + keys: invulnerables + .iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc.clone(), // validator id + session_keys(aura.clone()), // session keys + ) + }) + .collect(), + }, + // no need to pass anything to aura, in fact it will panic if we do. Session will take care + // of this. + aura: Default::default(), + aura_ext: Default::default(), + parachain_system: Default::default(), + polkadot_xcm: stout_runtime::PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION) }, + sudo: SudoConfig { + // Assign network admin rights. + key: Some(root_key), + }, + assets: AssetsConfig { assets: vec![], accounts: vec![], metadata: vec![] }, + council: CouncilConfig { + members: invulnerables.iter().map(|x| x.0.clone()).collect::>(), + phantom: Default::default(), + }, + } +} diff --git a/node/src/chain_spec/trappist.rs b/node/src/chain_spec/trappist.rs new file mode 100644 index 00000000..5d9fa82c --- /dev/null +++ b/node/src/chain_spec/trappist.rs @@ -0,0 +1,355 @@ +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 trappist_runtime::{ + constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AssetsConfig, AuraId, BalancesConfig, + CouncilConfig, GenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, +}; + +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). +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(), "HOP".into()); + properties.insert("tokenDecimals".into(), 12.into()); + properties.insert("ss58Format".into(), 42.into()); + + ChainSpec::from_genesis( + // Name + "Trappist Development", + // ID + "trappist_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"), + ], + 2000.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: TRAPPIST_PARA_ID, + }, + ) +} + +pub fn trappist_local_testnet_config() -> ChainSpec { + // Give your stout currency a unit name and decimal places + let mut properties = sc_chain_spec::Properties::new(); + properties.insert("tokenSymbol".into(), "HOP".into()); + properties.insert("tokenDecimals".into(), 12.into()); + properties.insert("ss58Format".into(), 42.into()); + + ChainSpec::from_genesis( + // Name + "Trappist Local", + // ID + "trappist_local", + ChainType::Local, + 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"), + get_account_id_from_seed::("Dave"), + get_account_id_from_seed::("Eve"), + get_account_id_from_seed::("Ferdie"), + ], + TRAPPIST_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: TRAPPIST_PARA_ID, + }, + ) +} + +/// Configure initial storage state for FRAME modules. +fn testnet_genesis( + invulnerables: Vec<(AccountId, AuraId)>, + root_key: AccountId, + endowed_accounts: Vec, + id: ParaId, +) -> GenesisConfig { + GenesisConfig { + system: SystemConfig { + code: trappist_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + }, + balances: BalancesConfig { + // Configure endowed accounts with initial balance of 1 << 60. + balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(), + }, + parachain_info: trappist_runtime::ParachainInfoConfig { parachain_id: id }, + collator_selection: trappist_runtime::CollatorSelectionConfig { + invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), + candidacy_bond: EXISTENTIAL_DEPOSIT * 16, + ..Default::default() + }, + democracy: Default::default(), + session: SessionConfig { + keys: invulnerables + .iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc.clone(), // validator id + session_keys(aura.clone()), // session keys + ) + }) + .collect(), + }, + // no need to pass anything to aura, in fact it will panic if we do. Session will take care + // of this. + aura: Default::default(), + aura_ext: Default::default(), + parachain_system: Default::default(), + polkadot_xcm: trappist_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + sudo: SudoConfig { + // Assign network admin rights. + key: Some(root_key), + }, + assets: AssetsConfig { assets: vec![], accounts: vec![], metadata: vec![] }, + council: CouncilConfig { + members: invulnerables.iter().map(|x| x.0.clone()).collect::>(), + phantom: Default::default(), + }, + treasury: Default::default(), + lockdown_mode: Default::default(), + } +} + +pub fn trappist_live_config() -> ChainSpec { + let mut properties = sc_chain_spec::Properties::new(); + properties.insert("tokenSymbol".into(), "HOP".into()); + properties.insert("tokenDecimals".into(), 12.into()); + properties.insert("ss58Format".into(), 42.into()); + + ChainSpec::from_genesis( + // Name + "Trappist", + // ID + "trappist", + ChainType::Live, + move || { + trappist_live_genesis( + // initial collators. + vec![ + ( + hex!("56266f110802ee790b5c40f63a0f9cba54d2889b014ea52661745557d09dbc1c") + .into(), + hex!("56266f110802ee790b5c40f63a0f9cba54d2889b014ea52661745557d09dbc1c") + .unchecked_into(), + ), + ( + hex!("64c2a2b803bdd4dcb88920ff4d56b618b2e5fbede48c4dc7cd78e562ebc06238") + .into(), + hex!("64c2a2b803bdd4dcb88920ff4d56b618b2e5fbede48c4dc7cd78e562ebc06238") + .unchecked_into(), + ), + ], + hex!("e40839fde680c01344c20d47b7f08d2926b8a7537697356d416987a04a4453d0").into(), + vec![ + // This account will have root origin + hex!("6a3db76f636ce43faaf58dde5a71a8e03b9d4ae3b331cff85c092f5bf98d971b").into(), + hex!("3e79b5cb39533bd4a20f1a4b8ca5e62d264164cdf1389d568f73bc3932b5144a").into(), + hex!("d00c901e43ab81cd9f26dc1b0c109a243134c47fee89d897f3fbf03e860c6d45").into(), + hex!("30a12eef517fb62d993a605bc98183fa9b2336197da9f34414bcbf67839d0b14").into(), + hex!("c0612ba544f0c34b5b0e102bfa7139e14cc7dc106ba7d34f317adca7fa30bb27").into(), + hex!("1a2477ef6ea36d70bc6058a97d9bbbdfea103710cf2fbb9586269db72ab98f1a").into(), + ], + TRAPPIST_PARA_ID.into(), + ) + }, + vec![], + None, + None, + None, + Some(properties), + Extensions { relay_chain: "rococo".into(), para_id: TRAPPIST_PARA_ID }, + ) +} + +fn trappist_live_genesis( + invulnerables: Vec<(AccountId, AuraId)>, + root_key: AccountId, + endowed_accounts: Vec, + id: ParaId, +) -> GenesisConfig { + GenesisConfig { + system: SystemConfig { + code: trappist_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + }, + balances: BalancesConfig { + balances: endowed_accounts + .iter() + .cloned() + .chain(std::iter::once(root_key.clone())) + .map(|k| { + if k == root_key { + (k, 1_000_000_000_000_000_000) + } else { + (k, 1_500_000_000_000_000_000) + } + }) + .collect(), + }, + parachain_info: trappist_runtime::ParachainInfoConfig { parachain_id: id }, + collator_selection: trappist_runtime::CollatorSelectionConfig { + invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), + candidacy_bond: EXISTENTIAL_DEPOSIT * 16, + ..Default::default() + }, + democracy: Default::default(), + session: SessionConfig { + keys: invulnerables + .iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc.clone(), // validator id + session_keys(aura.clone()), // session keys + ) + }) + .collect(), + }, + aura: Default::default(), + aura_ext: Default::default(), + parachain_system: Default::default(), + polkadot_xcm: trappist_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + sudo: SudoConfig { + // Assign network admin rights. + key: Some(root_key), + }, + assets: AssetsConfig { assets: vec![], accounts: vec![], metadata: vec![] }, + council: CouncilConfig { + // We set the endowed accounts with balance as members of the council. + members: endowed_accounts.iter().map(|x| x.clone()).collect::>(), + phantom: Default::default(), + }, + treasury: Default::default(), + lockdown_mode: Default::default(), + } +} diff --git a/node/src/cli.rs b/node/src/cli.rs new file mode 100644 index 00000000..90460095 --- /dev/null +++ b/node/src/cli.rs @@ -0,0 +1,118 @@ +// 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 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), + + /// Validate blocks. + CheckBlock(sc_cli::CheckBlockCmd), + + /// Export blocks. + ExportBlocks(sc_cli::ExportBlocksCmd), + + /// Export the state of a given block into a chain spec. + ExportState(sc_cli::ExportStateCmd), + + /// Import blocks. + ImportBlocks(sc_cli::ImportBlocksCmd), + + /// Revert the chain to a previous state. + Revert(sc_cli::RevertCmd), + + /// Remove the whole chain. + PurgeChain(cumulus_client_cli::PurgeChainCmd), + + /// Export the genesis state of the parachain. + ExportGenesisState(cumulus_client_cli::ExportGenesisStateCommand), + + /// Export the genesis wasm of the parachain. + ExportGenesisWasm(cumulus_client_cli::ExportGenesisWasmCommand), + + /// Sub-commands concerned with benchmarking. + /// The pallet benchmarking moved to the `pallet` sub-command. + #[command(subcommand)] + Benchmark(frame_benchmarking_cli::BenchmarkCmd), + + /// Try some testing command against a specified runtime state. + #[cfg(feature = "try-runtime")] + TryRuntime(try_runtime_cli::TryRuntimeCmd), + + /// Errors since the binary was not build with `--features try-runtime`. + #[cfg(not(feature = "try-runtime"))] + TryRuntime, +} + +#[derive(Debug, clap::Parser)] +#[command( + propagate_version = true, + args_conflicts_with_subcommands = true, + subcommand_negates_reqs = true +)] +pub struct Cli { + #[command(subcommand)] + pub subcommand: Option, + + #[command(flatten)] + pub run: cumulus_client_cli::RunCmd, + + /// Disable automatic hardware benchmarks. + /// + /// By default these benchmarks are automatically ran at startup and measure + /// the CPU speed, the memory bandwidth and the disk speed. + /// + /// The results are then printed out in the logs, and also sent as part of + /// telemetry, if telemetry is enabled. + #[arg(long)] + pub no_hardware_benchmarks: bool, + + /// Relay chain arguments + #[arg(raw = true)] + pub relaychain_args: Vec, +} + +#[derive(Debug)] +pub struct RelayChainCli { + /// The actual relay chain cli object. + pub base: polkadot_cli::RunCmd, + + /// Optional chain id that should be passed to the relay chain. + pub chain_id: Option, + + /// The base path that should be used by the relay chain. + pub base_path: Option, +} + +impl RelayChainCli { + /// Parse the relay chain CLI parameters using the para chain `Configuration`. + pub fn new<'a>( + para_config: &sc_service::Configuration, + relay_chain_args: impl Iterator, + ) -> Self { + 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/src/command.rs b/node/src/command.rs new file mode 100644 index 00000000..03d5b14b --- /dev/null +++ b/node/src/command.rs @@ -0,0 +1,709 @@ +// 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 codec::Encode; +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 sc_cli::{ + ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, + NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli, +}; +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, +} + +trait RuntimeResolver { + fn runtime(&self) -> Runtime; +} + +impl RuntimeResolver for dyn ChainSpec { + fn runtime(&self) -> Runtime { + runtime(self.id()) + } +} + +/// 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 { + "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)?), + } + }, + // -- Fallback (generic chainspec) + "" => { + log::warn!( + "No ChainSpec.id specified, so using default one, based on trappist-local runtime" + ); + Box::new(chain_spec::trappist::trappist_local_testnet_config()) + }, + }) +} + +impl SubstrateCli for Cli { + fn impl_name() -> String { + "Trappist Node".into() + } + + fn impl_version() -> String { + env!("SUBSTRATE_CLI_IMPL_VERSION").into() + } + + fn description() -> String { + format!( + "Trappist collator\n\nThe command-line arguments provided first will be \ + passed to the parachain node, while the arguments provided after -- will be passed \ + to the relay chain node.\n\n\ + {} -- ", + Self::executable_name() + ) + } + + fn author() -> String { + env!("CARGO_PKG_AUTHORS").into() + } + + fn support_url() -> String { + "https://github.com/TrappistNetwork/trappist/issues/new".into() + } + + fn copyright_start_year() -> i32 { + 2021 + } + + fn load_spec(&self, id: &str) -> std::result::Result, String> { + load_spec(id) + } + + 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 node".into() + } + + fn impl_version() -> String { + env!("SUBSTRATE_CLI_IMPL_VERSION").into() + } + + fn description() -> String { + format!( + "Trappist collator\n\nThe command-line arguments provided first will be \ + passed to the parachain node, while the arguments provided after -- will be passed \ + to the relay chain node.\n\n\ + {} -- ", + Self::executable_name() + ) + } + + fn author() -> String { + env!("CARGO_PKG_AUTHORS").into() + } + + fn support_url() -> String { + "https://github.com/TrappistNetwork/trappist/issues/new".into() + } + + fn copyright_start_year() -> i32 { + 2021 + } + + fn load_spec(&self, id: &str) -> std::result::Result, String> { + polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id) + } + + fn native_runtime_version(chain_spec: &Box) -> &'static RuntimeVersion { + polkadot_cli::Cli::native_runtime_version(chain_spec) + } +} + +/// 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)?; + match runner.config().chain_spec.runtime() { + 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)) + }) + } + } + }} +} + +/// Parse command line arguments into service configuration. +pub fn run() -> Result<()> { + let cli = Cli::from_args(); + + match &cli.subcommand { + Some(Subcommand::BuildSpec(cmd)) => { + let runner = cli.create_runner(cmd)?; + runner.sync_run(|config| cmd.run(config.chain_spec, config.network)) + }, + Some(Subcommand::CheckBlock(cmd)) => { + construct_async_run!(|components, cli, cmd, config| { + Ok(cmd.run(components.client, components.import_queue)) + }) + }, + Some(Subcommand::ExportBlocks(cmd)) => { + construct_async_run!(|components, cli, cmd, config| { + Ok(cmd.run(components.client, config.database)) + }) + }, + Some(Subcommand::ExportState(cmd)) => { + construct_async_run!(|components, cli, cmd, config| { + Ok(cmd.run(components.client, config.chain_spec)) + }) + }, + Some(Subcommand::ImportBlocks(cmd)) => { + construct_async_run!(|components, cli, cmd, config| { + 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::PurgeChain(cmd)) => { + let runner = cli.create_runner(cmd)?; + + runner.sync_run(|config| { + let polkadot_cli = RelayChainCli::new( + &config, + [RelayChainCli::executable_name()].iter().chain(cli.relaychain_args.iter()), + ); + + let polkadot_config = SubstrateCli::create_configuration( + &polkadot_cli, + &polkadot_cli, + config.tokio_handle.clone(), + ) + .map_err(|err| format!("Relay chain argument error: {}", err))?; + + cmd.run(config, polkadot_config) + }) + }, + Some(Subcommand::ExportGenesisState(cmd)) => { + let runner = cli.create_runner(cmd)?; + 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) + }) + }, + Some(Subcommand::ExportGenesisWasm(cmd)) => { + let runner = cli.create_runner(cmd)?; + runner.sync_run(|_config| { + let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?; + cmd.run(&*spec) + }) + }, + 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| 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`." + .into()) + }, + BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { + construct_benchmark_partials!(config, |partials| cmd.run(partials.client)) + }), + #[cfg(not(feature = "runtime-benchmarks"))] + BenchmarkCmd::Storage(_) => + return Err(sc_cli::Error::Input( + "Compile with --features=runtime-benchmarks \ + to enable storage benchmarks." + .into(), + ) + .into()), + #[cfg(feature = "runtime-benchmarks")] + BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| { + 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())), + // NOTE: this allows the Client to leniently implement + // new benchmark commands without requiring a companion MR. + #[allow(unreachable_patterns)] + _ => Err("Benchmarking sub-command unsupported".into()), + } + }, + #[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, + >; + + 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(); + + runner.run_node_until_exit(|config| async move { + let hwbench = if !cli.no_hardware_benchmarks { + config.database.path().map(|database_path| { + let _ = std::fs::create_dir_all(&database_path); + sc_sysinfo::gather_hwbench(Some(database_path)) + }) + } else { + None + }; + + let para_id = chain_spec::Extensions::try_get(&*config.chain_spec) + .map(|e| e.para_id) + .ok_or_else(|| "Could not find parachain extension in chain-spec.")?; + + let polkadot_cli = RelayChainCli::new( + &config, + [RelayChainCli::executable_name()].iter().chain(cli.relaychain_args.iter()), + ); + + let id = ParaId::from(para_id); + + let parachain_account = + AccountIdConversion::::into_account_truncating(&id); + + let state_version = Cli::native_runtime_version(&config.chain_spec).state_version(); + + 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(); + let polkadot_config = + SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, tokio_handle) + .map_err(|err| format!("Relay chain argument error: {}", err))?; + + info!("Parachain id: {:?}", id); + info!("Parachain Account: {}", parachain_account); + 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.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."); + } + + match config.chain_spec.runtime() { + Runtime::Trappist => crate::service::start_generic_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_generic_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()), + } + }) + }, + } +} + +impl DefaultConfigurationValues for RelayChainCli { + fn p2p_listen_port() -> u16 { + 30334 + } + + fn rpc_ws_listen_port() -> u16 { + 9945 + } + + fn rpc_http_listen_port() -> u16 { + 9934 + } + + fn prometheus_listen_port() -> u16 { + 9616 + } +} + +impl CliConfiguration for RelayChainCli { + fn shared_params(&self) -> &SharedParams { + self.base.base.shared_params() + } + + fn import_params(&self) -> Option<&ImportParams> { + self.base.base.import_params() + } + + fn network_params(&self) -> Option<&NetworkParams> { + self.base.base.network_params() + } + + fn keystore_params(&self) -> Option<&KeystoreParams> { + self.base.base.keystore_params() + } + + fn base_path(&self) -> Result> { + Ok(self + .shared_params() + .base_path()? + .or_else(|| self.base_path.clone().map(Into::into))) + } + + fn rpc_http(&self, default_listen_port: u16) -> Result> { + self.base.base.rpc_http(default_listen_port) + } + + fn rpc_ipc(&self) -> Result> { + self.base.base.rpc_ipc() + } + + fn rpc_ws(&self, default_listen_port: u16) -> Result> { + self.base.base.rpc_ws(default_listen_port) + } + + fn prometheus_config( + &self, + default_listen_port: u16, + chain_spec: &Box, + ) -> Result> { + self.base.base.prometheus_config(default_listen_port, chain_spec) + } + + fn init( + &self, + _support_url: &String, + _impl_version: &String, + _logger_hook: F, + _config: &sc_service::Configuration, + ) -> Result<()> + where + F: FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Configuration), + { + unreachable!("PolkadotCli is never initialized; qed"); + } + + fn chain_id(&self, is_dev: bool) -> Result { + let chain_id = self.base.base.chain_id(is_dev)?; + + Ok(if chain_id.is_empty() { self.chain_id.clone().unwrap_or_default() } else { chain_id }) + } + + fn role(&self, is_dev: bool) -> Result { + self.base.base.role(is_dev) + } + + fn transaction_pool(&self, is_dev: bool) -> Result { + 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() + } + + fn rpc_ws_max_connections(&self) -> Result> { + self.base.base.rpc_ws_max_connections() + } + + fn rpc_cors(&self, is_dev: bool) -> Result>> { + self.base.base.rpc_cors(is_dev) + } + + fn default_heap_pages(&self) -> Result> { + self.base.base.default_heap_pages() + } + + fn force_authoring(&self) -> Result { + self.base.base.force_authoring() + } + + fn disable_grandpa(&self) -> Result { + self.base.base.disable_grandpa() + } + + fn max_runtime_instances(&self) -> Result> { + self.base.base.max_runtime_instances() + } + + fn announce_block(&self) -> Result { + self.base.base.announce_block() + } + + fn telemetry_endpoints( + &self, + chain_spec: &Box, + ) -> Result> { + self.base.base.telemetry_endpoints(chain_spec) + } + + fn node_name(&self) -> Result { + self.base.base.node_name() + } +} + +#[cfg(test)] +mod tests { + use crate::{ + chain_spec::{get_account_id_from_seed, get_from_seed}, + command::{Runtime, RuntimeResolver}, + }; + 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::rococo_parachain::testnet_genesis( + get_account_id_from_seed::("Alice"), + vec![ + get_from_seed::("Alice"), + get_from_seed::("Bob"), + ], + 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(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/node/src/rpc.rs b/node/src/rpc.rs new file mode 100644 index 00000000..616c91a5 --- /dev/null +++ b/node/src/rpc.rs @@ -0,0 +1,86 @@ +// Copyright 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 . + +//! Parachain-specific RPCs implementation. + +#![warn(missing_docs)] + +use std::sync::Arc; + +use parachains_common::{AccountId, Balance, Block, Index as Nonce}; +use sc_client_api::AuxStore; +pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor}; +use sc_transaction_pool_api::TransactionPool; +use sp_api::ProvideRuntimeApi; +use sp_block_builder::BlockBuilder; +use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; + +/// A type representing all RPC extensions. +pub type RpcExtension = jsonrpsee::RpcModule<()>; + +/// Full client dependencies +pub struct FullDeps { + /// The client instance to use. + pub client: Arc, + /// Transaction pool instance. + pub pool: Arc

, + /// Whether to deny unsafe calls + pub deny_unsafe: DenyUnsafe, +} + +/// Instantiate all RPC extensions. +pub fn create_full( + deps: FullDeps, + backend: Arc, +) -> Result> +where + C: ProvideRuntimeApi + + HeaderBackend + + AuxStore + + HeaderMetadata + + Send + + Sync + + 'static, + 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::AssetId, + trappist_runtime::Balance, + trappist_runtime::AssetBalance, + >, + 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_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, deny_unsafe).into_rpc())?; + module.merge(TransactionPayment::new(client.clone()).into_rpc())?; + module.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?; + module.merge(Dev::new(client.clone(), deny_unsafe).into_rpc())?; + module.merge(Dex::new(client).into_rpc())?; + + Ok(module) +} diff --git a/node/src/service.rs b/node/src/service.rs new file mode 100644 index 00000000..8c55b065 --- /dev/null +++ b/node/src/service.rs @@ -0,0 +1,583 @@ +// 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 codec::Codec; +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_network::BlockAnnounceValidator; +use cumulus_client_service::{ + build_relay_chain_interface, prepare_node_config, start_collator, start_full_node, + StartCollatorParams, StartFullNodeParams, +}; +use cumulus_primitives_core::{ + relay_chain::v2::{Hash as PHash, PersistedValidationData}, + ParaId, +}; +use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface}; +use sp_core::Pair; + +use jsonrpsee::RpcModule; + +use crate::rpc; +pub use parachains_common::{ + AccountId, AssetId, 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::NetworkService; +use sc_network_common::service::NetworkBlock; +use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager}; +use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; +use sp_api::{ApiExt, ConstructRuntimeApi}; +use sp_consensus::CacheKeyId; +use sp_consensus_aura::AuraApi; +use sp_keystore::SyncCryptoStorePtr; +use sp_runtime::{ + app_crypto::AppKey, + generic::BlockId, + 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 + + sp_block_builder::BlockBuilder + + pallet_dex_rpc::DexRuntimeApi, + 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 + + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + + pallet_dex_rpc::DexRuntimeApi, + 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>, +{ + 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| match e { + RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, + s => s.to_string().into(), + })?; + + let block_announce_validator = + BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id); + + 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) = + sc_service::build_network(sc_service::BuildNetworkParams { + config: ¶chain_config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + spawn_handle: task_manager.spawn_handle(), + import_queue: params.import_queue, + block_announce_validator_builder: Some(Box::new(|_| { + Box::new(block_announce_validator) + })), + warp_sync: None, + })?; + + 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(), + })?; + + if let Some(hwbench) = hwbench { + sc_sysinfo::print_hwbench(&hwbench); + + 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 network = network.clone(); + Arc::new(move |hash, data| network.announce_block(hash, data)) + }; + + 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, + network, + 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, + }; + + 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, + }; + + 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> { + let block_id = BlockId::hash(parent.hash()); + if self + .client + .runtime_api() + .has_api::>(&block_id) + .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<(BlockImportParams, Option)>>), String> { + let block_id = BlockId::hash(*block_import.header.parent_hash()); + + if self + .client + .runtime_api() + .has_api::>(&block_id) + .unwrap_or(false) + { + self.aura_verifier.get_mut().verify(block_import).await + } else { + self.relay_chain_verifier.verify(block_import).await + } + } +} + +/// Build the import queue for Statemint and other Aura-based runtimes. +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 + + 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; +} From 39a0966dae2ed249492433a6fb5fef2dd1c4af8d Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Thu, 25 May 2023 11:00:10 +0200 Subject: [PATCH 02/15] WIP --- node/src/command.rs | 8 +- node/src/rpc.rs | 36 +++- node/src/service.rs | 470 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 508 insertions(+), 6 deletions(-) diff --git a/node/src/command.rs b/node/src/command.rs index 03d5b14b..7320bb30 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -17,7 +17,9 @@ use crate::{ chain_spec, cli::{Cli, RelayChainCli, Subcommand}, - service::{new_partial, Block, StoutRuntimeExecutor, TrappistRuntimeExecutor}, + service::{ + new_partial, new_stout_partial, Block, StoutRuntimeExecutor, TrappistRuntimeExecutor, + }, }; use codec::Encode; use cumulus_client_cli::generate_genesis_block; @@ -204,7 +206,7 @@ macro_rules! construct_benchmark_partials { $code }, Runtime::Stout => { - let $partials = new_partial::( + let $partials = new_stout_partial::( &$config, crate::service::aura_build_import_queue::<_, AuraId>, )?; @@ -231,7 +233,7 @@ macro_rules! construct_async_run { }, Runtime::Stout => { runner.async_run(|$config| { - let $components = new_partial::( + let $components = new_stout_partial::( &$config, crate::service::aura_build_import_queue::<_, AuraId>, )?; diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 616c91a5..674bf5b1 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -70,7 +70,6 @@ where 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_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer}; let mut module = RpcExtension::new(()); @@ -79,8 +78,41 @@ where module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; module.merge(TransactionPayment::new(client.clone()).into_rpc())?; module.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?; - module.merge(Dev::new(client.clone(), deny_unsafe).into_rpc())?; module.merge(Dex::new(client).into_rpc())?; Ok(module) } + +/// Instantiate all RPC extensions. +pub fn create_stout_full( + deps: FullDeps, + backend: Arc, +) -> Result> +where + C: ProvideRuntimeApi + + HeaderBackend + + AuxStore + + HeaderMetadata + + Send + + Sync + + 'static, + C::Api: frame_rpc_system::AccountNonceApi, + C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, + 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_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; + 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, deny_unsafe).into_rpc())?; + module.merge(TransactionPayment::new(client.clone()).into_rpc())?; + module.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?; + + Ok(module) +} diff --git a/node/src/service.rs b/node/src/service.rs index 8c55b065..debcc86f 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -410,6 +410,308 @@ where Ok((task_manager, client)) } +/// 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_stout_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 + + 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_stout_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 + + 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>, +{ + let parachain_config = prepare_node_config(parachain_config); + + let params = new_stout_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| match e { + RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, + s => s.to_string().into(), + })?; + + let block_announce_validator = + BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id); + + 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) = + sc_service::build_network(sc_service::BuildNetworkParams { + config: ¶chain_config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + spawn_handle: task_manager.spawn_handle(), + import_queue: params.import_queue, + block_announce_validator_builder: Some(Box::new(|_| { + Box::new(block_announce_validator) + })), + warp_sync: None, + })?; + + 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_stout_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(), + })?; + + if let Some(hwbench) = hwbench { + sc_sysinfo::print_hwbench(&hwbench); + + 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 network = network.clone(); + Arc::new(move |hash, data| network.announce_block(hash, data)) + }; + + 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, + network, + 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, + }; + + 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, + }; + + start_full_node(params)?; + } + + start_network.start_network(); + + Ok((task_manager, client)) +} + enum BuildOnAccess { Uninitialized(Option R + Send + Sync>>), Initialized(R), @@ -517,7 +819,173 @@ where } } -/// Build the import queue for Statemint and other Aura-based runtimes. +/// Start an aura powered parachain node. +/// (collective-polkadot and statemine/t use this) +pub async fn start_generic_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 + + 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, From 366fd4e45e7103131a4627b6c6d216dd881e0b4f Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Thu, 25 May 2023 12:50:41 +0200 Subject: [PATCH 03/15] adding service_stout with repeated code --- node/src/command.rs | 13 +- node/src/main.rs | 1 + node/src/service.rs | 311 +--------------- node/src/service_stout.rs | 733 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 745 insertions(+), 313 deletions(-) create mode 100644 node/src/service_stout.rs diff --git a/node/src/command.rs b/node/src/command.rs index 7320bb30..e566ce59 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -17,9 +17,8 @@ use crate::{ chain_spec, cli::{Cli, RelayChainCli, Subcommand}, - service::{ - new_partial, new_stout_partial, Block, StoutRuntimeExecutor, TrappistRuntimeExecutor, - }, + service::{new_partial, Block, TrappistRuntimeExecutor}, + service_stout::{new_stout_partial, StoutRuntimeExecutor}, }; use codec::Encode; use cumulus_client_cli::generate_genesis_block; @@ -208,7 +207,7 @@ macro_rules! construct_benchmark_partials { Runtime::Stout => { let $partials = new_stout_partial::( &$config, - crate::service::aura_build_import_queue::<_, AuraId>, + crate::service_stout::aura_stout_build_import_queue::<_, AuraId>, )?; $code }, @@ -221,7 +220,7 @@ macro_rules! construct_async_run { (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{ let runner = $cli.create_runner($cmd)?; match runner.config().chain_spec.runtime() { - Runtime::Trappist => { + Runtime::Default | Runtime::Trappist => { runner.async_run(|$config| { let $components = new_partial::( &$config, @@ -235,7 +234,7 @@ macro_rules! construct_async_run { runner.async_run(|$config| { let $components = new_stout_partial::( &$config, - crate::service::aura_build_import_queue::<_, AuraId>, + crate::service_stout::aura_stout_build_import_queue::<_, AuraId>, )?; let task_manager = $components.task_manager; { $( $code )* }.map(|v| (v, task_manager)) @@ -446,7 +445,7 @@ pub fn run() -> Result<()> { .await .map(|r| r.0) .map_err(Into::into), - Runtime::Stout => crate::service::start_generic_aura_node::< + Runtime::Stout => crate::service_stout::start_stout_aura_node::< stout_runtime::RuntimeApi, AuraId, >(config, polkadot_config, collator_options, id, hwbench) diff --git a/node/src/main.rs b/node/src/main.rs index d114d2f5..d53c3fe5 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -25,6 +25,7 @@ mod service; mod cli; mod command; mod rpc; +mod service_stout; fn main() -> sc_cli::Result<()> { command::run() diff --git a/node/src/service.rs b/node/src/service.rs index debcc86f..ea442eb2 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -133,8 +133,8 @@ where Block, StateBackend = sc_client_api::StateBackendFor, > + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder - + pallet_dex_rpc::DexRuntimeApi, + + pallet_dex_rpc::DexRuntimeApi + + sp_block_builder::BlockBuilder, sc_client_api::StateBackendFor: sp_api::StateBackend, BIQ: FnOnce( Arc>, @@ -239,7 +239,8 @@ where + sp_block_builder::BlockBuilder + cumulus_primitives_core::CollectCollationInfo + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + pallet_dex_rpc::DexRuntimeApi, + + pallet_dex_rpc::DexRuntimeApi + + frame_rpc_system::AccountNonceApi, sc_client_api::StateBackendFor: sp_api::StateBackend, RB: Fn(Arc>) -> Result, sc_service::Error>, BIQ: FnOnce( @@ -409,309 +410,6 @@ where Ok((task_manager, client)) } - -/// 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_stout_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 - + 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_stout_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 - + 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>, -{ - let parachain_config = prepare_node_config(parachain_config); - - let params = new_stout_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| match e { - RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, - s => s.to_string().into(), - })?; - - let block_announce_validator = - BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id); - - 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) = - sc_service::build_network(sc_service::BuildNetworkParams { - config: ¶chain_config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - spawn_handle: task_manager.spawn_handle(), - import_queue: params.import_queue, - block_announce_validator_builder: Some(Box::new(|_| { - Box::new(block_announce_validator) - })), - warp_sync: None, - })?; - - 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_stout_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(), - })?; - - if let Some(hwbench) = hwbench { - sc_sysinfo::print_hwbench(&hwbench); - - 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 network = network.clone(); - Arc::new(move |hash, data| network.announce_block(hash, data)) - }; - - 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, - network, - 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, - }; - - 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, - }; - - start_full_node(params)?; - } - - start_network.start_network(); - - Ok((task_manager, client)) -} - enum BuildOnAccess { Uninitialized(Option R + Send + Sync>>), Initialized(R), @@ -841,6 +539,7 @@ where + 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: diff --git a/node/src/service_stout.rs b/node/src/service_stout.rs new file mode 100644 index 00000000..3d221907 --- /dev/null +++ b/node/src/service_stout.rs @@ -0,0 +1,733 @@ +// 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 codec::Codec; +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_network::BlockAnnounceValidator; +use cumulus_client_service::{ + build_relay_chain_interface, prepare_node_config, start_collator, start_full_node, + StartCollatorParams, StartFullNodeParams, +}; +use cumulus_primitives_core::{ + relay_chain::v2::{Hash as PHash, PersistedValidationData}, + ParaId, +}; +use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface}; +use sp_core::Pair; + +use jsonrpsee::RpcModule; + +use crate::rpc; +pub use parachains_common::{ + AccountId, AssetId, 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::NetworkService; +use sc_network_common::service::NetworkBlock; +use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager}; +use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; +use sp_api::{ApiExt, ConstructRuntimeApi}; +use sp_consensus::CacheKeyId; +use sp_consensus_aura::AuraApi; +use sp_keystore::SyncCryptoStorePtr; +use sp_runtime::{ + app_crypto::AppKey, + generic::BlockId, + 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() + } +} + +/// 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_stout_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 + + 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_stout_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_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>, +{ + let parachain_config = prepare_node_config(parachain_config); + + let params = new_stout_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| match e { + RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, + s => s.to_string().into(), + })?; + + let block_announce_validator = + BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id); + + 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) = + sc_service::build_network(sc_service::BuildNetworkParams { + config: ¶chain_config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + spawn_handle: task_manager.spawn_handle(), + import_queue: params.import_queue, + block_announce_validator_builder: Some(Box::new(|_| { + Box::new(block_announce_validator) + })), + warp_sync: None, + })?; + + 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_stout_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(), + })?; + + if let Some(hwbench) = hwbench { + sc_sysinfo::print_hwbench(&hwbench); + + 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 network = network.clone(); + Arc::new(move |hash, data| network.announce_block(hash, data)) + }; + + 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, + network, + 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, + }; + + 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, + }; + + 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> { + let block_id = BlockId::hash(parent.hash()); + if self + .client + .runtime_api() + .has_api::>(&block_id) + .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<(BlockImportParams, Option)>>), String> { + let block_id = BlockId::hash(*block_import.header.parent_hash()); + + if self + .client + .runtime_api() + .has_api::>(&block_id) + .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_stout_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 + + 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_stout_node_impl::( + parachain_config, + polkadot_config, + collator_options, + para_id, + |_| Ok(RpcModule::new(())), + aura_stout_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_stout_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 + + 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)) +} From 6d385977787c26c56a0e7dd605fcb8e48ef717b7 Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Fri, 26 May 2023 11:56:07 +0200 Subject: [PATCH 04/15] Compiling: new_partial with generics --- node/src/service.rs | 136 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/node/src/service.rs b/node/src/service.rs index ea442eb2..5d4ba4b9 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -106,6 +106,142 @@ impl sc_executor::NativeExecutionDispatch for TrappistRuntimeExecutor { } } +pub trait RuntimeApiExt: + 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 + + Send + + Sync + + 'static +{ +} + +type ImportQueueBuilder = + dyn FnOnce( + Arc>, + ParachainBlockImport, + &Configuration, + Option, + &TaskManager, + ) -> Result< + sc_consensus::DefaultImportQueue>, + sc_service::Error, + >; + + +pub fn new_generic_partial( + config: &Configuration, + build_import_queue: Box>, +) -> 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: RuntimeApiExt, + sc_client_api::StateBackendFor: sp_api::StateBackend, +{ + 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) +} + +pub fn new_trappist_partial( + config: &Configuration, + build_import_queue: Box>, +) -> 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: RuntimeApiExt + pallet_dex_rpc::DexRuntimeApi , + sc_client_api::StateBackendFor: sp_api::StateBackend +{ + new_generic_partial::(config, build_import_queue) +} + + + /// 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 From 539fe6f48ad7f0f94350c8d10e66cd52a9399d15 Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Fri, 26 May 2023 14:35:43 +0200 Subject: [PATCH 05/15] start_generic_node_impl accepts a closure and RPC types are extracted@ --- node/src/rpc.rs | 63 ++++++++--- node/src/service.rs | 257 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 288 insertions(+), 32 deletions(-) diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 674bf5b1..e00244d0 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -83,25 +83,64 @@ where Ok(module) } -/// Instantiate all RPC extensions. -pub fn create_stout_full( - deps: FullDeps, - backend: Arc, -) -> Result> +pub trait RuntimeApiCollection: + frame_rpc_system::AccountNonceApi + + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + + BlockBuilder + + 'static +{ +} + +pub trait ClientRequiredTraits: + ProvideRuntimeApi + + HeaderBackend + + AuxStore + + HeaderMetadata + + Send + + Sync + + 'static where - C: ProvideRuntimeApi + >::Api: RuntimeApiCollection, +{ +} + +pub trait PoolRequiredTraits: TransactionPool + Sync + Send + 'static {} + +pub trait BackendRequiredTraits: sc_client_api::Backend + Send + Sync + 'static +where + >::State: + sc_client_api::backend::StateBackend>, +{ +} + +impl ClientRequiredTraits for T +where + T: ProvideRuntimeApi + HeaderBackend + AuxStore + HeaderMetadata + Send + Sync + 'static, - C::Api: frame_rpc_system::AccountNonceApi, - C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, - C::Api: BlockBuilder, - P: TransactionPool + Sync + Send + 'static, - B: sc_client_api::Backend + Send + Sync + 'static, - B::State: sc_client_api::backend::StateBackend>, + T::Api: RuntimeApiCollection, +{ +} + +impl PoolRequiredTraits for T where T: TransactionPool + Sync + Send + 'static {} + +impl BackendRequiredTraits for T +where + T: sc_client_api::Backend + Send + Sync + 'static, + T::State: sc_client_api::backend::StateBackend>, +{ +} + +pub fn create_stout_full( + deps: FullDeps, + backend: Arc, +) -> Result> +where + C::Api: RuntimeApiCollection, { use frame_rpc_system::{System, SystemApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; diff --git a/node/src/service.rs b/node/src/service.rs index 5d4ba4b9..de0b517a 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -120,22 +120,9 @@ pub trait RuntimeApiExt: { } -type ImportQueueBuilder = - dyn FnOnce( - Arc>, - ParachainBlockImport, - &Configuration, - Option, - &TaskManager, - ) -> Result< - sc_consensus::DefaultImportQueue>, - sc_service::Error, - >; - - -pub fn new_generic_partial( +pub fn new_generic_partial( config: &Configuration, - build_import_queue: Box>, + build_import_queue: BIQ, ) -> Result< PartialComponents< ParachainClient, @@ -151,6 +138,16 @@ where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, RuntimeApi::RuntimeApi: RuntimeApiExt, 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 @@ -218,9 +215,9 @@ where Ok(params) } -pub fn new_trappist_partial( +pub fn new_trappist_partial( config: &Configuration, - build_import_queue: Box>, + build_import_queue: BIQ, ) -> Result< PartialComponents< ParachainClient, @@ -235,9 +232,230 @@ pub fn new_trappist_partial( where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, RuntimeApi::RuntimeApi: RuntimeApiExt + pallet_dex_rpc::DexRuntimeApi , - sc_client_api::StateBackendFor: sp_api::StateBackend + sc_client_api::StateBackendFor: sp_api::StateBackend, + BIQ: FnOnce( + Arc>, + ParachainBlockImport, + &Configuration, + Option, + &TaskManager, + ) -> Result< + sc_consensus::DefaultImportQueue>, + sc_service::Error, + >, +{ + new_generic_partial::(config, build_import_queue) +} + + + +fn create_stout_full_rpc( + deps: rpc::FullDeps, + backend: Arc, +) -> Result, sc_service::Error> +where + C: rpc::ClientRequiredTraits, + P: rpc::PoolRequiredTraits, + B: rpc::BackendRequiredTraits, + C::Api: rpc::RuntimeApiCollection, +{ + rpc::create_stout_full(deps, backend.clone()).map_err(Into::into) +} + + /// 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_generic_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: RuntimeApiExt + + cumulus_primitives_core::CollectCollationInfo + + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + + frame_rpc_system::AccountNonceApi, + sc_client_api::StateBackendFor: sp_api::StateBackend, + RB: Fn( + rpc::FullDeps< + ParachainClient, + sc_transaction_pool::FullPool> + >, + Arc + ) -> Result, sc_service::Error> + 'static, + 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>, { - new_generic_partial::(config, build_import_queue) + let parachain_config = prepare_node_config(parachain_config); + + let params = new_generic_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| match e { + RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, + s => s.to_string().into(), + })?; + + let block_announce_validator = + BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id); + + 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) = + sc_service::build_network(sc_service::BuildNetworkParams { + config: ¶chain_config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + spawn_handle: task_manager.spawn_handle(), + import_queue: params.import_queue, + block_announce_validator_builder: Some(Box::new(|_| { + Box::new(block_announce_validator) + })), + warp_sync: None, + })?; + + 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_ext_builder(deps, backend_for_rpc.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: backend.clone(), + network: network.clone(), + system_rpc_tx, + tx_handler_controller, + telemetry: telemetry.as_mut(), + })?; + + if let Some(hwbench) = hwbench { + sc_sysinfo::print_hwbench(&hwbench); + + 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 network = network.clone(); + Arc::new(move |hash, data| network.announce_block(hash, data)) + }; + + 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, + network, + 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, + }; + + 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, + }; + + start_full_node(params)?; + } + + start_network.start_network(); + + Ok((task_manager, client)) } @@ -269,7 +487,6 @@ where 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( From 0b0b74652f12bdb1c32574bc316c171ad4f6940b Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Fri, 26 May 2023 15:34:07 +0200 Subject: [PATCH 06/15] start_generic_2_aura_node seems to be working --- node/src/service.rs | 239 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 235 insertions(+), 4 deletions(-) diff --git a/node/src/service.rs b/node/src/service.rs index de0b517a..1400ed48 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -120,6 +120,14 @@ pub trait RuntimeApiExt: { } +pub trait NodeRuntimeApiExt: RuntimeApiExt + + cumulus_primitives_core::CollectCollationInfo + + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + + frame_rpc_system::AccountNonceApi +{ +} + + pub fn new_generic_partial( config: &Configuration, build_import_queue: BIQ, @@ -278,10 +286,7 @@ async fn start_generic_node_impl( ) -> sc_service::error::Result<(TaskManager, Arc>)> where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: RuntimeApiExt - + cumulus_primitives_core::CollectCollationInfo - + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + frame_rpc_system::AccountNonceApi, + RuntimeApi::RuntimeApi: NodeRuntimeApiExt, sc_client_api::StateBackendFor: sp_api::StateBackend, RB: Fn( rpc::FullDeps< @@ -763,6 +768,7 @@ where Ok((task_manager, client)) } + enum BuildOnAccess { Uninitialized(Option R + Send + Sync>>), Initialized(R), @@ -870,6 +876,164 @@ where } } +/// Start an aura powered parachain node. +/// (collective-polkadot and statemine/t use this) +pub async fn start_generic_2_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: NodeRuntimeApiExt + + sp_consensus_aura::AuraApi::Pair as Pair>::Public> + + rpc::RuntimeApiCollection, + sc_client_api::StateBackendFor: sp_api::StateBackend, + <::Pair as Pair>::Signature: + TryFrom> + std::hash::Hash + sp_runtime::traits::Member + Codec, +{ + start_generic_node_impl::( + parachain_config, + polkadot_config, + collator_options, + para_id, + |deps, backend| create_stout_full_rpc::<_, _, _>(deps, backend), + aura_build_generic_import_queue::, + |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 +} + + /// Start an aura powered parachain node. /// (collective-polkadot and statemine/t use this) pub async fn start_generic_aura_node( @@ -1037,6 +1201,73 @@ where .await } + +pub fn aura_build_generic_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: NodeRuntimeApiExt, + 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 + + 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)) +} + + /// Build the import queue for Aura-based parachains. pub fn aura_build_import_queue( client: Arc>, From c199a57528445252083338adadb034fbb52b396d Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Fri, 26 May 2023 20:19:32 +0200 Subject: [PATCH 07/15] compiling :) --- node/src/command.rs | 13 +++--- node/src/main.rs | 1 - node/src/rpc.rs | 106 ++++++++++++++++++++++++++++++-------------- node/src/service.rs | 52 +++++++++++++++++----- 4 files changed, 120 insertions(+), 52 deletions(-) diff --git a/node/src/command.rs b/node/src/command.rs index e566ce59..cbcc860b 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -17,8 +17,7 @@ use crate::{ chain_spec, cli::{Cli, RelayChainCli, Subcommand}, - service::{new_partial, Block, TrappistRuntimeExecutor}, - service_stout::{new_stout_partial, StoutRuntimeExecutor}, + service::{new_partial, new_generic_partial, Block, TrappistRuntimeExecutor, StoutRuntimeExecutor}, }; use codec::Encode; use cumulus_client_cli::generate_genesis_block; @@ -205,9 +204,9 @@ macro_rules! construct_benchmark_partials { $code }, Runtime::Stout => { - let $partials = new_stout_partial::( + let $partials = new_generic_partial::( &$config, - crate::service_stout::aura_stout_build_import_queue::<_, AuraId>, + crate::service::aura_build_generic_import_queue::<_, AuraId>, )?; $code }, @@ -232,9 +231,9 @@ macro_rules! construct_async_run { }, Runtime::Stout => { runner.async_run(|$config| { - let $components = new_stout_partial::( + let $components = new_generic_partial::( &$config, - crate::service_stout::aura_stout_build_import_queue::<_, AuraId>, + crate::service::aura_build_generic_import_queue::<_, AuraId>, )?; let task_manager = $components.task_manager; { $( $code )* }.map(|v| (v, task_manager)) @@ -445,7 +444,7 @@ pub fn run() -> Result<()> { .await .map(|r| r.0) .map_err(Into::into), - Runtime::Stout => crate::service_stout::start_stout_aura_node::< + Runtime::Stout => crate::service::start_generic_2_aura_node::< stout_runtime::RuntimeApi, AuraId, >(config, polkadot_config, collator_options, id, hwbench) diff --git a/node/src/main.rs b/node/src/main.rs index d53c3fe5..d114d2f5 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -25,7 +25,6 @@ mod service; mod cli; mod command; mod rpc; -mod service_stout; fn main() -> sc_cli::Result<()> { command::run() diff --git a/node/src/rpc.rs b/node/src/rpc.rs index e00244d0..9caedd86 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -83,64 +83,102 @@ where Ok(module) } -pub trait RuntimeApiCollection: - frame_rpc_system::AccountNonceApi - + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + BlockBuilder - + 'static -{ -} - -pub trait ClientRequiredTraits: - ProvideRuntimeApi - + HeaderBackend - + AuxStore - + HeaderMetadata - + Send - + Sync - + 'static -where - >::Api: RuntimeApiCollection, -{ -} - -pub trait PoolRequiredTraits: TransactionPool + Sync + Send + 'static {} - -pub trait BackendRequiredTraits: sc_client_api::Backend + Send + Sync + 'static -where - >::State: - sc_client_api::backend::StateBackend>, -{ +/* pub trait ClientRequiredTraits { + type Client: ProvideRuntimeApi + + HeaderBackend + + AuxStore + + HeaderMetadata + + Send + + Sync + + 'static; + type Api: frame_rpc_system::AccountNonceApi + + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + + BlockBuilder; } -impl ClientRequiredTraits for T +impl ClientRequiredTraits for C where - T: ProvideRuntimeApi + C: ProvideRuntimeApi + HeaderBackend + AuxStore + HeaderMetadata + Send + Sync + 'static, - T::Api: RuntimeApiCollection, + C::Api: frame_rpc_system::AccountNonceApi + + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + + BlockBuilder, { + type Client = C; + type Api = C::Api; +} + +pub trait PoolRequiredTraits { + type Pool: TransactionPool + Sync + Send + 'static; } -impl PoolRequiredTraits for T where T: TransactionPool + Sync + Send + 'static {} +impl PoolRequiredTraits for T +where + T: TransactionPool + Sync + Send + 'static, +{ + type Pool = T; +} + +pub trait BackendRequiredTraits { + type Backend: sc_client_api::Backend + Send + Sync + 'static; + type State: sc_client_api::backend::StateBackend>; +} impl BackendRequiredTraits for T where T: sc_client_api::Backend + Send + Sync + 'static, T::State: sc_client_api::backend::StateBackend>, { + type Backend = T; + type State = T::State; } -pub fn create_stout_full( +pub fn create_stout_full_bck( + deps: FullDeps, + backend: Arc, +) -> Result> +where + C: ClientRequiredTraits, + P: PoolRequiredTraits, + B: BackendRequiredTraits, +{ + use frame_rpc_system::{System, SystemApiServer}; + use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; + 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, deny_unsafe).into_rpc())?; + module.merge(TransactionPayment::new(client.clone()).into_rpc())?; + module.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?; + + Ok(module) +} */ + +pub fn create_stout_full( deps: FullDeps, backend: Arc, ) -> Result> where - C::Api: RuntimeApiCollection, + C: ProvideRuntimeApi + + HeaderBackend + + AuxStore + + HeaderMetadata + + Send + + Sync + + 'static, + C::Api: frame_rpc_system::AccountNonceApi, + C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, + 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_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; diff --git a/node/src/service.rs b/node/src/service.rs index 1400ed48..2c145f4a 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -144,7 +144,14 @@ pub fn new_generic_partial( > where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: RuntimeApiExt, + 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, sc_client_api::StateBackendFor: sp_api::StateBackend, BIQ: FnOnce( Arc>, @@ -239,7 +246,15 @@ pub fn new_trappist_partial( > where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: RuntimeApiExt + pallet_dex_rpc::DexRuntimeApi , + 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 , sc_client_api::StateBackendFor: sp_api::StateBackend, BIQ: FnOnce( Arc>, @@ -257,7 +272,7 @@ where -fn create_stout_full_rpc( +/* fn create_stout_full_rpc( deps: rpc::FullDeps, backend: Arc, ) -> Result, sc_service::Error> @@ -265,10 +280,9 @@ where C: rpc::ClientRequiredTraits, P: rpc::PoolRequiredTraits, B: rpc::BackendRequiredTraits, - C::Api: rpc::RuntimeApiCollection, { rpc::create_stout_full(deps, backend.clone()).map_err(Into::into) -} +} */ /// Start a node with the given parachain `Configuration` and relay chain `Configuration`. /// @@ -286,7 +300,17 @@ async fn start_generic_node_impl( ) -> sc_service::error::Result<(TaskManager, Arc>)> where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: NodeRuntimeApiExt, + 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 + + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + + frame_rpc_system::AccountNonceApi, sc_client_api::StateBackendFor: sp_api::StateBackend, RB: Fn( rpc::FullDeps< @@ -887,9 +911,18 @@ pub async fn start_generic_2_aura_node( ) -> sc_service::error::Result<(TaskManager, Arc>)> where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: NodeRuntimeApiExt + 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> - + rpc::RuntimeApiCollection, + + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + + frame_rpc_system::AccountNonceApi, sc_client_api::StateBackendFor: sp_api::StateBackend, <::Pair as Pair>::Signature: TryFrom> + std::hash::Hash + sp_runtime::traits::Member + Codec, @@ -899,7 +932,7 @@ where polkadot_config, collator_options, para_id, - |deps, backend| create_stout_full_rpc::<_, _, _>(deps, backend), + |deps, backend| rpc::create_stout_full::<_, _, _>(deps, backend).map_err(Into::into), aura_build_generic_import_queue::, |client, block_import, @@ -1211,7 +1244,6 @@ pub fn aura_build_generic_import_queue( ) -> Result>, sc_service::Error> where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - //RuntimeApi::RuntimeApi: NodeRuntimeApiExt, RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue + sp_api::Metadata + sp_session::SessionKeys From ba3476253ca05090f713c20bf81fda085f633648 Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Wed, 31 May 2023 10:09:46 +0200 Subject: [PATCH 08/15] Adding dex pallet to stout --- node/service/src/chain_spec/stout.rs | 1 + rpc/src/lib.rs | 9 +++++ runtime/stout/src/lib.rs | 52 ++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/node/service/src/chain_spec/stout.rs b/node/service/src/chain_spec/stout.rs index dbc7e7e5..3155e7a8 100644 --- a/node/service/src/chain_spec/stout.rs +++ b/node/service/src/chain_spec/stout.rs @@ -228,5 +228,6 @@ fn testnet_genesis( members: invulnerables.iter().map(|x| x.0.clone()).collect::>(), phantom: Default::default(), }, + dex: Default::default(), } } diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 2b78319d..0e48877a 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -86,6 +86,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, @@ -101,9 +102,16 @@ where + 'static, C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, + C::Api: pallet_dex_rpc::DexRuntimeApi< + trappist_runtime::opaque::Block, + trappist_runtime::AssetId, + trappist_runtime::Balance, + trappist_runtime::AssetBalance, + >, C::Api: BlockBuilder, P: TransactionPool + Sync + Send + 'static, { + 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}; @@ -114,6 +122,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/runtime/stout/src/lib.rs b/runtime/stout/src/lib.rs index d16e2c78..3e225e5e 100644 --- a/runtime/stout/src/lib.rs +++ b/runtime/stout/src/lib.rs @@ -475,6 +475,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 = AssetId; + 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 @@ -520,6 +540,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, } @@ -543,6 +564,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] @@ -629,6 +651,36 @@ impl_runtime_apis! { } } + impl pallet_dex_rpc_runtime_api::DexApi for Runtime { + fn get_currency_to_asset_output_amount( + asset_id: AssetId, + 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: AssetId, + 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: AssetId, + 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: AssetId, + 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) From ef7abfa3b16c5e433223445bd067d8a90f46422c Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Wed, 31 May 2023 11:32:31 +0200 Subject: [PATCH 09/15] a simplified working version --- Cargo.lock | 18 + node/src/chain_spec/mod.rs | 6 +- node/src/chain_spec/stout.rs | 115 +---- node/src/chain_spec/trappist.rs | 64 +-- node/src/command.rs | 45 +- node/src/rpc.rs | 113 +---- node/src/service.rs | 624 +-------------------------- node/src/service_stout.rs | 733 -------------------------------- 8 files changed, 69 insertions(+), 1649 deletions(-) delete mode 100644 node/src/service_stout.rs diff --git a/Cargo.lock b/Cargo.lock index 438cafbb..2d91127c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6534,6 +6534,23 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "pallet-xcm-benchmarks" +version = "0.9.37" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", + "xcm", + "xcm-executor", +] + [[package]] name = "parachain-info" version = "0.1.0" @@ -13581,6 +13598,7 @@ name = "xcm-executor" version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ + "frame-benchmarking", "frame-support", "impl-trait-for-tuples", "log", diff --git a/node/src/chain_spec/mod.rs b/node/src/chain_spec/mod.rs index 48205702..36b1b67a 100644 --- a/node/src/chain_spec/mod.rs +++ b/node/src/chain_spec/mod.rs @@ -44,7 +44,7 @@ impl Extensions { } /// Helper function to generate a crypto pair from seed -pub fn get_from_seed(seed: &str) -> ::Public { +pub fn get_public_from_seed(seed: &str) -> ::Public { TPublic::Pair::from_string(&format!("//{}", seed), None) .expect("static values are valid; qed") .public() @@ -57,12 +57,12 @@ pub fn get_account_id_from_seed(seed: &str) -> AccountId where AccountPublic: From<::Public>, { - AccountPublic::from(get_from_seed::(seed)).into_account() + 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_from_seed::(seed) + get_public_from_seed::(seed) } diff --git a/node/src/chain_spec/stout.rs b/node/src/chain_spec/stout.rs index dbc7e7e5..e7cfda94 100644 --- a/node/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/src/chain_spec/trappist.rs b/node/src/chain_spec/trappist.rs index 5d9fa82c..81c1d6e2 100644 --- a/node/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/src/command.rs b/node/src/command.rs index cbcc860b..88a75176 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -17,7 +17,7 @@ use crate::{ chain_spec, cli::{Cli, RelayChainCli, Subcommand}, - service::{new_partial, new_generic_partial, Block, TrappistRuntimeExecutor, StoutRuntimeExecutor}, + service::{new_partial, Block, StoutRuntimeExecutor, TrappistRuntimeExecutor}, }; use codec::Encode; use cumulus_client_cli::generate_genesis_block; @@ -86,6 +86,7 @@ fn runtime(id: &str) -> Runtime { 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] @@ -99,13 +100,6 @@ fn load_spec(id: &str) -> std::result::Result, String> { Box::new(chain_spec::trappist::ChainSpec::from_json_file(path)?), } }, - // -- Fallback (generic chainspec) - "" => { - log::warn!( - "No ChainSpec.id specified, so using default one, based on trappist-local runtime" - ); - Box::new(chain_spec::trappist::trappist_local_testnet_config()) - }, }) } @@ -204,9 +198,9 @@ macro_rules! construct_benchmark_partials { $code }, Runtime::Stout => { - let $partials = new_generic_partial::( + let $partials = new_partial::( &$config, - crate::service::aura_build_generic_import_queue::<_, AuraId>, + crate::service::aura_build_import_queue::<_, AuraId>, )?; $code }, @@ -231,9 +225,9 @@ macro_rules! construct_async_run { }, Runtime::Stout => { runner.async_run(|$config| { - let $components = new_generic_partial::( + let $components = new_partial::( &$config, - crate::service::aura_build_generic_import_queue::<_, AuraId>, + crate::service::aura_build_import_queue::<_, AuraId>, )?; let task_manager = $components.task_manager; { $( $code )* }.map(|v| (v, task_manager)) @@ -437,14 +431,14 @@ pub fn run() -> Result<()> { } match config.chain_spec.runtime() { - Runtime::Trappist => crate::service::start_generic_aura_node::< + 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_generic_2_aura_node::< + Runtime::Stout => crate::service::start_aura_node::< stout_runtime::RuntimeApi, AuraId, >(config, polkadot_config, collator_options, id, hwbench) @@ -602,15 +596,15 @@ impl CliConfiguration for RelayChainCli { #[cfg(test)] mod tests { use crate::{ - chain_spec::{get_account_id_from_seed, get_from_seed}, + 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, )] @@ -641,8 +635,7 @@ mod tests { cfg_file_path } - pub type DummyChainSpec = - sc_service::GenericChainSpec; + pub type DummyChainSpec = sc_service::GenericChainSpec; pub fn create_default_with_extensions( id: &str, @@ -653,12 +646,18 @@ mod tests { id, ChainType::Local, move || { - crate::chain_spec::rococo_parachain::testnet_genesis( - get_account_id_from_seed::("Alice"), + crate::chain_spec::trappist::testnet_genesis( vec![ - get_from_seed::("Alice"), - get_from_seed::("Bob"), + ( + 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(), ) @@ -702,7 +701,7 @@ mod tests { let path = store_configuration( &temp_dir, - Box::new(chain_spec::trappist::trappist_local_testnet_config()), + Box::new(crate::chain_spec::trappist::trappist_local_testnet_config()), ); assert_eq!(Runtime::Trappist, path.runtime()); } diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 9caedd86..11801c55 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -81,115 +81,4 @@ where module.merge(Dex::new(client).into_rpc())?; Ok(module) -} - -/* pub trait ClientRequiredTraits { - type Client: ProvideRuntimeApi - + HeaderBackend - + AuxStore - + HeaderMetadata - + Send - + Sync - + 'static; - type Api: frame_rpc_system::AccountNonceApi - + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + BlockBuilder; -} - -impl ClientRequiredTraits for C -where - C: ProvideRuntimeApi - + HeaderBackend - + AuxStore - + HeaderMetadata - + Send - + Sync - + 'static, - C::Api: frame_rpc_system::AccountNonceApi - + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + BlockBuilder, -{ - type Client = C; - type Api = C::Api; -} - -pub trait PoolRequiredTraits { - type Pool: TransactionPool + Sync + Send + 'static; -} - -impl PoolRequiredTraits for T -where - T: TransactionPool + Sync + Send + 'static, -{ - type Pool = T; -} - -pub trait BackendRequiredTraits { - type Backend: sc_client_api::Backend + Send + Sync + 'static; - type State: sc_client_api::backend::StateBackend>; -} - -impl BackendRequiredTraits for T -where - T: sc_client_api::Backend + Send + Sync + 'static, - T::State: sc_client_api::backend::StateBackend>, -{ - type Backend = T; - type State = T::State; -} - -pub fn create_stout_full_bck( - deps: FullDeps, - backend: Arc, -) -> Result> -where - C: ClientRequiredTraits, - P: PoolRequiredTraits, - B: BackendRequiredTraits, -{ - use frame_rpc_system::{System, SystemApiServer}; - use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; - 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, deny_unsafe).into_rpc())?; - module.merge(TransactionPayment::new(client.clone()).into_rpc())?; - module.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?; - - Ok(module) -} */ - -pub fn create_stout_full( - deps: FullDeps, - backend: Arc, -) -> Result> -where - C: ProvideRuntimeApi - + HeaderBackend - + AuxStore - + HeaderMetadata - + Send - + Sync - + 'static, - C::Api: frame_rpc_system::AccountNonceApi, - C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, - 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_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; - 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, deny_unsafe).into_rpc())?; - module.merge(TransactionPayment::new(client.clone()).into_rpc())?; - module.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?; - - Ok(module) -} +} \ No newline at end of file diff --git a/node/src/service.rs b/node/src/service.rs index 2c145f4a..adf737c2 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -106,389 +106,6 @@ impl sc_executor::NativeExecutionDispatch for TrappistRuntimeExecutor { } } -pub trait RuntimeApiExt: - 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 - + Send - + Sync - + 'static -{ -} - -pub trait NodeRuntimeApiExt: RuntimeApiExt - + cumulus_primitives_core::CollectCollationInfo - + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + frame_rpc_system::AccountNonceApi -{ -} - - -pub fn new_generic_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 - + 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) -} - -pub fn new_trappist_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 - + sp_block_builder::BlockBuilder - + pallet_dex_rpc::DexRuntimeApi , - sc_client_api::StateBackendFor: sp_api::StateBackend, - BIQ: FnOnce( - Arc>, - ParachainBlockImport, - &Configuration, - Option, - &TaskManager, - ) -> Result< - sc_consensus::DefaultImportQueue>, - sc_service::Error, - >, -{ - new_generic_partial::(config, build_import_queue) -} - - - -/* fn create_stout_full_rpc( - deps: rpc::FullDeps, - backend: Arc, -) -> Result, sc_service::Error> -where - C: rpc::ClientRequiredTraits, - P: rpc::PoolRequiredTraits, - B: rpc::BackendRequiredTraits, -{ - rpc::create_stout_full(deps, backend.clone()).map_err(Into::into) -} */ - - /// 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_generic_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 - + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + frame_rpc_system::AccountNonceApi, - sc_client_api::StateBackendFor: sp_api::StateBackend, - RB: Fn( - rpc::FullDeps< - ParachainClient, - sc_transaction_pool::FullPool> - >, - Arc - ) -> Result, sc_service::Error> + 'static, - 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>, -{ - let parachain_config = prepare_node_config(parachain_config); - - let params = new_generic_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| match e { - RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, - s => s.to_string().into(), - })?; - - let block_announce_validator = - BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id); - - 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) = - sc_service::build_network(sc_service::BuildNetworkParams { - config: ¶chain_config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - spawn_handle: task_manager.spawn_handle(), - import_queue: params.import_queue, - block_announce_validator_builder: Some(Box::new(|_| { - Box::new(block_announce_validator) - })), - warp_sync: None, - })?; - - 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_ext_builder(deps, backend_for_rpc.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: backend.clone(), - network: network.clone(), - system_rpc_tx, - tx_handler_controller, - telemetry: telemetry.as_mut(), - })?; - - if let Some(hwbench) = hwbench { - sc_sysinfo::print_hwbench(&hwbench); - - 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 network = network.clone(); - Arc::new(move |hash, data| network.announce_block(hash, data)) - }; - - 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, - network, - 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, - }; - - 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, - }; - - start_full_node(params)?; - } - - start_network.start_network(); - - Ok((task_manager, client)) -} - - - /// 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 @@ -516,6 +133,7 @@ where 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( @@ -620,9 +238,9 @@ where > + sp_offchain::OffchainWorkerApi + sp_block_builder::BlockBuilder + cumulus_primitives_core::CollectCollationInfo - + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + + frame_rpc_system::AccountNonceApi + pallet_dex_rpc::DexRuntimeApi - + frame_rpc_system::AccountNonceApi, + + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, sc_client_api::StateBackendFor: sp_api::StateBackend, RB: Fn(Arc>) -> Result, sc_service::Error>, BIQ: FnOnce( @@ -902,174 +520,7 @@ where /// Start an aura powered parachain node. /// (collective-polkadot and statemine/t use this) -pub async fn start_generic_2_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 - + 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_generic_node_impl::( - parachain_config, - polkadot_config, - collator_options, - para_id, - |deps, backend| rpc::create_stout_full::<_, _, _>(deps, backend).map_err(Into::into), - aura_build_generic_import_queue::, - |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 -} - - -/// Start an aura powered parachain node. -/// (collective-polkadot and statemine/t use this) -pub async fn start_generic_aura_node( +pub async fn start_aura_node( parachain_config: Configuration, polkadot_config: Configuration, collator_options: CollatorOptions, @@ -1234,72 +685,6 @@ where .await } - -pub fn aura_build_generic_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 - + 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)) -} - - /// Build the import queue for Aura-based parachains. pub fn aura_build_import_queue( client: Arc>, @@ -1318,6 +703,7 @@ where 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: diff --git a/node/src/service_stout.rs b/node/src/service_stout.rs deleted file mode 100644 index 3d221907..00000000 --- a/node/src/service_stout.rs +++ /dev/null @@ -1,733 +0,0 @@ -// 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 codec::Codec; -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_network::BlockAnnounceValidator; -use cumulus_client_service::{ - build_relay_chain_interface, prepare_node_config, start_collator, start_full_node, - StartCollatorParams, StartFullNodeParams, -}; -use cumulus_primitives_core::{ - relay_chain::v2::{Hash as PHash, PersistedValidationData}, - ParaId, -}; -use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface}; -use sp_core::Pair; - -use jsonrpsee::RpcModule; - -use crate::rpc; -pub use parachains_common::{ - AccountId, AssetId, 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::NetworkService; -use sc_network_common::service::NetworkBlock; -use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager}; -use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; -use sp_api::{ApiExt, ConstructRuntimeApi}; -use sp_consensus::CacheKeyId; -use sp_consensus_aura::AuraApi; -use sp_keystore::SyncCryptoStorePtr; -use sp_runtime::{ - app_crypto::AppKey, - generic::BlockId, - 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() - } -} - -/// 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_stout_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 - + 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_stout_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_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>, -{ - let parachain_config = prepare_node_config(parachain_config); - - let params = new_stout_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| match e { - RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, - s => s.to_string().into(), - })?; - - let block_announce_validator = - BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id); - - 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) = - sc_service::build_network(sc_service::BuildNetworkParams { - config: ¶chain_config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - spawn_handle: task_manager.spawn_handle(), - import_queue: params.import_queue, - block_announce_validator_builder: Some(Box::new(|_| { - Box::new(block_announce_validator) - })), - warp_sync: None, - })?; - - 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_stout_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(), - })?; - - if let Some(hwbench) = hwbench { - sc_sysinfo::print_hwbench(&hwbench); - - 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 network = network.clone(); - Arc::new(move |hash, data| network.announce_block(hash, data)) - }; - - 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, - network, - 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, - }; - - 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, - }; - - 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> { - let block_id = BlockId::hash(parent.hash()); - if self - .client - .runtime_api() - .has_api::>(&block_id) - .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<(BlockImportParams, Option)>>), String> { - let block_id = BlockId::hash(*block_import.header.parent_hash()); - - if self - .client - .runtime_api() - .has_api::>(&block_id) - .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_stout_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 - + 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_stout_node_impl::( - parachain_config, - polkadot_config, - collator_options, - para_id, - |_| Ok(RpcModule::new(())), - aura_stout_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_stout_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 - + 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)) -} From c1ae42299ace13621072c3309d4cf53cb2466430 Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Wed, 31 May 2023 11:44:29 +0200 Subject: [PATCH 10/15] removing unwanted dir --- node copy/Cargo.toml | 54 -- node copy/cli/Cargo.toml | 97 --- node copy/cli/build.rs | 7 - node copy/cli/src/cli.rs | 118 ---- node copy/cli/src/command.rs | 461 -------------- node copy/cli/src/lib.rs | 17 - node copy/service/Cargo.toml | 121 ---- node copy/service/src/chain_spec/mod.rs | 5 - node copy/service/src/chain_spec/stout.rs | 233 ------- node copy/service/src/chain_spec/trappist.rs | 355 ----------- node copy/service/src/lib.rs | 634 ------------------- node copy/src/main.rs | 24 - 12 files changed, 2126 deletions(-) delete mode 100644 node copy/Cargo.toml delete mode 100644 node copy/cli/Cargo.toml delete mode 100644 node copy/cli/build.rs delete mode 100644 node copy/cli/src/cli.rs delete mode 100644 node copy/cli/src/command.rs delete mode 100644 node copy/cli/src/lib.rs delete mode 100644 node copy/service/Cargo.toml delete mode 100644 node copy/service/src/chain_spec/mod.rs delete mode 100644 node copy/service/src/chain_spec/stout.rs delete mode 100644 node copy/service/src/chain_spec/trappist.rs delete mode 100644 node copy/service/src/lib.rs delete mode 100644 node copy/src/main.rs diff --git a/node copy/Cargo.toml b/node copy/Cargo.toml deleted file mode 100644 index d8b8ba5f..00000000 --- a/node copy/Cargo.toml +++ /dev/null @@ -1,54 +0,0 @@ -[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" - -[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.37" } - -[[bin]] -required-features = ["with-trappist-runtime"] -name = "trappist-collator" -path = "src/main.rs" - - -[[bin]] -required-features = ["with-stout-runtime"] -name = "stout-collator" -path = "src/main.rs" - -[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" } - -[dev-dependencies] -assert_cmd = "2.0" -nix = "0.23" -tempfile = "3.2.0" - -[features] -default = ["with-trappist-runtime"] -runtime-benchmarks = [ - "trappist-cli/runtime-benchmarks" -] -with-trappist-runtime = [ - "trappist-service/with-trappist-runtime", - "trappist-cli/with-trappist-runtime", -] -with-stout-runtime = [ - "trappist-service/with-stout-runtime", - "trappist-cli/with-stout-runtime", -] diff --git a/node copy/cli/Cargo.toml b/node copy/cli/Cargo.toml deleted file mode 100644 index 5dbcfa53..00000000 --- a/node copy/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.37" } - -[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.37", optional = true } -try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", optional = true } - -## Substrate Client Dependencies -sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", optional = true} -sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", optional = true } -sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } - -## Substrate Primitive Dependencies -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" , optional = true} -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } - -# Cumulus dependencies -cumulus-client-cli = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-client-consensus-aura = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-client-consensus-relay-chain = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-client-consensus-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-client-network = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } - -parachains-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37", default-features = false } - -# Polkadot dependencies -polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37", features = [ "rococo-native" ] } -polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } -polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } -polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } - -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 copy/cli/build.rs b/node copy/cli/build.rs deleted file mode 100644 index e3bfe311..00000000 --- a/node copy/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 copy/cli/src/cli.rs b/node copy/cli/src/cli.rs deleted file mode 100644 index 2a7615e4..00000000 --- a/node copy/cli/src/cli.rs +++ /dev/null @@ -1,118 +0,0 @@ -// 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 . - -#[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 { - /// Build a chain specification. - BuildSpec(sc_cli::BuildSpecCmd), - - /// Validate blocks. - CheckBlock(sc_cli::CheckBlockCmd), - - /// Export blocks. - ExportBlocks(sc_cli::ExportBlocksCmd), - - /// Export the state of a given block into a chain spec. - ExportState(sc_cli::ExportStateCmd), - - /// Import blocks. - ImportBlocks(sc_cli::ImportBlocksCmd), - - /// Revert the chain to a previous state. - Revert(sc_cli::RevertCmd), - - /// Remove the whole chain. - PurgeChain(cumulus_client_cli::PurgeChainCmd), - - /// Export the genesis state of the parachain. - ExportGenesisState(cumulus_client_cli::ExportGenesisStateCommand), - - /// Export the genesis wasm of the parachain. - ExportGenesisWasm(cumulus_client_cli::ExportGenesisWasmCommand), - - /// Sub-commands concerned with benchmarking. - /// The pallet benchmarking moved to the `pallet` sub-command. - #[command(subcommand)] - Benchmark(frame_benchmarking_cli::BenchmarkCmd), - - /// Try some testing command against a specified runtime state. - #[cfg(feature = "try-runtime")] - TryRuntime(try_runtime_cli::TryRuntimeCmd), - - /// Errors since the binary was not build with `--features try-runtime`. - #[cfg(not(feature = "try-runtime"))] - TryRuntime, -} - -#[derive(Debug, clap::Parser)] -#[command( - propagate_version = true, - args_conflicts_with_subcommands = true, - subcommand_negates_reqs = true -)] -pub struct Cli { - #[command(subcommand)] - pub subcommand: Option, - - #[command(flatten)] - pub run: cumulus_client_cli::RunCmd, - - /// Disable automatic hardware benchmarks. - /// - /// By default these benchmarks are automatically ran at startup and measure - /// the CPU speed, the memory bandwidth and the disk speed. - /// - /// The results are then printed out in the logs, and also sent as part of - /// telemetry, if telemetry is enabled. - #[arg(long)] - pub no_hardware_benchmarks: bool, - - /// Relay chain arguments - #[arg(raw = true)] - pub relay_chain_args: Vec, -} - -#[derive(Debug)] -pub struct RelayChainCli { - /// The actual relay chain cli object. - pub base: polkadot_cli::RunCmd, - - /// Optional chain id that should be passed to the relay chain. - pub chain_id: Option, - - /// The base path that should be used by the relay chain. - pub base_path: Option, -} - -impl RelayChainCli { - /// Parse the relay chain CLI parameters using the para chain `Configuration`. - pub fn new<'a>( - para_config: &sc_service::Configuration, - relay_chain_args: impl Iterator, - ) -> Self { - let extension = 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 copy/cli/src/command.rs b/node copy/cli/src/command.rs deleted file mode 100644 index 6f50ea8a..00000000 --- a/node copy/cli/src/command.rs +++ /dev/null @@ -1,461 +0,0 @@ -use std::net::SocketAddr; - -use codec::Encode; -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 sc_cli::{ - ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, - NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli, -}; -use sc_service::config::{BasePath, PrometheusConfig}; -use sp_core::hexdisplay::HexDisplay; -use sp_runtime::traits::{AccountIdConversion, Block as BlockT}; - -#[cfg(feature = "with-stout-runtime")] -use stout_runtime::Block; -#[cfg(feature = "with-trappist-runtime")] -use trappist_runtime::Block; - -use crate::cli::{Cli, RelayChainCli, Subcommand}; -use service::{new_partial, NativeExecutor}; - -#[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, -}; - -impl SubstrateCli for Cli { - fn impl_name() -> String { - "Trappist Collator".into() - } - - fn impl_version() -> String { - env!("SUBSTRATE_CLI_IMPL_VERSION").into() - } - - fn description() -> String { - format!( - "Trappist collator\n\nThe command-line arguments provided first will be \ - passed to the parachain node, while the arguments provided after -- will be passed \ - to the relay chain node.\n\n\ - {} -- ", - Self::executable_name() - ) - } - - fn author() -> String { - env!("CARGO_PKG_AUTHORS").into() - } - - fn support_url() -> String { - "https://github.com/TrappistNetwork/trappist/issues/new".into() - } - - fn copyright_start_year() -> i32 { - 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 native_runtime_version(_: &Box) -> &'static RuntimeVersion { - &trappist_runtime::VERSION - } -} - -impl SubstrateCli for RelayChainCli { - fn impl_name() -> String { - "Trappist Collator".into() - } - - fn impl_version() -> String { - env!("SUBSTRATE_CLI_IMPL_VERSION").into() - } - - fn description() -> String { - format!( - "Trappist collator\n\nThe command-line arguments provided first will be \ - passed to the parachain node, while the arguments provided after -- will be passed \ - to the relay chain node.\n\n\ - {} -- ", - Self::executable_name() - ) - } - - fn author() -> String { - env!("CARGO_PKG_AUTHORS").into() - } - - fn support_url() -> String { - "https://github.com/TrappistNetwork/trappist/issues/new".into() - } - - fn copyright_start_year() -> i32 { - 2023 - } - - fn load_spec(&self, id: &str) -> std::result::Result, String> { - polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id) - } - - fn native_runtime_version(chain_spec: &Box) -> &'static RuntimeVersion { - polkadot_cli::Cli::native_runtime_version(chain_spec) - } -} - -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)) - }) - }} -} - -/// Parse command line arguments into service configuration. -pub fn run() -> Result<()> { - let cli = Cli::from_args(); - - match &cli.subcommand { - Some(Subcommand::BuildSpec(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run(config.chain_spec, config.network)) - }, - Some(Subcommand::CheckBlock(cmd)) => { - construct_async_run!(|components, cli, cmd, config| { - Ok(cmd.run(components.client, components.import_queue)) - }) - }, - Some(Subcommand::ExportBlocks(cmd)) => { - construct_async_run!(|components, cli, cmd, config| { - Ok(cmd.run(components.client, config.database)) - }) - }, - Some(Subcommand::ExportState(cmd)) => { - construct_async_run!(|components, cli, cmd, config| { - Ok(cmd.run(components.client, config.chain_spec)) - }) - }, - Some(Subcommand::ImportBlocks(cmd)) => { - construct_async_run!(|components, cli, cmd, config| { - 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::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()), - ); - - let polkadot_config = SubstrateCli::create_configuration( - &polkadot_cli, - &polkadot_cli, - config.tokio_handle.clone(), - ) - .map_err(|err| format!("Relay chain argument error: {}", err))?; - - cmd.run(config, polkadot_config) - }) - }, - Some(Subcommand::ExportGenesisState(cmd)) => { - let runner = cli.create_runner(cmd)?; - 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) - }) - }, - Some(Subcommand::ExportGenesisWasm(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.sync_run(|_config| { - let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?; - cmd.run(&*spec) - }) - }, - 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)) - } else { - Err("Benchmarking wasn't enabled when building the node. \ - 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) - }), - #[cfg(not(feature = "runtime-benchmarks"))] - BenchmarkCmd::Storage(_) => - return Err(sc_cli::Error::Input( - "Compile with --features=runtime-benchmarks \ - to enable storage benchmarks." - .into(), - ) - .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) - }), - BenchmarkCmd::Machine(cmd) => - runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())), - // NOTE: this allows the Client to leniently implement - // new benchmark commands without requiring a companion MR. - #[allow(unreachable_patterns)] - _ => Err("Benchmarking sub-command unsupported".into()), - } - }, - #[cfg(feature = "try-runtime")] - Some(Subcommand::TryRuntime(cmd)) => { - let runner = cli.create_runner(cmd)?; - - 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)) - }) - }, - #[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()), - None => { - let runner = cli.create_runner(&cli.run.normalize())?; - let collator_options = cli.run.collator_options(); - - runner.run_node_until_exit(|config| async move { - let hwbench = if !cli.no_hardware_benchmarks { - config.database.path().map(|database_path| { - let _ = std::fs::create_dir_all(&database_path); - sc_sysinfo::gather_hwbench(Some(database_path)) - }) - } else { - None - }; - - let para_id = Extensions::try_get(&*config.chain_spec) - .map(|e| e.para_id) - .ok_or_else(|| "Could not find parachain ID in chain-spec.")?; - - let polkadot_cli = RelayChainCli::new( - &config, - [RelayChainCli::executable_name()].iter().chain(cli.relay_chain_args.iter()), - ); - - let id = ParaId::from(para_id); - - let parachain_account = - 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 genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode())); - - let tokio_handle = config.tokio_handle.clone(); - let polkadot_config = - SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, tokio_handle) - .map_err(|err| format!("Relay chain argument error: {}", err))?; - - info!("Parachain id: {:?}", id); - info!("Parachain Account: {}", parachain_account); - 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 { - 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) - }) - }, - } -} - -impl DefaultConfigurationValues for RelayChainCli { - fn p2p_listen_port() -> u16 { - 30334 - } - - fn rpc_ws_listen_port() -> u16 { - 9945 - } - - fn rpc_http_listen_port() -> u16 { - 9934 - } - - fn prometheus_listen_port() -> u16 { - 9616 - } -} - -impl CliConfiguration for RelayChainCli { - fn shared_params(&self) -> &SharedParams { - self.base.base.shared_params() - } - - fn import_params(&self) -> Option<&ImportParams> { - self.base.base.import_params() - } - - fn network_params(&self) -> Option<&NetworkParams> { - self.base.base.network_params() - } - - fn keystore_params(&self) -> Option<&KeystoreParams> { - self.base.base.keystore_params() - } - - fn base_path(&self) -> Result> { - Ok(self - .shared_params() - .base_path()? - .or_else(|| self.base_path.clone().map(Into::into))) - } - - fn rpc_http(&self, default_listen_port: u16) -> Result> { - self.base.base.rpc_http(default_listen_port) - } - - fn rpc_ipc(&self) -> Result> { - self.base.base.rpc_ipc() - } - - fn rpc_ws(&self, default_listen_port: u16) -> Result> { - self.base.base.rpc_ws(default_listen_port) - } - - fn prometheus_config( - &self, - default_listen_port: u16, - chain_spec: &Box, - ) -> Result> { - self.base.base.prometheus_config(default_listen_port, chain_spec) - } - - fn init( - &self, - _support_url: &String, - _impl_version: &String, - _logger_hook: F, - _config: &sc_service::Configuration, - ) -> Result<()> - where - F: FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Configuration), - { - unreachable!("PolkadotCli is never initialized; qed"); - } - - fn chain_id(&self, is_dev: bool) -> Result { - let chain_id = self.base.base.chain_id(is_dev)?; - - Ok(if chain_id.is_empty() { self.chain_id.clone().unwrap_or_default() } else { chain_id }) - } - - fn role(&self, is_dev: bool) -> Result { - self.base.base.role(is_dev) - } - - fn transaction_pool(&self, is_dev: bool) -> Result { - self.base.base.transaction_pool(is_dev) - } - - fn rpc_methods(&self) -> Result { - self.base.base.rpc_methods() - } - - fn rpc_ws_max_connections(&self) -> Result> { - self.base.base.rpc_ws_max_connections() - } - - fn rpc_cors(&self, is_dev: bool) -> Result>> { - self.base.base.rpc_cors(is_dev) - } - - fn default_heap_pages(&self) -> Result> { - self.base.base.default_heap_pages() - } - - fn force_authoring(&self) -> Result { - self.base.base.force_authoring() - } - - fn disable_grandpa(&self) -> Result { - self.base.base.disable_grandpa() - } - - fn max_runtime_instances(&self) -> Result> { - self.base.base.max_runtime_instances() - } - - fn announce_block(&self) -> Result { - self.base.base.announce_block() - } - - fn telemetry_endpoints( - &self, - chain_spec: &Box, - ) -> Result> { - self.base.base.telemetry_endpoints(chain_spec) - } - - fn node_name(&self) -> Result { - self.base.base.node_name() - } -} diff --git a/node copy/cli/src/lib.rs b/node copy/cli/src/lib.rs deleted file mode 100644 index 89e28302..00000000 --- a/node copy/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 copy/service/Cargo.toml b/node copy/service/Cargo.toml deleted file mode 100644 index b9410b84..00000000 --- a/node copy/service/Cargo.toml +++ /dev/null @@ -1,121 +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.37" } - -[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.37" } -frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } - -pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } - -substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } - -## Substrate Client Dependencies -sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } - -## Substrate Primitive Dependencies -sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } -sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } - -# Cumulus dependencies -cumulus-client-cli = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-client-consensus-aura = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-client-consensus-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-client-network = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } - -parachains-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37", default-features = false } - -# Polkadot dependencies -polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } -polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } -polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } -polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.37" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.37" } - -# External Dependencies -pallet-dex-rpc = { version = "0.0.1", git = "https://github.com/paritytech/substrate-dex.git", default-features = false, branch = "polkadot-v0.9.37" } - -[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 copy/service/src/chain_spec/mod.rs b/node copy/service/src/chain_spec/mod.rs deleted file mode 100644 index c71d9824..00000000 --- a/node copy/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 copy/service/src/chain_spec/stout.rs b/node copy/service/src/chain_spec/stout.rs deleted file mode 100644 index 3155e7a8..00000000 --- a/node copy/service/src/chain_spec/stout.rs +++ /dev/null @@ -1,233 +0,0 @@ -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 stout_runtime::{ - constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AssetsConfig, AuraId, BalancesConfig, - CouncilConfig, GenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, -}; - -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). -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(); - properties.insert("tokenSymbol".into(), "STOUT".into()); - properties.insert("tokenDecimals".into(), 12.into()); - properties.insert("ss58Format".into(), 42.into()); - - ChainSpec::from_genesis( - // Name - "Stout Local", - // ID - "stout_local", - ChainType::Local, - 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"), - get_account_id_from_seed::("Dave"), - get_account_id_from_seed::("Eve"), - get_account_id_from_seed::("Ferdie"), - ], - 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, - }, - ) -} - -/// Configure initial storage state for FRAME modules. -fn testnet_genesis( - invulnerables: Vec<(AccountId, AuraId)>, - root_key: AccountId, - endowed_accounts: Vec, - id: ParaId, -) -> GenesisConfig { - GenesisConfig { - system: SystemConfig { - code: stout_runtime::WASM_BINARY - .expect("WASM binary was not build, please build it!") - .to_vec(), - }, - balances: BalancesConfig { - // Configure endowed accounts with initial balance of 1 << 60. - balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(), - }, - parachain_info: stout_runtime::ParachainInfoConfig { parachain_id: id }, - collator_selection: stout_runtime::CollatorSelectionConfig { - invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), - candidacy_bond: EXISTENTIAL_DEPOSIT * 16, - ..Default::default() - }, - session: SessionConfig { - keys: invulnerables - .iter() - .map(|(acc, aura)| { - ( - acc.clone(), // account id - acc.clone(), // validator id - session_keys(aura.clone()), // session keys - ) - }) - .collect(), - }, - // no need to pass anything to aura, in fact it will panic if we do. Session will take care - // of this. - aura: Default::default(), - aura_ext: Default::default(), - parachain_system: Default::default(), - polkadot_xcm: stout_runtime::PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION) }, - sudo: SudoConfig { - // Assign network admin rights. - key: Some(root_key), - }, - assets: AssetsConfig { assets: vec![], accounts: vec![], metadata: vec![] }, - council: CouncilConfig { - members: invulnerables.iter().map(|x| x.0.clone()).collect::>(), - phantom: Default::default(), - }, - dex: Default::default(), - } -} diff --git a/node copy/service/src/chain_spec/trappist.rs b/node copy/service/src/chain_spec/trappist.rs deleted file mode 100644 index 5d9fa82c..00000000 --- a/node copy/service/src/chain_spec/trappist.rs +++ /dev/null @@ -1,355 +0,0 @@ -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 trappist_runtime::{ - constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AssetsConfig, AuraId, BalancesConfig, - CouncilConfig, GenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, -}; - -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). -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(), "HOP".into()); - properties.insert("tokenDecimals".into(), 12.into()); - properties.insert("ss58Format".into(), 42.into()); - - ChainSpec::from_genesis( - // Name - "Trappist Development", - // ID - "trappist_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"), - ], - 2000.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: TRAPPIST_PARA_ID, - }, - ) -} - -pub fn trappist_local_testnet_config() -> ChainSpec { - // Give your stout currency a unit name and decimal places - let mut properties = sc_chain_spec::Properties::new(); - properties.insert("tokenSymbol".into(), "HOP".into()); - properties.insert("tokenDecimals".into(), 12.into()); - properties.insert("ss58Format".into(), 42.into()); - - ChainSpec::from_genesis( - // Name - "Trappist Local", - // ID - "trappist_local", - ChainType::Local, - 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"), - get_account_id_from_seed::("Dave"), - get_account_id_from_seed::("Eve"), - get_account_id_from_seed::("Ferdie"), - ], - TRAPPIST_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: TRAPPIST_PARA_ID, - }, - ) -} - -/// Configure initial storage state for FRAME modules. -fn testnet_genesis( - invulnerables: Vec<(AccountId, AuraId)>, - root_key: AccountId, - endowed_accounts: Vec, - id: ParaId, -) -> GenesisConfig { - GenesisConfig { - system: SystemConfig { - code: trappist_runtime::WASM_BINARY - .expect("WASM binary was not build, please build it!") - .to_vec(), - }, - balances: BalancesConfig { - // Configure endowed accounts with initial balance of 1 << 60. - balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(), - }, - parachain_info: trappist_runtime::ParachainInfoConfig { parachain_id: id }, - collator_selection: trappist_runtime::CollatorSelectionConfig { - invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), - candidacy_bond: EXISTENTIAL_DEPOSIT * 16, - ..Default::default() - }, - democracy: Default::default(), - session: SessionConfig { - keys: invulnerables - .iter() - .map(|(acc, aura)| { - ( - acc.clone(), // account id - acc.clone(), // validator id - session_keys(aura.clone()), // session keys - ) - }) - .collect(), - }, - // no need to pass anything to aura, in fact it will panic if we do. Session will take care - // of this. - aura: Default::default(), - aura_ext: Default::default(), - parachain_system: Default::default(), - polkadot_xcm: trappist_runtime::PolkadotXcmConfig { - safe_xcm_version: Some(SAFE_XCM_VERSION), - }, - sudo: SudoConfig { - // Assign network admin rights. - key: Some(root_key), - }, - assets: AssetsConfig { assets: vec![], accounts: vec![], metadata: vec![] }, - council: CouncilConfig { - members: invulnerables.iter().map(|x| x.0.clone()).collect::>(), - phantom: Default::default(), - }, - treasury: Default::default(), - lockdown_mode: Default::default(), - } -} - -pub fn trappist_live_config() -> ChainSpec { - let mut properties = sc_chain_spec::Properties::new(); - properties.insert("tokenSymbol".into(), "HOP".into()); - properties.insert("tokenDecimals".into(), 12.into()); - properties.insert("ss58Format".into(), 42.into()); - - ChainSpec::from_genesis( - // Name - "Trappist", - // ID - "trappist", - ChainType::Live, - move || { - trappist_live_genesis( - // initial collators. - vec![ - ( - hex!("56266f110802ee790b5c40f63a0f9cba54d2889b014ea52661745557d09dbc1c") - .into(), - hex!("56266f110802ee790b5c40f63a0f9cba54d2889b014ea52661745557d09dbc1c") - .unchecked_into(), - ), - ( - hex!("64c2a2b803bdd4dcb88920ff4d56b618b2e5fbede48c4dc7cd78e562ebc06238") - .into(), - hex!("64c2a2b803bdd4dcb88920ff4d56b618b2e5fbede48c4dc7cd78e562ebc06238") - .unchecked_into(), - ), - ], - hex!("e40839fde680c01344c20d47b7f08d2926b8a7537697356d416987a04a4453d0").into(), - vec![ - // This account will have root origin - hex!("6a3db76f636ce43faaf58dde5a71a8e03b9d4ae3b331cff85c092f5bf98d971b").into(), - hex!("3e79b5cb39533bd4a20f1a4b8ca5e62d264164cdf1389d568f73bc3932b5144a").into(), - hex!("d00c901e43ab81cd9f26dc1b0c109a243134c47fee89d897f3fbf03e860c6d45").into(), - hex!("30a12eef517fb62d993a605bc98183fa9b2336197da9f34414bcbf67839d0b14").into(), - hex!("c0612ba544f0c34b5b0e102bfa7139e14cc7dc106ba7d34f317adca7fa30bb27").into(), - hex!("1a2477ef6ea36d70bc6058a97d9bbbdfea103710cf2fbb9586269db72ab98f1a").into(), - ], - TRAPPIST_PARA_ID.into(), - ) - }, - vec![], - None, - None, - None, - Some(properties), - Extensions { relay_chain: "rococo".into(), para_id: TRAPPIST_PARA_ID }, - ) -} - -fn trappist_live_genesis( - invulnerables: Vec<(AccountId, AuraId)>, - root_key: AccountId, - endowed_accounts: Vec, - id: ParaId, -) -> GenesisConfig { - GenesisConfig { - system: SystemConfig { - code: trappist_runtime::WASM_BINARY - .expect("WASM binary was not build, please build it!") - .to_vec(), - }, - balances: BalancesConfig { - balances: endowed_accounts - .iter() - .cloned() - .chain(std::iter::once(root_key.clone())) - .map(|k| { - if k == root_key { - (k, 1_000_000_000_000_000_000) - } else { - (k, 1_500_000_000_000_000_000) - } - }) - .collect(), - }, - parachain_info: trappist_runtime::ParachainInfoConfig { parachain_id: id }, - collator_selection: trappist_runtime::CollatorSelectionConfig { - invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), - candidacy_bond: EXISTENTIAL_DEPOSIT * 16, - ..Default::default() - }, - democracy: Default::default(), - session: SessionConfig { - keys: invulnerables - .iter() - .map(|(acc, aura)| { - ( - acc.clone(), // account id - acc.clone(), // validator id - session_keys(aura.clone()), // session keys - ) - }) - .collect(), - }, - aura: Default::default(), - aura_ext: Default::default(), - parachain_system: Default::default(), - polkadot_xcm: trappist_runtime::PolkadotXcmConfig { - safe_xcm_version: Some(SAFE_XCM_VERSION), - }, - sudo: SudoConfig { - // Assign network admin rights. - key: Some(root_key), - }, - assets: AssetsConfig { assets: vec![], accounts: vec![], metadata: vec![] }, - council: CouncilConfig { - // We set the endowed accounts with balance as members of the council. - members: endowed_accounts.iter().map(|x| x.clone()).collect::>(), - phantom: Default::default(), - }, - treasury: Default::default(), - lockdown_mode: Default::default(), - } -} diff --git a/node copy/service/src/lib.rs b/node copy/service/src/lib.rs deleted file mode 100644 index 56487948..00000000 --- a/node copy/service/src/lib.rs +++ /dev/null @@ -1,634 +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_network::BlockAnnounceValidator; -use cumulus_client_service::{ - build_relay_chain_interface, prepare_node_config, start_collator, start_full_node, - StartCollatorParams, StartFullNodeParams, -}; -use cumulus_primitives_core::ParaId; -use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface}; - -use sc_consensus::ImportQueue; -use sc_executor::NativeElseWasmExecutor; -use sc_network::{NetworkBlock, NetworkService}; -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)> { - 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| match e { - RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, - s => s.to_string().into(), - })?; - - let block_announce_validator = - BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id); - - 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) = - sc_service::build_network(sc_service::BuildNetworkParams { - config: ¶chain_config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - spawn_handle: task_manager.spawn_handle(), - import_queue: params.import_queue, - block_announce_validator_builder: Some(Box::new(|_| { - Box::new(block_announce_validator) - })), - warp_sync: None, - })?; - - 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(), - })?; - - if let Some(hwbench) = hwbench { - sc_sysinfo::print_hwbench(&hwbench); - - 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 network = network.clone(); - Arc::new(move |hash, data| network.announce_block(hash, data)) - }; - - 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, - network, - 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, - }; - - 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, - }; - - 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)> { - 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| match e { - RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, - s => s.to_string().into(), - })?; - - let block_announce_validator = - BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id); - - 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) = - sc_service::build_network(sc_service::BuildNetworkParams { - config: ¶chain_config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - spawn_handle: task_manager.spawn_handle(), - import_queue: params.import_queue, - block_announce_validator_builder: Some(Box::new(|_| { - Box::new(block_announce_validator) - })), - warp_sync: None, - })?; - - 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(), - })?; - - if let Some(hwbench) = hwbench { - sc_sysinfo::print_hwbench(&hwbench); - - 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 network = network.clone(); - Arc::new(move |hash, data| network.announce_block(hash, data)) - }; - - 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, - network, - 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, - }; - - 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, - }; - - 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 copy/src/main.rs b/node copy/src/main.rs deleted file mode 100644 index c39414b3..00000000 --- a/node copy/src/main.rs +++ /dev/null @@ -1,24 +0,0 @@ -// 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 . - -//! Cumulus test parachain collator - -#![warn(missing_docs)] -#![warn(unused_extern_crates)] - -fn main() -> trappist_cli::Result<()> { - trappist_cli::run() -} From d48984d9d348077d2aaa64a4628fc4448c150a62 Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Wed, 31 May 2023 11:49:01 +0200 Subject: [PATCH 11/15] Fixing docs --- README.md | 9 +-------- scripts/build_runtimes.sh | 2 -- zombienet/full_network.toml | 8 ++++---- zombienet/stout_rococo.toml | 4 ++-- zombienet/trappist_rococo.toml | 4 ++-- 5 files changed, 9 insertions(+), 18 deletions(-) delete mode 100755 scripts/build_runtimes.sh diff --git a/README.md b/README.md index aa26ed34..ec9d40c4 100644 --- a/README.md +++ b/README.md @@ -56,16 +56,9 @@ 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 +cargo build --release ``` -Alternatively, run: -```bash -./scripts/build_runtimes.sh -``` - - ### XCM Playground via Zombienet Create a `bin` directory into the root of this repository and place the following binaries inside of it: 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"] From a442e19f0f15a0c5fdc90730e312e3db9a97e431 Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Wed, 31 May 2023 11:50:27 +0200 Subject: [PATCH 12/15] updating gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) 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 From f6fa5c689c2d1e6124f477dc636e052229ef833e Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Wed, 31 May 2023 12:10:52 +0200 Subject: [PATCH 13/15] Fixing docker and github actions files --- .github/workflows/check.yml | 6 +----- docker/scripts/inject_bootnodes.sh | 4 ++-- docker/trappist-parachain.dockerfile | 8 ++++---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 13ee5236..f918afde 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -47,11 +47,7 @@ jobs: - name: Check Build Trappist Runtime run: | - SKIP_WASM_BUILD=1 cargo check --release --features with-trappist-runtime - - - name: Check Build Stout Runtime - run: | - SKIP_WASM_BUILD=1 cargo check --release --no-default-features --features with-stout-runtime + SKIP_WASM_BUILD=1 cargo check --release test: needs: lint 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"] From 36866c40704c094c356ae79a17c3f906261b80e4 Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Wed, 31 May 2023 12:50:46 +0200 Subject: [PATCH 14/15] fmt --- node/src/rpc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 11801c55..c9489c28 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -81,4 +81,4 @@ where module.merge(Dex::new(client).into_rpc())?; Ok(module) -} \ No newline at end of file +} From 486affd7c53e7fc5c7b1e3990105868eb1c13bff Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Wed, 31 May 2023 14:34:04 +0200 Subject: [PATCH 15/15] Adding missing polkadot-cli in benchmark feature --- Cargo.lock | 638 +++++++++++++++++++++++++++++++----------------- node/Cargo.toml | 8 +- 2 files changed, 424 insertions(+), 222 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2d91127c..be8ca92f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -115,9 +115,9 @@ dependencies = [ [[package]] name = "aes-gcm" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e1366e0c69c9f927b1fa5ce2c7bf9eafc8f9268c0b9800729e8b267612447c" +checksum = "209b47e8954a928e1d72e86eca7000ebb6655fe1436d33eefc2201cad027e237" dependencies = [ "aead 0.5.2", "aes 0.8.2", @@ -182,6 +182,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" @@ -202,9 +208,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6342bd4f5a1205d7f41e94a41a901f5647c938cdfa96036338e8533c9d6c2450" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" dependencies = [ "anstyle", "anstyle-parse", @@ -251,9 +257,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.70" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "approx" @@ -313,7 +319,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.20", + "time 0.3.21", ] [[package]] @@ -329,7 +335,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.20", + "time 0.3.21", ] [[package]] @@ -408,7 +414,7 @@ dependencies = [ "log", "parking", "polling", - "rustix 0.37.15", + "rustix 0.37.19", "slab", "socket2", "waker-fn", @@ -431,7 +437,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -480,7 +486,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.6.2", "object 0.30.3", "rustc-demangle", ] @@ -511,9 +517,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" [[package]] name = "base64ct" @@ -646,7 +652,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -682,7 +688,7 @@ dependencies = [ "cc", "cfg-if", "constant_time_eq", - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -757,9 +763,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d4260bcc2e8fc9df1eac4919a720effeb63a3f0952f5bf4944adfa18897f09" +checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5" dependencies = [ "memchr", "once_cell", @@ -778,9 +784,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.1" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" [[package]] name = "byte-slice-cast" @@ -925,13 +931,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", @@ -1001,9 +1007,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.2.5" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a1f23fa97e1d1641371b51f35535cb26959b8e27ab50d167a8b996b5bada819" +checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc" dependencies = [ "clap_builder", "clap_derive", @@ -1012,9 +1018,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.2.5" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fdc5d93c358224b4d6867ef1356d740de2303e9892edc06c5340daeccd96bab" +checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990" dependencies = [ "anstream", "anstyle", @@ -1025,21 +1031,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.2.0" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" +checksum = "191d9573962933b4027f932c600cd252ce27a8ad5979418fe78e43c07996f27b" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "clap_lex" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" [[package]] name = "coarsetime" @@ -1071,9 +1077,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", @@ -1977,9 +1983,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" +checksum = "109308c20e8445959c2792e81871054c6a17e6976489a93d2769641a2ba5839c" dependencies = [ "cc", "cxxbridge-flags", @@ -1989,9 +1995,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" +checksum = "daf4c6755cdf10798b97510e0e2b3edb9573032bd9379de8fffa59d68165494f" dependencies = [ "cc", "codespan-reporting", @@ -1999,24 +2005,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "cxxbridge-flags" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" +checksum = "882074421238e84fe3b4c65d0081de34e5b323bf64555d3e61991f76eb64a7bb" [[package]] name = "cxxbridge-macro" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" +checksum = "4a076022ece33e7686fb76513518e219cca4fce5750a8ae6d1ce6c0f48fd1af9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -2056,15 +2062,15 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" +checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" [[package]] name = "data-encoding-macro" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86927b7cd2fe88fa698b87404b287ab98d1a0063a34071d92e575b72d3029aca" +checksum = "c904b33cc60130e1aeea4956ab803d08a3f4a0ca82d64ed757afac3891f2bb99" dependencies = [ "data-encoding", "data-encoding-macro-internal", @@ -2072,9 +2078,9 @@ dependencies = [ [[package]] name = "data-encoding-macro-internal" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5bbed42daaa95e780b60a50546aa345b8413a1e46f9a40a12907d3598f038db" +checksum = "8fdf3fce3ce863539ec1d7fd1b6dcc3c645663376b43ed376bbf887733e4f772" dependencies = [ "data-encoding", "syn 1.0.109", @@ -2200,9 +2206,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", "crypto-common", @@ -2252,13 +2258,13 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bf95dc3f046b9da4f2d51833c0d3547d8564ef6910f5c1ed130306a75b92886" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -2376,7 +2382,7 @@ dependencies = [ "base16ct", "crypto-bigint", "der", - "digest 0.10.6", + "digest 0.10.7", "ff", "generic-array 0.14.7", "group", @@ -2418,7 +2424,7 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -2429,7 +2435,7 @@ checksum = "48016319042fb7c87b78d2993084a831793a897a5cd1a2a67cab9d1eeb4b7d76" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -2665,13 +2671,13 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", "libz-sys", - "miniz_oxide", + "miniz_oxide 0.7.1", ] [[package]] @@ -3071,7 +3077,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -3250,9 +3256,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f8a914c2987b688368b5138aa05321db91f4090cf26118185672ad588bce21" +checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" dependencies = [ "bytes", "fnv", @@ -3269,9 +3275,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "4.3.6" +version = "4.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "035ef95d03713f2c347a72547b7cd38cbc9af7cd51e6099fb62d586d4a6dee3a" +checksum = "83c3372087601b532857d332f5957cbae686da52bb7810bf038c3e3c3cc2fa0d" dependencies = [ "log", "pest", @@ -3382,7 +3388,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -3508,12 +3514,11 @@ dependencies = [ [[package]] name = "iana-time-zone-haiku" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ - "cxx", - "cxx-build", + "cc", ] [[package]] @@ -3678,9 +3683,9 @@ checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" [[package]] name = "io-lifetimes" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ "hermit-abi 0.3.1", "libc", @@ -3718,8 +3723,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi 0.3.1", - "io-lifetimes 1.0.10", - "rustix 0.37.15", + "io-lifetimes 1.0.11", + "rustix 0.37.19", "windows-sys 0.48.0", ] @@ -3749,9 +3754,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.61" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" dependencies = [ "wasm-bindgen", ] @@ -3894,9 +3899,9 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" dependencies = [ "cpufeatures", ] @@ -3907,12 +3912,15 @@ version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ "bitvec", + "frame-benchmarking", "frame-election-provider-support", "frame-executive", "frame-support", "frame-system", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", + "hex-literal", "kusama-runtime-constants", "log", "pallet-authority-discovery", @@ -3926,6 +3934,7 @@ dependencies = [ "pallet-conviction-voting", "pallet-democracy", "pallet-election-provider-multi-phase", + "pallet-election-provider-support-benchmarking", "pallet-elections-phragmen", "pallet-fast-unstake", "pallet-grandpa", @@ -3936,8 +3945,10 @@ dependencies = [ "pallet-multisig", "pallet-nis", "pallet-nomination-pools", + "pallet-nomination-pools-benchmarking", "pallet-nomination-pools-runtime-api", "pallet-offences", + "pallet-offences-benchmarking", "pallet-preimage", "pallet-proxy", "pallet-ranked-collective", @@ -3945,6 +3956,7 @@ dependencies = [ "pallet-referenda", "pallet-scheduler", "pallet-session", + "pallet-session-benchmarking", "pallet-society", "pallet-staking", "pallet-timestamp", @@ -3956,6 +3968,7 @@ dependencies = [ "pallet-vesting", "pallet-whitelist", "pallet-xcm", + "pallet-xcm-benchmarks", "parity-scale-codec", "polkadot-primitives", "polkadot-runtime-common", @@ -4051,9 +4064,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.142" +version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" [[package]] name = "libloading" @@ -4073,9 +4086,9 @@ checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" [[package]] name = "libm" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" [[package]] name = "libp2p" @@ -4147,9 +4160,9 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.39.1" +version = "0.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7f8b7d65c070a5a1b5f8f0510648189da08f787b8963f8e21219e0710733af" +checksum = "3c1df63c0b582aa434fb09b2d86897fa2b419ffeccf934b36f87fcedc8e835c2" dependencies = [ "either", "fnv", @@ -4210,18 +4223,18 @@ dependencies = [ [[package]] name = "libp2p-identity" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a8ea433ae0cea7e3315354305237b9897afe45278b2118a7a57ca744e70fd27" +checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" dependencies = [ "bs58", "ed25519-dalek", "log", "multiaddr 0.17.1", "multihash 0.17.0", - "prost", "quick-protobuf", "rand 0.8.5", + "sha2 0.10.6", "thiserror", "zeroize", ] @@ -4441,7 +4454,7 @@ checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" dependencies = [ "futures", "futures-rustls", - "libp2p-core 0.39.1", + "libp2p-core 0.39.2", "libp2p-identity", "rcgen 0.10.0", "ring", @@ -4595,9 +4608,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" +checksum = "56ee889ecc9568871456d42f603d6a0ce59ff328d291063a45cbdf0036baf6db" dependencies = [ "cc", "pkg-config", @@ -4646,9 +4659,9 @@ checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" [[package]] name = "linux-raw-sys" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e8776872cdc2f073ccaab02e336fa321328c1e02646ebcb9d2108d0baab480d" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "lock_api" @@ -4662,12 +4675,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" @@ -4739,10 +4749,11 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "matrixmultiply" -version = "0.3.3" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb99c395ae250e1bf9133673f03ca9f97b7e71b705436bf8f089453445d1e9fe" +checksum = "090126dc04f95dc0d1c1c91f61bdd474b3930ca064c1edc8a849da2c6cbe1e77" dependencies = [ + "autocfg", "rawpointer", ] @@ -4752,7 +4763,7 @@ version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -4767,7 +4778,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" dependencies = [ - "rustix 0.37.15", + "rustix 0.37.19", ] [[package]] @@ -4851,16 +4862,24 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + [[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]] @@ -4983,7 +5002,7 @@ dependencies = [ "blake2s_simd", "blake3", "core2", - "digest 0.10.6", + "digest 0.10.7", "multihash-derive", "sha2 0.10.6", "sha3", @@ -4997,9 +5016,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" dependencies = [ "core2", - "digest 0.10.6", "multihash-derive", - "sha2 0.10.6", "unsigned-varint", ] @@ -5254,7 +5271,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", - "libm 0.2.6", + "libm 0.2.7", ] [[package]] @@ -5308,9 +5325,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" @@ -6093,6 +6110,26 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-nomination-pools-benchmarking" +version = "1.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "pallet-bags-list", + "pallet-nomination-pools", + "pallet-staking", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-runtime-interface", + "sp-staking", + "sp-std", +] + [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" @@ -6120,6 +6157,29 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-offences-benchmarking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "pallet-babe", + "pallet-balances", + "pallet-grandpa", + "pallet-im-online", + "pallet-offences", + "pallet-session", + "pallet-staking", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-staking", + "sp-std", +] + [[package]] name = "pallet-preimage" version = "4.0.0-dev" @@ -6204,6 +6264,7 @@ name = "pallet-referenda" version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" dependencies = [ + "assert_matches", "frame-benchmarking", "frame-support", "frame-system", @@ -6270,6 +6331,22 @@ dependencies = [ "sp-trie", ] +[[package]] +name = "pallet-session-benchmarking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6fa7fe1326ecaab9921c2c3888530ad679cfbb87" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-session", + "pallet-staking", + "rand 0.8.5", + "sp-runtime", + "sp-session", + "sp-std", +] + [[package]] name = "pallet-society" version = "4.0.0-dev" @@ -6297,6 +6374,7 @@ dependencies = [ "pallet-authorship", "pallet-session", "parity-scale-codec", + "rand_chacha 0.2.2", "scale-info", "serde", "sp-application-crypto", @@ -6591,9 +6669,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.4.6" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00bfb81cf5c90a222db2fb7b3a7cbf8cc7f38dfb6647aca4d98edf8281f56ed5" +checksum = "4890dcb9556136a4ec2b0c51fa4a08c8b733b829506af8fff2e853f3a065985b" dependencies = [ "blake2", "crc32fast", @@ -6611,9 +6689,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "637935964ff85a605d114591d4d2c13c5d1ba2806dae97cea6bf180238a749ac" +checksum = "5ddb756ca205bd108aee3c62c6d3c994e1df84a59b9d6d4a5ea42ee1fd5a9a28" dependencies = [ "arrayvec 0.7.2", "bitvec", @@ -6723,7 +6801,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -6786,7 +6864,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -6812,22 +6890,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.12" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" +checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.0.12" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" +checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -6860,9 +6938,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "platforms" @@ -7671,12 +7749,15 @@ version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ "bitvec", + "frame-benchmarking", "frame-election-provider-support", "frame-executive", "frame-support", "frame-system", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", + "hex-literal", "log", "pallet-authority-discovery", "pallet-authorship", @@ -7688,6 +7769,7 @@ dependencies = [ "pallet-collective", "pallet-democracy", "pallet-election-provider-multi-phase", + "pallet-election-provider-support-benchmarking", "pallet-elections-phragmen", "pallet-fast-unstake", "pallet-grandpa", @@ -7697,12 +7779,15 @@ dependencies = [ "pallet-membership", "pallet-multisig", "pallet-nomination-pools", + "pallet-nomination-pools-benchmarking", "pallet-nomination-pools-runtime-api", "pallet-offences", + "pallet-offences-benchmarking", "pallet-preimage", "pallet-proxy", "pallet-scheduler", "pallet-session", + "pallet-session-benchmarking", "pallet-staking", "pallet-staking-reward-curve", "pallet-timestamp", @@ -7753,6 +7838,7 @@ version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ "bitvec", + "frame-benchmarking", "frame-election-provider-support", "frame-support", "frame-system", @@ -7760,6 +7846,7 @@ dependencies = [ "libsecp256k1", "log", "pallet-authorship", + "pallet-babe", "pallet-bags-list", "pallet-balances", "pallet-beefy-mmr", @@ -7827,6 +7914,7 @@ dependencies = [ "bitflags", "bitvec", "derive_more", + "frame-benchmarking", "frame-support", "frame-system", "log", @@ -7847,6 +7935,7 @@ dependencies = [ "scale-info", "serde", "sp-api", + "sp-application-crypto", "sp-core", "sp-inherents", "sp-io", @@ -7855,6 +7944,7 @@ dependencies = [ "sp-session", "sp-staking", "sp-std", + "static_assertions", "xcm", "xcm-executor", ] @@ -7870,6 +7960,7 @@ dependencies = [ "frame-system-rpc-runtime-api", "futures", "hex-literal", + "kusama-runtime", "kvdb", "kvdb-rocksdb", "lru", @@ -7962,6 +8053,7 @@ dependencies = [ "substrate-prometheus-endpoint", "thiserror", "tracing-gum", + "westend-runtime", ] [[package]] @@ -8043,7 +8135,7 @@ dependencies = [ "cfg-if", "cpufeatures", "opaque-debug 0.3.0", - "universal-hash 0.5.0", + "universal-hash 0.5.1", ] [[package]] @@ -8169,9 +8261,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" dependencies = [ "unicode-ident", ] @@ -8335,9 +8427,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" dependencies = [ "proc-macro2", ] @@ -8474,7 +8566,7 @@ checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" dependencies = [ "pem", "ring", - "time 0.3.20", + "time 0.3.21", "x509-parser 0.13.2", "yasna", ] @@ -8487,7 +8579,7 @@ checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", "ring", - "time 0.3.20", + "time 0.3.21", "yasna", ] @@ -8550,7 +8642,7 @@ checksum = "8d2275aab483050ab2a7364c1a46604865ee7d6906684e08db0f090acf74f9e7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -8567,13 +8659,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.8.1" +version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" +checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390" dependencies = [ "aho-corasick 1.0.1", "memchr", - "regex-syntax 0.7.1", + "regex-syntax 0.7.2", ] [[package]] @@ -8593,9 +8685,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" +checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" [[package]] name = "resolv-conf" @@ -8649,9 +8741,11 @@ version = "0.9.37" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" dependencies = [ "beefy-merkle-tree", + "frame-benchmarking", "frame-executive", "frame-support", "frame-system", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", @@ -8693,6 +8787,7 @@ dependencies = [ "pallet-utility", "pallet-vesting", "pallet-xcm", + "pallet-xcm-benchmarks", "parity-scale-codec", "polkadot-parachain", "polkadot-primitives", @@ -8862,15 +8957,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.15" +version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0661814f891c57c930a610266415528da53c4933e6dea5fb350cbfe048a9ece" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ "bitflags", "errno 0.3.1", - "io-lifetimes 1.0.10", + "io-lifetimes 1.0.11", "libc", - "linux-raw-sys 0.3.5", + "linux-raw-sys 0.3.8", "windows-sys 0.48.0", ] @@ -8917,7 +9012,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" dependencies = [ - "base64 0.21.0", + "base64 0.21.2", ] [[package]] @@ -10011,9 +10106,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfdef77228a4c05dc94211441595746732131ad7f6530c6c18f045da7b7ab937" +checksum = "b569c32c806ec3abdf3b5869fb8bf1e0d275a7c1c9b0b05603d9464632649edf" dependencies = [ "bitvec", "cfg-if", @@ -10149,9 +10244,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.8.2" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" +checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" dependencies = [ "bitflags", "core-foundation", @@ -10162,9 +10257,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7" dependencies = [ "core-foundation-sys", "libc", @@ -10205,22 +10300,22 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.160" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" +checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.160" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" +checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -10255,7 +10350,7 @@ checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -10291,16 +10386,16 @@ checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.6", + "digest 0.10.7", ] [[package]] name = "sha3" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54c2bb1a323307527314a36bfb73f24febb08ce2b8a554bf4ffd6f51ad15198c" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", "keccak", ] @@ -10334,7 +10429,7 @@ version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", "rand_core 0.6.4", ] @@ -10367,9 +10462,9 @@ dependencies = [ [[package]] name = "slice-group-by" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "slot-range-helper" @@ -10710,7 +10805,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#6f dependencies = [ "blake2", "byteorder", - "digest 0.10.6", + "digest 0.10.7", "sha2 0.10.6", "sha3", "sp-std", @@ -11537,9 +11632,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.15" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" dependencies = [ "proc-macro2", "quote", @@ -11560,9 +11655,9 @@ dependencies = [ [[package]] name = "system-configuration" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75182f12f490e953596550b65ee31bda7c8e043d9386174b353bda50838c3fd" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ "bitflags", "core-foundation", @@ -11600,7 +11695,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.37.15", + "rustix 0.37.19", "windows-sys 0.45.0", ] @@ -11636,7 +11731,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -11711,9 +11806,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.20" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" dependencies = [ "itoa", "serde", @@ -11723,15 +11818,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" +checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" dependencies = [ "time-core", ] @@ -11782,9 +11877,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.28.0" +version = "1.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c786bf8134e5a3a166db9b29ab8f48134739014a3eca7bc6bfa95d673b136f" +checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2" dependencies = [ "autocfg", "bytes", @@ -11807,7 +11902,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -11859,15 +11954,15 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" +checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" [[package]] name = "toml_edit" -version = "0.19.8" +version = "0.19.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" +checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" dependencies = [ "indexmap", "toml_datetime", @@ -11917,10 +12012,11 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.38" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9cf6a813d3f40c88b0b6b6f29a5c95c6cdbf97c1f9cc53fb820200f5ad814d" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ + "cfg-if", "log", "pin-project-lite 0.2.9", "tracing-attributes", @@ -11935,14 +12031,14 @@ checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", "valuable", @@ -12333,7 +12429,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", - "digest 0.10.6", + "digest 0.10.7", "rand 0.8.5", "static_assertions", ] @@ -12370,9 +12466,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" [[package]] name = "unicode-normalization" @@ -12407,9 +12503,9 @@ dependencies = [ [[package]] name = "universal-hash" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d3160b73c9a19f7e2939a2fdad446c57c1bbbbf4d919d3213ff1267a580d8b5" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" dependencies = [ "crypto-common", "subtle", @@ -12452,9 +12548,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.3.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b55a3fef2a1e3b3a00ce878640918820d3c51081576ac657d23af9fc7928fdb" +checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" dependencies = [ "getrandom 0.2.9", ] @@ -12547,9 +12643,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -12557,24 +12653,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.34" +version = "0.4.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e" dependencies = [ "cfg-if", "js-sys", @@ -12584,9 +12680,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -12594,22 +12690,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" [[package]] name = "wasm-instrument" @@ -12730,7 +12826,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" dependencies = [ "downcast-rs", - "libm 0.2.6", + "libm 0.2.7", "memory_units", "num-rational", "num-traits", @@ -12743,7 +12839,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5bf998ab792be85e20e771fe14182b4295571ad1d4f89d3da521c1bef5f597a" dependencies = [ "downcast-rs", - "libm 0.2.6", + "libm 0.2.7", "num-traits", ] @@ -12937,9 +13033,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.61" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" dependencies = [ "js-sys", "wasm-bindgen", @@ -13000,7 +13096,7 @@ dependencies = [ "sha2 0.10.6", "stun", "thiserror", - "time 0.3.20", + "time 0.3.21", "tokio", "turn", "url", @@ -13037,7 +13133,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "942be5bd85f072c3128396f6e5a9bfb93ca8c1939ded735d177b7bcba9a13d05" dependencies = [ "aes 0.6.0", - "aes-gcm 0.10.1", + "aes-gcm 0.10.2", "async-trait", "bincode", "block-modes", @@ -13183,6 +13279,110 @@ dependencies = [ "winapi", ] +[[package]] +name = "westend-runtime" +version = "0.9.37" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" +dependencies = [ + "bitvec", + "frame-benchmarking", + "frame-election-provider-support", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal", + "log", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-bags-list", + "pallet-balances", + "pallet-collective", + "pallet-democracy", + "pallet-election-provider-multi-phase", + "pallet-election-provider-support-benchmarking", + "pallet-elections-phragmen", + "pallet-fast-unstake", + "pallet-grandpa", + "pallet-identity", + "pallet-im-online", + "pallet-indices", + "pallet-membership", + "pallet-multisig", + "pallet-nomination-pools", + "pallet-nomination-pools-benchmarking", + "pallet-nomination-pools-runtime-api", + "pallet-offences", + "pallet-offences-benchmarking", + "pallet-preimage", + "pallet-proxy", + "pallet-recovery", + "pallet-scheduler", + "pallet-session", + "pallet-session-benchmarking", + "pallet-society", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", + "pallet-utility", + "pallet-vesting", + "pallet-xcm", + "pallet-xcm-benchmarks", + "parity-scale-codec", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "rustc-hex", + "scale-info", + "serde", + "serde_derive", + "smallvec", + "sp-api", + "sp-authority-discovery", + "sp-beefy", + "sp-block-builder", + "sp-consensus-babe", + "sp-core", + "sp-inherents", + "sp-io", + "sp-mmr-primitives", + "sp-npos-elections", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "westend-runtime-constants", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "westend-runtime-constants" +version = "0.9.37" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.37#645723987cf9662244be8faf4e9b63e8b9a1b3a3" +dependencies = [ + "frame-support", + "polkadot-primitives", + "polkadot-runtime-common", + "smallvec", + "sp-core", + "sp-runtime", + "sp-weights", +] + [[package]] name = "which" version = "4.4.0" @@ -13475,9 +13675,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.4.1" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28" +checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" dependencies = [ "memchr", ] @@ -13538,7 +13738,7 @@ dependencies = [ "ring", "rusticata-macros", "thiserror", - "time 0.3.20", + "time 0.3.21", ] [[package]] @@ -13556,7 +13756,7 @@ dependencies = [ "oid-registry 0.6.1", "rusticata-macros", "thiserror", - "time 0.3.20", + "time 0.3.21", ] [[package]] @@ -13670,7 +13870,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" dependencies = [ - "time 0.3.20", + "time 0.3.21", ] [[package]] @@ -13690,7 +13890,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] diff --git a/node/Cargo.toml b/node/Cargo.toml index 0a41aebc..79bc3041 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -17,7 +17,7 @@ name = "trappist-node" path = "src/main.rs" [dependencies] -async-trait = "0.1.60" +async-trait = "0.1.57" clap = { version = "4.0.32", features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0" } futures = "0.3.25" @@ -87,7 +87,8 @@ cumulus-client-network = { git = "https://github.com/paritytech/cumulus", branch cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } -parachains-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } + +parachains-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37", default-features = false } [build-dependencies] substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" } @@ -105,7 +106,8 @@ polkadot-cli = { git = "https://github.com/paritytech/polkadot", features = ["ro default = [] runtime-benchmarks = [ "trappist-runtime/runtime-benchmarks", - "stout-runtime/runtime-benchmarks" + "stout-runtime/runtime-benchmarks", + "polkadot-cli/runtime-benchmarks" ] try-runtime = [ "trappist-runtime/try-runtime",