diff --git a/Cargo.lock b/Cargo.lock index a5c6703e..ac4d0f19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -153,7 +153,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "once_cell", "version_check", ] @@ -169,9 +169,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" dependencies = [ "memchr", ] @@ -319,7 +319,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.21", + "time 0.3.22", ] [[package]] @@ -335,7 +335,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.21", + "time 0.3.22", ] [[package]] @@ -416,7 +416,7 @@ dependencies = [ "polling", "rustix 0.37.19", "slab", - "socket2", + "socket2 0.4.9", "waker-fn", ] @@ -487,7 +487,7 @@ dependencies = [ "cfg-if", "libc", "miniz_oxide 0.6.2", - "object 0.30.3", + "object 0.30.4", "rustc-demangle", ] @@ -1007,9 +1007,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.0" +version = "4.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc" +checksum = "401a4694d2bf92537b6867d94de48c4842089645fdcdf6c71865b175d836e9c2" dependencies = [ "clap_builder", "clap_derive", @@ -1018,9 +1018,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.0" +version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990" +checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980" dependencies = [ "anstream", "anstyle", @@ -1031,9 +1031,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.0" +version = "4.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "191d9573962933b4027f932c600cd252ce27a8ad5979418fe78e43c07996f27b" +checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" dependencies = [ "heck", "proc-macro2", @@ -2705,9 +2705,9 @@ dependencies = [ [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] @@ -3178,9 +3178,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", @@ -3476,7 +3476,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite 0.2.9", - "socket2", + "socket2 0.4.9", "tokio", "tower-service", "tracing", @@ -3500,9 +3500,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.56" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" +checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -3540,9 +3540,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -3700,13 +3700,13 @@ checksum = "aa2f047c0a98b2f299aa5d6d7088443570faae494e9ae1305e48be000c9e0eb1" [[package]] name = "ipconfig" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" +checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2", + "socket2 0.5.3", "widestring", - "winapi", + "windows-sys 0.48.0", "winreg", ] @@ -4064,9 +4064,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.144" +version = "0.2.146" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b" [[package]] name = "libloading" @@ -4099,7 +4099,7 @@ dependencies = [ "bytes", "futures", "futures-timer", - "getrandom 0.2.9", + "getrandom 0.2.10", "instant", "libp2p-core 0.38.0", "libp2p-dns", @@ -4281,7 +4281,7 @@ dependencies = [ "log", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.4.9", "tokio", "trust-dns-proto", "void", @@ -4442,7 +4442,7 @@ dependencies = [ "libc", "libp2p-core 0.38.0", "log", - "socket2", + "socket2 0.4.9", "tokio", ] @@ -4665,9 +4665,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", @@ -5298,9 +5298,9 @@ dependencies = [ [[package]] name = "object" -version = "0.30.3" +version = "0.30.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" dependencies = [ "memchr", ] @@ -5325,9 +5325,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.2" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "opaque-debug" @@ -6750,7 +6750,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.7", + "parking_lot_core 0.9.8", ] [[package]] @@ -6769,15 +6769,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.16", + "redox_syscall 0.3.5", "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] @@ -6830,9 +6830,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" @@ -8261,9 +8261,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" +checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" dependencies = [ "unicode-ident", ] @@ -8499,7 +8499,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", ] [[package]] @@ -8566,7 +8566,7 @@ checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" dependencies = [ "pem", "ring", - "time 0.3.21", + "time 0.3.22", "x509-parser 0.13.2", "yasna", ] @@ -8579,7 +8579,7 @@ checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", "ring", - "time 0.3.21", + "time 0.3.22", "yasna", ] @@ -8607,7 +8607,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "redox_syscall 0.2.16", "thiserror", ] @@ -8659,11 +8659,11 @@ dependencies = [ [[package]] name = "regex" -version = "1.8.3" +version = "1.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390" +checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" dependencies = [ - "aho-corasick 1.0.1", + "aho-corasick 1.0.2", "memchr", "regex-syntax 0.7.2", ] @@ -10300,18 +10300,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.163" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.163" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" dependencies = [ "proc-macro2", "quote", @@ -10526,6 +10526,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "socket2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "soketto" version = "0.7.1" @@ -11689,15 +11699,16 @@ checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" [[package]] name = "tempfile" -version = "3.5.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" dependencies = [ + "autocfg", "cfg-if", "fastrand", "redox_syscall 0.3.5", "rustix 0.37.19", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -11807,9 +11818,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.21" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" +checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd" dependencies = [ "itoa", "serde", @@ -11890,7 +11901,7 @@ dependencies = [ "parking_lot 0.12.1", "pin-project-lite 0.2.9", "signal-hook-registry", - "socket2", + "socket2 0.4.9", "tokio-macros", "windows-sys 0.48.0", ] @@ -12140,11 +12151,13 @@ dependencies = [ "cumulus-relay-chain-interface", "frame-benchmarking", "frame-benchmarking-cli", + "frame-system", "futures", "hex-literal", "jsonrpsee", "log", "nix 0.25.1", + "pallet-asset-tx-payment", "pallet-dex-rpc", "pallet-transaction-payment-rpc", "parachains-common", @@ -12174,7 +12187,9 @@ dependencies = [ "sp-consensus", "sp-consensus-aura", "sp-core", + "sp-inherents", "sp-io", + "sp-keyring", "sp-keystore", "sp-offchain", "sp-runtime", @@ -12270,6 +12285,7 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", + "sp-weights", "substrate-wasm-builder", "trappist-runtime-benchmarks", "xcm", @@ -12334,7 +12350,7 @@ dependencies = [ "lazy_static", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.4.9", "thiserror", "tinyvec", "tokio", @@ -12532,12 +12548,12 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" dependencies = [ "form_urlencoded", - "idna 0.3.0", + "idna 0.4.0", "percent-encoding", ] @@ -12553,7 +12569,7 @@ version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", ] [[package]] @@ -13097,7 +13113,7 @@ dependencies = [ "sha2 0.10.6", "stun", "thiserror", - "time 0.3.21", + "time 0.3.22", "tokio", "turn", "url", @@ -13199,7 +13215,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f08dfd7a6e3987e255c4dbe710dde5d94d0f0574f8a21afa95d171376c143106" dependencies = [ "log", - "socket2", + "socket2 0.4.9", "thiserror", "tokio", "webrtc-util", @@ -13397,9 +13413,9 @@ dependencies = [ [[package]] name = "widestring" -version = "0.5.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" +checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" [[package]] name = "winapi" @@ -13451,7 +13467,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.0", + "windows-targets", ] [[package]] @@ -13482,37 +13498,13 @@ dependencies = [ "windows_x86_64_msvc 0.42.2", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets", ] [[package]] @@ -13685,11 +13677,12 @@ dependencies = [ [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if", + "windows-sys 0.48.0", ] [[package]] @@ -13739,7 +13732,7 @@ dependencies = [ "ring", "rusticata-macros", "thiserror", - "time 0.3.21", + "time 0.3.22", ] [[package]] @@ -13757,7 +13750,7 @@ dependencies = [ "oid-registry 0.6.1", "rusticata-macros", "thiserror", - "time 0.3.21", + "time 0.3.22", ] [[package]] @@ -13871,7 +13864,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" dependencies = [ - "time 0.3.21", + "time 0.3.22", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f4b58d86..74e70601 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,13 +1,13 @@ [workspace] members = [ - "node", - "runtime/stout", - "runtime/trappist", - "primitives/xcm", + "node", + "runtime/stout", + "runtime/trappist", + "primitives/xcm", ] exclude = [ - "contracts", - "xcm-simulator" + "contracts", + "xcm-simulator" ] [profile.release] @@ -32,15 +32,15 @@ license = "Apache License v2" async-trait = "0.1.57" clap = { version = "4.0.32" } parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] } -futures = { version = "0.3.25"} -hex-literal = { version = "0.3.4"} -log = { version = "0.4.17"} +futures = { version = "0.3.25" } +hex-literal = { version = "0.3.4" } +log = { version = "0.4.17" } serde = { version = "1.0.152" } scale-info = { version = "2.3.1", default-features = false, features = ["derive"] } smallvec = "1.9.0" # Local dependencies -trappist-runtime = { path = "runtime/trappist"} +trappist-runtime = { path = "runtime/trappist" } stout-runtime = { path = "runtime/stout" } jsonrpsee = { version = "0.16.2" } @@ -57,7 +57,7 @@ pallet-lockdown-mode = { version = "0.1.0", default-features = false, path = "pa # Substrate std try-runtime-cli = { 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"} +frame-benchmarking-cli = { 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", default-features = false } pallet-transaction-payment-rpc = { 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" } @@ -76,9 +76,10 @@ sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkad sc-sysinfo = { 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-serializer = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37"} +sp-keyring = { 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" } -substrate-state-trie-migration-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" } # Substrate non-std frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", default-features = false } @@ -97,6 +98,7 @@ sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", bra # Substrate Runtime sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", default-features = false } +sp-weights = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37", default-features = false } sp-inherents = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.37" } sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.37" } sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.37" } @@ -138,7 +140,7 @@ pallet-utility = { git = "https://github.com/paritytech/substrate", default-feat pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.37" } # Cumulus client dependencies -cumulus-client-cli ={ git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.37" } +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" } diff --git a/node/Cargo.toml b/node/Cargo.toml index a4d7b44d..da99cc61 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -19,7 +19,7 @@ path = "src/main.rs" [dependencies] async-trait = { workspace = true } clap = { workspace = true } -parity-scale-codec = { workspace = true } +parity-scale-codec = { workspace = true } futures = { workspace = true } hex-literal = { workspace = true } log = { workspace = true } @@ -34,13 +34,13 @@ jsonrpsee = { workspace = true, features = ["server"] } pallet-dex-rpc = { workspace = true } # Substrate -frame-benchmarking = { workspace = true, features = [ "std" ] } +frame-benchmarking = { workspace = true, features = ["std"] } frame-benchmarking-cli = { workspace = true } sp-runtime = { workspace = true } -sp-io = { workspace = true, features = [ "std" ] } -sp-core = { workspace = true, features = [ "std" ] } +sp-io = { workspace = true, features = ["std"] } +sp-core = { workspace = true, features = ["std"] } sp-consensus = { workspace = true } -sp-session = { workspace = true, features = [ "std" ] } +sp-session = { workspace = true, features = ["std"] } sc-consensus = { workspace = true } sc-cli = { workspace = true } sc-client-api = { workspace = true } @@ -48,26 +48,30 @@ sc-executor = { workspace = true } sc-service = { workspace = true } sc-telemetry = { workspace = true } sc-transaction-pool = { workspace = true } -sp-transaction-pool = { workspace = true, features = [ "std" ] } +sp-transaction-pool = { workspace = true, features = ["std"] } sc-network = { workspace = true } sc-network-common = { workspace = true } sc-basic-authorship = { workspace = true } -sp-timestamp = { workspace = true, features = [ "std" ] } +sp-timestamp = { workspace = true, features = ["std"] } +sp-inherents = { workspace = true } sp-blockchain = { workspace = true } -sp-block-builder = { workspace = true, features = [ "std" ] } -sp-keystore = { workspace = true, features = [ "std" ] } +sp-block-builder = { workspace = true, features = ["std"] } +sp-keyring = { workspace = true } +sp-keystore = { workspace = true, features = ["std"] } sc-chain-spec = { workspace = true } sc-rpc = { workspace = true } sc-tracing = { workspace = true } -sp-offchain = { workspace = true, features = [ "std" ] } -sp-api = { workspace = true, features = [ "std" ] } -sp-consensus-aura = { workspace = true, features = [ "std" ] } +sp-offchain = { workspace = true, features = ["std"] } +sp-api = { workspace = true, features = ["std"] } +sp-consensus-aura = { workspace = true, features = ["std"] } sc-sysinfo = { workspace = true } sp-serializer = { workspace = true } substrate-prometheus-endpoint = { workspace = true } try-runtime-cli = { workspace = true, optional = true } sc-transaction-pool-api = { workspace = true } +frame-system = { workspace = true } frame-rpc-system = { workspace = true } +pallet-asset-tx-payment = { workspace = true } pallet-transaction-payment-rpc = { workspace = true } substrate-state-trie-migration-rpc = { workspace = true } @@ -75,16 +79,16 @@ substrate-state-trie-migration-rpc = { workspace = true } polkadot-cli = { workspace = true } polkadot-primitives = { workspace = true } polkadot-service = { workspace = true } -xcm = { workspace = true, features = [ "std" ] } +xcm = { workspace = true, features = ["std"] } # Cumulus -cumulus-client-cli ={ workspace = true } +cumulus-client-cli = { workspace = true } cumulus-client-consensus-aura = { workspace = true } cumulus-client-consensus-relay-chain = { workspace = true } cumulus-client-consensus-common = { workspace = true } cumulus-client-service = { workspace = true } cumulus-client-network = { workspace = true } -cumulus-primitives-core = { workspace = true, features = [ "std" ] } +cumulus-primitives-core = { workspace = true, features = ["std"] } cumulus-primitives-parachain-inherent = { workspace = true } cumulus-relay-chain-interface = { workspace = true } @@ -105,7 +109,7 @@ polkadot-cli = { workspace = true } [features] default = [] runtime-benchmarks = [ - "trappist-runtime/runtime-benchmarks", + "trappist-runtime/runtime-benchmarks", "stout-runtime/runtime-benchmarks", "polkadot-cli/runtime-benchmarks" ] diff --git a/node/src/benchmarking.rs b/node/src/benchmarking.rs new file mode 100644 index 00000000..c66b9c8d --- /dev/null +++ b/node/src/benchmarking.rs @@ -0,0 +1,176 @@ +use std::{sync::Arc, time::Duration}; + +use cumulus_primitives_parachain_inherent::MockValidationDataInherentDataProvider; +use parity_scale_codec::Encode; +use sc_client_api::BlockBackend; +use sp_core::Pair; +use sp_inherents::{InherentData, InherentDataProvider}; +use sp_keyring::Sr25519Keyring; +use sp_runtime::{generic, OpaqueExtrinsic, SaturatedConversion}; + +use crate::service::ParachainClient; + +/// Generates `System::Remark` extrinsics for the benchmarks. +/// +/// Note: Should only be used for benchmarking. +pub struct RemarkBuilder { + client: Arc>, +} + +impl RemarkBuilder { + /// Creates a new [`Self`] from the given client. + pub fn new(client: Arc>) -> Self { + Self { client } + } +} + +impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder { + fn pallet(&self) -> &str { + "system" + } + + fn extrinsic(&self) -> &str { + "remark" + } + + fn build(&self, nonce: u32) -> Result { + use trappist_runtime as runtime; + + let call: runtime::RuntimeCall = runtime::SystemCall::remark { remark: vec![] }.into(); + let period = runtime::BlockHashCount::get() + .checked_next_power_of_two() + .map(|c| c / 2) + .unwrap_or(2) as u64; + let best_block = self.client.chain_info().best_number; + let tip = 0; + let extra: runtime::SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from(generic::Era::mortal( + period, + best_block.saturated_into(), + )), + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + pallet_asset_tx_payment::ChargeAssetTxPayment::::from(tip, None), + ); + + let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists"); + let best_hash = self.client.chain_info().best_hash; + let payload = runtime::SignedPayload::from_raw( + call.clone(), + extra.clone(), + ( + (), + runtime::VERSION.spec_version, + runtime::VERSION.transaction_version, + genesis_hash, + best_hash, + (), + (), + (), + ), + ); + + let sender = Sr25519Keyring::Bob.pair(); + let signature = payload.using_encoded(|x| sender.sign(x)); + let extrinsic = runtime::UncheckedExtrinsic::new_signed( + call, + sp_runtime::AccountId32::from(sender.public()).into(), + runtime::Signature::Sr25519(signature), + extra, + ); + + Ok(extrinsic.into()) + } +} + +impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder { + fn pallet(&self) -> &str { + "system" + } + + fn extrinsic(&self) -> &str { + "remark" + } + + fn build(&self, nonce: u32) -> Result { + use stout_runtime as runtime; + + let call: runtime::RuntimeCall = runtime::SystemCall::remark { remark: vec![] }.into(); + let period = runtime::BlockHashCount::get() + .checked_next_power_of_two() + .map(|c| c / 2) + .unwrap_or(2) as u64; + let best_block = self.client.chain_info().best_number; + let tip = 0; + let extra: runtime::SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from(generic::Era::mortal( + period, + best_block.saturated_into(), + )), + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + pallet_asset_tx_payment::ChargeAssetTxPayment::::from(tip, None), + ); + + let genesis_hash = self.client.block_hash(0).ok().flatten().expect("Genesis block exists"); + let best_hash = self.client.chain_info().best_hash; + let payload = runtime::SignedPayload::from_raw( + call.clone(), + extra.clone(), + ( + (), + runtime::VERSION.spec_version, + runtime::VERSION.transaction_version, + genesis_hash, + best_hash, + (), + (), + (), + ), + ); + + let sender = Sr25519Keyring::Bob.pair(); + let signature = payload.using_encoded(|x| sender.sign(x)); + let extrinsic = runtime::UncheckedExtrinsic::new_signed( + call, + sp_runtime::AccountId32::from(sender.public()).into(), + runtime::Signature::Sr25519(signature), + extra, + ); + + Ok(extrinsic.into()) + } +} + +/// Generates inherent data for the `benchmark overhead` command. +pub fn inherent_benchmark_data() -> sc_cli::Result { + let mut inherent_data = InherentData::new(); + + let timestamp = sp_timestamp::InherentDataProvider::new(Duration::ZERO.into()); + futures::executor::block_on(timestamp.provide_inherent_data(&mut inherent_data)) + .map_err(|e| format!("creating inherent data: {e:?}"))?; + + let parachain_inherent = MockValidationDataInherentDataProvider { + current_para_block: 1, + relay_offset: 0, + relay_blocks_per_para_block: 1, + para_blocks_per_relay_epoch: 0, + relay_randomness_config: (), + xcm_config: Default::default(), + raw_downward_messages: Default::default(), + raw_horizontal_messages: Default::default(), + }; + + futures::executor::block_on(parachain_inherent.provide_inherent_data(&mut inherent_data)) + .map_err(|e| format!("creating inherent data: {e:?}"))?; + + Ok(inherent_data) +} diff --git a/node/src/command.rs b/node/src/command.rs index e5d6f6c5..3abf424b 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -15,6 +15,7 @@ // along with Cumulus. If not, see . use crate::{ + benchmarking::{inherent_benchmark_data, RemarkBuilder}, chain_spec, cli::{Cli, RelayChainCli, Subcommand}, service::{new_partial, Block, StoutRuntimeExecutor, TrappistRuntimeExecutor}, @@ -34,24 +35,83 @@ use sp_core::hexdisplay::HexDisplay; use sp_runtime::traits::{AccountIdConversion, Block as BlockT}; use std::{net::SocketAddr, path::PathBuf}; +/// Dispatches the code to the currently selected runtime. +macro_rules! dispatch_runtime { + ($runtime:expr, |$alias: ident| $code:expr) => { + match $runtime { + Runtime::Trappist => { + #[allow(unused_imports)] + use trappist_runtime as $alias; + + $code + }, + Runtime::Stout => { + #[allow(unused_imports)] + use stout_runtime as $alias; + + $code + }, + } + }; +} + +/// Generates boilerplate code for constructing partial node for the runtimes that are supported +/// by the benchmarks. +macro_rules! construct_partial { + ($config:expr, |$partial:ident| $code:expr) => { + dispatch_runtime!($config.chain_spec.runtime(), |rt| { + let $partial = new_partial::( + &$config, + crate::service::aura_build_import_queue::<_, AuraId>, + )?; + + $code + }) + }; +} + +/// Generates boilerplate code for async run on partial node. +macro_rules! construct_async_run { + (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{ + let runner = $cli.create_runner($cmd)?; + construct_partial!(runner.config(), |$components| { + runner.async_run(|$config| { + let task_manager = $components.task_manager; + { $( $code )* }.map(|v| (v, task_manager)) + }) + }) + }}; +} + /// 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, } +impl From<&str> for Runtime { + fn from(value: &str) -> Self { + if value.starts_with("trappist") { + Runtime::Trappist + } else if value.starts_with("stout") { + Runtime::Stout + } else { + log::warn!("No specific runtime was recognized for ChainSpec's id: '{value}', so `Trappist` will be used as default."); + Runtime::default() + } + } +} + trait RuntimeResolver { fn runtime(&self) -> Runtime; } impl RuntimeResolver for dyn ChainSpec { fn runtime(&self) -> Runtime { - runtime(self.id()) + self.id().into() } } @@ -68,25 +128,14 @@ impl RuntimeResolver for PathBuf { 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() + chain_spec.id.as_str().into() } } fn load_spec(id: &str) -> std::result::Result, String> { Ok(match id { - "dev" => Box::new(chain_spec::trappist::development_config()), + "dev" | "trappist-dev" => Box::new(chain_spec::trappist::development_config()), + "stout-dev" => unimplemented!("stout-dev chain spec is not available yet"), "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] @@ -96,7 +145,7 @@ fn load_spec(id: &str) -> std::result::Result, String> { let path: PathBuf = path.into(); match path.runtime() { Runtime::Stout => Box::new(chain_spec::stout::ChainSpec::from_json_file(path)?), - Runtime::Default | Runtime::Trappist => + Runtime::Trappist => Box::new(chain_spec::trappist::ChainSpec::from_json_file(path)?), } }, @@ -139,10 +188,7 @@ impl SubstrateCli for Cli { } 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, - } + dispatch_runtime!(chain_spec.runtime(), |runtime| &runtime::VERSION) } } @@ -186,57 +232,6 @@ impl SubstrateCli for RelayChainCli { } } -/// Creates partial components for the runtimes that are supported by the benchmarks. -macro_rules! construct_benchmark_partials { - ($config:expr, |$partials:ident| $code:expr) => { - match $config.chain_spec.runtime() { - Runtime::Trappist => { - let $partials = new_partial::( - &$config, - crate::service::aura_build_import_queue::<_, AuraId>, - )?; - $code - }, - Runtime::Stout => { - let $partials = new_partial::( - &$config, - crate::service::aura_build_import_queue::<_, AuraId>, - )?; - $code - }, - _ => Err("The chain is not supported".into()), - } - }; -} - -macro_rules! construct_async_run { - (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{ - let runner = $cli.create_runner($cmd)?; - match runner.config().chain_spec.runtime() { - Runtime::Default | Runtime::Trappist => { - runner.async_run(|$config| { - let $components = new_partial::( - &$config, - crate::service::aura_build_import_queue::<_, AuraId>, - )?; - let task_manager = $components.task_manager; - { $( $code )* }.map(|v| (v, task_manager)) - }) - }, - Runtime::Stout => { - runner.async_run(|$config| { - let $components = new_partial::( - &$config, - crate::service::aura_build_import_queue::<_, AuraId>, - )?; - let task_manager = $components.task_manager; - { $( $code )* }.map(|v| (v, task_manager)) - }) - } - } - }} -} - /// Parse command line arguments into service configuration. pub fn run() -> Result<()> { let cli = Cli::from_args(); @@ -247,7 +242,7 @@ pub fn run() -> Result<()> { runner.sync_run(|config| cmd.run(config.chain_spec, config.network)) }, Some(Subcommand::CheckBlock(cmd)) => { - construct_async_run!(|components, cli, cmd, config| { + construct_async_run!(|components, cli, cmd, _config| { Ok(cmd.run(components.client, components.import_queue)) }) }, @@ -262,11 +257,11 @@ pub fn run() -> Result<()> { }) }, Some(Subcommand::ImportBlocks(cmd)) => { - construct_async_run!(|components, cli, cmd, config| { + 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| { + Some(Subcommand::Revert(cmd)) => construct_async_run!(|components, cli, cmd, _config| { Ok(cmd.run(components.client, components.backend, None)) }), Some(Subcommand::PurgeChain(cmd)) => { @@ -283,7 +278,7 @@ pub fn run() -> Result<()> { &polkadot_cli, config.tokio_handle.clone(), ) - .map_err(|err| format!("Relay chain argument error: {}", err))?; + .map_err(|err| format!("Relay chain argument error: {err}"))?; cmd.run(config, polkadot_config) }) @@ -305,52 +300,60 @@ pub fn run() -> Result<()> { }, Some(Subcommand::Benchmark(cmd)) => { let runner = cli.create_runner(cmd)?; - - // Switch on the concrete benchmark sub-command- - match cmd { - BenchmarkCmd::Pallet(cmd) => - if cfg!(feature = "runtime-benchmarks") { - runner.sync_run(|config| match config.chain_spec.runtime() { + runner.sync_run(|config| { + // Switch on the concrete benchmark sub-command + match cmd { + BenchmarkCmd::Pallet(cmd) => { + if !cfg!(feature = "runtime-benchmarks") { + return Err("Benchmarking wasn't enabled when building the node. \ + You can enable it with `--features runtime-benchmarks`." + .into()) + } + + 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( + BenchmarkCmd::Block(cmd) => { + construct_partial!(config, |partial| cmd.run(partial.client)) + }, + #[cfg(not(feature = "runtime-benchmarks"))] + BenchmarkCmd::Storage(_) => 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 = "runtime-benchmarks")] + BenchmarkCmd::Storage(cmd) => { + construct_partial!(config, |partial| { + let db = partial.backend.expose_db(); + let storage = partial.backend.expose_storage(); + + cmd.run(config, partial.client, db, storage) + }) + }, + BenchmarkCmd::Machine(cmd) => + cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()), + BenchmarkCmd::Overhead(cmd) => { + construct_partial!(config, |partial| { + let ext_builder = RemarkBuilder::new(partial.client.clone()); + + cmd.run( + config, + partial.client, + inherent_benchmark_data()?, + Vec::new(), + &ext_builder, + ) + }) + }, + // 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)) => { @@ -373,7 +376,6 @@ pub fn run() -> Result<()> { Runtime::Stout => runner.async_run(|_| { Ok((cmd.run::>(), task_manager)) }), - _ => Err("Chain doesn't support try-runtime".into()), } }, #[cfg(not(feature = "try-runtime"))] @@ -388,7 +390,7 @@ pub fn run() -> Result<()> { 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); + let _ = std::fs::create_dir_all(database_path); sc_sysinfo::gather_hwbench(Some(database_path)) }) } else { @@ -397,7 +399,7 @@ pub fn run() -> Result<()> { 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.")?; + .ok_or("Could not find parachain extension in chain-spec.")?; let polkadot_cli = RelayChainCli::new( &config, @@ -413,44 +415,35 @@ pub fn run() -> Result<()> { let block: crate::service::Block = generate_genesis_block(&*config.chain_spec, state_version) - .map_err(|e| format!("{:?}", e))?; + .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))?; + .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 { + if !(collator_options.relay_chain_rpc_urls.is_empty() || cli.relaychain_args.is_empty()) { 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_aura_node::< - trappist_runtime::RuntimeApi, - AuraId, - >(config, polkadot_config, collator_options, id, hwbench) - .await - .map(|r| r.0) - .map_err(Into::into), - Runtime::Stout => crate::service::start_aura_node::< - stout_runtime::RuntimeApi, - AuraId, - >(config, polkadot_config, collator_options, id, hwbench) + dispatch_runtime!(config.chain_spec.runtime(), |runtime| { + crate::service::start_aura_node::( + 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()), - } + .map_err(Into::into) + }) }) }, } diff --git a/node/src/main.rs b/node/src/main.rs index d114d2f5..d05f0488 100644 --- a/node/src/main.rs +++ b/node/src/main.rs @@ -22,6 +22,7 @@ mod chain_spec; #[macro_use] mod service; +mod benchmarking; mod cli; mod command; mod rpc; diff --git a/node/src/service.rs b/node/src/service.rs index dabe31bd..b8011471 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -69,7 +69,7 @@ type HostFunctions = sp_io::SubstrateHostFunctions; type HostFunctions = (sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions); -type ParachainClient = TFullClient>; +pub type ParachainClient = TFullClient>; type ParachainBackend = TFullBackend; @@ -106,10 +106,7 @@ impl sc_executor::NativeExecutionDispatch for TrappistRuntimeExecutor { } } -/// 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. +/// Creates a new partial node. pub fn new_partial( config: &Configuration, build_import_queue: BIQ, diff --git a/primitives/xcm/src/lib.rs b/primitives/xcm/src/lib.rs index b300a786..65e39ed1 100644 --- a/primitives/xcm/src/lib.rs +++ b/primitives/xcm/src/lib.rs @@ -4,6 +4,7 @@ use frame_support::{ sp_runtime::{SaturatedConversion, Saturating}, traits::{fungibles::Inspect, Currency}, }; +#[cfg(not(test))] use sp_runtime::DispatchResult; use sp_std::{borrow::Borrow, marker::PhantomData}; use xcm::latest::{ diff --git a/runtime/stout/src/lib.rs b/runtime/stout/src/lib.rs index 5cf15755..ca2216ee 100644 --- a/runtime/stout/src/lib.rs +++ b/runtime/stout/src/lib.rs @@ -68,12 +68,14 @@ pub use parachains_common::{ }; use xcm_config::{CollatorSelectionUpdateOrigin, RelayLocation}; +pub use frame_system::Call as SystemCall; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; // Polkadot imports use pallet_xcm::{EnsureXcm, IsMajorityOfBody}; -use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; +pub use polkadot_runtime_common::BlockHashCount; +use polkadot_runtime_common::SlowAdjustingFeeUpdate; use xcm::latest::prelude::BodyId; pub const MICROUNIT: Balance = 1_000_000; @@ -100,6 +102,8 @@ pub type SignedExtra = ( /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +/// The payload being signed in transactions. +pub type SignedPayload = generic::SignedPayload; /// Extrinsic type that has already been checked. pub type CheckedExtrinsic = generic::CheckedExtrinsic; /// Executive: handles dispatch to the various modules. @@ -832,7 +836,6 @@ impl_runtime_apis! { let params = (&config, &whitelist); add_benchmarks!(params, batches); - if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) } } diff --git a/runtime/trappist/Cargo.toml b/runtime/trappist/Cargo.toml index d833adce..1c4cda66 100644 --- a/runtime/trappist/Cargo.toml +++ b/runtime/trappist/Cargo.toml @@ -15,7 +15,7 @@ substrate-wasm-builder = { workspace = true } [dependencies] hex-literal = { workspace = true, optional = true } -parity-scale-codec = { workspace = true, features = [ "derive" ] } +parity-scale-codec = { workspace = true, features = ["derive"] } log = { workspace = true, default-features = false } scale-info = { workspace = true } serde = { workspace = true, optional = true } @@ -35,10 +35,11 @@ sp-session = { workspace = true } sp-std = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } +sp-weights = { workspace = true } ## Substrate FRAME Dependencies -frame-benchmarking = { workspace = true, optional = true} -frame-try-runtime = { workspace = true, optional = true} +frame-benchmarking = { workspace = true, optional = true } +frame-try-runtime = { workspace = true, optional = true } frame-executive = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } @@ -102,7 +103,7 @@ pallet-dex-rpc-runtime-api = { workspace = true } pallet-chess = { workspace = true } # Trappist Pallets -pallet-asset-registry = {workspace = true } +pallet-asset-registry = { workspace = true } trappist-runtime-benchmarks = { workspace = true } pallet-lockdown-mode = { workspace = true } @@ -125,6 +126,7 @@ std = [ "sp-std/std", "sp-transaction-pool/std", "sp-version/std", + "sp-weights/std", "frame-executive/std", "frame-support/std", "frame-system/std", diff --git a/runtime/trappist/src/lib.rs b/runtime/trappist/src/lib.rs index c41e8c6f..bddfa5e9 100644 --- a/runtime/trappist/src/lib.rs +++ b/runtime/trappist/src/lib.rs @@ -30,12 +30,10 @@ use frame_support::{ AsEnsureOriginWithArg, ConstU128, ConstU16, ConstU32, ConstU64, Contains, EitherOfDiverse, EqualPrivilegeOnly, }, - weights::{ - constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}, - ConstantMultiplier, Weight, - }, + weights::{constants::RocksDbWeight, ConstantMultiplier, Weight}, PalletId, }; +pub use frame_system::Call as SystemCall; use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, EnsureSigned, @@ -48,10 +46,8 @@ pub use parachains_common::{ Header, Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, MINUTES, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; - -use impls::{LockdownDmpHandler, RuntimeBlackListedCalls, XcmExecutionManager}; - -use polkadot_runtime_common::{prod_or_fast, BlockHashCount, SlowAdjustingFeeUpdate}; +pub use polkadot_runtime_common::BlockHashCount; +use polkadot_runtime_common::{prod_or_fast, SlowAdjustingFeeUpdate}; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, ConstU8, OpaqueMetadata}; #[cfg(any(feature = "std", test))] @@ -69,9 +65,11 @@ use sp_version::RuntimeVersion; use xcm::latest::prelude::BodyId; use constants::{currency::*, fee::WeightToFee}; -use impls::DealWithFees; +use impls::{DealWithFees, LockdownDmpHandler, RuntimeBlackListedCalls, XcmExecutionManager}; use xcm_config::{CollatorSelectionUpdateOrigin, RelayLocation}; +use crate::weights::{block_weights::BlockExecutionWeight, extrinsic_weights::ExtrinsicBaseWeight}; + // Make the WASM binary available. #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); @@ -106,6 +104,8 @@ pub type SignedExtra = ( /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +/// The payload being signed in transactions. +pub type SignedPayload = generic::SignedPayload; /// Extrinsic type that has already been checked. pub type CheckedExtrinsic = generic::CheckedExtrinsic; @@ -1128,7 +1128,6 @@ impl_runtime_apis! { let params = (&config, &whitelist); add_benchmarks!(params, batches); - if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) } } diff --git a/runtime/trappist/src/weights/block_weights.rs b/runtime/trappist/src/weights/block_weights.rs new file mode 100644 index 00000000..f27c0d9b --- /dev/null +++ b/runtime/trappist/src/weights/block_weights.rs @@ -0,0 +1,61 @@ +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-06-08 (Y/M/D) +//! HOSTNAME: `kalan-x1x`, CPU: `12th Gen Intel(R) Core(TM) i7-12800H` +//! +//! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Trappist Development` +//! WARMUPS: `10`, REPEAT: `100` +//! WEIGHT-PATH: `./runtime/trappist/src/weights` +//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0` + +// Executed Command: +// target/debug/trappist-node +// benchmark +// overhead +// --chain +// dev +// --weight-path=./runtime/trappist/src/weights + +use sp_core::parameter_types; +use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight}; + +parameter_types! { + /// Time to execute an empty block. + /// Calculated by multiplying the *Average* with `1.0` and adding `0`. + /// + /// Stats nanoseconds: + /// Min, Max: 5_120_602, 10_113_574 + /// Average: 6_901_058 + /// Median: 6_276_001 + /// Std-Dev: 1393716.66 + /// + /// Percentiles nanoseconds: + /// 99th: 9_958_901 + /// 95th: 8_509_417 + /// 75th: 8_216_945 + pub const BlockExecutionWeight: Weight = + Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(6_901_058)); +} + +#[cfg(test)] +mod test_weights { + use sp_weights::constants; + + /// Checks that the weight exists and is sane. + // NOTE: If this test fails but you are sure that the generated values are fine, + // you can delete it. + #[test] + fn sane() { + let w = super::BlockExecutionWeight::get(); + + // At least 100 µs. + assert!( + w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS, + "Weight should be at least 100 µs." + ); + // At most 50 ms. + assert!( + w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS, + "Weight should be at most 50 ms." + ); + } +} diff --git a/runtime/trappist/src/weights/extrinsic_weights.rs b/runtime/trappist/src/weights/extrinsic_weights.rs new file mode 100644 index 00000000..400163a0 --- /dev/null +++ b/runtime/trappist/src/weights/extrinsic_weights.rs @@ -0,0 +1,61 @@ +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-06-08 (Y/M/D) +//! HOSTNAME: `kalan-x1x`, CPU: `12th Gen Intel(R) Core(TM) i7-12800H` +//! +//! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Trappist Development` +//! WARMUPS: `10`, REPEAT: `100` +//! WEIGHT-PATH: `./runtime/trappist/src/weights` +//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0` + +// Executed Command: +// target/debug/trappist-node +// benchmark +// overhead +// --chain +// dev +// --weight-path=./runtime/trappist/src/weights + +use sp_core::parameter_types; +use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight}; + +parameter_types! { + /// Time to execute a NO-OP extrinsic, for example `System::remark`. + /// Calculated by multiplying the *Average* with `1.0` and adding `0`. + /// + /// Stats nanoseconds: + /// Min, Max: 1_538_002, 2_494_865 + /// Average: 1_980_785 + /// Median: 2_006_809 + /// Std-Dev: 131423.95 + /// + /// Percentiles nanoseconds: + /// 99th: 2_378_849 + /// 95th: 2_080_265 + /// 75th: 2_030_767 + pub const ExtrinsicBaseWeight: Weight = + Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(1_980_785)); +} + +#[cfg(test)] +mod test_weights { + use sp_weights::constants; + + /// Checks that the weight exists and is sane. + // NOTE: If this test fails but you are sure that the generated values are fine, + // you can delete it. + #[test] + fn sane() { + let w = super::ExtrinsicBaseWeight::get(); + + // At least 10 µs. + assert!( + w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS, + "Weight should be at least 10 µs." + ); + // At most 1 ms. + assert!( + w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, + "Weight should be at most 1 ms." + ); + } +} diff --git a/runtime/trappist/src/weights/mod.rs b/runtime/trappist/src/weights/mod.rs index 2aabac36..8eae0e9c 100644 --- a/runtime/trappist/src/weights/mod.rs +++ b/runtime/trappist/src/weights/mod.rs @@ -3,7 +3,9 @@ use xcm_primitives::DropAssetsWeigher; use crate::Runtime; -mod trappist_runtime_benchmarks; +pub mod block_weights; +pub mod extrinsic_weights; +pub mod trappist_runtime_benchmarks; pub mod xcm; pub struct TrappistDropAssetsWeigher(); diff --git a/templates/xcm-bench-template.hbs b/templates/xcm-bench-template.hbs new file mode 100644 index 00000000..0c11d7bd --- /dev/null +++ b/templates/xcm-bench-template.hbs @@ -0,0 +1,51 @@ +//! Autogenerated weights for `{{pallet}}` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION {{version}} +//! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: {{cmd.repeat}}, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}` +//! HOSTNAME: `{{hostname}}`, CPU: `{{cpuname}}` +//! EXECUTION: {{cmd.execution}}, WASM-EXECUTION: {{cmd.wasm_execution}}, CHAIN: {{cmd.chain}}, DB CACHE: {{cmd.db_cache}} + +// Executed Command: +{{#each args as |arg|}} +// {{arg}} +{{/each}} + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weights for `{{pallet}}`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + {{#each benchmarks as |benchmark|}} + {{#each benchmark.comments as |comment|}} + // {{comment}} + {{/each}} + pub(crate) fn {{benchmark.name~}} + ( + {{~#each benchmark.components as |c| ~}} + {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} + ) -> Weight { + Weight::from_ref_time({{underscore benchmark.base_weight}} as u64) + {{#each benchmark.component_weight as |cw|}} + // Standard Error: {{underscore cw.error}} + .saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}} as u64)) + {{/each}} + {{#if (ne benchmark.base_reads "0")}} + .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as u64)) + {{/if}} + {{#each benchmark.component_reads as |cr|}} + .saturating_add(T::DbWeight::get().reads(({{cr.slope}} as u64).saturating_mul({{cr.name}} as u64))) + {{/each}} + {{#if (ne benchmark.base_writes "0")}} + .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as u64)) + {{/if}} + {{#each benchmark.component_writes as |cw|}} + .saturating_add(T::DbWeight::get().writes(({{cw.slope}} as u64).saturating_mul({{cw.name}} as u64))) + {{/each}} + } + {{/each}} +}