diff --git a/Cargo.lock b/Cargo.lock index 81000c6053..b17d0b6a1d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -776,6 +776,11 @@ name = "cc" version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" +dependencies = [ + "jobserver", + "libc", + "once_cell", +] [[package]] name = "cesu8" @@ -1048,6 +1053,50 @@ dependencies = [ "libc", ] +[[package]] +name = "cranelift-bforest" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1277fbfa94bc82c8ec4af2ded3e639d49ca5f7f3c7eeab2c66accd135ece4e70" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6e8c31ad3b2270e9aeec38723888fe1b0ace3bea2b06b3f749ccf46661d3220" +dependencies = [ + "bumpalo", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-entity", + "cranelift-isle", + "gimli 0.27.3", + "hashbrown 0.13.2", + "log", + "regalloc2", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ac5ac30d62b2d66f12651f6b606dbdfd9c2cfd0908de6b387560a277c5c9da" +dependencies = [ + "cranelift-codegen-shared", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd82b8b376247834b59ed9bdc0ddeb50f517452827d4a11bccf5937b213748b8" + [[package]] name = "cranelift-entity" version = "0.95.1" @@ -1057,6 +1106,51 @@ dependencies = [ "serde", ] +[[package]] +name = "cranelift-frontend" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a25d9d0a0ae3079c463c34115ec59507b4707175454f0eee0891e83e30e82d" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-isle" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80de6a7d0486e4acbd5f9f87ec49912bf4c8fb6aea00087b989685460d4469ba" + +[[package]] +name = "cranelift-native" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6b03e0e03801c4b3fd8ce0758a94750c07a44e7944cc0ffbf0d3f2e7c79b00" +dependencies = [ + "cranelift-codegen", + "libc", + "target-lexicon", +] + +[[package]] +name = "cranelift-wasm" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff3220489a3d928ad91e59dd7aeaa8b3de18afb554a6211213673a71c90737ac" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "itertools 0.10.5", + "log", + "smallvec", + "wasmparser", + "wasmtime-types", +] + [[package]] name = "crc32fast" version = "1.4.0" @@ -1384,6 +1478,27 @@ dependencies = [ "subtle", ] +[[package]] +name = "directories-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "docify" version = "0.2.8" @@ -1407,7 +1522,7 @@ dependencies = [ "regex", "syn 2.0.60", "termcolor", - "toml", + "toml 0.8.12", "walkdir", ] @@ -1538,6 +1653,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "env_logger" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + [[package]] name = "environmental" version = "1.1.4" @@ -1654,6 +1782,16 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38793c55593b33412e3ae40c2c9781ffaa6f438f6f8c10f24e71846fbd7ae01e" +[[package]] +name = "file-per-thread-logger" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84f2e425d9790201ba4af4630191feac6dcc98765b118d4d18e91d23c2353866" +dependencies = [ + "env_logger", + "log", +] + [[package]] name = "finito" version = "0.1.0" @@ -1842,6 +1980,15 @@ dependencies = [ "slab", ] +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "generate-custom-metadata" version = "0.37.0" @@ -2071,6 +2218,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -2185,6 +2338,12 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hyper" version = "1.3.1" @@ -2394,7 +2553,7 @@ dependencies = [ "regex", "scale-info", "serde", - "sp-core", + "sp-core 31.0.0", "substrate-runner", "subxt", "subxt-codegen", @@ -2420,6 +2579,17 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi 0.4.0", + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "itertools" version = "0.10.5" @@ -2429,6 +2599,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.12.1" @@ -2464,6 +2643,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" +[[package]] +name = "jobserver" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.70" @@ -2684,6 +2872,16 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.5.0", + "libc", +] + [[package]] name = "libsecp256k1" version = "0.7.1" @@ -3037,9 +3235,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.9" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" +checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" dependencies = [ "arrayvec 0.7.4", "bitvec", @@ -3052,16 +3250,22 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.9" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" +checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" dependencies = [ - "proc-macro-crate 2.0.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 1.0.109", ] +[[package]] +name = "parity-wasm" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" + [[package]] name = "parking" version = "2.2.0" @@ -3184,6 +3388,12 @@ dependencies = [ "spki", ] +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + [[package]] name = "platforms" version = "3.4.0" @@ -3218,6 +3428,28 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "polkavm" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a3693e5efdb2bf74e449cd25fd777a28bd7ed87e41f5d5da75eb31b4de48b94" +dependencies = [ + "libc", + "log", + "polkavm-assembler", + "polkavm-common 0.9.0", + "polkavm-linux-raw", +] + +[[package]] +name = "polkavm-assembler" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa96d6d868243acc12de813dd48e756cbadcc8e13964c70d272753266deadc1" +dependencies = [ + "log", +] + [[package]] name = "polkavm-common" version = "0.8.0" @@ -3229,6 +3461,9 @@ name = "polkavm-common" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d9428a5cfcc85c5d7b9fc4b6a18c4b802d0173d768182a51cc7751640f08b92" +dependencies = [ + "log", +] [[package]] name = "polkavm-derive" @@ -3292,6 +3527,12 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "polkavm-linux-raw" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26e85d3456948e650dff0cfc85603915847faf893ed1e66b020bb82ef4557120" + [[package]] name = "polling" version = "3.7.0" @@ -3367,15 +3608,6 @@ dependencies = [ "toml_edit 0.19.15", ] -[[package]] -name = "proc-macro-crate" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" -dependencies = [ - "toml_edit 0.20.7", -] - [[package]] name = "proc-macro-crate" version = "3.1.0" @@ -3542,6 +3774,17 @@ dependencies = [ "bitflags 2.5.0", ] +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + [[package]] name = "ref-cast" version = "1.0.22" @@ -3562,6 +3805,18 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "regalloc2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80535183cae11b149d618fbd3c37e38d7cda589d82d7769e196ca9a9042d7621" +dependencies = [ + "fxhash", + "log", + "slice-group-by", + "smallvec", +] + [[package]] name = "regex" version = "1.10.6" @@ -3835,6 +4090,87 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "sc-allocator" +version = "29.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b975ee3a95eaacb611e7b415737a7fa2db4d8ad7b880cc1b97371b04e95c7903" +dependencies = [ + "log", + "sp-core 34.0.0", + "sp-wasm-interface 21.0.0", + "thiserror", +] + +[[package]] +name = "sc-executor" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "963c1ebaf6bd0bc4ab0603c3cd7200ed25230a897a3217928a559fedce6019df" +dependencies = [ + "parity-scale-codec", + "parking_lot", + "sc-executor-common", + "sc-executor-polkavm", + "sc-executor-wasmtime", + "schnellru", + "sp-api", + "sp-core 34.0.0", + "sp-externalities 0.29.0", + "sp-io 38.0.0", + "sp-panic-handler", + "sp-runtime-interface 28.0.0", + "sp-trie 37.0.0", + "sp-version", + "sp-wasm-interface 21.0.0", + "tracing", +] + +[[package]] +name = "sc-executor-common" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c3b703a33dcb7cddf19176fdf12294b9a6408125836b0f4afee3e6969e7f190" +dependencies = [ + "polkavm", + "sc-allocator", + "sp-maybe-compressed-blob", + "sp-wasm-interface 21.0.0", + "thiserror", + "wasm-instrument", +] + +[[package]] +name = "sc-executor-polkavm" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26fe58d9cacfab73e5595fa84b80f7bd03efebe54a0574daaeb221a1d1f7ab80" +dependencies = [ + "log", + "polkavm", + "sc-executor-common", + "sp-wasm-interface 21.0.0", +] + +[[package]] +name = "sc-executor-wasmtime" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cd498f2f77ec1f861c30804f5bfd796d4afcc8ce44ea1f11bfbe2847551d161" +dependencies = [ + "anyhow", + "cfg-if", + "libc", + "log", + "parking_lot", + "rustix 0.36.17", + "sc-allocator", + "sc-executor-common", + "sp-runtime-interface 28.0.0", + "sp-wasm-interface 21.0.0", + "wasmtime", +] + [[package]] name = "scale-bits" version = "0.6.0" @@ -4298,6 +4634,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slice-group-by" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" + [[package]] name = "smallvec" version = "1.13.2" @@ -4454,22 +4796,73 @@ dependencies = [ ] [[package]] -name = "sp-application-crypto" -version = "33.0.0" +name = "sp-api" +version = "34.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13ca6121c22c8bd3d1dce1f05c479101fd0d7b159bef2a3e8c834138d839c75c" +checksum = "bbce492e0482134128b7729ea36f5ef1a9f9b4de2d48ff8dde7b5e464e28ce75" dependencies = [ + "docify", + "hash-db", + "log", "parity-scale-codec", "scale-info", - "serde", - "sp-core", - "sp-io", - "sp-std", + "sp-api-proc-macro", + "sp-core 34.0.0", + "sp-externalities 0.29.0", + "sp-metadata-ir", + "sp-runtime 39.0.0", + "sp-runtime-interface 28.0.0", + "sp-state-machine 0.43.0", + "sp-trie 37.0.0", + "sp-version", + "thiserror", ] [[package]] -name = "sp-arithmetic" -version = "25.0.0" +name = "sp-api-proc-macro" +version = "20.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9aadf9e97e694f0e343978aa632938c5de309cbcc8afed4136cb71596737278" +dependencies = [ + "Inflector", + "blake2", + "expander", + "proc-macro-crate 3.1.0", + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "sp-application-crypto" +version = "33.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13ca6121c22c8bd3d1dce1f05c479101fd0d7b159bef2a3e8c834138d839c75c" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-core 31.0.0", + "sp-io 33.0.0", + "sp-std", +] + +[[package]] +name = "sp-application-crypto" +version = "38.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8133012faa5f75b2f0b1619d9f720c1424ac477152c143e5f7dbde2fe1a958" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-core 34.0.0", + "sp-io 38.0.0", +] + +[[package]] +name = "sp-arithmetic" +version = "25.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "910c07fa263b20bf7271fdd4adcb5d3217dfdac14270592e0780223542e7e114" dependencies = [ @@ -4482,6 +4875,22 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "sp-arithmetic" +version = "26.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46d0d0a4c591c421d3231ddd5e27d828618c24456d51445d21a1f79fcee97c23" +dependencies = [ + "docify", + "integer-sqrt", + "num-traits", + "parity-scale-codec", + "scale-info", + "serde", + "sp-std", + "static_assertions", +] + [[package]] name = "sp-core" version = "31.0.0" @@ -4517,12 +4926,59 @@ dependencies = [ "serde", "sp-crypto-hashing", "sp-debug-derive", - "sp-externalities", - "sp-runtime-interface", + "sp-externalities 0.27.0", + "sp-runtime-interface 26.0.0", + "sp-std", + "sp-storage 20.0.0", + "ss58-registry", + "substrate-bip39 0.5.0", + "thiserror", + "tracing", + "w3f-bls", + "zeroize", +] + +[[package]] +name = "sp-core" +version = "34.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c961a5e33fb2962fa775c044ceba43df9c6f917e2c35d63bfe23738468fa76a7" +dependencies = [ + "array-bytes", + "bitflags 1.3.2", + "blake2", + "bounded-collections", + "bs58", + "dyn-clonable", + "ed25519-zebra 4.0.3", + "futures", + "hash-db", + "hash256-std-hasher", + "impl-serde", + "itertools 0.11.0", + "k256", + "libsecp256k1", + "log", + "merlin", + "parity-bip39", + "parity-scale-codec", + "parking_lot", + "paste", + "primitive-types", + "rand", + "scale-info", + "schnorrkel", + "secp256k1", + "secrecy", + "serde", + "sp-crypto-hashing", + "sp-debug-derive", + "sp-externalities 0.29.0", + "sp-runtime-interface 28.0.0", "sp-std", - "sp-storage", + "sp-storage 21.0.0", "ss58-registry", - "substrate-bip39", + "substrate-bip39 0.6.0", "thiserror", "tracing", "w3f-bls", @@ -4543,6 +4999,17 @@ dependencies = [ "twox-hash", ] +[[package]] +name = "sp-crypto-hashing-proc-macro" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b85d0f1f1e44bd8617eb2a48203ee854981229e3e79e6f468c7175d5fd37489b" +dependencies = [ + "quote", + "sp-crypto-hashing", + "syn 2.0.60", +] + [[package]] name = "sp-debug-derive" version = "14.0.0" @@ -4563,7 +5030,18 @@ dependencies = [ "environmental", "parity-scale-codec", "sp-std", - "sp-storage", + "sp-storage 20.0.0", +] + +[[package]] +name = "sp-externalities" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a904407d61cb94228c71b55a9d3708e9d6558991f9e83bd42bd91df37a159d30" +dependencies = [ + "environmental", + "parity-scale-codec", + "sp-storage 21.0.0", ] [[package]] @@ -4580,15 +5058,42 @@ dependencies = [ "polkavm-derive 0.9.1", "rustversion", "secp256k1", - "sp-core", + "sp-core 31.0.0", "sp-crypto-hashing", - "sp-externalities", - "sp-keystore", - "sp-runtime-interface", - "sp-state-machine", + "sp-externalities 0.27.0", + "sp-keystore 0.37.0", + "sp-runtime-interface 26.0.0", + "sp-state-machine 0.38.0", "sp-std", - "sp-tracing", - "sp-trie", + "sp-tracing 16.0.0", + "sp-trie 32.0.0", + "tracing", + "tracing-core", +] + +[[package]] +name = "sp-io" +version = "38.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ef7eb561bb4839cc8424ce58c5ea236cbcca83f26fcc0426d8decfe8aa97d4" +dependencies = [ + "bytes", + "docify", + "ed25519-dalek", + "libsecp256k1", + "log", + "parity-scale-codec", + "polkavm-derive 0.9.1", + "rustversion", + "secp256k1", + "sp-core 34.0.0", + "sp-crypto-hashing", + "sp-externalities 0.29.0", + "sp-keystore 0.40.0", + "sp-runtime-interface 28.0.0", + "sp-state-machine 0.43.0", + "sp-tracing 17.0.0", + "sp-trie 37.0.0", "tracing", "tracing-core", ] @@ -4599,8 +5104,8 @@ version = "34.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a07a31da596d705b3a3458d784a897af7fd2f8090de436dc386a112e8ea7f34f" dependencies = [ - "sp-core", - "sp-runtime", + "sp-core 31.0.0", + "sp-runtime 34.0.0", "strum", ] @@ -4612,8 +5117,41 @@ checksum = "bdbab8b61bd61d5f8625a0c75753b5d5a23be55d3445419acd42caf59cf6236b" dependencies = [ "parity-scale-codec", "parking_lot", - "sp-core", - "sp-externalities", + "sp-core 31.0.0", + "sp-externalities 0.27.0", +] + +[[package]] +name = "sp-keystore" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0248b4d784cb4a01472276928977121fa39d977a5bb24793b6b15e64b046df42" +dependencies = [ + "parity-scale-codec", + "parking_lot", + "sp-core 34.0.0", + "sp-externalities 0.29.0", +] + +[[package]] +name = "sp-maybe-compressed-blob" +version = "11.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c768c11afbe698a090386876911da4236af199cd38a5866748df4d8628aeff" +dependencies = [ + "thiserror", + "zstd 0.12.4", +] + +[[package]] +name = "sp-metadata-ir" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a616fa51350b35326682a472ee8e6ba742fdacb18babac38ecd46b3e05ead869" +dependencies = [ + "frame-metadata 16.0.0", + "parity-scale-codec", + "scale-info", ] [[package]] @@ -4644,12 +5182,39 @@ dependencies = [ "scale-info", "serde", "simple-mermaid", - "sp-application-crypto", - "sp-arithmetic", - "sp-core", - "sp-io", + "sp-application-crypto 33.0.0", + "sp-arithmetic 25.0.0", + "sp-core 31.0.0", + "sp-io 33.0.0", "sp-std", - "sp-weights", + "sp-weights 30.0.0", +] + +[[package]] +name = "sp-runtime" +version = "39.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5641385c2cd8e2252aacf35e0aff2f236331dfaea8dc11c5a4ec6bb36544450" +dependencies = [ + "docify", + "either", + "hash256-std-hasher", + "impl-trait-for-tuples", + "log", + "num-traits", + "parity-scale-codec", + "paste", + "rand", + "scale-info", + "serde", + "simple-mermaid", + "sp-application-crypto 38.0.0", + "sp-arithmetic 26.0.0", + "sp-core 34.0.0", + "sp-io 38.0.0", + "sp-std", + "sp-weights 31.0.0", + "tracing", ] [[package]] @@ -4663,12 +5228,32 @@ dependencies = [ "parity-scale-codec", "polkavm-derive 0.8.0", "primitive-types", - "sp-externalities", + "sp-externalities 0.27.0", + "sp-runtime-interface-proc-macro", + "sp-std", + "sp-storage 20.0.0", + "sp-tracing 16.0.0", + "sp-wasm-interface 20.0.0", + "static_assertions", +] + +[[package]] +name = "sp-runtime-interface" +version = "28.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985eb981f40c689c6a0012c937b68ed58dabb4341d06f2dfe4dfd5ed72fa4017" +dependencies = [ + "bytes", + "impl-trait-for-tuples", + "parity-scale-codec", + "polkavm-derive 0.9.1", + "primitive-types", + "sp-externalities 0.29.0", "sp-runtime-interface-proc-macro", "sp-std", - "sp-storage", - "sp-tracing", - "sp-wasm-interface", + "sp-storage 21.0.0", + "sp-tracing 17.0.0", + "sp-wasm-interface 21.0.0", "static_assertions", ] @@ -4698,14 +5283,35 @@ dependencies = [ "parking_lot", "rand", "smallvec", - "sp-core", - "sp-externalities", + "sp-core 31.0.0", + "sp-externalities 0.27.0", "sp-panic-handler", "sp-std", - "sp-trie", + "sp-trie 32.0.0", "thiserror", "tracing", - "trie-db", + "trie-db 0.28.0", +] + +[[package]] +name = "sp-state-machine" +version = "0.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "930104d6ae882626e8880d9b1578da9300655d337a3ffb45e130c608b6c89660" +dependencies = [ + "hash-db", + "log", + "parity-scale-codec", + "parking_lot", + "rand", + "smallvec", + "sp-core 34.0.0", + "sp-externalities 0.29.0", + "sp-panic-handler", + "sp-trie 37.0.0", + "thiserror", + "tracing", + "trie-db 0.29.1", ] [[package]] @@ -4728,6 +5334,19 @@ dependencies = [ "sp-std", ] +[[package]] +name = "sp-storage" +version = "21.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99c82989b3a4979a7e1ad848aad9f5d0b4388f1f454cc131766526601ab9e8f8" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "ref-cast", + "serde", + "sp-debug-derive", +] + [[package]] name = "sp-tracing" version = "16.0.0" @@ -4741,6 +5360,18 @@ dependencies = [ "tracing-subscriber 0.2.25", ] +[[package]] +name = "sp-tracing" +version = "17.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90b3decf116db9f1dfaf1f1597096b043d0e12c952d3bcdc018c6d6b77deec7e" +dependencies = [ + "parity-scale-codec", + "tracing", + "tracing-core", + "tracing-subscriber 0.2.25", +] + [[package]] name = "sp-trie" version = "32.0.0" @@ -4757,15 +5388,69 @@ dependencies = [ "rand", "scale-info", "schnellru", - "sp-core", - "sp-externalities", + "sp-core 31.0.0", + "sp-externalities 0.27.0", "sp-std", "thiserror", "tracing", - "trie-db", + "trie-db 0.28.0", + "trie-root", +] + +[[package]] +name = "sp-trie" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6282aef9f4b6ecd95a67a45bcdb67a71f4a4155c09a53c10add4ffe823db18cd" +dependencies = [ + "ahash 0.8.11", + "hash-db", + "lazy_static", + "memory-db", + "nohash-hasher", + "parity-scale-codec", + "parking_lot", + "rand", + "scale-info", + "schnellru", + "sp-core 34.0.0", + "sp-externalities 0.29.0", + "thiserror", + "tracing", + "trie-db 0.29.1", "trie-root", ] +[[package]] +name = "sp-version" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d521a405707b5be561367cd3d442ff67588993de24062ce3adefcf8437ee9fe1" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "parity-wasm", + "scale-info", + "serde", + "sp-crypto-hashing-proc-macro", + "sp-runtime 39.0.0", + "sp-std", + "sp-version-proc-macro", + "thiserror", +] + +[[package]] +name = "sp-version-proc-macro" +version = "14.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aee8f6730641a65fcf0c8f9b1e448af4b3bb083d08058b47528188bccc7b7a7" +dependencies = [ + "parity-scale-codec", + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "sp-wasm-interface" version = "20.0.0" @@ -4780,6 +5465,19 @@ dependencies = [ "wasmtime", ] +[[package]] +name = "sp-wasm-interface" +version = "21.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b04b919e150b4736d85089d49327eab65507deb1485eec929af69daa2278eb3" +dependencies = [ + "anyhow", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "wasmtime", +] + [[package]] name = "sp-weights" version = "30.0.0" @@ -4791,11 +5489,26 @@ dependencies = [ "scale-info", "serde", "smallvec", - "sp-arithmetic", + "sp-arithmetic 25.0.0", "sp-debug-derive", "sp-std", ] +[[package]] +name = "sp-weights" +version = "31.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93cdaf72a1dad537bbb130ba4d47307ebe5170405280ed1aa31fa712718a400e" +dependencies = [ + "bounded-collections", + "parity-scale-codec", + "scale-info", + "serde", + "smallvec", + "sp-arithmetic 26.0.0", + "sp-debug-derive", +] + [[package]] name = "spin" version = "0.9.8" @@ -4895,6 +5608,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "substrate-bip39" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca58ffd742f693dc13d69bdbb2e642ae239e0053f6aab3b104252892f856700a" +dependencies = [ + "hmac 0.12.1", + "pbkdf2", + "schnorrkel", + "sha2 0.10.8", + "zeroize", +] + [[package]] name = "substrate-runner" version = "0.37.0" @@ -4933,10 +5659,10 @@ dependencies = [ "scale-value", "serde", "serde_json", - "sp-core", + "sp-core 31.0.0", "sp-crypto-hashing", "sp-keyring", - "sp-runtime", + "sp-runtime 34.0.0", "subxt-core", "subxt-lightclient", "subxt-macro", @@ -5024,10 +5750,10 @@ dependencies = [ "scale-value", "serde", "serde_json", - "sp-core", + "sp-core 31.0.0", "sp-crypto-hashing", "sp-keyring", - "sp-runtime", + "sp-runtime 34.0.0", "subxt-macro", "subxt-metadata", "subxt-signer", @@ -5067,7 +5793,12 @@ dependencies = [ "parity-scale-codec", "proc-macro-error", "quote", + "sc-executor", + "sc-executor-common", "scale-typegen", + "sp-io 38.0.0", + "sp-maybe-compressed-blob", + "sp-state-machine 0.43.0", "subxt-codegen", "syn 2.0.60", ] @@ -5111,7 +5842,7 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.8", - "sp-core", + "sp-core 31.0.0", "sp-crypto-hashing", "sp-keyring", "subxt-core", @@ -5331,6 +6062,15 @@ dependencies = [ "tokio", ] +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + [[package]] name = "toml" version = "0.8.12" @@ -5363,17 +6103,6 @@ dependencies = [ "winnow 0.5.40", ] -[[package]] -name = "toml_edit" -version = "0.20.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" -dependencies = [ - "indexmap 2.2.6", - "toml_datetime", - "winnow 0.5.40", -] - [[package]] name = "toml_edit" version = "0.21.1" @@ -5550,6 +6279,18 @@ dependencies = [ "smallvec", ] +[[package]] +name = "trie-db" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c992b4f40c234a074d48a757efeabb1a6be88af84c0c23f7ca158950cb0ae7f" +dependencies = [ + "hash-db", + "log", + "rustc-hex", + "smallvec", +] + [[package]] name = "trie-root" version = "0.18.0" @@ -5576,7 +6317,7 @@ dependencies = [ "serde_derive", "serde_json", "termcolor", - "toml", + "toml 0.8.12", ] [[package]] @@ -5869,6 +6610,15 @@ version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +[[package]] +name = "wasm-instrument" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a47ecb37b9734d1085eaa5ae1a81e60801fd8c28d4cabdd8aedb982021918bc" +dependencies = [ + "parity-wasm", +] + [[package]] name = "wasmi" version = "0.31.2" @@ -5935,9 +6685,12 @@ dependencies = [ "once_cell", "paste", "psm", + "rayon", "serde", "target-lexicon", "wasmparser", + "wasmtime-cache", + "wasmtime-cranelift", "wasmtime-environ", "wasmtime-jit", "wasmtime-runtime", @@ -5953,6 +6706,63 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "wasmtime-cache" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c86437fa68626fe896e5afc69234bb2b5894949083586535f200385adfd71213" +dependencies = [ + "anyhow", + "base64 0.21.7", + "bincode", + "directories-next", + "file-per-thread-logger", + "log", + "rustix 0.36.17", + "serde", + "sha2 0.10.8", + "toml 0.5.11", + "windows-sys 0.45.0", + "zstd 0.11.2+zstd.1.5.2", +] + +[[package]] +name = "wasmtime-cranelift" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1cefde0cce8cb700b1b21b6298a3837dba46521affd7b8c38a9ee2c869eee04" +dependencies = [ + "anyhow", + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "cranelift-native", + "cranelift-wasm", + "gimli 0.27.3", + "log", + "object 0.30.4", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-cranelift-shared", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-cranelift-shared" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd041e382ef5aea1b9fc78442394f1a4f6d676ce457e7076ca4cb3f397882f8b" +dependencies = [ + "anyhow", + "cranelift-codegen", + "cranelift-native", + "gimli 0.27.3", + "object 0.30.4", + "target-lexicon", + "wasmtime-environ", +] + [[package]] name = "wasmtime-environ" version = "8.0.1" @@ -5990,6 +6800,7 @@ dependencies = [ "serde", "target-lexicon", "wasmtime-environ", + "wasmtime-jit-debug", "wasmtime-jit-icache-coherence", "wasmtime-runtime", "windows-sys 0.45.0", @@ -6001,7 +6812,9 @@ version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e0554b84c15a27d76281d06838aed94e13a77d7bf604bbbaf548aa20eb93846" dependencies = [ + "object 0.30.4", "once_cell", + "rustix 0.36.17", ] [[package]] @@ -6418,3 +7231,51 @@ dependencies = [ "quote", "syn 2.0.60", ] + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe 5.0.2+zstd.1.5.2", +] + +[[package]] +name = "zstd" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" +dependencies = [ + "zstd-safe 6.0.6", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-safe" +version = "6.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.13+zstd.1.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml index 9f75698d18..5062a0dd32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -116,6 +116,8 @@ which = "5.0.0" strip-ansi-escapes = "0.2.0" proptest = "1.5.0" hex-literal = "0.4.1" +sc-executor = "0.40.0" +sc-executor-common = "0.35.0" # Light client support: smoldot = { version = "0.16.0", default-features = false } @@ -140,6 +142,9 @@ sp-core = { version = "31.0.0", default-features = false } sp-crypto-hashing = { version = "0.1.0", default-features = false } sp-runtime = "34.0.0" sp-keyring = "34.0.0" +sp-maybe-compressed-blob = "11.0.0" +sp-state-machine = "0.43.0" +sp-io = "38.0.0" # Subxt workspace crates: subxt = { version = "0.37.0", path = "subxt", default-features = false } @@ -167,6 +172,7 @@ base64 = { version = "0.22.1", default-features = false } scrypt = { version = "0.11.0", default-features = false } crypto_secretbox = { version = "0.1.1", default-features = false } + [profile.dev.package.smoldot-light] opt-level = 2 [profile.test.package.smoldot-light] diff --git a/artifacts/westend_runtime.compact.compressed.wasm b/artifacts/westend_runtime.compact.compressed.wasm new file mode 100644 index 0000000000..dd2b35547d Binary files /dev/null and b/artifacts/westend_runtime.compact.compressed.wasm differ diff --git a/artifacts/westend_runtime.wasm b/artifacts/westend_runtime.wasm new file mode 100755 index 0000000000..3083fe20fd Binary files /dev/null and b/artifacts/westend_runtime.wasm differ diff --git a/codegen/src/error.rs b/codegen/src/error.rs index 4a77d247af..93091b59d6 100644 --- a/codegen/src/error.rs +++ b/codegen/src/error.rs @@ -57,6 +57,9 @@ pub enum CodegenError { /// Cannot generate types. #[error("Type Generation failed: {0}")] TypeGeneration(#[from] TypegenError), + /// Error when generating metadata from Wasm-runtime + #[error("Failed to generate metadata from wasm file. reason: {0}")] + Wasm(String), } impl CodegenError { diff --git a/macro/Cargo.toml b/macro/Cargo.toml index 90fb392591..a9fb46df28 100644 --- a/macro/Cargo.toml +++ b/macro/Cargo.toml @@ -15,6 +15,7 @@ description = "Generate types and helpers for interacting with Substrate runtime [features] web = ["subxt-codegen/web"] +runtime-path = ["sp-io", "sc-executor-common", "sp-state-machine", "sp-maybe-compressed-blob", "sc-executor"] [lib] proc-macro = true @@ -27,6 +28,11 @@ syn = { workspace = true } quote = { workspace = true } subxt-codegen = { workspace = true, features = ["fetch-metadata"] } scale-typegen = { workspace = true } +sc-executor = { workspace = true, optional = true } +sp-maybe-compressed-blob = { workspace = true, optional = true } +sp-state-machine = { workspace = true, optional = true } +sp-io = { workspace = true, optional = true } +sc-executor-common = { workspace = true, optional = true } [lints] workspace = true \ No newline at end of file diff --git a/macro/src/lib.rs b/macro/src/lib.rs index 288ac6162b..777f616afb 100644 --- a/macro/src/lib.rs +++ b/macro/src/lib.rs @@ -23,6 +23,9 @@ use subxt_codegen::{ }; use syn::{parse_macro_input, punctuated::Punctuated}; +#[cfg(feature = "runtime-path")] +mod wasm_loader; + #[derive(Clone, Debug)] struct OuterAttribute(syn::Attribute); @@ -60,6 +63,9 @@ struct RuntimeMetadataArgs { no_default_substitutions: bool, #[darling(default)] unstable_metadata: darling::util::Flag, + #[cfg(feature = "runtime-path")] + #[darling(default)] + runtime_path: Option, } #[derive(Debug, FromMeta)] @@ -206,6 +212,22 @@ fn validate_type_path(path: &syn::Path, metadata: &Metadata) { fn fetch_metadata(args: &RuntimeMetadataArgs) -> Result { // Do we want to fetch unstable metadata? This only works if fetching from a URL. let unstable_metadata = args.unstable_metadata.is_present(); + + #[cfg(feature = "runtime-path")] + if let Some(path) = &args.runtime_path { + if args.runtime_metadata_insecure_url.is_some() || args.runtime_metadata_path.is_some() { + abort_call_site!( + "Only one of 'runtime_metadata_path', 'runtime_metadata_insecure_url' or `runtime_path` must be provided" + ); + }; + let root = std::env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| ".".into()); + let root_path = std::path::Path::new(&root); + let path = root_path.join(path); + + let metadata = wasm_loader::from_wasm_file(&path).map_err(|e| e.into_compile_error())?; + return Ok(metadata); + }; + let metadata = match ( &args.runtime_metadata_path, &args.runtime_metadata_insecure_url, @@ -239,12 +261,26 @@ fn fetch_metadata(args: &RuntimeMetadataArgs) -> Result { abort_call_site!( - "One of 'runtime_metadata_path' or 'runtime_metadata_insecure_url' must be provided" + "At least one of 'runtime_metadata_path', 'runtime_metadata_insecure_url' or 'runtime_path` can be provided" + ) + } + #[cfg(not(feature = "runtime-path"))] + (None, None) => { + abort_call_site!( + "At least one of 'runtime_metadata_path', 'runtime_metadata_insecure_url' can be provided" ) } - (Some(_), Some(_)) => { + #[cfg(feature = "runtime-path")] + _ => { + abort_call_site!( + "Only one of 'runtime_metadata_path', 'runtime_metadata_insecure_url' or 'runtime_path` can be provided" + ) + } + #[cfg(not(feature = "runtime-path"))] + _ => { abort_call_site!( "Only one of 'runtime_metadata_path' or 'runtime_metadata_insecure_url' can be provided" ) diff --git a/macro/src/wasm_loader.rs b/macro/src/wasm_loader.rs new file mode 100644 index 0000000000..ed5ac6cf84 --- /dev/null +++ b/macro/src/wasm_loader.rs @@ -0,0 +1,55 @@ +// Copyright 2024 Parity Technologies (UK) Ltd. +// This file is dual-licensed as Apache-2.0 or GPL-3.0. +// see LICENSE for license details. + +use std::{borrow::Cow, path::Path}; + +use codec::Decode; +use sc_executor::{WasmExecutionMethod, WasmExecutor}; +use sc_executor_common::runtime_blob::RuntimeBlob; +use sp_maybe_compressed_blob::CODE_BLOB_BOMB_LIMIT; +use subxt_codegen::{fetch_metadata::fetch_metadata_from_file_blocking, CodegenError, Metadata}; + +/// Result type shorthand +pub type WasmMetadataResult = Result; + +/// Uses wasm artifact produced by compiling the runtime to generate metadata +pub fn from_wasm_file(wasm_file_path: &Path) -> WasmMetadataResult { + let wasm_file = fetch_metadata_from_file_blocking(wasm_file_path) + .map_err(Into::::into) + .and_then(maybe_decompress)?; + call_and_decode(wasm_file) +} + +fn call_and_decode(wasm_file: Vec) -> WasmMetadataResult { + let mut ext: sp_state_machine::BasicExternalities = Default::default(); + + let executor: WasmExecutor = WasmExecutor::builder() + .with_execution_method(WasmExecutionMethod::default()) + .with_offchain_heap_alloc_strategy(sc_executor::HeapAllocStrategy::Dynamic { + maximum_pages: Some(64), + }) + .with_max_runtime_instances(1) + .with_runtime_cache_size(1) + .build(); + + let runtime_blob = + RuntimeBlob::new(&wasm_file).map_err(|e| CodegenError::Wasm(e.to_string()))?; + let metadata_encoded = executor + .uncached_call(runtime_blob, &mut ext, true, "Metadata_metadata", &[]) + .map_err(|_| CodegenError::Wasm("method \"Metadata_metadata\" doesnt exist".to_owned()))?; + + let metadata = >::decode(&mut &metadata_encoded[..]).map_err(CodegenError::Decode)?; + + decode(metadata) +} + +fn decode(encoded_metadata: Vec) -> WasmMetadataResult { + Metadata::decode(&mut encoded_metadata.as_ref()).map_err(Into::into) +} + +fn maybe_decompress(file_contents: Vec) -> WasmMetadataResult> { + sp_maybe_compressed_blob::decompress(file_contents.as_ref(), CODE_BLOB_BOMB_LIMIT) + .map_err(|e| CodegenError::Wasm(e.to_string())) + .map(Cow::into_owned) +} diff --git a/subxt/Cargo.toml b/subxt/Cargo.toml index 0ccffb7d7b..4faee43718 100644 --- a/subxt/Cargo.toml +++ b/subxt/Cargo.toml @@ -70,6 +70,9 @@ unstable-metadata = [] # Note that this feature is experimental and things may break or not work as expected. unstable-light-client = ["subxt-lightclient"] +# Activate this to expose the ability to generate metadata from Wasm runtime files. +runtime-path = ["subxt-macro/runtime-path"] + [dependencies] async-trait = { workspace = true } codec = { package = "parity-scale-codec", workspace = true, features = ["derive"] } diff --git a/testing/ui-tests/Cargo.toml b/testing/ui-tests/Cargo.toml index 3ae0f25e92..e3fce0041b 100644 --- a/testing/ui-tests/Cargo.toml +++ b/testing/ui-tests/Cargo.toml @@ -14,6 +14,6 @@ hex = { workspace = true } scale-info = { workspace = true, features = ["bit-vec"] } frame-metadata = { workspace = true } codec = { package = "parity-scale-codec", workspace = true, features = ["derive", "bit-vec"] } -subxt = { workspace = true, features = ["native", "jsonrpsee"] } +subxt = { workspace = true, features = ["native", "jsonrpsee", "runtime-path"] } subxt-metadata = { workspace = true } generate-custom-metadata = { path = "../generate-custom-metadata" } diff --git a/testing/ui-tests/src/correct/wasm_runtime_metadata.rs b/testing/ui-tests/src/correct/wasm_runtime_metadata.rs new file mode 100644 index 0000000000..df43123c5c --- /dev/null +++ b/testing/ui-tests/src/correct/wasm_runtime_metadata.rs @@ -0,0 +1,13 @@ +#[subxt::subxt(runtime_path = "../../../../artifacts/westend_runtime.wasm")] +mod runtime {} + +#[subxt::subxt(runtime_path = "../../../../artifacts/westend_runtime.compact.compressed.wasm")] +mod runtime_compressed {} + +fn main() { + use runtime; + use runtime_compressed; + + let _ = runtime::system::events::CodeUpdated; + let _ = runtime_compressed::system::events::CodeUpdated; +} diff --git a/testing/ui-tests/src/incorrect/need_url_or_path.stderr b/testing/ui-tests/src/incorrect/need_url_or_path.stderr index 366544dfb4..5de86d5c88 100644 --- a/testing/ui-tests/src/incorrect/need_url_or_path.stderr +++ b/testing/ui-tests/src/incorrect/need_url_or_path.stderr @@ -1,4 +1,4 @@ -error: One of 'runtime_metadata_path' or 'runtime_metadata_insecure_url' must be provided +error: At least one of 'runtime_metadata_path', 'runtime_metadata_insecure_url' or 'runtime_path` can be provided --> src/incorrect/need_url_or_path.rs:1:1 | 1 | #[subxt::subxt()] diff --git a/testing/ui-tests/src/incorrect/url_and_path_provided.rs b/testing/ui-tests/src/incorrect/url_and_path_provided.rs index a088841d69..7e868e2afc 100644 --- a/testing/ui-tests/src/incorrect/url_and_path_provided.rs +++ b/testing/ui-tests/src/incorrect/url_and_path_provided.rs @@ -4,4 +4,11 @@ )] pub mod node_runtime {} +#[subxt::subxt( + runtime_metadata_path = "../../../../artifacts/polkadot_metadata_tiny.scale", + runtime_metadata_insecure_url = "wss://rpc.polkadot.io:443", + runtime_path = "../../../../artifacts/westend_runtime.wasm" +)] +pub mod node_runtime2 {} + fn main() {} diff --git a/testing/ui-tests/src/incorrect/url_and_path_provided.stderr b/testing/ui-tests/src/incorrect/url_and_path_provided.stderr index afbeadb42b..eb30a20856 100644 --- a/testing/ui-tests/src/incorrect/url_and_path_provided.stderr +++ b/testing/ui-tests/src/incorrect/url_and_path_provided.stderr @@ -1,4 +1,4 @@ -error: Only one of 'runtime_metadata_path' or 'runtime_metadata_insecure_url' can be provided +error: Only one of 'runtime_metadata_path', 'runtime_metadata_insecure_url' or 'runtime_path` can be provided --> src/incorrect/url_and_path_provided.rs:1:1 | 1 | / #[subxt::subxt( @@ -8,3 +8,15 @@ error: Only one of 'runtime_metadata_path' or 'runtime_metadata_insecure_url' ca | |__^ | = note: this error originates in the attribute macro `subxt::subxt` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: Only one of 'runtime_metadata_path', 'runtime_metadata_insecure_url' or `runtime_path` must be provided + --> src/incorrect/url_and_path_provided.rs:7:1 + | +7 | / #[subxt::subxt( +8 | | runtime_metadata_path = "../../../../artifacts/polkadot_metadata_tiny.scale", +9 | | runtime_metadata_insecure_url = "wss://rpc.polkadot.io:443", +10 | | runtime_path = "../../../../artifacts/westend_runtime.wasm" +11 | | )] + | |__^ + | + = note: this error originates in the attribute macro `subxt::subxt` (in Nightly builds, run with -Z macro-backtrace for more info)