diff --git a/Cargo.lock b/Cargo.lock index 80063eae02b6..b586db99c227 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,6 +64,15 @@ dependencies = [ "const-random", ] +[[package]] +name = "ahash" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0989268a37e128d4d7a8028f1c60099430113fdbc70419010601ce51a228e4fe" +dependencies = [ + "const-random", +] + [[package]] name = "aho-corasick" version = "0.7.8" @@ -73,6 +82,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi 0.3.8", +] + [[package]] name = "anyhow" version = "1.0.26" @@ -100,6 +118,64 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" +[[package]] +name = "async-std" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "538ecb01eb64eecd772087e5b6f7540cbc917f047727339a472dafed2185b267" +dependencies = [ + "async-task", + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "futures-core", + "futures-io", + "futures-timer 2.0.2", + "kv-log-macro", + "log", + "memchr", + "mio", + "mio-uds", + "num_cpus", + "once_cell 1.3.1", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "async-task" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ac2c016b079e771204030951c366db398864f5026f84a44dafb0ff20f02085d" +dependencies = [ + "libc", + "winapi 0.3.8", +] + +[[package]] +name = "async-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce6977f57fa68da77ffe5542950d47e9c23d65f5bc7cb0a9f8700996913eec7" +dependencies = [ + "futures", + "rustls", + "webpki", + "webpki-roots", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi 0.3.8", +] + [[package]] name = "autocfg" version = "0.1.7" @@ -150,6 +226,21 @@ dependencies = [ "safemem", ] +[[package]] +name = "base64" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" +dependencies = [ + "byteorder", +] + +[[package]] +name = "base64" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" + [[package]] name = "bitflags" version = "1.2.1" @@ -218,6 +309,21 @@ dependencies = [ "byte-tools", ] +[[package]] +name = "bs58" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b170cd256a3f9fa6b9edae3e44a7dfdfc77e8124dbc3e2612d75f9c3e2396dae" + +[[package]] +name = "bstr" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "502ae1441a0a5adb8fbd38a5955a6416b9493e92b465de5e4a9bde6a539c2c48" +dependencies = [ + "memchr", +] + [[package]] name = "bumpalo" version = "3.2.0" @@ -242,6 +348,12 @@ version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +[[package]] +name = "bytes" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" + [[package]] name = "c2-chacha" version = "0.2.3" @@ -263,6 +375,21 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +[[package]] +name = "clap" +version = "2.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + [[package]] name = "clear_on_drop" version = "0.2.3" @@ -307,6 +434,50 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "crossbeam-channel" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acec9a3b0b3559f15aee4f90746c4e5e293b701c0f7d3925d24e01645267b68c" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac" +dependencies = [ + "autocfg 0.1.7", + "cfg-if", + "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard 1.0.0", +] + +[[package]] +name = "crossbeam-utils" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4" +dependencies = [ + "autocfg 0.1.7", + "cfg-if", + "lazy_static", +] + [[package]] name = "crunchy" version = "0.2.2" @@ -333,6 +504,16 @@ dependencies = [ "stream-cipher", ] +[[package]] +name = "ctrlc" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7dfd2d8b4c82121dfdff120f818e09fc4380b0b7e17a742081a89b94853e87f" +dependencies = [ + "nix", + "winapi 0.3.8", +] + [[package]] name = "curve25519-dalek" version = "1.2.3" @@ -391,6 +572,19 @@ dependencies = [ "sha2", ] +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + [[package]] name = "environmental" version = "1.1.1" @@ -465,10 +659,16 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "fnv" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" + [[package]] name = "frame-metadata" version = "11.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "parity-scale-codec", "serde", @@ -479,7 +679,7 @@ dependencies = [ [[package]] name = "frame-support" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "bitmask", "frame-metadata", @@ -503,7 +703,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "frame-support-procedural-tools", "proc-macro2 1.0.8", @@ -514,7 +714,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -526,7 +726,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "proc-macro2 1.0.8", "quote 1.0.2", @@ -536,7 +736,7 @@ dependencies = [ [[package]] name = "frame-system" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "frame-support", "impl-trait-for-tuples", @@ -555,6 +755,22 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + [[package]] name = "futures" version = "0.3.4" @@ -627,6 +843,18 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27" +[[package]] +name = "futures-timer" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1de7508b218029b0f01662ed8f61b1c964b3ae99d6f25462d0f55a595109df6" + +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" + [[package]] name = "futures-util" version = "0.3.4" @@ -666,6 +894,38 @@ dependencies = [ "wasi", ] +[[package]] +name = "globset" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925aa2cac82d8834e2b2a4415b6f6879757fb5c0928fc445ae76461a12eed8f2" +dependencies = [ + "aho-corasick", + "bstr", + "fnv", + "log", + "regex", +] + +[[package]] +name = "h2" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9433d71e471c1736fd5a61b671fc0b148d7a2992f666c958d03cd8feb3b88d1" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "log", + "slab", + "tokio", + "tokio-util", +] + [[package]] name = "hash-db" version = "0.15.2" @@ -697,10 +957,20 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead" dependencies = [ - "ahash", + "ahash 0.2.18", "autocfg 0.1.7", ] +[[package]] +name = "hashbrown" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728e7d31e63d53c436094370f1e6fa249f60a4bb318cc5dfbbbe0aa2bc5a29d7" +dependencies = [ + "ahash 0.3.2", + "autocfg 1.0.0", +] + [[package]] name = "heck" version = "0.3.1" @@ -710,6 +980,15 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "hermit-abi" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772" +dependencies = [ + "libc", +] + [[package]] name = "hex" version = "0.4.1" @@ -737,6 +1016,77 @@ dependencies = [ "hmac", ] +[[package]] +name = "http" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b708cc7f06493459026f53b9a61a7a121a5d1ec6238dee58ea4941132b30156b" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "httparse" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" + +[[package]] +name = "humantime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +dependencies = [ + "quick-error", +] + +[[package]] +name = "hyper" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa1c527bbc634be72aa7ba31e4e4def9bbb020f5416916279b7c705cd838893e" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "log", + "net2", + "pin-project", + "time", + "tokio", + "tower-service", + "want", +] + +[[package]] +name = "idna" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "impl-codec" version = "0.4.2" @@ -784,12 +1134,36 @@ dependencies = [ "syn 1.0.14", ] +[[package]] +name = "indexmap" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" +dependencies = [ + "autocfg 1.0.0", +] + [[package]] name = "integer-sqrt" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f65877bf7d44897a473350b1046277941cee20b263397e90869c50b6e766088b" +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + +[[package]] +name = "itoa" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" + [[package]] name = "js-sys" version = "0.3.35" @@ -799,12 +1173,74 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonrpsee" +version = "1.0.0" +source = "git+https://github.com/paritytech/jsonrpsee#de7cbf2b7528802b6c1079de837db1d4f24561a6" +dependencies = [ + "async-std", + "async-tls", + "bs58", + "bytes", + "fnv", + "futures", + "futures-timer 3.0.2", + "globset", + "hashbrown 0.7.0", + "hyper", + "jsonrpsee-proc-macros", + "lazy_static", + "log", + "parking_lot 0.10.0", + "pin-project", + "rand 0.7.3", + "serde", + "serde_json", + "smallvec 1.2.0", + "soketto", + "thiserror", + "tokio", + "unicase", + "url", + "webpki", +] + +[[package]] +name = "jsonrpsee-proc-macros" +version = "1.0.0" +source = "git+https://github.com/paritytech/jsonrpsee#de7cbf2b7528802b6c1079de837db1d4f24561a6" +dependencies = [ + "Inflector", + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", +] + [[package]] name = "keccak" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "kv-log-macro" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c54d9f465d530a752e6ebdc217e081a7a614b48cb200f6f0aee21ba6bc9aabb" +dependencies = [ + "log", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -860,6 +1296,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + [[package]] name = "maybe-uninit" version = "2.0.0" @@ -872,13 +1314,22 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" +[[package]] +name = "memoffset" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9" +dependencies = [ + "rustc_version", +] + [[package]] name = "memory-db" version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "198831fe8722331a395bc199a5d08efbc197497ef354cb4c77b969c02ffc0fc4" dependencies = [ - "ahash", + "ahash 0.2.18", "hash-db", "hashbrown 0.6.3", "parity-util-mem", @@ -896,10 +1347,85 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b0942b357c1b4d0dc43ba724674ec89c3218e6ca2b3e8269e7cb53bcecd2f6e" dependencies = [ - "byteorder", - "keccak", - "rand_core 0.4.2", - "zeroize 1.1.0", + "byteorder", + "keccak", + "rand_core 0.4.2", + "zeroize 1.1.0", +] + +[[package]] +name = "mio" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" +dependencies = [ + "cfg-if", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "mio-uds" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" +dependencies = [ + "iovec", + "libc", + "mio", +] + +[[package]] +name = "miow" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + +[[package]] +name = "net2" +version = "0.2.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" +dependencies = [ + "cfg-if", + "libc", + "winapi 0.3.8", +] + +[[package]] +name = "nix" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce" +dependencies = [ + "bitflags", + "cc", + "cfg-if", + "libc", + "void", +] + +[[package]] +name = "node-primitives" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" +dependencies = [ + "sp-core", + "sp-runtime", ] [[package]] @@ -915,7 +1441,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" dependencies = [ "memchr", - "version_check", + "version_check 0.1.5", ] [[package]] @@ -960,6 +1486,16 @@ dependencies = [ "autocfg 1.0.0", ] +[[package]] +name = "num_cpus" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6" +dependencies = [ + "hermit-abi", + "libc", +] + [[package]] name = "once_cell" version = "0.1.8" @@ -975,6 +1511,12 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d584f08c2d717d5c23a6414fc2822b71c651560713e54fa7eace675f758a355e" +[[package]] +name = "once_cell" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c601810575c99596d4afc46f78a678c80105117c379eb3650cf99b8a21ce5b" + [[package]] name = "opaque-debug" version = "0.2.3" @@ -1017,7 +1559,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "frame-support", "frame-system", @@ -1035,7 +1577,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "frame-support", "frame-system", @@ -1128,7 +1670,7 @@ dependencies = [ "parity-util-mem-derive", "parking_lot 0.10.0", "primitive-types", - "winapi", + "winapi 0.3.8", ] [[package]] @@ -1189,7 +1731,7 @@ dependencies = [ "rand 0.6.5", "rustc_version", "smallvec 0.6.13", - "winapi", + "winapi 0.3.8", ] [[package]] @@ -1204,7 +1746,7 @@ dependencies = [ "redox_syscall", "rustc_version", "smallvec 0.6.13", - "winapi", + "winapi 0.3.8", ] [[package]] @@ -1218,7 +1760,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec 1.2.0", - "winapi", + "winapi 0.3.8", ] [[package]] @@ -1249,7 +1791,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" dependencies = [ - "base64", + "base64 0.9.3", "byteorder", "crypto-mac", "hmac", @@ -1258,6 +1800,38 @@ dependencies = [ "subtle 1.0.0", ] +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pin-project" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7804a463a8d9572f13453c516a5faea534a2403d7ced2f0c7e100eeff072772c" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "385322a45f2ecf3410c68d2a549a4a2685e8051d0f278e39743ff4e451cb9b3f" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", +] + +[[package]] +name = "pin-project-lite" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae" + [[package]] name = "pin-utils" version = "0.1.0-alpha.4" @@ -1336,6 +1910,12 @@ dependencies = [ "unicode-xid 0.2.0", ] +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quote" version = "0.6.13" @@ -1364,7 +1944,7 @@ dependencies = [ "fuchsia-cprng", "libc", "rand_core 0.3.1", - "winapi", + "winapi 0.3.8", ] [[package]] @@ -1383,7 +1963,7 @@ dependencies = [ "rand_os", "rand_pcg", "rand_xorshift", - "winapi", + "winapi 0.3.8", ] [[package]] @@ -1478,7 +2058,7 @@ checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" dependencies = [ "libc", "rand_core 0.4.2", - "winapi", + "winapi 0.3.8", ] [[package]] @@ -1492,7 +2072,7 @@ dependencies = [ "libc", "rand_core 0.4.2", "rdrand", - "winapi", + "winapi 0.3.8", ] [[package]] @@ -1547,6 +2127,21 @@ version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b28dfe3fe9badec5dbf0a79a9cccad2cfc2ab5484bdb3e44cbd1ae8b3ba2be06" +[[package]] +name = "ring" +version = "0.16.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "741ba1704ae21999c00942f9f5944f801e977f54302af346b596287599ad1862" +dependencies = [ + "cc", + "lazy_static", + "libc", + "spin", + "untrusted", + "web-sys", + "winapi 0.3.8", +] + [[package]] name = "ripemd160" version = "0.8.0" @@ -1588,6 +2183,25 @@ dependencies = [ "semver", ] +[[package]] +name = "rustls" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b25a18b1bf7387f0145e7f8324e700805aade3842dd3db2e74e4cdeb4677c09e" +dependencies = [ + "base64 0.10.1", + "log", + "ring", + "sct", + "webpki", +] + +[[package]] +name = "ryu" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" + [[package]] name = "safemem" version = "0.3.3" @@ -1636,6 +2250,16 @@ dependencies = [ "sha2", ] +[[package]] +name = "sct" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "semver" version = "0.9.0" @@ -1687,6 +2311,23 @@ dependencies = [ "syn 1.0.14", ] +[[package]] +name = "serde_json" +version = "1.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9371ade75d4c2d6cb154141b9752cf3781ec9c05e0e5cf35060e1e70ee7b9c25" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" + [[package]] name = "sha2" version = "0.8.1" @@ -1720,6 +2361,25 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" +[[package]] +name = "soketto" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c9dab3f95c9ebdf3a88268c19af668f637a3c5039c2c56ff2d40b1b2d64a25b" +dependencies = [ + "base64 0.11.0", + "bytes", + "futures", + "http", + "httparse", + "log", + "rand 0.7.3", + "sha1", + "smallvec 1.2.0", + "static_assertions", + "thiserror", +] + [[package]] name = "sourcefile" version = "0.1.4" @@ -1729,7 +2389,7 @@ checksum = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" [[package]] name = "sp-api" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "hash-db", "parity-scale-codec", @@ -1744,7 +2404,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "blake2-rfc", "proc-macro-crate", @@ -1756,7 +2416,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "parity-scale-codec", "serde", @@ -1768,7 +2428,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "integer-sqrt", "num-traits", @@ -1804,7 +2464,7 @@ dependencies = [ [[package]] name = "sp-core" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "base58", "blake2-rfc", @@ -1844,7 +2504,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "proc-macro2 1.0.8", "quote 1.0.2", @@ -1854,7 +2514,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.8.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "environmental", "sp-std", @@ -1864,7 +2524,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "parity-scale-codec", "serde", @@ -1877,7 +2537,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "derive_more", "parity-scale-codec", @@ -1889,7 +2549,7 @@ dependencies = [ [[package]] name = "sp-io" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "hash-db", "libsecp256k1", @@ -1907,16 +2567,25 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "backtrace", "log", ] +[[package]] +name = "sp-rpc" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" +dependencies = [ + "serde", + "sp-core", +] + [[package]] name = "sp-runtime" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "impl-trait-for-tuples", "log", @@ -1936,7 +2605,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "parity-scale-codec", "primitive-types", @@ -1950,7 +2619,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "Inflector", "proc-macro-crate", @@ -1962,7 +2631,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "parity-scale-codec", "sp-runtime", @@ -1972,7 +2641,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.8.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "hash-db", "log", @@ -1991,12 +2660,12 @@ dependencies = [ [[package]] name = "sp-std" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" [[package]] name = "sp-storage" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "impl-serde 0.2.3", "serde", @@ -2007,7 +2676,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -2021,7 +2690,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "hash-db", "memory-db", @@ -2035,7 +2704,7 @@ dependencies = [ [[package]] name = "sp-version" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "impl-serde 0.2.3", "parity-scale-codec", @@ -2047,7 +2716,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate.git#d78534edc04bb1a2eedf7feac0da9ddf85b348e4" +source = "git+https://github.com/paritytech/substrate.git#2e8080e2902fc477bbce36512a8f5bcdc4b49f17" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -2055,6 +2724,12 @@ dependencies = [ "wasmi", ] +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + [[package]] name = "static_assertions" version = "1.1.0" @@ -2070,6 +2745,12 @@ dependencies = [ "generic-array", ] +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + [[package]] name = "substrate-bip39" version = "0.3.1" @@ -2082,6 +2763,25 @@ dependencies = [ "sha2", ] +[[package]] +name = "substrate-bridge" +version = "0.1.0" +dependencies = [ + "async-std", + "clap", + "ctrlc", + "derive_more", + "env_logger", + "futures", + "jsonrpsee", + "log", + "node-primitives", + "serde_json", + "sp-core", + "sp-rpc", + "url", +] + [[package]] name = "subtle" version = "1.0.0" @@ -2140,6 +2840,44 @@ dependencies = [ "unicode-xid 0.2.0", ] +[[package]] +name = "termcolor" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee14bf8e6767ab4c687c9e8bc003879e042a96fd67a3ba5934eadb6536bef4db" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7b51e1fbc44b5a0840be594fbc0f960be09050f2617e61e6aa43bef97cd3ef4" +dependencies = [ + "proc-macro2 1.0.8", + "quote 1.0.2", + "syn 1.0.14", +] + [[package]] name = "thread_local" version = "1.0.1" @@ -2149,6 +2887,17 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "time" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +dependencies = [ + "libc", + "redox_syscall", + "winapi 0.3.8", +] + [[package]] name = "tiny-bip39" version = "0.6.2" @@ -2182,6 +2931,36 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tokio" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fdd17989496f49cdc57978c96f0c9fe5e4a58a8bddc6813c449a4624f6a030b" +dependencies = [ + "bytes", + "fnv", + "iovec", + "lazy_static", + "memchr", + "mio", + "pin-project-lite", + "slab", +] + +[[package]] +name = "tokio-util" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + [[package]] name = "toml" version = "0.5.6" @@ -2191,6 +2970,12 @@ dependencies = [ "serde", ] +[[package]] +name = "tower-service" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" + [[package]] name = "tracing" version = "0.1.12" @@ -2253,6 +3038,12 @@ dependencies = [ "rlp", ] +[[package]] +name = "try-lock" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" + [[package]] name = "twox-hash" version = "1.5.0" @@ -2280,12 +3071,45 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check 0.9.1", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" +dependencies = [ + "matches", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4" +dependencies = [ + "smallvec 1.2.0", +] + [[package]] name = "unicode-segmentation" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" +[[package]] +name = "unicode-width" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" + [[package]] name = "unicode-xid" version = "0.1.0" @@ -2298,12 +3122,57 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +[[package]] +name = "untrusted" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60369ef7a31de49bcb3f6ca728d4ba7300d9a1658f94c727d4cab8c8d9f4aece" + +[[package]] +name = "url" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" +dependencies = [ + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "vec_map" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" + [[package]] name = "version_check" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" +[[package]] +name = "version_check" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -2444,6 +3313,25 @@ dependencies = [ "wasm-bindgen-webidl", ] +[[package]] +name = "webpki" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f50e1972865d6b1adb54167d1c8ed48606004c2c9d0ea5f1eeb34d95e863ef" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a262ae37dd9d60f60dd473d1158f9fbebf110ba7b6a5051c8160460f6043718b" +dependencies = [ + "webpki", +] + [[package]] name = "weedle" version = "0.10.0" @@ -2453,6 +3341,12 @@ dependencies = [ "nom", ] +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + [[package]] name = "winapi" version = "0.3.8" @@ -2463,18 +3357,43 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80" +dependencies = [ + "winapi 0.3.8", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + [[package]] name = "zeroize" version = "0.9.3" diff --git a/Cargo.toml b/Cargo.toml index 8945715e9c1f..91e62a33047b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,4 +3,5 @@ members = [ "modules/substrate", "modules/ethereum", + "relays/substrate", ] diff --git a/modules/substrate/src/lib.rs b/modules/substrate/src/lib.rs index ca3fe2839a56..ad27627f62ca 100644 --- a/modules/substrate/src/lib.rs +++ b/modules/substrate/src/lib.rs @@ -247,6 +247,9 @@ mod tests { type MaximumBlockLength = (); type Version = (); type ModuleToIndex = (); + type AccountData = (); + type OnNewAccount = (); + type OnReapAccount = (); } impl Trait for Test {} diff --git a/relays/substrate/Cargo.toml b/relays/substrate/Cargo.toml new file mode 100644 index 000000000000..d3382cedd462 --- /dev/null +++ b/relays/substrate/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "substrate-bridge" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" + +[dependencies] +async-std = "1.0.1" +clap = "2.3.3" +ctrlc = "3.1.3" +derive_more = "0.99.1" +env_logger = "0.7.1" +futures = "0.3.1" +jsonrpsee = { git = "https://github.com/paritytech/jsonrpsee", features = ["ws"] } +log = "0.4.8" +node-primitives = { version = "2.0.0", git = "https://github.com/paritytech/substrate" } +serde_json = "1.0.41" +sp-core = { version = "2.0.0", git = "https://github.com/paritytech/substrate.git" } +sp-rpc = { version = "2.0.0", git = "https://github.com/paritytech/substrate.git" } +url = "2.1.0" diff --git a/relays/substrate/README.md b/relays/substrate/README.md new file mode 100644 index 000000000000..dcbaeaaed5a8 --- /dev/null +++ b/relays/substrate/README.md @@ -0,0 +1,32 @@ +# Substrate-to-Substrate Bridge Relay + +The bridge relay is a process that connects to running Substrate nodes and sends data over the Substrate-to-Substrate bridge. The process communicates with the nodes over the JSON-RPC interface and reads data from the relays information required by the `bridge` pallet using runtime calls and writes data to the modules by constructing and submitting extrinsics. + +For more details, see the [design document](doc/design.md). + +## Status + +This is a not-in-progress prototype. + +## Running in development + +Run two development Substrate chains: + +```bash +> TMPDIR=(mktemp -d) +> cd $TMPDIR +> substrate build-spec --dev > red-spec.json +> cp red-spec.json blue-spec.json +# Modify the chain spec in an editor so that the genesis hashes of the two chains differ. +# For example, double one of the balances in '$.genesis.runtime.balances.balances'. +> substrate --chain red-spec.json --alice --base-path ./red --port 30343 --ws-port 9954 +> substrate --chain blue-spec.json --alice --base-path ./blue --port 30353 --ws-port 9964 +``` + +Now run the bridge relay: + +``` +> target/release/substrate-bridge --base-path ./relay \ + --rpc-url ws://localhost:9954 \ + --rpc-url ws://localhost:9964 +``` diff --git a/relays/substrate/src/bridge.rs b/relays/substrate/src/bridge.rs new file mode 100644 index 000000000000..7a733c5862e5 --- /dev/null +++ b/relays/substrate/src/bridge.rs @@ -0,0 +1,391 @@ +use crate::error::Error; +use crate::rpc::{self, SubstrateRPC}; +use crate::params::{RPCUrlParam, Params}; + +use futures::{prelude::*, channel::{mpsc, oneshot}, future, select}; +use jsonrpsee::{ + core::client::{RawClientError, RawClientEvent, RawClientRequestId, RawClientSubscription}, + ws::{WsRawClient, WsConnecError, ws_raw_client}, +}; +use node_primitives::{Hash, Header}; +use std::cell::RefCell; +use std::collections::HashMap; +use std::pin::Pin; +use sp_core::Bytes; + +type ChainId = Hash; + +struct BridgeState { + channel: mpsc::Sender, + locally_finalized_head_on_bridged_chain: Header, +} + +struct ChainState { + current_finalized_head: Header, + bridges: HashMap, +} + +enum Event { + SubmitExtrinsic(Bytes), +} + +struct Chain { + url: String, + client: WsRawClient, + sender: mpsc::Sender, + receiver: mpsc::Receiver, + genesis_hash: Hash, + state: ChainState, +} + +async fn init_rpc_connection(url: &RPCUrlParam) -> Result { + let url_str = url.to_string(); + log::debug!("Connecting to {}", url_str); + + // Skip the leading "ws://" and trailing "/". + let url_without_scheme = &url_str[5..(url_str.len() - 1)]; + let mut client = ws_raw_client(url_without_scheme) + .await + .map_err(|err| Error::WsConnectionError(err.to_string()))?; + + let genesis_hash = rpc::genesis_block_hash(&mut client) + .await + .map_err(|e| Error::RPCError(e.to_string()))? + .ok_or_else(|| Error::InvalidChainState(format!( + "chain with RPC URL {} is missing a genesis block hash", + url_str, + )))?; + + let latest_finalized_hash = SubstrateRPC::chain_finalized_head(&mut client) + .await + .map_err(|e| Error::RPCError(e.to_string()))?; + let latest_finalized_header = SubstrateRPC::chain_header( + &mut client, + Some(latest_finalized_hash) + ) + .await + .map_err(|e| Error::RPCError(e.to_string()))? + .ok_or_else(|| Error::InvalidChainState(format!( + "chain {} is missing header for finalized block hash {}", + genesis_hash, latest_finalized_hash + )))?; + + let (sender, receiver) = mpsc::channel(0); + + Ok(Chain { + url: url_str, + client, + sender, + receiver, + genesis_hash, + state: ChainState { + current_finalized_head: latest_finalized_header, + bridges: HashMap::new(), + } + }) +} + +/// Returns IDs of the bridged chains. +async fn read_bridges(chain: &mut Chain, chain_ids: &[Hash]) + -> Result, Error> +{ + // This should make an RPC call to read this information from the bridge pallet state. + // For now, just pretend every chain is bridged to every other chain. + // + // TODO: The correct thing. + Ok( + chain_ids + .iter() + .cloned() + .filter(|&chain_id| chain_id != chain.genesis_hash) + .collect() + ) +} + +pub async fn run_async( + params: Params, + exit: Box + Unpin + Send> +) -> Result<(), Error> +{ + let chains = init_chains(¶ms).await?; + + let (chain_tasks, exit_signals) = chains.into_iter() + .map(|(chain_id, chain_cell)| { + let chain = chain_cell.into_inner(); + let (task_exit_signal, task_exit_receiver) = oneshot::channel(); + let task_exit = Box::new(task_exit_receiver.map(|result| { + result.expect("task_exit_signal is not dropped before send() is called") + })); + let chain_task = async_std::task::spawn(async move { + if let Err(err) = chain_task(chain_id, chain, task_exit).await { + log::error!("Error in task for chain {}: {}", chain_id, err); + } + }); + (chain_task, task_exit_signal) + }) + .unzip::<_, _, Vec<_>, Vec<_>>(); + + async_std::task::spawn(async move { + exit.await; + for exit_signal in exit_signals { + let _ = exit_signal.send(()); + } + }); + + future::join_all(chain_tasks).await; + Ok(()) +} + +fn initial_next_events<'a>(chains: &'a HashMap>) + -> Vec> + 'a>>> +{ + chains.values() + .map(|chain_cell| async move { + let mut chain = chain_cell.borrow_mut(); + let event = chain.client.next_event() + .await + .map_err(|err| Error::RPCError(err.to_string()))?; + Ok((chain.genesis_hash, event)) + }) + .map(|fut| Box::pin(fut) as Pin>>) + .collect() +} + +async fn next_event<'a>( + next_events: Vec> + 'a>>>, + chains: &'a HashMap>, +) + -> ( + Result<(Hash, RawClientEvent), Error>, + Vec> +'a>>> + ) +{ + let (result, _, mut rest) = future::select_all(next_events).await; + + match result { + Ok((chain_id, _)) => { + let fut = async move { + let chain_cell = chains.get(&chain_id) + .expect("chain must be in the map as a function precondition; qed"); + let mut chain = chain_cell.borrow_mut(); + let event = chain.client.next_event() + .await + .map_err(|err| Error::RPCError(err.to_string()))?; + Ok((chain_id, event)) + }; + rest.push(Box::pin(fut)); + } + Err(ref err) => log::warn!("error in RPC connection with a chain: {}", err), + } + + (result, rest) +} + +async fn init_chains(params: &Params) -> Result>, Error> { + let chains = future::join_all(params.rpc_urls.iter().map(init_rpc_connection)) + .await + .into_iter() + .map(|result| result.map(|chain| (chain.genesis_hash, RefCell::new(chain)))) + .collect::, _>>()?; + + // TODO: Remove when read_bridges is implemented correctly. + let chain_ids = chains.keys() + .cloned() + .collect::>(); + // let chain_ids_slice = chain_ids.as_slice(); + + for (&chain_id, chain_cell) in chains.iter() { + let mut chain = chain_cell.borrow_mut(); + for bridged_chain_id in read_bridges(&mut chain, &chain_ids).await? { + if chain_id == bridged_chain_id { + log::warn!("chain {} has a bridge to itself", chain_id); + continue; + } + + if let Some(bridged_chain_cell) = chains.get(&bridged_chain_id) { + let bridged_chain = bridged_chain_cell.borrow_mut(); + + // TODO: Get this from RPC to runtime API. + let genesis_head = SubstrateRPC::chain_header(&mut chain.client, chain_id) + .await + .map_err(|e| Error::RPCError(e.to_string()))? + .ok_or_else(|| Error::InvalidChainState(format!( + "chain {} is missing a genesis block header", chain_id + )))?; + + let channel = chain.sender.clone(); + chain.state.bridges.insert(bridged_chain_id, BridgeState { + channel, + locally_finalized_head_on_bridged_chain: genesis_head, + }); + + // The conditional ensures that we don't log twice per pair of chains. + if chain_id.as_ref() < bridged_chain_id.as_ref() { + log::info!("initialized bridge between {} and {}", chain_id, bridged_chain_id); + } + } + } + } + + Ok(chains) +} + +async fn setup_subscriptions(chain: &mut Chain) + -> Result<(RawClientRequestId, RawClientRequestId), RawClientError> +{ + let new_heads_subscription_id = chain.client + .start_subscription( + "chain_subscribeNewHeads", + jsonrpsee::core::common::Params::None, + ) + .await + .map_err(RawClientError::Inner)?; + + let finalized_heads_subscription_id = chain.client + .start_subscription( + "chain_subscribeFinalizedHeads", + jsonrpsee::core::common::Params::None, + ) + .await + .map_err(RawClientError::Inner)?; + + let new_heads_subscription = + chain.client.subscription_by_id(new_heads_subscription_id) + .expect("subscription_id was returned from start_subscription above; qed"); + let new_heads_subscription = match new_heads_subscription { + RawClientSubscription::Active(_) => {} + RawClientSubscription::Pending(subscription) => { + subscription.wait().await?; + } + }; + + let finalized_heads_subscription = + chain.client.subscription_by_id(finalized_heads_subscription_id) + .expect("subscription_id was returned from start_subscription above; qed"); + let finalized_heads_subscription = match finalized_heads_subscription { + RawClientSubscription::Active(subscription) => {} + RawClientSubscription::Pending(subscription) => { + subscription.wait().await?; + } + }; + + Ok((new_heads_subscription_id, finalized_heads_subscription_id)) +} + +async fn handle_rpc_event( + chain_id: ChainId, + chain: &mut Chain, + event: RawClientEvent, + new_heads_subscription_id: RawClientRequestId, + finalized_heads_subscription_id: RawClientRequestId, +) -> Result<(), Error> +{ + match event { + RawClientEvent::SubscriptionNotif { request_id, result } => + if request_id == new_heads_subscription_id { + let header: Header = serde_json::from_value(result) + .map_err(Error::SerializationError)?; + log::info!("Received new head {:?} on chain {}", header, chain_id); + } else if request_id == finalized_heads_subscription_id { + let header: Header = serde_json::from_value(result) + .map_err(Error::SerializationError)?; + log::info!("Received finalized head {:?} on chain {}", header, chain_id); + + // let old_finalized_head = chain_state.current_finalized_head; + chain.state.current_finalized_head = header; + for (bridged_chain_id, bridged_chain) in chain.state.bridges.iter_mut() { + if bridged_chain.locally_finalized_head_on_bridged_chain.number < + chain.state.current_finalized_head.number { + // Craft and submit an extrinsic over RPC + log::info!("Sending command to submit extrinsic to chain {}", chain_id); + let mut send_event = bridged_chain.channel + .send(Event::SubmitExtrinsic(Bytes(Vec::new()))) + .fuse(); + + // Continue processing events from other chain tasks while waiting to send + // event to other chain task in order to prevent deadlocks. + loop { + select! { + result = send_event => { + result.map_err(Error::ChannelError)?; + break; + } + event = chain.receiver.next().fuse() => { + let event = event + .expect("stream will never close as the chain has an mpsc Sender"); + handle_bridge_event(chain_id, &mut chain.client, event) + .await?; + } + // TODO: exit + } + } + } + } + } else { + return Err(Error::RPCError(format!( + "unexpected subscription response with request ID {:?}", request_id + ))); + }, + _ => return Err(Error::RPCError(format!( + "unexpected RPC event from chain {}: {:?}", chain_id, event + ))), + } + Ok(()) +} + +// Let's say this never sends over a channel (ie. cannot block on another task). +async fn handle_bridge_event( + chain_id: ChainId, + rpc_client: &mut WsRawClient, + event: Event, +) -> Result<(), Error> +{ + match event { + Event::SubmitExtrinsic(data) => { + log::info!("Submitting extrinsic to chain {}", chain_id); + if let Err(err) = SubstrateRPC::author_submit_extrinsic(rpc_client, data).await { + log::error!("failed to submit extrinsic: {}", err); + } + } + } + Ok(()) +} + +async fn chain_task( + chain_id: ChainId, + mut chain: Chain, + exit: impl Future + Unpin + Send +) -> Result<(), Error> +{ + let (new_heads_subscription_id, finalized_heads_subscription_id) = + setup_subscriptions(&mut chain) + .await + .map_err(|e| Error::RPCError(e.to_string()))?; + + let mut exit = exit.fuse(); + loop { + select! { + result = chain.client.next_event().fuse() => { + let event = result.map_err(|e| Error::RPCError(e.to_string()))?; + handle_rpc_event( + chain_id, + &mut chain, + event, + new_heads_subscription_id, + finalized_heads_subscription_id, + ).await?; + } + event = chain.receiver.next().fuse() => { + let event = event + .expect("stream will never close as the chain has an mpsc Sender"); + handle_bridge_event(chain_id, &mut chain.client, event) + .await?; + } + _ = exit => { + log::debug!("Received exit signal, shutting down task for chain {}", chain_id); + break; + } + } + } + Ok(()) +} diff --git a/relays/substrate/src/error.rs b/relays/substrate/src/error.rs new file mode 100644 index 000000000000..a612c84707d6 --- /dev/null +++ b/relays/substrate/src/error.rs @@ -0,0 +1,31 @@ +use futures::channel::mpsc; + +#[derive(Debug, derive_more::Display)] +pub enum Error { + #[display(fmt = "invalid RPC URL: {}", _0)] + UrlError(String), + #[display(fmt = "RPC response indicates invalid chain state: {}", _0)] + InvalidChainState(String), + #[display(fmt = "could not make RPC call: {}", _0)] + RPCError(String), + #[display(fmt = "could not connect to RPC URL: {}", _0)] + WsConnectionError(String), + #[display(fmt = "unexpected client event from RPC URL {}: {:?}", _0, _1)] + UnexpectedClientEvent(String, String), + #[display(fmt = "serialization error: {}", _0)] + SerializationError(serde_json::error::Error), + #[display(fmt = "invalid event received from bridged chain: {}", _0)] + InvalidBridgeEvent(String), + #[display(fmt = "error sending over MPSC channel: {}", _0)] + ChannelError(mpsc::SendError), +} + +impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Error::SerializationError(err) => Some(err), + Error::ChannelError(err) => Some(err), + _ => None, + } + } +} diff --git a/relays/substrate/src/main.rs b/relays/substrate/src/main.rs new file mode 100644 index 000000000000..bfa183cb2e50 --- /dev/null +++ b/relays/substrate/src/main.rs @@ -0,0 +1,80 @@ +mod bridge; +mod error; +mod params; +mod rpc; + +use bridge::run_async; +use params::{Params, RPCUrlParam}; + +use clap::{App, Arg, value_t, values_t}; +use futures::{prelude::*, channel}; +use std::cell::Cell; +use std::process; + +fn main() { + let params = parse_args(); + env_logger::init(); + let exit = setup_exit_handler(); + + let result = async_std::task::block_on(async move { + run_async(params, exit).await + }); + if let Err(err) = result { + log::error!("{}", err); + process::exit(1); + } +} + +fn parse_args() -> Params { + let matches = App::new("substrate-bridge") + .version("1.0") + .author("Parity Technologies") + .about("Bridges Substrates, duh") + .arg( + Arg::with_name("base-path") + .long("base-path") + .value_name("DIRECTORY") + .required(true) + .help("Sets the base path") + .takes_value(true), + ) + .arg( + Arg::with_name("rpc-url") + .long("rpc-url") + .value_name("HOST[:PORT]") + .help("The URL of a bridged Substrate node") + .takes_value(true) + .multiple(true) + ) + .get_matches(); + + let base_path = value_t!(matches, "base-path", String) + .unwrap_or_else(|e| e.exit()); + let rpc_urls = values_t!(matches, "rpc-url", RPCUrlParam) + .unwrap_or_else(|e| e.exit()); + + Params { + base_path, + rpc_urls, + } +} + +fn setup_exit_handler() -> Box + Unpin + Send> { + let (exit_sender, exit_receiver) = channel::oneshot::channel(); + let exit_sender = Cell::new(Some(exit_sender)); + + ctrlc::set_handler(move || { + if let Some(exit_sender) = exit_sender.take() { + if let Err(()) = exit_sender.send(()) { + log::warn!("failed to send exit signal"); + } + } + }) + .expect("must be able to set Ctrl-C handler"); + + Box::new(exit_receiver.map(|result| { + result.expect( + "exit_sender cannot be dropped as it is moved into a globally-referenced closure" + ) + })) +} diff --git a/relays/substrate/src/params.rs b/relays/substrate/src/params.rs new file mode 100644 index 000000000000..019581eb8c4b --- /dev/null +++ b/relays/substrate/src/params.rs @@ -0,0 +1,75 @@ +use crate::error::Error; + +use url::Url; +use std::str::FromStr; + +const DEFAULT_WS_PORT: u16 = 9944; + +#[derive(Debug, Clone)] +pub struct Params { + pub base_path: String, + pub rpc_urls: Vec, +} + +#[derive(Debug, Clone)] +pub struct RPCUrlParam { + url: Url, +} + +impl ToString for RPCUrlParam { + fn to_string(&self) -> String { + self.url.to_string() + } +} + +impl FromStr for RPCUrlParam { + type Err = Error; + + fn from_str(url_str: &str) -> Result { + let mut url = Url::parse(url_str) + .map_err(|e| Error::UrlError(format!("could not parse {}: {}", url_str, e)))?; + + if url.scheme() != "ws" { + return Err(Error::UrlError(format!("must have scheme ws, found {}", url.scheme()))); + } + + if url.port().is_none() { + url.set_port(Some(DEFAULT_WS_PORT)) + .expect("the scheme is checked above to be ws; qed"); + } + + if url.path() != "/" { + return Err(Error::UrlError(format!("cannot have a path, found {}", url.path()))); + } + if let Some(query) = url.query() { + return Err(Error::UrlError(format!("cannot have a query, found {}", query))); + } + if let Some(fragment) = url.fragment() { + return Err(Error::UrlError(format!("cannot have a fragment, found {}", fragment))); + } + + Ok(RPCUrlParam { url }) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn rpc_url_from_str() { + assert_eq!( + RPCUrlParam::from_str("ws://127.0.0.1").unwrap().to_string(), + "ws://127.0.0.1:9944/" + ); + assert_eq!( + RPCUrlParam::from_str("ws://127.0.0.1/").unwrap().to_string(), + "ws://127.0.0.1:9944/" + ); + assert_eq!( + RPCUrlParam::from_str("ws://127.0.0.1:4499").unwrap().to_string(), + "ws://127.0.0.1:4499/" + ); + assert!(RPCUrlParam::from_str("http://127.0.0.1").is_err()); + } +} diff --git a/relays/substrate/src/rpc.rs b/relays/substrate/src/rpc.rs new file mode 100644 index 000000000000..575419e3c5f0 --- /dev/null +++ b/relays/substrate/src/rpc.rs @@ -0,0 +1,29 @@ +use jsonrpsee::core::client::{RawClient, RawClientError, TransportClient}; +use node_primitives::{BlockNumber, Hash, Header}; +use sp_core::Bytes; +use sp_rpc::number::NumberOrHex; + +jsonrpsee::rpc_api! { + pub SubstrateRPC { + #[rpc(method = "author_submitExtrinsic", positional_params)] + fn author_submit_extrinsic(extrinsic: Bytes) -> Hash; + + #[rpc(method = "chain_getFinalizedHead")] + fn chain_finalized_head() -> Hash; + + #[rpc(method = "chain_getBlockHash", positional_params)] + fn chain_block_hash(id: Option>) -> Option; + + #[rpc(method = "chain_getHeader", positional_params)] + fn chain_header(hash: Option) -> Option
; + + #[rpc(positional_params)] + fn state_call(name: String, bytes: Bytes, hash: Option) -> Bytes; + } +} + +pub async fn genesis_block_hash(client: &mut RawClient) + -> Result, RawClientError> +{ + SubstrateRPC::chain_block_hash(client, Some(NumberOrHex::Number(0))).await +}