diff --git a/.github/workflows/subquery-dev.yml b/.github/workflows/subquery-dev.yml index b794ba5d4..55d66d82b 100644 --- a/.github/workflows/subquery-dev.yml +++ b/.github/workflows/subquery-dev.yml @@ -41,7 +41,7 @@ jobs: strategy: max-parallel: 1 matrix: - chain: + chain: - kusama - rococo steps: @@ -65,14 +65,15 @@ jobs: subql_path: subql/parachain/${{ matrix.chain }} bridge-s2s: - name: Subql Parachain + name: Subql s2s runs-on: ubuntu-latest strategy: max-parallel: 1 matrix: - chain: + chain: - pangolin - pangolin-parachain + - pangoro - rococo - crab - crab-parachain diff --git a/.maintain/config/bridge-pangolin-pangoro.toml b/.maintain/config/bridge-pangolin-pangoro.toml index a7f6e8dc3..52895c563 100644 --- a/.maintain/config/bridge-pangolin-pangoro.toml +++ b/.maintain/config/bridge-pangolin-pangoro.toml @@ -1,53 +1,14 @@ [pangolin] endpoint = "wss://pangolin-rpc.darwinia.network" signer = "//Alice" -# Bundle/Auto/Custom -runtime_version_mode = "Bundle" -# If the runtime version mode is custom, you need to set this. -#spec_version = 12345 -# If the runtime version mode is custom, you need to set this. -#transaction_version = 0 [pangoro] endpoint = "wss://pangoro-rpc.darwinia.network" signer = "//Alice" -# Bundle/Auto/Custom -runtime_version_mode = "Bundle" -# If the runtime version mode is custom, you need to set this. -#spec_version = 12345 -# If the runtime version mode is custom, you need to set this. -#transaction_version = 0 [relay] # substrate-substrate bridger message relay lanes, default use `00000000` lanes = ["726f6c69"] -# (optional) The relay message signer, if not set will use [panglin.signer] -signer_pangolin = "//Alice" -# (optional) the relay message signer, if not set will use [pangoro.signer] -signer_pangoro = "//Alice" -# If passed, only mandatory headers (headers that are changing the GRANDPA authorities set) are relayed. -only_mandatory_headers = false -# Create relayers fund accounts on both chains, if it does not exists yet. -create_relayers_fund_accounts = false - -# The SURI of secret key to use when transactions are submitted to the pangolin node. -#pangolin_messages_pallet_owner = "//PangoroMessagesOwner" -# The password for the SURI of secret key to use when transactions are submitted to the pangolin node. -#pangolin_messages_pallet_owner_password = "123456" -# The SURI of secret key to use when transactions are submitted to the pangoro node. -#pangoro_messages_pallet_owner = "//PangolinMessagesOwner" -# The password for the SURI of secret key to use when transactions are submitted to the pangoro node. -#pangoro_messages_pallet_owner_password = "123456" - -# Transactions mortality period, in blocks. MUST be a power of two in [4; 65536] range. -# MAY NOT be larger than `BlockHashCount` parameter of the chain system module. -# Discuss: https://github.com/darwinia-network/bridger/pull/266#discussion_r705943606 -#transactions_mortality = 256 - -[relay.prometheus_params] -no_prometheus = false -prometheus_host = "127.0.0.1" -prometheus_port = 9616 #[feemarket] #[feemarket.subscan_left] @@ -69,3 +30,12 @@ interval_update_fee = 1800 # - Crazy: If the first assigned relay is not mine. set the first assigned relayer's fee-1 to your fee. # - Reasonable: Query rencently orders from subscan. and calculate your fee. update_fee_strategy = "Nothing" + +[index.pangolin] +# Subquery pangolin indexer queries url +endpoint = "https://api.subquery.network/sq/darwinia-network/subql-bridge-s2s-pangolin" + +[index.pangoro] +# Subquery pangoro indexer queries url +endpoint = "https://api.subquery.network/sq/darwinia-network/subql-bridge-s2s-pangoro" + diff --git a/bridges/crab-crabparachain/Cargo.lock b/bridges/crab-crabparachain/Cargo.lock index 32fb4a81a..4b2ba4912 100644 --- a/bridges/crab-crabparachain/Cargo.lock +++ b/bridges/crab-crabparachain/Cargo.lock @@ -6583,6 +6583,7 @@ dependencies = [ name = "subquery-s2s" version = "0.5.7" dependencies = [ + "array-bytes", "async-trait", "gql_client", "hex", diff --git a/bridges/pangolin-pangolinparachain/Cargo.lock b/bridges/pangolin-pangolinparachain/Cargo.lock index ba7083c35..e447db7d1 100644 --- a/bridges/pangolin-pangolinparachain/Cargo.lock +++ b/bridges/pangolin-pangolinparachain/Cargo.lock @@ -1012,12 +1012,13 @@ name = "client-pangolin" version = "0.5.7" dependencies = [ "array-bytes", - "futures-util", - "jsonrpsee", + "bp-header-chain", + "finality-grandpa", "parity-scale-codec", "serde 1.0.137", "serde_json", - "sp-core", + "sp-finality-grandpa", + "sp-runtime", "subxt", "support-toolkit", "thiserror", @@ -6597,6 +6598,7 @@ dependencies = [ name = "subquery-s2s" version = "0.5.7" dependencies = [ + "array-bytes", "async-trait", "gql_client", "hex", diff --git a/bridges/pangolin-pangolinparachain/bridge/Cargo.toml b/bridges/pangolin-pangolinparachain/bridge/Cargo.toml index 9e908d528..d0a4fbc77 100644 --- a/bridges/pangolin-pangolinparachain/bridge/Cargo.toml +++ b/bridges/pangolin-pangolinparachain/bridge/Cargo.toml @@ -64,7 +64,7 @@ relay-utils = { git = "https://github.com/darwinia-network/d substrate-relay-helper = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2" } subxt = { git = "https://github.com/darwinia-network/subxt.git", branch = "darwinia-v0.12.2" } ## component -client-pangolin = { path = "../../../frame/assistants/client-pangolin" } +client-pangolin = { path = "../../../frame/assistants/client-pangolin", features = ["s2s"] } client-pangolin-parachain = { path = "../../../frame/assistants/client-pangolin-parachain" } client-rococo = { path = "../../../frame/assistants/client-rococo" } component-subscan = { path = "../../../frame/components/subscan" } diff --git a/bridges/pangolin-pangoro/Cargo.lock b/bridges/pangolin-pangoro/Cargo.lock index 6dfd59cbd..7968d5a3a 100644 --- a/bridges/pangolin-pangoro/Cargo.lock +++ b/bridges/pangolin-pangoro/Cargo.lock @@ -27,41 +27,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aead" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" -dependencies = [ - "generic-array 0.14.5", -] - -[[package]] -name = "aes" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" -dependencies = [ - "cfg-if 1.0.0", - "cipher", - "cpufeatures 0.2.2", - "opaque-debug 0.3.0", -] - -[[package]] -name = "aes-gcm" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" -dependencies = [ - "aead", - "aes", - "cipher", - "ctr", - "ghash", - "subtle", -] - [[package]] name = "ahash" version = "0.7.6" @@ -98,13 +63,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" [[package]] -name = "approx" -version = "0.5.1" +name = "array-bytes" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" -dependencies = [ - "num-traits 0.2.14", -] +checksum = "b48bc78d3fa4a9a0925d5009f731cbf7e5613d2a4f1a937208f6dde89a287bab" [[package]] name = "array-init" @@ -115,12 +77,6 @@ dependencies = [ "nodrop", ] -[[package]] -name = "array_tool" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f8cb5d814eb646a863c4f24978cff2880c4be96ad8cde2c0f0678732902e271" - [[package]] name = "arrayref" version = "0.3.6" @@ -148,166 +104,6 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" -[[package]] -name = "asn1_der" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e22d1f4b888c298a027c99dc9048015fac177587de20fc30232a057dfbe24a21" - -[[package]] -name = "async-attributes" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "async-channel" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319" -dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", -] - -[[package]] -name = "async-executor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965" -dependencies = [ - "async-task", - "concurrent-queue", - "fastrand", - "futures-lite", - "once_cell", - "slab", -] - -[[package]] -name = "async-global-executor" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c290043c9a95b05d45e952fb6383c67bcb61471f60cfa21e890dba6654234f43" -dependencies = [ - "async-channel", - "async-executor", - "async-io", - "async-mutex", - "blocking", - "futures-lite", - "num_cpus", - "once_cell", -] - -[[package]] -name = "async-io" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a811e6a479f2439f0c04038796b5cfb3d2ad56c230e0f2d3f7b04d68cfee607b" -dependencies = [ - "concurrent-queue", - "futures-lite", - "libc", - "log", - "once_cell", - "parking", - "polling", - "slab", - "socket2 0.4.4", - "waker-fn", - "winapi", -] - -[[package]] -name = "async-lock" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e97a171d191782fba31bb902b14ad94e24a68145032b7eedf871ab0bc0d077b6" -dependencies = [ - "event-listener", -] - -[[package]] -name = "async-mutex" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479db852db25d9dbf6204e6cb6253698f175c15726470f78af0d918e99d6156e" -dependencies = [ - "event-listener", -] - -[[package]] -name = "async-process" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83137067e3a2a6a06d67168e49e68a0957d215410473a740cea95a2425c0b7c6" -dependencies = [ - "async-io", - "blocking", - "cfg-if 1.0.0", - "event-listener", - "futures-lite", - "libc", - "once_cell", - "signal-hook", - "winapi", -] - -[[package]] -name = "async-std" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52580991739c5cdb36cde8b2a516371c0a3b70dda36d916cc08b82372916808c" -dependencies = [ - "async-attributes", - "async-channel", - "async-global-executor", - "async-io", - "async-lock", - "async-process", - "crossbeam-utils", - "futures-channel", - "futures-core", - "futures-io", - "futures-lite", - "gloo-timers", - "kv-log-macro", - "log", - "memchr", - "num_cpus", - "once_cell", - "pin-project-lite 0.2.8", - "pin-utils", - "slab", - "wasm-bindgen-futures", -] - -[[package]] -name = "async-std-resolver" -version = "0.20.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf3e776afdf3a2477ef4854b85ba0dff3bd85792f685fb3c68948b4d304e4f0" -dependencies = [ - "async-std", - "async-trait", - "futures-io", - "futures-util", - "pin-utils", - "trust-dns-resolver", -] - -[[package]] -name = "async-task" -version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9" - [[package]] name = "async-trait" version = "0.1.53" @@ -319,32 +115,6 @@ dependencies = [ "syn", ] -[[package]] -name = "asynchronous-codec" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb4401f0a3622dad2e0763fa79e0eb328bc70fb7dccfdd645341f00d671247d6" -dependencies = [ - "bytes 1.1.0", - "futures-sink", - "futures-util", - "memchr", - "pin-project-lite 0.2.8", -] - -[[package]] -name = "asynchronous-codec" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0de5164e5edbf51c45fb8c2d9664ae1c095cce1b265ecf7569093c0d66ef690" -dependencies = [ - "bytes 1.1.0", - "futures-sink", - "futures-util", - "memchr", - "pin-project-lite 0.2.8", -] - [[package]] name = "atomic" version = "0.5.1" @@ -354,12 +124,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "atomic-waker" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" - [[package]] name = "atty" version = "0.2.14" @@ -377,16 +141,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "backoff" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721c249ab59cbc483ad4294c9ee2671835c1e43e9ffc277e6b4ecfef733cfdc5" -dependencies = [ - "instant", - "rand 0.7.3", -] - [[package]] name = "backtrace" version = "0.3.65" @@ -402,12 +156,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base-x" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" - [[package]] name = "base58" version = "0.1.0" @@ -453,17 +201,6 @@ dependencies = [ "wyz", ] -[[package]] -name = "blake2" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" -dependencies = [ - "crypto-mac 0.8.0", - "digest 0.9.0", - "opaque-debug 0.3.0", -] - [[package]] name = "blake2-rfc" version = "0.2.18" @@ -474,50 +211,13 @@ dependencies = [ "constant_time_eq", ] -[[package]] -name = "blake2b_simd" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" -dependencies = [ - "arrayref", - "arrayvec 0.5.2", - "constant_time_eq", -] - -[[package]] -name = "blake2s_simd" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e461a7034e85b211a4acb57ee2e6730b32912b06c08cc242243c39fc21ae6a2" -dependencies = [ - "arrayref", - "arrayvec 0.5.2", - "constant_time_eq", -] - -[[package]] -name = "blake3" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b64485778c4f16a6a5a9d335e80d449ac6c70cdd6a06d2af18a6f6f775a125b3" -dependencies = [ - "arrayref", - "arrayvec 0.5.2", - "cc", - "cfg-if 0.1.10", - "constant_time_eq", - "crypto-mac 0.8.0", - "digest 0.9.0", -] - [[package]] name = "block-buffer" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ - "block-padding 0.1.5", + "block-padding", "byte-tools", "byteorder", "generic-array 0.12.4", @@ -529,7 +229,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "block-padding 0.2.1", "generic-array 0.14.5", ] @@ -542,46 +241,10 @@ dependencies = [ "byte-tools", ] -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - -[[package]] -name = "blocking" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6ccb65d468978a086b69884437ded69a90faab3bbe6e67f242173ea728acccc" -dependencies = [ - "async-channel", - "async-task", - "atomic-waker", - "fastrand", - "futures-lite", - "once_cell", -] - -[[package]] -name = "bp-darwinia-core" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "bp-messages", - "bp-runtime", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-std", -] - [[package]] name = "bp-header-chain" version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" +source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#734a60313dd32e77574d8c72298660c291440151" dependencies = [ "finality-grandpa", "frame-support", @@ -595,241 +258,32 @@ dependencies = [ ] [[package]] -name = "bp-message-dispatch" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "bp-runtime", - "frame-support", - "parity-scale-codec", - "scale-info", - "sp-std", -] - -[[package]] -name = "bp-messages" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" +name = "bridge-pangolin-pangoro" +version = "0.5.7" dependencies = [ - "bitvec", - "bp-runtime", - "frame-support", - "frame-system", - "impl-trait-for-tuples", + "array-bytes", + "client-pangolin", + "client-pangoro", + "color-eyre", + "component-http-client", + "futures", + "lifeline", + "once_cell", "parity-scale-codec", - "scale-info", + "postage", "serde 1.0.136", "sp-core", - "sp-std", + "structopt", + "strum", + "subquery-s2s", + "subxt", + "support-common", + "support-lifeline", + "support-terminal", + "tokio", + "tracing", ] -[[package]] -name = "bp-pangolin" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "bp-darwinia-core", - "bp-messages", - "bp-runtime", - "frame-support", - "sp-api", - "sp-runtime", - "sp-std", - "sp-version", -] - -[[package]] -name = "bp-pangolin-parachain" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "bp-darwinia-core", - "bp-messages", - "bp-runtime", - "frame-support", - "sp-api", - "sp-runtime", - "sp-std", - "sp-version", -] - -[[package]] -name = "bp-pangoro" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "bp-darwinia-core", - "bp-messages", - "bp-runtime", - "frame-support", - "sp-api", - "sp-runtime", - "sp-std", - "sp-version", -] - -[[package]] -name = "bp-parachains" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "bp-polkadot-core", - "bp-runtime", - "frame-support", - "parity-scale-codec", - "scale-info", - "serde 1.0.136", - "sp-core", -] - -[[package]] -name = "bp-polkadot-core" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "bp-messages", - "bp-runtime", - "frame-support", - "frame-system", - "parity-scale-codec", - "parity-util-mem", - "scale-info", - "serde 1.0.136", - "sp-api", - "sp-core", - "sp-runtime", - "sp-std", - "sp-version", -] - -[[package]] -name = "bp-rococo" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "bp-messages", - "bp-polkadot-core", - "bp-runtime", - "frame-support", - "parity-scale-codec", - "smallvec 1.8.0", - "sp-api", - "sp-runtime", - "sp-std", - "sp-version", -] - -[[package]] -name = "bp-runtime" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "frame-support", - "hash-db", - "num-traits 0.2.14", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-trie", -] - -[[package]] -name = "bp-test-utils" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "bp-header-chain", - "ed25519-dalek", - "finality-grandpa", - "parity-scale-codec", - "sp-application-crypto", - "sp-finality-grandpa", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "bridge-pangolin-pangoro" -version = "0.5.7" -dependencies = [ - "async-trait", - "bp-darwinia-core", - "bp-header-chain", - "bp-messages", - "bp-pangolin", - "bp-pangoro", - "bp-runtime", - "bridge-runtime-common", - "color-eyre", - "colored", - "feemarket-s2s", - "frame-support", - "futures 0.3.21", - "futures-timer", - "hex", - "lifeline", - "messages-relay", - "pallet-bridge-messages", - "pallet-fee-market", - "parity-scale-codec", - "postage", - "relay-pangolin-client", - "relay-pangoro-client", - "relay-substrate-client", - "relay-utils", - "serde 1.0.136", - "serde_json", - "sp-core", - "sp-finality-grandpa", - "sp-runtime", - "sp-trie", - "sp-version", - "structopt", - "strum", - "subquery-s2s", - "substrate-relay-helper", - "support-common", - "support-lifeline", - "support-terminal", - "tokio", - "tracing", -] - -[[package]] -name = "bridge-runtime-common" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "bp-message-dispatch", - "bp-messages", - "bp-polkadot-core", - "bp-runtime", - "frame-support", - "hash-db", - "pallet-bridge-dispatch", - "pallet-bridge-grandpa", - "pallet-bridge-messages", - "pallet-bridge-parachains", - "pallet-transaction-payment", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-trie", -] - -[[package]] -name = "bs58" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" - [[package]] name = "bumpalo" version = "3.9.1" @@ -854,38 +308,17 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" -[[package]] -name = "bytes" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" - [[package]] name = "bytes" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" -[[package]] -name = "cache-padded" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" - -[[package]] -name = "castaway" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2698f953def977c68f935bb0dfa959375ad4638570e969e2f1e9f433cbf1af6" - [[package]] name = "cc" version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" -dependencies = [ - "jobserver", -] [[package]] name = "cfg-if" @@ -900,29 +333,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "chacha20" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fee7ad89dc1128635074c268ee661f90c3f7e83d9fd12910608c36b47d6c3412" -dependencies = [ - "cfg-if 1.0.0", - "cipher", - "cpufeatures 0.1.5", - "zeroize", -] - -[[package]] -name = "chacha20poly1305" -version = "0.8.0" +name = "chameleon" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1580317203210c517b6d44794abfbe600698276db18127e37ad3e69bf5e848e5" -dependencies = [ - "aead", - "chacha20", - "cipher", - "poly1305", - "zeroize", -] +checksum = "12bd83544cd11113170ce1eee45383928f3f720bc8b305af18c2a3da3547e1ae" [[package]] name = "chrono" @@ -933,30 +347,10 @@ dependencies = [ "libc", "num-integer", "num-traits 0.2.14", - "time 0.1.44", + "time", "winapi", ] -[[package]] -name = "cid" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff0e3bc0b6446b3f9663c1a6aba6ef06c5aeaa1bc92bd18077be337198ab9768" -dependencies = [ - "multibase", - "multihash 0.13.2", - "unsigned-varint 0.5.1", -] - -[[package]] -name = "cipher" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" -dependencies = [ - "generic-array 0.14.5", -] - [[package]] name = "clap" version = "2.34.0" @@ -966,12 +360,48 @@ dependencies = [ "ansi_term", "atty", "bitflags", - "strsim", + "strsim 0.8.0", "textwrap", "unicode-width", "vec_map", ] +[[package]] +name = "client-pangolin" +version = "0.5.7" +dependencies = [ + "array-bytes", + "bp-header-chain", + "finality-grandpa", + "parity-scale-codec", + "serde 1.0.136", + "serde_json", + "sp-finality-grandpa", + "sp-runtime", + "subxt", + "support-toolkit", + "thiserror", + "tracing", +] + +[[package]] +name = "client-pangoro" +version = "0.5.7" +dependencies = [ + "array-bytes", + "bp-header-chain", + "finality-grandpa", + "parity-scale-codec", + "serde 1.0.136", + "serde_json", + "sp-finality-grandpa", + "sp-runtime", + "subxt", + "support-toolkit", + "thiserror", + "tracing", +] + [[package]] name = "cloudabi" version = "0.0.3" @@ -1020,27 +450,15 @@ dependencies = [ ] [[package]] -name = "component-subscan" +name = "component-http-client" version = "0.5.7" dependencies = [ + "color-eyre", "reqwest", "serde 1.0.136", - "serde-aux", - "serde-hex", - "serde_json", - "thiserror", "tracing", ] -[[package]] -name = "concurrent-queue" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" -dependencies = [ - "cache-padded", -] - [[package]] name = "config" version = "0.11.0" @@ -1057,12 +475,6 @@ dependencies = [ "yaml-rust", ] -[[package]] -name = "const_fn" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935" - [[package]] name = "constant_time_eq" version = "0.1.5" @@ -1091,15 +503,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" -[[package]] -name = "cpufeatures" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" -dependencies = [ - "libc", -] - [[package]] name = "cpufeatures" version = "0.2.2" @@ -1110,83 +513,39 @@ dependencies = [ ] [[package]] -name = "crc32fast" -version = "1.3.2" +name = "crossbeam-queue" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2" dependencies = [ "cfg-if 1.0.0", + "crossbeam-utils", ] [[package]] -name = "crossbeam-channel" -version = "0.5.4" +name = "crossbeam-utils" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" +checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils", + "lazy_static", ] [[package]] -name = "crossbeam-deque" -version = "0.8.1" +name = "crunchy" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-epoch", - "crossbeam-utils", -] +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] -name = "crossbeam-epoch" -version = "0.9.8" +name = "crypto-mac" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "autocfg", - "cfg-if 1.0.0", - "crossbeam-utils", - "lazy_static", - "memoffset", - "scopeguard", -] - -[[package]] -name = "crossbeam-queue" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" -dependencies = [ - "cfg-if 1.0.0", - "lazy_static", -] - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-mac" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" -dependencies = [ - "generic-array 0.14.5", - "subtle", + "generic-array 0.14.5", + "subtle", ] [[package]] @@ -1199,67 +558,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ctor" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f877be4f7c9f246b183111634f75baa039715e3f46ce860677d3b19a69fb229c" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "ctr" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" -dependencies = [ - "cipher", -] - -[[package]] -name = "cuckoofilter" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b810a8449931679f64cd7eef1bbd0fa315801b6d5d9cdc1ace2804d6529eee18" -dependencies = [ - "byteorder", - "fnv", - "rand 0.7.3", -] - -[[package]] -name = "curl" -version = "0.4.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d855aeef205b43f65a5001e0997d81f8efca7badad4fad7d897aa7f0d0651f" -dependencies = [ - "curl-sys", - "libc", - "openssl-probe", - "openssl-sys", - "schannel", - "socket2 0.4.4", - "winapi", -] - -[[package]] -name = "curl-sys" -version = "0.4.53+curl-7.82.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8092905a5a9502c312f223b2775f57ec5c5b715f9a15ee9d2a8591d1364a0352" -dependencies = [ - "cc", - "libc", - "libnghttp2-sys", - "libz-sys", - "openssl-sys", - "pkg-config", - "vcpkg", - "winapi", -] - [[package]] name = "curve25519-dalek" version = "2.1.3" @@ -1287,28 +585,48 @@ dependencies = [ ] [[package]] -name = "data-encoding" -version = "2.3.2" +name = "darling" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" +checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.10.0", + "syn", +] [[package]] -name = "data-encoding-macro" -version = "0.1.12" +name = "darling_macro" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86927b7cd2fe88fa698b87404b287ab98d1a0063a34071d92e575b72d3029aca" +checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ - "data-encoding", - "data-encoding-macro-internal", + "darling_core", + "quote", + "syn", ] [[package]] -name = "data-encoding-macro-internal" -version = "0.1.10" +name = "derivative" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5bbed42daaa95e780b60a50546aa345b8413a1e46f9a40a12907d3598f038db" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ - "data-encoding", + "proc-macro2", + "quote", "syn", ] @@ -1321,7 +639,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version 0.4.0", + "rustc_version", "syn", ] @@ -1363,28 +681,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" - -[[package]] -name = "dns-parser" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4d33be9473d06f75f58220f71f7a9317aca647dc061dbd3c361b0bef505fbea" -dependencies = [ - "byteorder", - "quick-error", -] - -[[package]] -name = "doc-comment" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" - [[package]] name = "downcast-rs" version = "1.2.0" @@ -1420,9 +716,9 @@ checksum = "21e50f3adc76d6a43f5ed73b698a87d0760ca74617f60f7c3b879003536fdd28" [[package]] name = "ed25519" -version = "1.4.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d5c4b5e5959dc2c2b89918d8e2cc40fcdd623cef026ed09d2f0ee05199dc8e4" +checksum = "1e9c280362032ea4203659fc489832d0204ef09f247a0506f170dafcac08c369" dependencies = [ "signature", ] @@ -1456,44 +752,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "enum-as-inner" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "570d109b813e904becc80d8d5da38376818a143348413f7149f1340fe04754d4" -dependencies = [ - "heck 0.4.0", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime 1.3.0", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "env_logger" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" -dependencies = [ - "atty", - "humantime 2.1.0", - "log", - "regex", - "termcolor", -] - [[package]] name = "environmental" version = "1.1.3" @@ -1509,39 +767,6 @@ dependencies = [ "serde 1.0.136", ] -[[package]] -name = "ethbloom" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb684ac8fa8f6c5759f788862bb22ec6fe3cb392f6bfd08e3c64b603661e3f8" -dependencies = [ - "crunchy", - "fixed-hash", - "impl-rlp", - "impl-serde", - "tiny-keccak", -] - -[[package]] -name = "ethereum-types" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05136f7057fe789f06e6d41d07b34e6f70d8c86e5693b60f97aaa6553553bdaf" -dependencies = [ - "ethbloom", - "fixed-hash", - "impl-rlp", - "impl-serde", - "primitive-types", - "uint", -] - -[[package]] -name = "event-listener" -version = "2.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" - [[package]] name = "eyre" version = "0.6.8" @@ -1567,26 +792,6 @@ dependencies = [ "instant", ] -[[package]] -name = "feemarket-s2s" -version = "0.5.7" -dependencies = [ - "async-trait", - "bp-messages", - "component-subscan", - "frame-support", - "messages-relay", - "pallet-fee-market", - "parity-scale-codec", - "relay-substrate-client", - "relay-utils", - "serde 1.0.136", - "sp-core", - "sp-runtime", - "thiserror", - "tracing", -] - [[package]] name = "finality-grandpa" version = "0.14.4" @@ -1594,7 +799,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8ac3ff5224ef91f3c97e03eb1de2db82743427e91aaa5ac635f454f0b164f5a" dependencies = [ "either", - "futures 0.3.21", + "futures", "futures-timer", "log", "num-traits 0.2.14", @@ -1603,21 +808,6 @@ dependencies = [ "scale-info", ] -[[package]] -name = "finality-relay" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "async-std", - "async-trait", - "backoff", - "bp-header-chain", - "futures 0.3.21", - "log", - "num-traits 0.2.14", - "relay-utils", -] - [[package]] name = "fixed-hash" version = "0.7.0" @@ -1630,25 +820,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "fixedbitset" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" - -[[package]] -name = "flate2" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39522e96686d38f4bc984b9198e3a0613264abaebaff2c5c918bfa6b6da09af" -dependencies = [ - "cfg-if 1.0.0", - "crc32fast", - "libc", - "libz-sys", - "miniz_oxide", -] - [[package]] name = "fnv" version = "1.0.7" @@ -1670,14 +841,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" -[[package]] -name = "fork-tree" -version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "parity-scale-codec", -] - [[package]] name = "form_urlencoded" version = "1.0.1" @@ -1685,27 +848,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" dependencies = [ "matches", - "percent-encoding 2.1.0", -] - -[[package]] -name = "frame-benchmarking" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "frame-support", - "frame-system", - "linregress", - "log", - "parity-scale-codec", - "paste", - "scale-info", - "sp-api", - "sp-io", - "sp-runtime", - "sp-runtime-interface", - "sp-std", - "sp-storage", + "percent-encoding", ] [[package]] @@ -1781,35 +924,12 @@ dependencies = [ "syn", ] -[[package]] -name = "frame-system" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "frame-support", - "log", - "parity-scale-codec", - "scale-info", - "serde 1.0.136", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-version", -] - [[package]] name = "funty" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" -[[package]] -name = "futures" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" - [[package]] name = "futures" version = "0.3.21" @@ -1859,21 +979,6 @@ version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" -[[package]] -name = "futures-lite" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite 0.2.8", - "waker-fn", -] - [[package]] name = "futures-macro" version = "0.3.21" @@ -1885,17 +990,6 @@ dependencies = [ "syn", ] -[[package]] -name = "futures-rustls" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a1387e07917c711fb4ee4f48ea0adb04a3c9739e53ef85bf43ae1edc2937a8b" -dependencies = [ - "futures-io", - "rustls 0.19.1", - "webpki 0.21.4", -] - [[package]] name = "futures-sink" version = "0.3.21" @@ -1920,7 +1014,6 @@ version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" dependencies = [ - "futures 0.1.31", "futures-channel", "futures-core", "futures-io", @@ -1928,7 +1021,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.8", + "pin-project-lite", "pin-utils", "slab", ] @@ -1976,34 +1069,12 @@ dependencies = [ "wasi 0.10.0+wasi-snapshot-preview1", ] -[[package]] -name = "ghash" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" -dependencies = [ - "opaque-debug 0.3.0", - "polyval", -] - [[package]] name = "gimli" version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" -[[package]] -name = "gloo-timers" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fb7d06c1c8cc2a29bee7ec961009a0b2caa0793ee4900c2ffb348734ba1c8f9" -dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", -] - [[package]] name = "gql_client" version = "1.0.4" @@ -2021,7 +1092,7 @@ version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37a82c6d637fc9515a4694bbf1cb2457b79d81ce52b3108bdeea58b07dd34a57" dependencies = [ - "bytes 1.1.0", + "bytes", "fnv", "futures-core", "futures-sink", @@ -2067,12 +1138,6 @@ dependencies = [ "unicode-segmentation", ] -[[package]] -name = "heck" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" - [[package]] name = "hermit-abi" version = "0.1.19" @@ -2088,12 +1153,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hex_fmt" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f" - [[package]] name = "hmac" version = "0.8.1" @@ -2125,24 +1184,13 @@ dependencies = [ "hmac 0.8.1", ] -[[package]] -name = "hostname" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" -dependencies = [ - "libc", - "match_cfg", - "winapi", -] - [[package]] name = "http" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03" dependencies = [ - "bytes 1.1.0", + "bytes", "fnv", "itoa", ] @@ -2153,9 +1201,9 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" dependencies = [ - "bytes 1.1.0", + "bytes", "http", - "pin-project-lite 0.2.8", + "pin-project-lite", ] [[package]] @@ -2170,28 +1218,13 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hyper" version = "0.14.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b26ae0a80afebe130861d90abf98e3814a4f28a4c6ffeb5ab8ebb2be311e0ef2" dependencies = [ - "bytes 1.1.0", + "bytes", "futures-channel", "futures-core", "futures-util", @@ -2201,8 +1234,8 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project-lite 0.2.8", - "socket2 0.4.4", + "pin-project-lite", + "socket2", "tokio", "tower-service", "tracing", @@ -2217,7 +1250,7 @@ checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac" dependencies = [ "http", "hyper", - "rustls 0.20.4", + "rustls", "tokio", "tokio-rustls", ] @@ -2228,7 +1261,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ - "bytes 1.1.0", + "bytes", "hyper", "native-tls", "tokio", @@ -2236,15 +1269,10 @@ dependencies = [ ] [[package]] -name = "idna" -version = "0.1.5" +name = "ident_case" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" @@ -2257,43 +1285,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "if-addrs" -version = "0.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2273e421f7c4f0fc99e1934fe4776f59d8df2972f4199d703fc0da9f2a9f73de" -dependencies = [ - "if-addrs-sys", - "libc", - "winapi", -] - -[[package]] -name = "if-addrs-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de74b9dd780476e837e5eb5ab7c88b49ed304126e412030a0adba99c8efe79ea" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "if-watch" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8ab7f67bad3240049cb24fb9cb0b4c2c6af4c245840917fbbdededeee91179" -dependencies = [ - "async-io", - "futures 0.3.21", - "futures-lite", - "if-addrs", - "ipnet", - "libc", - "log", - "winapi", -] - [[package]] name = "impl-codec" version = "0.5.1" @@ -2303,15 +1294,6 @@ dependencies = [ "parity-scale-codec", ] -[[package]] -name = "impl-rlp" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" -dependencies = [ - "rlp", -] - [[package]] name = "impl-serde" version = "0.3.2" @@ -2385,81 +1367,18 @@ dependencies = [ "num-traits 0.2.14", ] -[[package]] -name = "ip_network" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa2f047c0a98b2f299aa5d6d7088443570faae494e9ae1305e48be000c9e0eb1" - -[[package]] -name = "ipconfig" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7e2f18aece9709094573a9f24f483c4f65caa4298e2f7ae1b71cc65d853fad7" -dependencies = [ - "socket2 0.3.19", - "widestring", - "winapi", - "winreg 0.6.2", -] - [[package]] name = "ipnet" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" -[[package]] -name = "isahc" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "437f8808009c031df3c1d532c8fd7e3d73239dfe522ebf0b94b5e34d5d01044b" -dependencies = [ - "async-channel", - "castaway", - "crossbeam-utils", - "curl", - "curl-sys", - "encoding_rs", - "event-listener", - "futures-lite", - "http", - "log", - "mime", - "once_cell", - "polling", - "slab", - "sluice", - "tracing", - "tracing-futures", - "url 2.2.2", - "waker-fn", -] - -[[package]] -name = "itertools" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" -[[package]] -name = "jobserver" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" -dependencies = [ - "libc", -] - [[package]] name = "js-sys" version = "0.3.57" @@ -2469,97 +1388,14 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "jsonpath_lib" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61352ec23883402b7d30b3313c16cbabefb8907361c4eb669d990cbb87ceee5a" -dependencies = [ - "array_tool", - "env_logger 0.7.1", - "log", - "serde 1.0.136", - "serde_json", -] - -[[package]] -name = "jsonrpc-client-transports" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b99d4207e2a04fb4581746903c2bb7eb376f88de9c699d0f3e10feeac0cd3a" -dependencies = [ - "derive_more", - "futures 0.3.21", - "jsonrpc-core", - "jsonrpc-pubsub", - "log", - "serde 1.0.136", - "serde_json", - "url 1.7.2", -] - -[[package]] -name = "jsonrpc-core" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f7f76aef2d054868398427f6c54943cf3d1caa9a7ec7d0c38d69df97a965eb" -dependencies = [ - "futures 0.3.21", - "futures-executor", - "futures-util", - "log", - "serde 1.0.136", - "serde_derive", - "serde_json", -] - -[[package]] -name = "jsonrpc-core-client" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b51da17abecbdab3e3d4f26b01c5ec075e88d3abe3ab3b05dc9aa69392764ec0" -dependencies = [ - "futures 0.3.21", - "jsonrpc-client-transports", -] - -[[package]] -name = "jsonrpc-derive" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b939a78fa820cdfcb7ee7484466746a7377760970f6f9c6fe19f9edcc8a38d2" -dependencies = [ - "proc-macro-crate 0.1.5", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "jsonrpc-pubsub" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240f87695e6c6f62fb37f05c02c04953cf68d6408b8c1c89de85c7a0125b1011" -dependencies = [ - "futures 0.3.21", - "jsonrpc-core", - "lazy_static", - "log", - "parking_lot 0.11.2", - "rand 0.7.3", - "serde 1.0.136", -] - [[package]] name = "jsonrpsee" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05fd8cd6c6b1bbd06881d2cf88f1fc83cc36c98f2219090f839115fb4a956cb9" dependencies = [ + "jsonrpsee-client-transport", "jsonrpsee-core", - "jsonrpsee-proc-macros", - "jsonrpsee-types", - "jsonrpsee-ws-client", ] [[package]] @@ -2568,19 +1404,19 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3303cdf246e6ab76e2866fb3d9acb6c76a068b1b28bd923a1b7a8122257ad7b5" dependencies = [ - "futures 0.3.21", + "futures", "http", "jsonrpsee-core", "jsonrpsee-types", "pin-project 1.0.10", "rustls-native-certs", - "soketto 0.7.1", + "soketto", "thiserror", "tokio", "tokio-rustls", - "tokio-util 0.6.9", + "tokio-util 0.6.10", "tracing", - "webpki-roots 0.22.3", + "webpki-roots", ] [[package]] @@ -2600,24 +1436,12 @@ dependencies = [ "rustc-hash", "serde 1.0.136", "serde_json", - "soketto 0.7.1", + "soketto", "thiserror", "tokio", "tracing", ] -[[package]] -name = "jsonrpsee-proc-macros" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4299ebf790ea9de1cb72e73ff2ae44c723ef264299e5e2d5ef46a371eb3ac3d8" -dependencies = [ - "proc-macro-crate 1.1.3", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "jsonrpsee-types" version = "0.8.0" @@ -2632,42 +1456,12 @@ dependencies = [ "tracing", ] -[[package]] -name = "jsonrpsee-ws-client" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aff425cee7c779e33920913bc695447416078ee6d119f443f3060feffa4e86b5" -dependencies = [ - "jsonrpsee-client-transport", - "jsonrpsee-core", - "jsonrpsee-types", -] - [[package]] name = "keccak" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" -[[package]] -name = "kv-log-macro" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" -dependencies = [ - "log", -] - -[[package]] -name = "kvdb" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a3f58dc069ec0e205a27f5b45920722a46faed802a0541538241af6228f512" -dependencies = [ - "parity-util-mem", - "smallvec 1.8.0", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -2694,528 +1488,366 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" [[package]] -name = "libm" -version = "0.2.2" +name = "libsecp256k1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33a33a362ce288760ec6a508b94caaec573ae7d3bbbd91b87aa0bad4456839db" +checksum = "c9d220bc1feda2ac231cb78c3d26f27676b8cf82c96971f7aeef3d0cf2797c73" +dependencies = [ + "arrayref", + "base64 0.12.3", + "digest 0.9.0", + "hmac-drbg", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand 0.7.3", + "serde 1.0.136", + "sha2 0.9.9", + "typenum", +] [[package]] -name = "libnghttp2-sys" -version = "0.1.7+1.45.0" +name = "libsecp256k1-core" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ed28aba195b38d5ff02b9170cbff627e336a20925e43b4945390401c5dc93f" +checksum = "d0f6ab710cec28cef759c5f18671a27dae2a5f952cdaaee1d8e2908cb2478a80" dependencies = [ - "cc", - "libc", + "crunchy", + "digest 0.9.0", + "subtle", ] [[package]] -name = "libp2p" -version = "0.39.1" +name = "libsecp256k1-gen-ecmult" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9004c06878ef8f3b4b4067e69a140d87ed20bf777287f82223e49713b36ee433" +checksum = "ccab96b584d38fac86a83f07e659f0deafd0253dc096dab5a36d53efe653c5c3" dependencies = [ - "atomic", - "bytes 1.1.0", - "futures 0.3.21", - "lazy_static", - "libp2p-core", - "libp2p-deflate", - "libp2p-dns", - "libp2p-floodsub", - "libp2p-gossipsub", - "libp2p-identify", - "libp2p-kad", - "libp2p-mdns", - "libp2p-mplex", - "libp2p-noise", - "libp2p-ping", - "libp2p-plaintext", - "libp2p-pnet", - "libp2p-relay", - "libp2p-request-response", - "libp2p-swarm", - "libp2p-swarm-derive", - "libp2p-tcp", - "libp2p-uds", - "libp2p-wasm-ext", - "libp2p-websocket", - "libp2p-yamux", - "multiaddr", - "parking_lot 0.11.2", - "pin-project 1.0.10", - "smallvec 1.8.0", - "wasm-timer", + "libsecp256k1-core", ] [[package]] -name = "libp2p-core" -version = "0.29.0" +name = "libsecp256k1-gen-genmult" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af9b4abdeaa420593a297c8592f63fad4234f4b88dc9343b8fd8e736c35faa59" +checksum = "67abfe149395e3aa1c48a2beb32b068e2334402df8181f818d3aee2b304c4f5d" dependencies = [ - "asn1_der", - "bs58", - "ed25519-dalek", - "either", - "fnv", - "futures 0.3.21", - "futures-timer", - "lazy_static", - "libsecp256k1 0.5.0", - "log", - "multiaddr", - "multihash 0.14.0", - "multistream-select", - "parking_lot 0.11.2", - "pin-project 1.0.10", - "prost", - "prost-build", - "rand 0.7.3", - "ring", - "rw-stream-sink", - "sha2 0.9.9", - "smallvec 1.8.0", - "thiserror", - "unsigned-varint 0.7.1", - "void", - "zeroize", + "libsecp256k1-core", ] [[package]] -name = "libp2p-deflate" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66097fccc0b7f8579f90a03ea76ba6196332ea049fd07fd969490a06819dcdc8" +name = "lifeline" +version = "0.6.1" +source = "git+https://github.com/fewensa/lifeline-rs.git?branch=threads-safely#6e45414f81e9905d8e018e6627cf3146184aa152" dependencies = [ - "flate2", - "futures 0.3.21", - "libp2p-core", + "anyhow", + "async-trait", + "futures-util", + "log", + "pin-project 0.4.29", + "postage", + "regex", + "thiserror", + "tokio", ] [[package]] -name = "libp2p-dns" -version = "0.29.0" +name = "linked-hash-map" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58ff08b3196b85a17f202d80589e93b1660a574af67275706657fdc762e42c32" +checksum = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd" dependencies = [ - "async-std-resolver", - "futures 0.3.21", - "libp2p-core", - "log", - "smallvec 1.8.0", - "trust-dns-resolver", + "serde 0.8.23", + "serde_test", ] [[package]] -name = "libp2p-floodsub" -version = "0.30.0" +name = "linked-hash-map" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "404eca8720967179dac7a5b4275eb91f904a53859c69ca8d018560ad6beb214f" -dependencies = [ - "cuckoofilter", - "fnv", - "futures 0.3.21", - "libp2p-core", - "libp2p-swarm", - "log", - "prost", - "prost-build", - "rand 0.7.3", - "smallvec 1.8.0", -] +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] -name = "libp2p-gossipsub" -version = "0.32.0" +name = "lock_api" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1cc48709bcbc3a3321f08a73560b4bbb4166a7d56f6fdb615bc775f4f91058e" +checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" dependencies = [ - "asynchronous-codec 0.6.0", - "base64 0.13.0", - "byteorder", - "bytes 1.1.0", - "fnv", - "futures 0.3.21", - "hex_fmt", - "libp2p-core", - "libp2p-swarm", - "log", - "prost", - "prost-build", - "rand 0.7.3", - "regex", - "sha2 0.9.9", - "smallvec 1.8.0", - "unsigned-varint 0.7.1", - "wasm-timer", + "scopeguard", ] [[package]] -name = "libp2p-identify" -version = "0.30.0" +name = "lock_api" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7b61f6cf07664fb97016c318c4d4512b3dd4cc07238607f3f0163245f99008e" +checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" dependencies = [ - "futures 0.3.21", - "libp2p-core", - "libp2p-swarm", - "log", - "prost", - "prost-build", - "smallvec 1.8.0", - "wasm-timer", + "autocfg", + "scopeguard", ] [[package]] -name = "libp2p-kad" -version = "0.31.0" +name = "log" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50ed78489c87924235665a0ab345b298ee34dff0f7ad62c0ba6608b2144fb75e" +checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8" dependencies = [ - "arrayvec 0.5.2", - "asynchronous-codec 0.6.0", - "bytes 1.1.0", - "either", - "fnv", - "futures 0.3.21", - "libp2p-core", - "libp2p-swarm", - "log", - "prost", - "prost-build", - "rand 0.7.3", - "sha2 0.9.9", - "smallvec 1.8.0", - "uint", - "unsigned-varint 0.7.1", - "void", - "wasm-timer", + "cfg-if 1.0.0", ] [[package]] -name = "libp2p-mdns" -version = "0.31.0" +name = "matchers" +version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a29e6cbc2a24b8471b6567e580a0e8e7b70a6d0f0ea2be0844d1e842d7d4fa33" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" dependencies = [ - "async-io", - "data-encoding", - "dns-parser", - "futures 0.3.21", - "if-watch", - "lazy_static", - "libp2p-core", - "libp2p-swarm", - "log", - "rand 0.8.5", - "smallvec 1.8.0", - "socket2 0.4.4", - "void", + "regex-automata", ] [[package]] -name = "libp2p-mplex" -version = "0.29.0" +name = "matches" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" + +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + +[[package]] +name = "memchr" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" + +[[package]] +name = "memory-db" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "313d9ea526c68df4425f580024e67a9d3ffd49f2c33de5154b1f5019816f7a99" +checksum = "de006e09d04fc301a5f7e817b75aa49801c4479a8af753764416b085337ddcc5" dependencies = [ - "asynchronous-codec 0.6.0", - "bytes 1.1.0", - "futures 0.3.21", - "libp2p-core", - "log", - "nohash-hasher", - "parking_lot 0.11.2", - "rand 0.7.3", - "smallvec 1.8.0", - "unsigned-varint 0.7.1", + "hash-db", + "hashbrown", + "parity-util-mem", ] [[package]] -name = "libp2p-noise" -version = "0.32.0" +name = "memory_units" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" + +[[package]] +name = "merlin" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f1db7212f342b6ba7c981cc40e31f76e9e56cb48e65fa4c142ecaca5839523e" +checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" dependencies = [ - "bytes 1.1.0", - "curve25519-dalek 3.2.0", - "futures 0.3.21", - "lazy_static", - "libp2p-core", - "log", - "prost", - "prost-build", - "rand 0.8.5", - "sha2 0.9.9", - "snow", - "static_assertions", - "x25519-dalek", + "byteorder", + "keccak", + "rand_core 0.5.1", "zeroize", ] [[package]] -name = "libp2p-ping" -version = "0.30.0" +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "miniz_oxide" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2482cfd9eb0b7a0baaf3e7b329dc4f2785181a161b1a47b7192f8d758f54a439" +checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082" dependencies = [ - "futures 0.3.21", - "libp2p-core", - "libp2p-swarm", - "log", - "rand 0.7.3", - "void", - "wasm-timer", + "adler", ] [[package]] -name = "libp2p-plaintext" -version = "0.29.0" +name = "mio" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13b4783e5423870b9a5c199f65a7a3bc66d86ab56b2b9beebf3c338d889cf8e4" +checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9" dependencies = [ - "asynchronous-codec 0.6.0", - "bytes 1.1.0", - "futures 0.3.21", - "libp2p-core", + "libc", "log", - "prost", - "prost-build", - "unsigned-varint 0.7.1", - "void", + "miow", + "ntapi", + "wasi 0.11.0+wasi-snapshot-preview1", + "winapi", ] [[package]] -name = "libp2p-pnet" -version = "0.21.0" +name = "miow" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07cb4dd4b917e5b40ddefe49b96b07adcd8d342e0317011d175b7b2bb1dcc974" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" dependencies = [ - "futures 0.3.21", - "log", - "pin-project 1.0.10", - "rand 0.7.3", - "salsa20", - "sha3", + "winapi", ] [[package]] -name = "libp2p-relay" -version = "0.3.0" +name = "native-tls" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0133f6cfd81cdc16e716de2982e012c62e6b9d4f12e41967b3ee361051c622aa" +checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9" dependencies = [ - "asynchronous-codec 0.6.0", - "bytes 1.1.0", - "futures 0.3.21", - "futures-timer", - "libp2p-core", - "libp2p-swarm", + "lazy_static", + "libc", "log", - "pin-project 1.0.10", - "prost", - "prost-build", - "rand 0.7.3", - "smallvec 1.8.0", - "unsigned-varint 0.7.1", - "void", - "wasm-timer", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", ] [[package]] -name = "libp2p-request-response" -version = "0.12.0" +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + +[[package]] +name = "nom" +version = "5.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06cdae44b6821466123af93cbcdec7c9e6ba9534a8af9cdc296446d39416d241" +checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" dependencies = [ - "async-trait", - "bytes 1.1.0", - "futures 0.3.21", - "libp2p-core", - "libp2p-swarm", - "log", - "lru", - "minicbor", - "rand 0.7.3", - "smallvec 1.8.0", - "unsigned-varint 0.7.1", - "wasm-timer", + "lexical-core", + "memchr", + "version_check", ] [[package]] -name = "libp2p-swarm" -version = "0.30.0" +name = "ntapi" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7083861341e1555467863b4cd802bea1e8c4787c0f7b5110097d0f1f3248f9a9" +checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" dependencies = [ - "either", - "futures 0.3.21", - "libp2p-core", - "log", - "rand 0.7.3", - "smallvec 1.8.0", - "void", - "wasm-timer", + "winapi", ] [[package]] -name = "libp2p-swarm-derive" -version = "0.24.0" +name = "num-bigint" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab8cb308d4fc854869f5abb54fdab0833d2cf670d407c745849dc47e6e08d79c" +checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" dependencies = [ - "quote", - "syn", + "autocfg", + "num-integer", + "num-traits 0.2.14", ] [[package]] -name = "libp2p-tcp" -version = "0.29.0" +name = "num-integer" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79edd26b6b4bb5feee210dcda562dca186940dfecb0024b979c3f50824b3bf28" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" dependencies = [ - "async-io", - "futures 0.3.21", - "futures-timer", - "if-watch", - "ipnet", - "libc", - "libp2p-core", - "log", - "socket2 0.4.4", + "autocfg", + "num-traits 0.2.14", ] [[package]] -name = "libp2p-uds" -version = "0.29.0" +name = "num-rational" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "280e793440dd4e9f273d714f4497325c72cddb0fe85a49f9a03c88f41dd20182" +checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" dependencies = [ - "async-std", - "futures 0.3.21", - "libp2p-core", - "log", + "autocfg", + "num-bigint", + "num-integer", + "num-traits 0.2.14", ] [[package]] -name = "libp2p-wasm-ext" -version = "0.29.0" +name = "num-traits" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f553b7140fad3d7a76f50497b0ea591e26737d9607428a75509fc191e4d1b1f6" +checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" dependencies = [ - "futures 0.3.21", - "js-sys", - "libp2p-core", - "parity-send-wrapper", - "wasm-bindgen", - "wasm-bindgen-futures", + "num-traits 0.2.14", ] [[package]] -name = "libp2p-websocket" -version = "0.30.0" +name = "num-traits" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddf99dcbf5063e9d59087f61b1e85c686ceab2f5abedb472d32288065c0e5e27" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ - "either", - "futures 0.3.21", - "futures-rustls", - "libp2p-core", - "log", - "quicksink", - "rw-stream-sink", - "soketto 0.4.2", - "url 2.2.2", - "webpki-roots 0.21.1", + "autocfg", ] [[package]] -name = "libp2p-yamux" -version = "0.33.0" +name = "num_cpus" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "214cc0dd9c37cbed27f0bb1eba0c41bbafdb93a8be5e9d6ae1e6b4b42cd044bf" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ - "futures 0.3.21", - "libp2p-core", - "parking_lot 0.11.2", - "thiserror", - "yamux", + "hermit-abi", + "libc", ] [[package]] -name = "libsecp256k1" -version = "0.5.0" +name = "object" +version = "0.28.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd1137239ab33b41aa9637a88a28249e5e70c40a42ccc92db7f12cc356c1fcd7" +checksum = "40bec70ba014595f99f7aa110b84331ffe1ee9aece7fe6f387cc7e3ecda4d456" dependencies = [ - "arrayref", - "base64 0.12.3", - "digest 0.9.0", - "hmac-drbg", - "libsecp256k1-core", - "libsecp256k1-gen-ecmult", - "libsecp256k1-gen-genmult", - "rand 0.7.3", - "serde 1.0.136", - "sha2 0.9.9", - "typenum", + "memchr", ] [[package]] -name = "libsecp256k1" -version = "0.6.0" +name = "once_cell" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9d220bc1feda2ac231cb78c3d26f27676b8cf82c96971f7aeef3d0cf2797c73" -dependencies = [ - "arrayref", - "base64 0.12.3", - "digest 0.9.0", - "hmac-drbg", - "libsecp256k1-core", - "libsecp256k1-gen-ecmult", - "libsecp256k1-gen-genmult", - "rand 0.7.3", - "serde 1.0.136", - "sha2 0.9.9", - "typenum", -] +checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" [[package]] -name = "libsecp256k1-core" -version = "0.2.2" +name = "opaque-debug" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f6ab710cec28cef759c5f18671a27dae2a5f952cdaaee1d8e2908cb2478a80" -dependencies = [ - "crunchy", - "digest 0.9.0", - "subtle", -] +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] -name = "libsecp256k1-gen-ecmult" -version = "0.2.1" +name = "opaque-debug" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccab96b584d38fac86a83f07e659f0deafd0253dc096dab5a36d53efe653c5c3" -dependencies = [ - "libsecp256k1-core", -] +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] -name = "libsecp256k1-gen-genmult" -version = "0.2.1" +name = "openssl" +version = "0.10.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67abfe149395e3aa1c48a2beb32b068e2334402df8181f818d3aee2b304c4f5d" +checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95" dependencies = [ - "libsecp256k1-core", + "bitflags", + "cfg-if 1.0.0", + "foreign-types", + "libc", + "once_cell", + "openssl-sys", ] [[package]] -name = "libz-sys" -version = "1.1.5" +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f35facd4a5673cb5a48822be2be1d4236c1c99cb4113cab7061ac720d5bf859" +checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" dependencies = [ + "autocfg", "cc", "libc", "pkg-config", @@ -3223,2084 +1855,635 @@ dependencies = [ ] [[package]] -name = "lifeline" -version = "0.6.1" -source = "git+https://github.com/fewensa/lifeline-rs.git?branch=threads-safely#6e45414f81e9905d8e018e6627cf3146184aa152" -dependencies = [ - "anyhow", - "async-trait", - "futures-util", - "log", - "pin-project 0.4.29", - "postage", - "regex", - "thiserror", - "tokio", -] +name = "owo-colors" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2386b4ebe91c2f7f51082d4cefa145d030e33a1842a96b12e4885cc3c01f7a55" [[package]] -name = "linked-hash-map" -version = "0.3.0" +name = "parity-scale-codec" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd" +checksum = "373b1a4c1338d9cd3d1fa53b3a11bdab5ab6bd80a20f7f7becd76953ae2be909" dependencies = [ - "serde 0.8.23", - "serde_test", + "arrayvec 0.7.2", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde 1.0.136", ] [[package]] -name = "linked-hash-map" -version = "0.5.4" +name = "parity-scale-codec-derive" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" +checksum = "1557010476e0595c9b568d16dcfb81b93cdeb157612726f5170d31aa707bed27" +dependencies = [ + "proc-macro-crate 1.1.3", + "proc-macro2", + "quote", + "syn", +] [[package]] -name = "linked_hash_set" -version = "0.1.4" +name = "parity-util-mem" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47186c6da4d81ca383c7c47c1bfc80f4b95f4720514d860a5407aaf4233f9588" +checksum = "6f4cb4e169446179cbc6b8b6320cc9fca49bd2e94e8db25f25f200a8ea774770" dependencies = [ - "linked-hash-map 0.5.4", + "cfg-if 1.0.0", + "hashbrown", + "impl-trait-for-tuples", + "parity-util-mem-derive", + "parking_lot 0.11.2", + "primitive-types", + "winapi", ] [[package]] -name = "linregress" -version = "0.4.4" +name = "parity-util-mem-derive" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c601a85f5ecd1aba625247bca0031585fb1c446461b142878a16f8245ddeb8" +checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" dependencies = [ - "nalgebra", - "statrs", + "proc-macro2", + "syn", + "synstructure", ] [[package]] -name = "lock_api" -version = "0.3.4" +name = "parity-wasm" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" -dependencies = [ - "scopeguard", -] +checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" [[package]] -name = "lock_api" -version = "0.4.7" +name = "parking_lot" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" +checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" dependencies = [ - "autocfg", - "scopeguard", + "lock_api 0.3.4", + "parking_lot_core 0.7.2", ] [[package]] -name = "log" -version = "0.4.16" +name = "parking_lot" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ - "cfg-if 1.0.0", - "value-bag", + "instant", + "lock_api 0.4.7", + "parking_lot_core 0.8.5", ] [[package]] -name = "lru" -version = "0.6.6" +name = "parking_lot" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ea2d928b485416e8908cff2d97d621db22b27f7b3b6729e438bcf42c671ba91" +checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" dependencies = [ - "hashbrown", + "lock_api 0.4.7", + "parking_lot_core 0.9.2", ] [[package]] -name = "lru-cache" -version = "0.1.2" +name = "parking_lot_core" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" +checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" dependencies = [ - "linked-hash-map 0.5.4", + "cfg-if 0.1.10", + "cloudabi", + "libc", + "redox_syscall 0.1.57", + "smallvec 1.8.0", + "winapi", ] [[package]] -name = "match_cfg" -version = "0.1.0" +name = "parking_lot_core" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if 1.0.0", + "instant", + "libc", + "redox_syscall 0.2.13", + "smallvec 1.8.0", + "winapi", +] [[package]] -name = "matchers" -version = "0.0.1" +name = "parking_lot_core" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +checksum = "995f667a6c822200b0433ac218e05582f0e2efa1b922a3fd2fbaadc5f87bab37" dependencies = [ - "regex-automata", + "cfg-if 1.0.0", + "libc", + "redox_syscall 0.2.13", + "smallvec 1.8.0", + "windows-sys", ] [[package]] -name = "matches" -version = "0.1.9" +name = "paste" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" +checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" [[package]] -name = "matrixmultiply" -version = "0.3.2" +name = "pbkdf2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84" +checksum = "216eaa586a190f0a738f2f918511eecfa90f13295abec0e457cdebcceda80cbd" dependencies = [ - "rawpointer", + "crypto-mac 0.8.0", ] [[package]] -name = "maybe-uninit" -version = "2.0.0" +name = "pbkdf2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" +checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" +dependencies = [ + "crypto-mac 0.11.1", +] [[package]] -name = "memchr" -version = "2.4.1" +name = "percent-encoding" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] -name = "memoffset" -version = "0.6.5" +name = "pin-project" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "9615c18d31137579e9ff063499264ddc1278e7b1982757ebc111028c4d1dc909" dependencies = [ - "autocfg", + "pin-project-internal 0.4.29", ] [[package]] -name = "memory-db" -version = "0.27.0" +name = "pin-project" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de006e09d04fc301a5f7e817b75aa49801c4479a8af753764416b085337ddcc5" +checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" dependencies = [ - "hash-db", - "hashbrown", - "parity-util-mem", + "pin-project-internal 1.0.10", ] [[package]] -name = "memory_units" -version = "0.3.0" +name = "pin-project-internal" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" +checksum = "044964427019eed9d49d9d5bbce6047ef18f37100ea400912a9fa4a3523ab12a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] -name = "merlin" -version = "2.0.1" +name = "pin-project-internal" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" +checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" dependencies = [ - "byteorder", - "keccak", - "rand_core 0.5.1", - "zeroize", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "messages-relay" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "async-std", - "async-trait", - "bp-messages", - "bp-runtime", - "futures 0.3.21", - "hex", - "log", - "num-traits 0.2.14", - "parking_lot 0.11.2", - "relay-utils", - "sp-arithmetic", -] - -[[package]] -name = "mime" -version = "0.3.16" +name = "pin-project-lite" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" [[package]] -name = "minicbor" -version = "0.8.1" +name = "pin-utils" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51aa5bb0ca22415daca596a227b507f880ad1b2318a87fa9325312a5d285ca0d" -dependencies = [ - "minicbor-derive", -] +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "minicbor-derive" -version = "0.6.4" +name = "pkg-config" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54999f917cd092b13904737e26631aa2b2b88d625db68e4bab461dcd8006c788" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] +checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" [[package]] -name = "miniz_oxide" -version = "0.5.1" +name = "pollster" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082" -dependencies = [ - "adler", -] +checksum = "5da3b0203fd7ee5720aa0b5e790b591aa5d3f41c3ed2c34a3a393382198af2f7" [[package]] -name = "mio" -version = "0.8.2" +name = "postage" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9" +checksum = "a63d25391d04a097954b76aba742b6b5b74f213dfe3dbaeeb36e8ddc1c657f0b" dependencies = [ - "libc", + "atomic", + "crossbeam-queue", "log", - "miow", - "ntapi", - "wasi 0.11.0+wasi-snapshot-preview1", - "winapi", + "pin-project 1.0.10", + "pollster", + "static_assertions", + "thiserror", ] [[package]] -name = "miow" -version = "0.3.7" +name = "ppv-lite86" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" -dependencies = [ - "winapi", -] +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] -name = "multiaddr" -version = "0.13.0" +name = "primitive-types" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48ee4ea82141951ac6379f964f71b20876d43712bea8faf6dd1a375e08a46499" +checksum = "05e4722c697a58a99d5d06a08c30821d7c082a4632198de1eaa5a6c22ef42373" dependencies = [ - "arrayref", - "bs58", - "byteorder", - "data-encoding", - "multihash 0.14.0", - "percent-encoding 2.1.0", - "serde 1.0.136", - "static_assertions", - "unsigned-varint 0.7.1", - "url 2.2.2", + "fixed-hash", + "impl-codec", + "impl-serde", + "scale-info", + "uint", ] [[package]] -name = "multibase" -version = "0.8.0" +name = "proc-macro-crate" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b78c60039650ff12e140ae867ef5299a58e19dded4d334c849dc7177083667e2" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" dependencies = [ - "base-x", - "data-encoding", - "data-encoding-macro", + "toml", ] [[package]] -name = "multihash" -version = "0.13.2" +name = "proc-macro-crate" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dac63698b887d2d929306ea48b63760431ff8a24fac40ddb22f9c7f49fb7cab" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" dependencies = [ - "blake2b_simd", - "blake2s_simd", - "blake3", - "digest 0.9.0", - "generic-array 0.14.5", - "multihash-derive", - "sha2 0.9.9", - "sha3", - "unsigned-varint 0.5.1", + "thiserror", + "toml", ] [[package]] -name = "multihash" -version = "0.14.0" +name = "proc-macro-error" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "752a61cd890ff691b4411423d23816d5866dd5621e4d1c5687a53b94b5a979d8" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ - "digest 0.9.0", - "generic-array 0.14.5", - "multihash-derive", - "sha2 0.9.9", - "unsigned-varint 0.7.1", + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", ] [[package]] -name = "multihash-derive" -version = "0.7.2" +name = "proc-macro-error-attr" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "424f6e86263cd5294cbd7f1e95746b95aca0e0d66bff31e5a40d6baa87b4aa99" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro-crate 1.1.3", - "proc-macro-error", "proc-macro2", "quote", - "syn", - "synstructure", + "version_check", ] [[package]] -name = "multimap" -version = "0.8.3" +name = "proc-macro2" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" +checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1" +dependencies = [ + "unicode-xid", +] [[package]] -name = "multistream-select" -version = "0.10.4" +name = "quote" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56a336acba8bc87c8876f6425407dbbe6c417bf478b22015f8fb0994ef3bc0ab" +checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" dependencies = [ - "bytes 1.1.0", - "futures 0.3.21", - "log", - "pin-project 1.0.10", - "smallvec 1.8.0", - "unsigned-varint 0.7.1", + "proc-macro2", ] [[package]] -name = "nalgebra" -version = "0.27.1" +name = "radium" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "462fffe4002f4f2e1f6a9dcf12cc1a6fc0e15989014efc02a941d3e0f5dc2120" -dependencies = [ - "approx", - "matrixmultiply", - "nalgebra-macros", - "num-complex", - "num-rational 0.4.0", - "num-traits 0.2.14", - "rand 0.8.5", - "rand_distr", - "simba", - "typenum", -] +checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" [[package]] -name = "nalgebra-macros" -version = "0.1.0" +name = "rand" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01fcc0b8149b4632adc89ac3b7b31a12fb6099a0317a4eb2ebff574ef7de7218" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "proc-macro2", - "quote", - "syn", + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", + "rand_pcg", ] [[package]] -name = "native-tls" -version = "0.2.10" +name = "rand" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "lazy_static", "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", + "rand_chacha 0.3.1", + "rand_core 0.6.3", ] [[package]] -name = "nodrop" -version = "0.1.14" +name = "rand_chacha" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] [[package]] -name = "nohash-hasher" -version = "0.2.0" +name = "rand_chacha" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.3", +] [[package]] -name = "nom" -version = "5.1.2" +name = "rand_core" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "lexical-core", - "memchr", - "version_check", + "getrandom 0.1.16", ] [[package]] -name = "ntapi" -version = "0.3.7" +name = "rand_core" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "winapi", + "getrandom 0.2.6", ] [[package]] -name = "num-bigint" -version = "0.2.6" +name = "rand_hc" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "autocfg", - "num-integer", - "num-traits 0.2.14", + "rand_core 0.5.1", ] [[package]] -name = "num-complex" -version = "0.4.0" +name = "rand_pcg" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085" +checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" dependencies = [ - "num-traits 0.2.14", + "rand_core 0.5.1", ] [[package]] -name = "num-integer" -version = "0.1.44" +name = "redox_syscall" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" -dependencies = [ - "autocfg", - "num-traits 0.2.14", -] +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] -name = "num-rational" -version = "0.2.4" +name = "redox_syscall" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" +checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" dependencies = [ - "autocfg", - "num-bigint", - "num-integer", - "num-traits 0.2.14", + "bitflags", ] [[package]] -name = "num-rational" -version = "0.4.0" +name = "redox_users" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "autocfg", - "num-integer", - "num-traits 0.2.14", + "getrandom 0.2.6", + "redox_syscall 0.2.13", + "thiserror", ] [[package]] -name = "num-traits" -version = "0.1.43" +name = "ref-cast" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" +checksum = "685d58625b6c2b83e4cc88a27c4bf65adb7b6b16dbdc413e515c9405b47432ab" dependencies = [ - "num-traits 0.2.14", + "ref-cast-impl", ] [[package]] -name = "num-traits" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" -dependencies = [ - "autocfg", - "libm", -] - -[[package]] -name = "num_cpus" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "object" -version = "0.28.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40bec70ba014595f99f7aa110b84331ffe1ee9aece7fe6f387cc7e3ecda4d456" -dependencies = [ - "memchr", -] - -[[package]] -name = "once_cell" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" - -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "openssl" -version = "0.10.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95" -dependencies = [ - "bitflags", - "cfg-if 1.0.0", - "foreign-types", - "libc", - "once_cell", - "openssl-sys", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" -dependencies = [ - "autocfg", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "owo-colors" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2386b4ebe91c2f7f51082d4cefa145d030e33a1842a96b12e4885cc3c01f7a55" - -[[package]] -name = "pallet-balances" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-bridge-dispatch" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "bp-message-dispatch", - "bp-runtime", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-bridge-grandpa" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "bp-header-chain", - "bp-runtime", - "bp-test-utils", - "finality-grandpa", - "frame-support", - "frame-system", - "log", - "num-traits 0.2.14", - "parity-scale-codec", - "scale-info", - "serde 1.0.136", - "sp-finality-grandpa", - "sp-runtime", - "sp-std", - "sp-trie", -] - -[[package]] -name = "pallet-bridge-messages" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "bitvec", - "bp-message-dispatch", - "bp-messages", - "bp-runtime", - "frame-support", - "frame-system", - "log", - "num-traits 0.2.14", - "parity-scale-codec", - "scale-info", - "serde 1.0.136", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-bridge-parachains" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "bp-parachains", - "bp-polkadot-core", - "bp-runtime", - "frame-support", - "frame-system", - "log", - "pallet-bridge-grandpa", - "parity-scale-codec", - "scale-info", - "serde 1.0.136", - "sp-core", - "sp-runtime", - "sp-std", - "sp-trie", -] - -[[package]] -name = "pallet-fee-market" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "bitvec", - "bp-messages", - "bp-runtime", - "frame-support", - "frame-system", - "pallet-bridge-messages", - "pallet-timestamp", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-timestamp" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-inherents", - "sp-runtime", - "sp-std", - "sp-timestamp", -] - -[[package]] -name = "pallet-transaction-payment" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "serde 1.0.136", - "smallvec 1.8.0", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-transaction-payment-rpc-runtime-api" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "pallet-transaction-payment", - "parity-scale-codec", - "sp-api", - "sp-runtime", -] - -[[package]] -name = "parachains-relay" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "async-std", - "async-trait", - "backoff", - "bp-parachains", - "bp-polkadot-core", - "futures 0.3.21", - "linked-hash-map 0.5.4", - "log", - "num-traits 0.2.14", - "parking_lot 0.11.2", - "relay-substrate-client", - "relay-utils", -] - -[[package]] -name = "parity-scale-codec" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373b1a4c1338d9cd3d1fa53b3a11bdab5ab6bd80a20f7f7becd76953ae2be909" -dependencies = [ - "arrayvec 0.7.2", - "bitvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", - "serde 1.0.136", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "2.3.1" +name = "ref-cast-impl" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1557010476e0595c9b568d16dcfb81b93cdeb157612726f5170d31aa707bed27" +checksum = "a043824e29c94169374ac5183ac0ed43f5724dc4556b19568007486bd840fa1f" dependencies = [ - "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", ] [[package]] -name = "parity-send-wrapper" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" - -[[package]] -name = "parity-util-mem" -version = "0.10.2" +name = "regex" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f4cb4e169446179cbc6b8b6320cc9fca49bd2e94e8db25f25f200a8ea774770" +checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" dependencies = [ - "cfg-if 1.0.0", - "ethereum-types", - "hashbrown", - "impl-trait-for-tuples", - "lru", - "parity-util-mem-derive", - "parking_lot 0.11.2", - "primitive-types", - "smallvec 1.8.0", - "winapi", + "aho-corasick", + "memchr", + "regex-syntax", ] [[package]] -name = "parity-util-mem-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" -dependencies = [ - "proc-macro2", - "syn", - "synstructure", -] - -[[package]] -name = "parity-wasm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" - -[[package]] -name = "parking" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" - -[[package]] -name = "parking_lot" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" -dependencies = [ - "lock_api 0.3.4", - "parking_lot_core 0.7.2", -] - -[[package]] -name = "parking_lot" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -dependencies = [ - "instant", - "lock_api 0.4.7", - "parking_lot_core 0.8.5", -] - -[[package]] -name = "parking_lot" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" -dependencies = [ - "lock_api 0.4.7", - "parking_lot_core 0.9.2", -] - -[[package]] -name = "parking_lot_core" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" -dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "libc", - "redox_syscall 0.1.57", - "smallvec 1.8.0", - "winapi", -] - -[[package]] -name = "parking_lot_core" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" -dependencies = [ - "cfg-if 1.0.0", - "instant", - "libc", - "redox_syscall 0.2.13", - "smallvec 1.8.0", - "winapi", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "995f667a6c822200b0433ac218e05582f0e2efa1b922a3fd2fbaadc5f87bab37" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "redox_syscall 0.2.13", - "smallvec 1.8.0", - "windows-sys", -] - -[[package]] -name = "paste" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" - -[[package]] -name = "pbkdf2" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216eaa586a190f0a738f2f918511eecfa90f13295abec0e457cdebcceda80cbd" -dependencies = [ - "crypto-mac 0.8.0", -] - -[[package]] -name = "pbkdf2" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" -dependencies = [ - "crypto-mac 0.11.1", -] - -[[package]] -name = "percent-encoding" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" - -[[package]] -name = "percent-encoding" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" - -[[package]] -name = "pest" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" -dependencies = [ - "ucd-trie", -] - -[[package]] -name = "petgraph" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" -dependencies = [ - "fixedbitset", - "indexmap", -] - -[[package]] -name = "pin-project" -version = "0.4.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9615c18d31137579e9ff063499264ddc1278e7b1982757ebc111028c4d1dc909" -dependencies = [ - "pin-project-internal 0.4.29", -] - -[[package]] -name = "pin-project" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" -dependencies = [ - "pin-project-internal 1.0.10", -] - -[[package]] -name = "pin-project-internal" -version = "0.4.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "044964427019eed9d49d9d5bbce6047ef18f37100ea400912a9fa4a3523ab12a" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-internal" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-lite" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" - -[[package]] -name = "pin-project-lite" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkg-config" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" - -[[package]] -name = "polling" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685404d509889fade3e86fe3a5803bca2ec09b0c0778d5ada6ec8bf7a8de5259" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "log", - "wepoll-ffi", - "winapi", -] - -[[package]] -name = "pollster" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da3b0203fd7ee5720aa0b5e790b591aa5d3f41c3ed2c34a3a393382198af2f7" - -[[package]] -name = "poly1305" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" -dependencies = [ - "cpufeatures 0.2.2", - "opaque-debug 0.3.0", - "universal-hash", -] - -[[package]] -name = "polyval" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" -dependencies = [ - "cfg-if 1.0.0", - "cpufeatures 0.2.2", - "opaque-debug 0.3.0", - "universal-hash", -] - -[[package]] -name = "postage" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a63d25391d04a097954b76aba742b6b5b74f213dfe3dbaeeb36e8ddc1c657f0b" -dependencies = [ - "atomic", - "crossbeam-queue", - "log", - "pin-project 1.0.10", - "pollster", - "static_assertions", - "thiserror", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" - -[[package]] -name = "primitive-types" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e4722c697a58a99d5d06a08c30821d7c082a4632198de1eaa5a6c22ef42373" -dependencies = [ - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", - "uint", -] - -[[package]] -name = "proc-macro-crate" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" -dependencies = [ - "toml", -] - -[[package]] -name = "proc-macro-crate" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" -dependencies = [ - "thiserror", - "toml", -] - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - -[[package]] -name = "proc-macro2" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "prometheus" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8425533e7122f0c3cc7a37e6244b16ad3a2cc32ae7ac6276e2a75da0d9c200d" -dependencies = [ - "cfg-if 1.0.0", - "fnv", - "lazy_static", - "parking_lot 0.11.2", - "regex", - "thiserror", -] - -[[package]] -name = "prost" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de5e2533f59d08fcf364fd374ebda0692a70bd6d7e66ef97f306f45c6c5d8020" -dependencies = [ - "bytes 1.1.0", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355f634b43cdd80724ee7848f95770e7e70eefa6dcf14fea676216573b8fd603" -dependencies = [ - "bytes 1.1.0", - "heck 0.3.3", - "itertools", - "log", - "multimap", - "petgraph", - "prost", - "prost-types", - "tempfile", - "which", -] - -[[package]] -name = "prost-derive" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "600d2f334aa05acb02a755e217ef1ab6dea4d51b58b7846588b747edec04efba" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "prost-types" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "603bbd6394701d13f3f25aada59c7de9d35a6a5887cfc156181234a44002771b" -dependencies = [ - "bytes 1.1.0", - "prost", -] - -[[package]] -name = "pwasm-utils" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "880b3384fb00b8f6ecccd5d358b93bd2201900ae3daad213791d1864f6441f5c" -dependencies = [ - "byteorder", - "log", - "parity-wasm", -] - -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quicksink" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77de3c815e5a160b1539c6592796801df2043ae35e123b46d73380cfa57af858" -dependencies = [ - "futures-core", - "futures-sink", - "pin-project-lite 0.1.12", -] - -[[package]] -name = "quote" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radium" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc", - "rand_pcg", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.3", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.3", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", -] - -[[package]] -name = "rand_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" -dependencies = [ - "getrandom 0.2.6", -] - -[[package]] -name = "rand_distr" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" -dependencies = [ - "num-traits 0.2.14", - "rand 0.8.5", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_pcg" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rawpointer" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" - -[[package]] -name = "rayon" -version = "1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd249e82c21598a9a426a4e00dd7adc1d640b22445ec8545feef801d1a74c221" -dependencies = [ - "autocfg", - "crossbeam-deque", - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f51245e1e62e1f1629cbfec37b5793bbabcaeb90f30e94d2ba03564687353e4" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "num_cpus", -] - -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - -[[package]] -name = "redox_syscall" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" -dependencies = [ - "bitflags", -] - -[[package]] -name = "redox_users" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" -dependencies = [ - "getrandom 0.2.6", - "redox_syscall 0.2.13", - "thiserror", -] - -[[package]] -name = "ref-cast" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "300f2a835d808734ee295d45007adacb9ebb29dd3ae2424acfa17930cae541da" -dependencies = [ - "ref-cast-impl", -] - -[[package]] -name = "ref-cast-impl" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c38e3aecd2b21cb3959637b883bb3714bc7e43f0268b9a29d3743ee3e55cdd2" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "regex" -version = "1.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" - -[[package]] -name = "relay-pangolin-client" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "bp-darwinia-core", - "bp-header-chain", - "bp-message-dispatch", - "bp-messages", - "bp-pangolin", - "bp-pangolin-parachain", - "bp-pangoro", - "bp-rococo", - "bp-runtime", - "bridge-runtime-common", - "frame-support", - "pallet-bridge-dispatch", - "parity-scale-codec", - "relay-substrate-client", - "relay-utils", - "scale-info", - "sp-core", - "sp-runtime", -] - -[[package]] -name = "relay-pangoro-client" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "bp-darwinia-core", - "bp-header-chain", - "bp-message-dispatch", - "bp-messages", - "bp-pangolin", - "bp-pangoro", - "bp-runtime", - "bridge-runtime-common", - "frame-support", - "pallet-bridge-dispatch", - "parity-scale-codec", - "relay-substrate-client", - "relay-utils", - "scale-info", - "sp-core", - "sp-runtime", -] - -[[package]] -name = "relay-substrate-client" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "async-std", - "async-trait", - "bp-header-chain", - "bp-messages", - "bp-runtime", - "finality-relay", - "frame-support", - "frame-system", - "futures 0.3.21", - "jsonrpsee", - "log", - "num-traits 0.2.14", - "pallet-balances", - "pallet-bridge-messages", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "parity-scale-codec", - "rand 0.7.3", - "relay-utils", - "sc-chain-spec", - "sc-rpc-api", - "sc-transaction-pool-api", - "serde 1.0.136", - "sp-core", - "sp-finality-grandpa", - "sp-rpc", - "sp-runtime", - "sp-storage", - "sp-trie", - "sp-version", - "thiserror", - "tokio", -] - -[[package]] -name = "relay-utils" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" -dependencies = [ - "ansi_term", - "anyhow", - "async-std", - "async-trait", - "backoff", - "bp-runtime", - "env_logger 0.8.4", - "futures 0.3.21", - "isahc", - "jsonpath_lib", - "log", - "num-traits 0.2.14", - "serde_json", - "substrate-prometheus-endpoint", - "sysinfo", - "thiserror", - "time 0.2.27", -] - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - -[[package]] -name = "reqwest" -version = "0.11.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a1f7aa4f35e5e8b4160449f51afc758f0ce6454315a9fa7d0d113e958c41eb" -dependencies = [ - "base64 0.13.0", - "bytes 1.1.0", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "hyper-rustls", - "hyper-tls", - "ipnet", - "js-sys", - "lazy_static", - "log", - "mime", - "native-tls", - "percent-encoding 2.1.0", - "pin-project-lite 0.2.8", - "rustls 0.20.4", - "rustls-pemfile 0.3.0", - "serde 1.0.136", - "serde_json", - "serde_urlencoded", - "tokio", - "tokio-native-tls", - "tokio-rustls", - "url 2.2.2", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots 0.22.3", - "winreg 0.10.1", -] - -[[package]] -name = "resolv-conf" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" -dependencies = [ - "hostname", - "quick-error", -] - -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin", - "untrusted", - "web-sys", - "winapi", -] - -[[package]] -name = "rlp" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "999508abb0ae792aabed2460c45b89106d97fe4adac593bdaef433c2605847b5" -dependencies = [ - "bytes 1.1.0", - "rustc-hex", -] - -[[package]] -name = "rust-ini" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" - -[[package]] -name = "rustc-demangle" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver 0.9.0", -] - -[[package]] -name = "rustc_version" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" -dependencies = [ - "semver 0.11.0", -] - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver 1.0.7", -] - -[[package]] -name = "rustls" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" -dependencies = [ - "base64 0.13.0", - "log", - "ring", - "sct 0.6.1", - "webpki 0.21.4", -] - -[[package]] -name = "rustls" -version = "0.20.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbfeb8d0ddb84706bc597a5574ab8912817c52a397f819e5b614e2265206921" -dependencies = [ - "log", - "ring", - "sct 0.7.0", - "webpki 0.22.0", -] - -[[package]] -name = "rustls-native-certs" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" -dependencies = [ - "openssl-probe", - "rustls-pemfile 1.0.0", - "schannel", - "security-framework", -] - -[[package]] -name = "rustls-pemfile" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee86d63972a7c661d1536fefe8c3c8407321c3df668891286de28abcd087360" -dependencies = [ - "base64 0.13.0", -] - -[[package]] -name = "rustls-pemfile" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7522c9de787ff061458fe9a829dc790a3f5b22dc571694fc5883f448b94d9a9" -dependencies = [ - "base64 0.13.0", -] - -[[package]] -name = "rw-stream-sink" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4da5fcb054c46f5a5dff833b129285a93d3f0179531735e6c866e8cc307d2020" -dependencies = [ - "futures 0.3.21", - "pin-project 0.4.29", - "static_assertions", -] - -[[package]] -name = "ryu" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" - -[[package]] -name = "salsa20" -version = "0.8.1" +name = "regex-automata" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecbd2eb639fd7cab5804a0837fe373cc2172d15437e804c054a9fb885cb923b0" -dependencies = [ - "cipher", -] - -[[package]] -name = "sc-allocator" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "log", - "sp-core", - "sp-wasm-interface", - "thiserror", -] - -[[package]] -name = "sc-block-builder" -version = "0.10.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "parity-scale-codec", - "sc-client-api", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-core", - "sp-inherents", - "sp-runtime", - "sp-state-machine", -] - -[[package]] -name = "sc-chain-spec" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "sc-chain-spec-derive", - "sc-network", - "sc-telemetry", - "serde 1.0.136", - "serde_json", - "sp-core", - "sp-runtime", -] - -[[package]] -name = "sc-chain-spec-derive" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "proc-macro-crate 1.1.3", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "sc-client-api" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "fnv", - "futures 0.3.21", - "hash-db", - "log", - "parity-scale-codec", - "parking_lot 0.11.2", - "sc-executor", - "sc-transaction-pool-api", - "sc-utils", - "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-database", - "sp-externalities", - "sp-keystore", - "sp-runtime", - "sp-state-machine", - "sp-storage", - "sp-trie", - "substrate-prometheus-endpoint", + "regex-syntax", ] [[package]] -name = "sc-consensus" -version = "0.10.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" +name = "regex-syntax" +version = "0.6.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ - "async-trait", - "futures 0.3.21", - "futures-timer", - "libp2p", - "log", - "parking_lot 0.11.2", - "sc-client-api", - "sc-utils", - "serde 1.0.136", - "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-runtime", - "sp-state-machine", - "substrate-prometheus-endpoint", - "thiserror", + "winapi", ] [[package]] -name = "sc-executor" -version = "0.10.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" +name = "reqwest" +version = "0.11.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46a1f7aa4f35e5e8b4160449f51afc758f0ce6454315a9fa7d0d113e958c41eb" dependencies = [ + "base64 0.13.0", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-rustls", + "hyper-tls", + "ipnet", + "js-sys", "lazy_static", - "libsecp256k1 0.6.0", "log", - "parity-scale-codec", - "parking_lot 0.11.2", - "sc-executor-common", - "sc-executor-wasmi", - "sp-api", - "sp-core", - "sp-externalities", - "sp-io", - "sp-panic-handler", - "sp-runtime-interface", - "sp-tasks", - "sp-trie", - "sp-version", - "sp-wasm-interface", - "wasmi", + "mime", + "native-tls", + "percent-encoding", + "pin-project-lite", + "rustls", + "rustls-pemfile 0.3.0", + "serde 1.0.136", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-native-tls", + "tokio-rustls", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", + "winreg", ] [[package]] -name = "sc-executor-common" -version = "0.10.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" dependencies = [ - "derive_more", - "environmental", - "parity-scale-codec", - "pwasm-utils", - "sc-allocator", - "sp-core", - "sp-maybe-compressed-blob", - "sp-serializer", - "sp-wasm-interface", - "thiserror", - "wasmi", + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", ] [[package]] -name = "sc-executor-wasmi" -version = "0.10.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "log", - "parity-scale-codec", - "sc-allocator", - "sc-executor-common", - "scoped-tls", - "sp-core", - "sp-runtime-interface", - "sp-wasm-interface", - "wasmi", -] +name = "rust-ini" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2" [[package]] -name = "sc-network" -version = "0.10.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "async-std", - "async-trait", - "asynchronous-codec 0.5.0", - "bitflags", - "bytes 1.1.0", - "cid", - "derive_more", - "either", - "fnv", - "fork-tree", - "futures 0.3.21", - "futures-timer", - "hex", - "ip_network", - "libp2p", - "linked-hash-map 0.5.4", - "linked_hash_set", - "log", - "lru", - "parity-scale-codec", - "parking_lot 0.11.2", - "pin-project 1.0.10", - "prost", - "prost-build", - "rand 0.7.3", - "sc-block-builder", - "sc-client-api", - "sc-consensus", - "sc-peerset", - "sc-utils", - "serde 1.0.136", - "serde_json", - "smallvec 1.8.0", - "sp-arithmetic", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-finality-grandpa", - "sp-runtime", - "substrate-prometheus-endpoint", - "thiserror", - "unsigned-varint 0.6.0", - "void", - "zeroize", -] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" [[package]] -name = "sc-peerset" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "futures 0.3.21", - "libp2p", - "log", - "sc-utils", - "serde_json", - "wasm-timer", + "semver", ] [[package]] -name = "sc-rpc-api" -version = "0.10.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" +name = "rustls" +version = "0.20.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fbfeb8d0ddb84706bc597a5574ab8912817c52a397f819e5b614e2265206921" dependencies = [ - "futures 0.3.21", - "jsonrpc-core", - "jsonrpc-core-client", - "jsonrpc-derive", - "jsonrpc-pubsub", "log", - "parity-scale-codec", - "parking_lot 0.11.2", - "sc-chain-spec", - "sc-transaction-pool-api", - "serde 1.0.136", - "serde_json", - "sp-core", - "sp-rpc", - "sp-runtime", - "sp-tracing", - "sp-version", - "thiserror", + "ring", + "sct", + "webpki", ] [[package]] -name = "sc-telemetry" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" +name = "rustls-native-certs" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" dependencies = [ - "chrono", - "futures 0.3.21", - "libp2p", - "log", - "parking_lot 0.11.2", - "pin-project 1.0.10", - "rand 0.7.3", - "serde 1.0.136", - "serde_json", - "thiserror", - "wasm-timer", + "openssl-probe", + "rustls-pemfile 1.0.0", + "schannel", + "security-framework", ] [[package]] -name = "sc-transaction-pool-api" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" +name = "rustls-pemfile" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee86d63972a7c661d1536fefe8c3c8407321c3df668891286de28abcd087360" dependencies = [ - "derive_more", - "futures 0.3.21", - "log", - "serde 1.0.136", - "sp-blockchain", - "sp-runtime", - "thiserror", + "base64 0.13.0", ] [[package]] -name = "sc-utils" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" +name = "rustls-pemfile" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7522c9de787ff061458fe9a829dc790a3f5b22dc571694fc5883f448b94d9a9" dependencies = [ - "futures 0.3.21", - "futures-timer", - "lazy_static", - "prometheus", + "base64 0.13.0", ] +[[package]] +name = "ryu" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" + [[package]] name = "scale-info" version = "1.0.0" @@ -5355,28 +2538,12 @@ dependencies = [ "zeroize", ] -[[package]] -name = "scoped-tls" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" - [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "sct" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "sct" version = "0.7.0" @@ -5421,42 +2588,9 @@ dependencies = [ [[package]] name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser 0.7.0", -] - -[[package]] -name = "semver" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser 0.10.2", -] - -[[package]] -name = "semver" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d65bd28f48be7196d222d95b9243287f48d27aca604e08497513019ff0502cc4" - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "semver-parser" -version = "0.10.2" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] +checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd" [[package]] name = "serde" @@ -5526,7 +2660,6 @@ version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" dependencies = [ - "indexmap", "itoa", "ryu", "serde 1.0.136", @@ -5573,26 +2706,11 @@ checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", - "cpufeatures 0.2.2", + "cpufeatures", "digest 0.9.0", "opaque-debug 0.3.0", ] -[[package]] -name = "sha1" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" -dependencies = [ - "sha1_smol", -] - -[[package]] -name = "sha1_smol" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" - [[package]] name = "sha2" version = "0.8.2" @@ -5613,20 +2731,8 @@ checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", - "cpufeatures 0.2.2", - "digest 0.9.0", - "opaque-debug 0.3.0", -] - -[[package]] -name = "sha3" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" -dependencies = [ - "block-buffer 0.9.0", + "cpufeatures", "digest 0.9.0", - "keccak", "opaque-debug 0.3.0", ] @@ -5639,16 +2745,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "signal-hook" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "647c97df271007dcea485bb74ffdb57f2e683f1306c854f468a0c244badabf2d" -dependencies = [ - "libc", - "signal-hook-registry", -] - [[package]] name = "signal-hook-registry" version = "1.4.0" @@ -5664,18 +2760,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f054c6c1a6e95179d6f23ed974060dcefb2d9388bb7256900badad682c499de4" -[[package]] -name = "simba" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e82063457853d00243beda9952e910b82593e4b07ae9f721b9278a99a0d3d5c" -dependencies = [ - "approx", - "num-complex", - "num-traits 0.2.14", - "paste", -] - [[package]] name = "slab" version = "0.4.6" @@ -5691,17 +2775,6 @@ dependencies = [ "erased-serde", ] -[[package]] -name = "sluice" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7400c0eff44aa2fcb5e31a5f24ba9716ed90138769e4977a2ba6014ae63eb5" -dependencies = [ - "async-channel", - "futures-core", - "futures-io", -] - [[package]] name = "smallvec" version = "0.6.14" @@ -5717,35 +2790,6 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" -[[package]] -name = "snow" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6142f7c25e94f6fd25a32c3348ec230df9109b463f59c8c7acc4bd34936babb7" -dependencies = [ - "aes-gcm", - "blake2", - "chacha20poly1305", - "rand 0.8.5", - "rand_core 0.6.3", - "ring", - "rustc_version 0.3.3", - "sha2 0.9.9", - "subtle", - "x25519-dalek", -] - -[[package]] -name = "socket2" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "winapi", -] - [[package]] name = "socket2" version = "0.4.4" @@ -5756,22 +2800,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "soketto" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5c71ed3d54db0a699f4948e1bb3e45b450fa31fe602621dee6680361d569c88" -dependencies = [ - "base64 0.12.3", - "bytes 0.5.6", - "flate2", - "futures 0.3.21", - "httparse", - "log", - "rand 0.7.3", - "sha-1", -] - [[package]] name = "soketto" version = "0.7.1" @@ -5779,8 +2807,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" dependencies = [ "base64 0.13.0", - "bytes 1.1.0", - "futures 0.3.21", + "bytes", + "futures", "httparse", "log", "rand 0.8.5", @@ -5844,55 +2872,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "sp-block-builder" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "parity-scale-codec", - "sp-api", - "sp-inherents", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "sp-blockchain" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "futures 0.3.21", - "log", - "lru", - "parity-scale-codec", - "parking_lot 0.11.2", - "sp-api", - "sp-consensus", - "sp-database", - "sp-runtime", - "sp-state-machine", - "thiserror", -] - -[[package]] -name = "sp-consensus" -version = "0.10.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "async-trait", - "futures 0.3.21", - "futures-timer", - "log", - "parity-scale-codec", - "sp-core", - "sp-inherents", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-version", - "thiserror", -] - [[package]] name = "sp-core" version = "4.0.0-dev" @@ -5903,13 +2882,13 @@ dependencies = [ "byteorder", "dyn-clonable", "ed25519-dalek", - "futures 0.3.21", + "futures", "hash-db", "hash256-std-hasher", "hex", "impl-serde", "lazy_static", - "libsecp256k1 0.6.0", + "libsecp256k1", "log", "merlin", "num-traits 0.2.14", @@ -5938,15 +2917,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "sp-database" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "kvdb", - "parking_lot 0.11.2", -] - [[package]] name = "sp-debug-derive" version = "3.0.0" @@ -6005,9 +2975,9 @@ name = "sp-io" version = "4.0.0-dev" source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" dependencies = [ - "futures 0.3.21", + "futures", "hash-db", - "libsecp256k1 0.6.0", + "libsecp256k1", "log", "parity-scale-codec", "parking_lot 0.11.2", @@ -6031,7 +3001,7 @@ source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia- dependencies = [ "async-trait", "derive_more", - "futures 0.3.21", + "futures", "merlin", "parity-scale-codec", "parking_lot 0.11.2", @@ -6040,14 +3010,6 @@ dependencies = [ "sp-externalities", ] -[[package]] -name = "sp-maybe-compressed-blob" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "zstd", -] - [[package]] name = "sp-panic-handler" version = "3.0.0" @@ -6056,16 +3018,6 @@ dependencies = [ "backtrace", ] -[[package]] -name = "sp-rpc" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "rustc-hash", - "serde 1.0.136", - "sp-core", -] - [[package]] name = "sp-runtime" version = "4.0.0-dev" @@ -6117,15 +3069,6 @@ dependencies = [ "syn", ] -[[package]] -name = "sp-serializer" -version = "3.0.0" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "serde 1.0.136", - "serde_json", -] - [[package]] name = "sp-staking" version = "4.0.0-dev" @@ -6178,35 +3121,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "sp-tasks" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "log", - "sp-core", - "sp-externalities", - "sp-io", - "sp-runtime-interface", - "sp-std", -] - -[[package]] -name = "sp-timestamp" -version = "4.0.0-dev" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "async-trait", - "futures-timer", - "log", - "parity-scale-codec", - "sp-api", - "sp-inherents", - "sp-runtime", - "sp-std", - "thiserror", -] - [[package]] name = "sp-tracing" version = "4.0.0-dev" @@ -6284,15 +3198,6 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" -[[package]] -name = "standback" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" -dependencies = [ - "version_check", -] - [[package]] name = "static_assertions" version = "1.1.0" @@ -6300,72 +3205,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] -name = "statrs" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05bdbb8e4e78216a85785a85d3ec3183144f98d0097b9281802c019bb07a6f05" -dependencies = [ - "approx", - "lazy_static", - "nalgebra", - "num-traits 0.2.14", - "rand 0.8.5", -] - -[[package]] -name = "stdweb" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" -dependencies = [ - "discard", - "rustc_version 0.2.3", - "stdweb-derive", - "stdweb-internal-macros", - "stdweb-internal-runtime", - "wasm-bindgen", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" -dependencies = [ - "proc-macro2", - "quote", - "serde 1.0.136", - "serde_derive", - "syn", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" -dependencies = [ - "base-x", - "proc-macro2", - "quote", - "serde 1.0.136", - "serde_derive", - "serde_json", - "sha1", - "syn", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.5" +name = "strsim" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "strsim" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "structopt" @@ -6384,7 +3233,7 @@ version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" dependencies = [ - "heck 0.3.3", + "heck", "proc-macro-error", "proc-macro2", "quote", @@ -6406,7 +3255,7 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d06aaeeee809dbc59eb4556183dd927df67db1540de5be8d3ec0b6636358a5ec" dependencies = [ - "heck 0.3.3", + "heck", "proc-macro2", "quote", "syn", @@ -6416,6 +3265,7 @@ dependencies = [ name = "subquery-s2s" version = "0.5.7" dependencies = [ + "array-bytes", "async-trait", "gql_client", "hex", @@ -6442,58 +3292,73 @@ dependencies = [ ] [[package]] -name = "substrate-prometheus-endpoint" -version = "0.9.0" -source = "git+https://github.com/darwinia-network/substrate.git?branch=darwinia-v0.12.2#5cb17b488d600befa4918915e18d40c28a25353d" -dependencies = [ - "async-std", - "derive_more", - "futures-util", - "hyper", - "log", - "prometheus", - "tokio", -] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] -name = "substrate-relay-helper" -version = "0.1.0" -source = "git+https://github.com/darwinia-network/darwinia-bridges-substrate.git?branch=darwinia-v0.12.2#3985f632dd3bc869de1ca27aa3da61df62ff780e" +name = "subxt" +version = "0.17.0" +source = "git+https://github.com/darwinia-network/subxt.git?branch=darwinia-v0.12.2#7a63da959877078de7db7c14cd2eed9e65e5d54e" dependencies = [ - "anyhow", - "async-std", "async-trait", - "bp-header-chain", - "bp-messages", - "bp-parachains", - "bp-polkadot-core", - "bp-runtime", - "bridge-runtime-common", - "finality-grandpa", - "finality-relay", - "frame-support", - "futures 0.3.21", + "bitvec", + "chameleon", + "derivative", + "frame-metadata", + "futures", + "hex", + "jsonrpsee", "log", - "messages-relay", "num-traits 0.2.14", - "pallet-bridge-grandpa", - "pallet-bridge-messages", - "pallet-bridge-parachains", - "parachains-relay", "parity-scale-codec", - "relay-substrate-client", - "relay-utils", + "scale-info", + "serde 1.0.136", + "serde_json", "sp-core", - "sp-finality-grandpa", "sp-runtime", + "sp-version", + "subxt-macro", "thiserror", ] [[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +name = "subxt-codegen" +version = "0.17.0" +source = "git+https://github.com/darwinia-network/subxt.git?branch=darwinia-v0.12.2#7a63da959877078de7db7c14cd2eed9e65e5d54e" +dependencies = [ + "async-trait", + "darling", + "frame-metadata", + "heck", + "parity-scale-codec", + "proc-macro-crate 0.1.5", + "proc-macro-error", + "proc-macro2", + "quote", + "scale-info", + "syn", +] + +[[package]] +name = "subxt-macro" +version = "0.17.0" +source = "git+https://github.com/darwinia-network/subxt.git?branch=darwinia-v0.12.2#7a63da959877078de7db7c14cd2eed9e65e5d54e" +dependencies = [ + "async-trait", + "darling", + "frame-metadata", + "heck", + "parity-scale-codec", + "proc-macro-crate 0.1.5", + "proc-macro-error", + "proc-macro2", + "quote", + "scale-info", + "subxt-codegen", + "syn", +] [[package]] name = "support-common" @@ -6532,6 +3397,13 @@ dependencies = [ "strum", ] +[[package]] +name = "support-toolkit" +version = "0.5.7" +dependencies = [ + "thiserror", +] + [[package]] name = "syn" version = "1.0.91" @@ -6555,23 +3427,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "sysinfo" -version = "0.15.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de94457a09609f33fec5e7fceaf907488967c6c7c75d64da6a7ce6ffdb8b5abd" -dependencies = [ - "cc", - "cfg-if 1.0.0", - "core-foundation-sys", - "doc-comment", - "libc", - "ntapi", - "once_cell", - "rayon", - "winapi", -] - [[package]] name = "tap" version = "1.0.1" @@ -6592,15 +3447,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "termcolor" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" -dependencies = [ - "winapi-util", -] - [[package]] name = "textwrap" version = "0.11.0" @@ -6650,44 +3496,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "time" -version = "0.2.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242" -dependencies = [ - "const_fn", - "libc", - "standback", - "stdweb", - "time-macros", - "version_check", - "winapi", -] - -[[package]] -name = "time-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" -dependencies = [ - "proc-macro-hack", - "time-macros-impl", -] - -[[package]] -name = "time-macros-impl" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "standback", - "syn", -] - [[package]] name = "tiny-bip39" version = "0.8.2" @@ -6737,16 +3545,16 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee" dependencies = [ - "bytes 1.1.0", + "bytes", "libc", "memchr", "mio", "num_cpus", "once_cell", "parking_lot 0.12.0", - "pin-project-lite 0.2.8", + "pin-project-lite", "signal-hook-registry", - "socket2 0.4.4", + "socket2", "tokio-macros", "winapi", ] @@ -6778,23 +3586,23 @@ version = "0.23.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4151fda0cf2798550ad0b34bcfc9b9dcc2a9d2471c895c68f3a8818e54f2389e" dependencies = [ - "rustls 0.20.4", + "rustls", "tokio", - "webpki 0.22.0", + "webpki", ] [[package]] name = "tokio-util" -version = "0.6.9" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0" +checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" dependencies = [ - "bytes 1.1.0", + "bytes", "futures-core", "futures-io", "futures-sink", "log", - "pin-project-lite 0.2.8", + "pin-project-lite", "tokio", ] @@ -6804,10 +3612,10 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0edfdeb067411dba2044da6d1cb2df793dd35add7888d73c16e3381ded401764" dependencies = [ - "bytes 1.1.0", + "bytes", "futures-core", "futures-sink", - "pin-project-lite 0.2.8", + "pin-project-lite", "tokio", "tracing", ] @@ -6834,8 +3642,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09" dependencies = [ "cfg-if 1.0.0", - "log", - "pin-project-lite 0.2.8", + "pin-project-lite", "tracing-attributes", "tracing-core", ] @@ -6871,16 +3678,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "tracing-futures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" -dependencies = [ - "pin-project 1.0.10", - "tracing", -] - [[package]] name = "tracing-log" version = "0.1.2" @@ -6946,49 +3743,6 @@ dependencies = [ "hash-db", ] -[[package]] -name = "trust-dns-proto" -version = "0.20.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca94d4e9feb6a181c690c4040d7a24ef34018d8313ac5044a61d21222ae24e31" -dependencies = [ - "async-trait", - "cfg-if 1.0.0", - "data-encoding", - "enum-as-inner", - "futures-channel", - "futures-io", - "futures-util", - "idna 0.2.3", - "ipnet", - "lazy_static", - "log", - "rand 0.8.5", - "smallvec 1.8.0", - "thiserror", - "tinyvec", - "url 2.2.2", -] - -[[package]] -name = "trust-dns-resolver" -version = "0.20.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecae383baad9995efaa34ce8e57d12c3f305e545887472a492b838f4b5cfb77a" -dependencies = [ - "cfg-if 1.0.0", - "futures-util", - "ipconfig", - "lazy_static", - "log", - "lru-cache", - "parking_lot 0.11.2", - "resolv-conf", - "smallvec 1.8.0", - "thiserror", - "trust-dns-proto", -] - [[package]] name = "try-lock" version = "0.2.3" @@ -6997,9 +3751,9 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "twox-hash" -version = "1.6.2" +version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee73e6e4924fe940354b8d4d98cad5231175d615cd855b758adc658c0aac6a0" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if 1.0.0", "rand 0.8.5", @@ -7012,12 +3766,6 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" -[[package]] -name = "ucd-trie" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" - [[package]] name = "uint" version = "0.9.3" @@ -7063,63 +3811,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" -[[package]] -name = "universal-hash" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" -dependencies = [ - "generic-array 0.14.5", - "subtle", -] - -[[package]] -name = "unsigned-varint" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fdeedbf205afadfe39ae559b75c3240f24e257d0ca27e85f85cb82aa19ac35" - -[[package]] -name = "unsigned-varint" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35581ff83d4101e58b582e607120c7f5ffb17e632a980b1f38334d76b36908b2" -dependencies = [ - "asynchronous-codec 0.5.0", - "bytes 1.1.0", - "futures-io", - "futures-util", -] - -[[package]] -name = "unsigned-varint" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" -dependencies = [ - "asynchronous-codec 0.6.0", - "bytes 1.1.0", - "futures-io", - "futures-util", -] - [[package]] name = "untrusted" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" -[[package]] -name = "url" -version = "1.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" -dependencies = [ - "idna 0.1.5", - "matches", - "percent-encoding 1.0.1", -] - [[package]] name = "url" version = "2.2.2" @@ -7127,9 +3824,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" dependencies = [ "form_urlencoded", - "idna 0.2.3", + "idna", "matches", - "percent-encoding 2.1.0", + "percent-encoding", ] [[package]] @@ -7138,16 +3835,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "value-bag" -version = "1.0.0-alpha.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79923f7731dc61ebfba3633098bf3ac533bbd35ccd8c57e7088d9a5eebe0263f" -dependencies = [ - "ctor", - "version_check", -] - [[package]] name = "vcpkg" version = "0.2.15" @@ -7166,18 +3853,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - -[[package]] -name = "waker-fn" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" - [[package]] name = "want" version = "0.3.0" @@ -7272,21 +3947,6 @@ version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" -[[package]] -name = "wasm-timer" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" -dependencies = [ - "futures 0.3.21", - "js-sys", - "parking_lot 0.11.2", - "pin-utils", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "wasmi" version = "0.9.1" @@ -7296,7 +3956,7 @@ dependencies = [ "downcast-rs", "libc", "memory_units", - "num-rational 0.2.4", + "num-rational", "num-traits 0.2.14", "parity-wasm", "wasmi-validation", @@ -7321,16 +3981,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "webpki" version = "0.22.0" @@ -7341,50 +3991,15 @@ dependencies = [ "untrusted", ] -[[package]] -name = "webpki-roots" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" -dependencies = [ - "webpki 0.21.4", -] - [[package]] name = "webpki-roots" version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d8de8415c823c8abd270ad483c6feeac771fad964890779f9a8cb24fbbc1bf" dependencies = [ - "webpki 0.22.0", -] - -[[package]] -name = "wepoll-ffi" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" -dependencies = [ - "cc", -] - -[[package]] -name = "which" -version = "4.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae" -dependencies = [ - "either", - "lazy_static", - "libc", + "webpki", ] -[[package]] -name = "widestring" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" - [[package]] name = "winapi" version = "0.3.9" @@ -7401,15 +4016,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -7459,15 +4065,6 @@ version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" -[[package]] -name = "winreg" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" -dependencies = [ - "winapi", -] - [[package]] name = "winreg" version = "0.10.1" @@ -7483,17 +4080,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" -[[package]] -name = "x25519-dalek" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" -dependencies = [ - "curve25519-dalek 3.2.0", - "rand_core 0.5.1", - "zeroize", -] - [[package]] name = "yaml-rust" version = "0.4.5" @@ -7503,25 +4089,11 @@ dependencies = [ "linked-hash-map 0.5.4", ] -[[package]] -name = "yamux" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7d9028f208dd5e63c614be69f115c1b53cacc1111437d4c765185856666c107" -dependencies = [ - "futures 0.3.21", - "log", - "nohash-hasher", - "parking_lot 0.11.2", - "rand 0.8.5", - "static_assertions", -] - [[package]] name = "zeroize" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb5728b8afd3f280a869ce1d4c554ffaed35f45c231fc41bfbd0381bef50317" +checksum = "94693807d016b2f2d2e14420eb3bfcca689311ff775dcf113d74ea624b7cdf07" dependencies = [ "zeroize_derive", ] @@ -7537,32 +4109,3 @@ dependencies = [ "syn", "synstructure", ] - -[[package]] -name = "zstd" -version = "0.9.2+zstd.1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2390ea1bf6c038c39674f22d95f0564725fc06034a47129179810b2fc58caa54" -dependencies = [ - "zstd-safe", -] - -[[package]] -name = "zstd-safe" -version = "4.1.3+zstd.1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e99d81b99fb3c2c2c794e3fe56c305c63d5173a16a46b5850b07c935ffc7db79" -dependencies = [ - "libc", - "zstd-sys", -] - -[[package]] -name = "zstd-sys" -version = "1.6.2+zstd.1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2daf2f248d9ea44454bfcb2516534e8b8ad2fc91bf818a1885495fc42bc8ac9f" -dependencies = [ - "cc", - "libc", -] diff --git a/bridges/pangolin-pangoro/bridge/Cargo.toml b/bridges/pangolin-pangoro/bridge/Cargo.toml index ad5d3875c..3a342bf29 100644 --- a/bridges/pangolin-pangoro/bridge/Cargo.toml +++ b/bridges/pangolin-pangoro/bridge/Cargo.toml @@ -13,60 +13,33 @@ repository = "https://github.com/darwinia-network/bridger" version = "0.5.7" [dependencies] - -color-eyre = "0.5" tracing = "0.1" +color-eyre = "0.5" -async-trait = "0.1" +array-bytes = "1.4" +tokio = { version = "1", features = ["full"] } -colored = "2" structopt = "0.3" strum = { version = "0.21", features = ["derive"] } -tokio = { version = "1", features = ["full"] } - -codec = { package = "parity-scale-codec", version = "2" } -futures = "0.3" -futures-timer = "3" -hex = "0.4" -serde = { version = "1", features = ["derive"] } -serde_json = "1" +serde = { version = "1", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "2", default-features = false } +once_cell = "1" +futures = "0.3" lifeline = { git = "https://github.com/fewensa/lifeline-rs.git", branch = "threads-safely" } postage = "0.4" -## Substrate Dependencies - -frame-support = { git = "https://github.com/darwinia-network/substrate.git", branch = "darwinia-v0.12.2" } -sp-core = { git = "https://github.com/darwinia-network/substrate.git", branch = "darwinia-v0.12.2" } -sp-finality-grandpa = { git = "https://github.com/darwinia-network/substrate.git", branch = "darwinia-v0.12.2" } -sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", branch = "darwinia-v0.12.2" } -sp-trie = { git = "https://github.com/darwinia-network/substrate.git", branch = "darwinia-v0.12.2" } -sp-version = { git = "https://github.com/darwinia-network/substrate.git", branch = "darwinia-v0.12.2" } +sp-core = { git = "https://github.com/darwinia-network/substrate.git", branch = "darwinia-v0.12.2" } -## bridge common +subxt = { git = "https://github.com/darwinia-network/subxt.git", branch = "darwinia-v0.12.2" } -bp-darwinia-core = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2" } -bp-header-chain = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2" } -bp-messages = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2" } -bp-pangolin = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2" } -bp-pangoro = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2" } -bp-runtime = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2" } -bridge-runtime-common = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2" } -messages-relay = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2" } -pallet-bridge-messages = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2" } -relay-pangolin-client = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2" } -relay-pangoro-client = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2" } -relay-substrate-client = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2" } -relay-utils = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2" } -substrate-relay-helper = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2" } +support-common = { path = "../../../frame/supports/support-common" } +support-lifeline = { path = "../../../frame/supports/support-lifeline" } +support-terminal = { path = "../../../frame/supports/support-terminal" } -pallet-fee-market = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2" } +component-http-client = { path = "../../../frame/components/http-client" } -## component -feemarket-s2s = { path = "../../../frame/assistants/feemarket-s2s" } -subquery-s2s = { path = "../../../frame/assistants/subquery-s2s" } +client-pangolin = { path = "../../../frame/assistants/client-pangolin", features = [ "s2s-pangoro" ]} +client-pangoro = { path = "../../../frame/assistants/client-pangoro", features = [ "s2s-pangolin" ]} -## support -support-common = { path = "../../../frame/supports/support-common" } -support-lifeline = { path = "../../../frame/supports/support-lifeline" } -support-terminal = { path = "../../../frame/supports/support-terminal" } +subquery-s2s = { path = "../../../frame/assistants/subquery-s2s" } diff --git a/bridges/pangolin-pangoro/bridge/src/bridge/bus.rs b/bridges/pangolin-pangoro/bridge/src/bridge/bus.rs index 0dd422c99..6b2e9b960 100644 --- a/bridges/pangolin-pangoro/bridge/src/bridge/bus.rs +++ b/bridges/pangolin-pangoro/bridge/src/bridge/bus.rs @@ -1,3 +1,3 @@ use lifeline::prelude::*; -lifeline_bus!(pub struct PangolinPangoroBus); +lifeline_bus!(pub struct BridgeBus); diff --git a/bridges/pangolin-pangoro/bridge/src/bridge/config.rs b/bridges/pangolin-pangoro/bridge/src/bridge/config.rs index 9020690d0..d3e1d20dd 100644 --- a/bridges/pangolin-pangoro/bridge/src/bridge/config.rs +++ b/bridges/pangolin-pangoro/bridge/src/bridge/config.rs @@ -1,137 +1,80 @@ -use feemarket_s2s::config::FeemarketConfig; use serde::{Deserialize, Serialize}; -use strum::{EnumString, EnumVariantNames}; +use subquery_s2s::SubqueryConfig; -use support_common::error::BridgerError; - -use crate::types::{ChainInfo, HexLaneId, PrometheusParamsInfo}; +use crate::types::HexLaneId; +/// Bridge template config #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct PangolinPangoroConfig { +pub struct BridgeConfig { + /// Pangolin chain pub pangolin: ChainInfoConfig, + /// Panogro chain pub pangoro: ChainInfoConfig, + /// Relay config pub relay: RelayConfig, - pub feemarket: Option, - pub task: TaskConfig, + /// Index config + pub index: IndexConfig, } -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct TaskConfig { - pub interval_update_fee: u64, - pub update_fee_strategy: UpdateFeeStrategyType, -} - -#[derive(Clone, Debug, Serialize, Deserialize, strum::EnumString)] -pub enum UpdateFeeStrategyType { - Nothing, - Crazy, - Reasonable, +/// Chain info +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct ChainInfoConfig { + /// Endpoint + pub endpoint: String, + /// Signer + pub signer: String, } -#[derive(Clone, Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct RelayConfig { /// Hex-encoded lane identifiers that should be served by the complex relay. pub lanes: Vec, - #[serde(skip_serializing_if = "Option::is_none")] - pub signer_pangolin: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub signer_pangoro: Option, - #[serde(default)] - pub prometheus_params: PrometheusParamsInfo, - /// If passed, only mandatory headers (headers that are changing the GRANDPA authorities set) - /// are relayed. - pub only_mandatory_headers: bool, - /// Create relayers fund accounts on both chains, if it does not exists yet. - pub create_relayers_fund_accounts: bool, - /// The SURI of secret key to use when transactions are submitted to the pangolin node. - #[serde(skip_serializing_if = "Option::is_none")] - pub pangolin_messages_pallet_owner: Option, - /// The password for the SURI of secret key to use when transactions are submitted to the pangolin node. - #[serde(skip_serializing_if = "Option::is_none")] - pub pangolin_messages_pallet_owner_password: Option, - /// The SURI of secret key to use when transactions are submitted to the pangoro node. - #[serde(skip_serializing_if = "Option::is_none")] - pub pangoro_messages_pallet_owner: Option, - /// The password for the SURI of secret key to use when transactions are submitted to the pangoro node. - #[serde(skip_serializing_if = "Option::is_none")] - pub pangoro_messages_pallet_owner_password: Option, } #[derive(Clone, Debug, Serialize, Deserialize)] -pub struct ChainInfoConfig { - pub endpoint: String, - #[serde(skip_serializing_if = "Option::is_none")] - pub signer: Option, - #[serde(skip)] - pub secure: bool, - #[serde(skip_serializing_if = "Option::is_none")] - pub signer_password: Option, - /// Transactions mortality period, in blocks. MUST be a power of two in [4; 65536] range. MAY NOT be larger than `BlockHashCount` parameter of the chain system module. - #[serde(skip_serializing_if = "Option::is_none")] - pub transactions_mortality: Option, - /// Runtime version mode, default is bundle - #[serde(skip_serializing_if = "Option::is_none")] - pub runtime_version_mode: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub spec_version: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_version: Option, +pub struct IndexConfig { + pub pangolin: SubqueryConfig, + pub pangoro: SubqueryConfig, } -#[derive(Clone, Debug, Serialize, Deserialize, EnumString, EnumVariantNames)] -#[strum(serialize_all = "kebab_case")] -pub enum RuntimeVersionMode { - /// Auto query version from chain - Auto, - /// Custom `spec_version` and `transaction_version` - Custom, - /// Read version from bundle dependencies directly. - Bundle, +impl From for client_pangolin::config::ClientConfig { + fn from(config: ChainInfoConfig) -> Self { + client_pangolin::config::ClientConfig { + endpoint: config.endpoint, + relayer_private_key: config.signer, + relayer_real_account: None, + } + } } -impl ChainInfoConfig { - fn host_port(&self) -> color_eyre::Result<(bool, String, u16)> { - if self.endpoint.find("ws://").unwrap_or(usize::MAX) != 0 - && self.endpoint.find("wss://").unwrap_or(usize::MAX) != 0 - { - return Err(BridgerError::Custom( - "The entrypoint isn't websocket protocol".to_string(), - ) - .into()); +impl From for client_pangoro::config::ClientConfig { + fn from(config: ChainInfoConfig) -> Self { + client_pangoro::config::ClientConfig { + endpoint: config.endpoint, + relayer_private_key: config.signer, + relayer_real_account: None, } - let secure = self.endpoint.starts_with("wss://"); - let endpoint = self - .endpoint - .replace(if secure { "wss://" } else { "ws://" }, "") - .replace('/', "") - .replace(' ', ""); - let host_port = endpoint.split(':').collect::>(); - let host = host_port.get(0).unwrap_or(&"127.0.0.1"); - let port = host_port - .get(1) - .unwrap_or(if secure { &"443" } else { &"80" }); - Ok((secure, host.to_string(), port.parse::()?)) } +} - pub fn to_chain_info(&self) -> color_eyre::Result { - self.to_chain_info_with_expect_signer(None) +impl ChainInfoConfig { + pub fn to_pangolin_client_config( + &self, + ) -> color_eyre::Result { + Ok(client_pangolin::config::ClientConfig { + endpoint: self.endpoint.clone(), + relayer_private_key: self.signer.clone(), + relayer_real_account: None, + }) } - pub fn to_chain_info_with_expect_signer( + pub fn to_pangoro_client_config( &self, - except_signer: Option, - ) -> color_eyre::Result { - let host_port = self.host_port()?; - Ok(ChainInfo { - secure: host_port.0, - host: host_port.1, - port: host_port.2, - signer: except_signer.or_else(|| self.signer.clone()), - signer_password: self.signer_password.clone(), - transactions_mortality: Some(256), - runtime_version_mode: self.runtime_version_mode.clone(), - spec_version: self.spec_version, - transaction_version: self.transaction_version, + ) -> color_eyre::Result { + Ok(client_pangoro::config::ClientConfig { + endpoint: self.endpoint.clone(), + relayer_private_key: self.signer.clone(), + relayer_real_account: None, }) } } diff --git a/bridges/pangolin-pangoro/bridge/src/bridge/task.rs b/bridges/pangolin-pangoro/bridge/src/bridge/task.rs index e1ba0d8a7..82678af19 100644 --- a/bridges/pangolin-pangoro/bridge/src/bridge/task.rs +++ b/bridges/pangolin-pangoro/bridge/src/bridge/task.rs @@ -1,35 +1,42 @@ use support_lifeline::task::TaskStack; -use crate::bridge::PangolinPangoroBus; -use crate::service::fee::UpdateFeeService; -use crate::service::relay::RelayService; +use crate::bridge::BridgeBus; +use crate::service::feemarket::FeemarketService; +use crate::service::header::pangolin_to_pangoro::PangolinToPangoroHeaderRelayService; +use crate::service::header::pangoro_to_pangolin::PangoroToPangolinHeaderRelayService; +use crate::service::message::pangolin_to_pangoro::PangolinToPangoroMessageRelayService; +use crate::service::message::pangoro_to_pangolin::PangoroToPangolinMessageRelayService; +use crate::service::subscribe::SubscribeService; #[derive(Debug)] -pub struct PangolinPangoroTask { - stack: TaskStack, +pub struct BridgeTask { + stack: TaskStack, } -impl PangolinPangoroTask { +impl BridgeTask { pub fn name() -> &'static str { - "task-pangolin-pangoro" + "pangolin-pangoro" } } -impl PangolinPangoroTask { +impl BridgeTask { pub async fn new() -> color_eyre::Result { - let bus = PangolinPangoroBus::default(); - + let bus = BridgeBus::default(); let mut stack = TaskStack::new(bus); - stack.spawn_service::()?; - stack.spawn_service::()?; + stack.spawn_service::()?; + stack.spawn_service::()?; + stack.spawn_service::()?; + stack.spawn_service::()?; + stack.spawn_service::()?; + stack.spawn_service::()?; Ok(Self { stack }) } } -impl PangolinPangoroTask { +impl BridgeTask { #[allow(dead_code)] - pub fn stack(&self) -> &TaskStack { + pub fn stack(&self) -> &TaskStack { &self.stack } } diff --git a/bridges/pangolin-pangoro/bridge/src/chains/mod.rs b/bridges/pangolin-pangoro/bridge/src/chains/mod.rs deleted file mode 100644 index 393de9221..000000000 --- a/bridges/pangolin-pangoro/bridge/src/chains/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod pangolin; -pub mod pangoro; diff --git a/bridges/pangolin-pangoro/bridge/src/chains/pangolin.rs b/bridges/pangolin-pangoro/bridge/src/chains/pangolin.rs deleted file mode 100644 index b7a8cfb48..000000000 --- a/bridges/pangolin-pangoro/bridge/src/chains/pangolin.rs +++ /dev/null @@ -1,165 +0,0 @@ -pub use s2s_const::*; -pub use s2s_headers::*; -pub use s2s_messages::*; - -mod s2s_const { - use relay_pangolin_client::PangolinChain; - use sp_version::RuntimeVersion; - - use crate::traits::CliChain; - - // === start const - impl CliChain for PangolinChain { - const RUNTIME_VERSION: RuntimeVersion = bp_pangolin::VERSION; - - type KeyPair = sp_core::sr25519::Pair; - } - - // === end -} - -mod s2s_headers { - use relay_pangolin_client::PangolinChain; - use relay_pangoro_client::PangoroChain; - use substrate_relay_helper::finality_pipeline::SubstrateFinalitySyncPipeline; - - /// Description of Pangolin -> Pangoro finalized headers bridge. - #[derive(Clone, Debug)] - pub struct PangolinFinalityToPangoro; - - substrate_relay_helper::generate_mocked_submit_finality_proof_call_builder!( - PangolinFinalityToPangoro, - PangolinFinalityToPangoroCallBuilder, - relay_pangoro_client::runtime::Call::BridgePangolinGrandpa, - relay_pangoro_client::runtime::BridgePangolinGrandpaCall::submit_finality_proof - ); - - impl SubstrateFinalitySyncPipeline for PangolinFinalityToPangoro { - type SourceChain = PangolinChain; - type TargetChain = PangoroChain; - - type SubmitFinalityProofCallBuilder = PangolinFinalityToPangoroCallBuilder; - type TransactionSignScheme = PangoroChain; - } - - // === end -} - -mod s2s_messages { - use frame_support::weights::Weight; - use relay_pangolin_client::PangolinChain; - use relay_pangoro_client::PangoroChain; - use substrate_relay_helper::messages_lane::SubstrateMessageLane; - - use feemarket_s2s::relay::BasicRelayStrategy; - - use crate::feemarket::PangolinFeemarketApi; - - #[derive(Clone, Debug)] - pub struct PangolinMessagesToPangoro; - - substrate_relay_helper::generate_mocked_receive_message_proof_call_builder!( - PangolinMessagesToPangoro, - PangolinMessagesToPangoroReceiveMessagesProofCallBuilder, - relay_pangoro_client::runtime::Call::BridgePangolinMessages, - relay_pangoro_client::runtime::BridgePangolinMessagesCall::receive_messages_proof - ); - substrate_relay_helper::generate_mocked_receive_message_delivery_proof_call_builder!( - PangolinMessagesToPangoro, - PangolinMessagesToPangoroReceiveMessagesDeliveryProofCallBuilder, - relay_pangolin_client::runtime::Call::BridgePangoroMessages, - relay_pangolin_client::runtime::BridgePangoroMessagesCall::receive_messages_delivery_proof - ); - - impl SubstrateMessageLane for PangolinMessagesToPangoro { - const SOURCE_TO_TARGET_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = None; - const TARGET_TO_SOURCE_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = None; - - type SourceChain = PangolinChain; - type TargetChain = PangoroChain; - - type SourceTransactionSignScheme = PangolinChain; - type TargetTransactionSignScheme = PangoroChain; - - type ReceiveMessagesProofCallBuilder = - PangolinMessagesToPangoroReceiveMessagesProofCallBuilder; - type ReceiveMessagesDeliveryProofCallBuilder = - PangolinMessagesToPangoroReceiveMessagesDeliveryProofCallBuilder; - - type RelayStrategy = BasicRelayStrategy; - } -} - -pub mod s2s_feemarket { - use codec::Encode; - use relay_pangolin_client::runtime as pangolin_runtime; - use relay_pangolin_client::PangolinChain; - use relay_substrate_client::{ - ChainBase, Client, SignParam, TransactionSignScheme, UnsignedTransaction, - }; - use sp_core::{Bytes, Pair}; - - use feemarket_s2s::error::FeemarketResult; - - pub(crate) async fn update_relay_fee( - client: &Client, - signer: ::AccountKeyPair, - amount: ::Balance, - ) -> FeemarketResult<()> { - let signer_id = (*signer.public().as_array_ref()).into(); - let genesis_hash = *client.genesis_hash(); - let (spec_version, transaction_version) = client.simple_runtime_version().await?; - client - .submit_signed_extrinsic(signer_id, move |_, transaction_nonce| { - Bytes( - PangolinChain::sign_transaction(SignParam { - spec_version, - transaction_version, - genesis_hash, - signer: signer.clone(), - era: relay_substrate_client::TransactionEra::immortal(), - unsigned: UnsignedTransaction::new( - pangolin_runtime::Call::PangoroFeemarket( - pangolin_runtime::FeemarketCall::update_relay_fee(amount), - ), - transaction_nonce, - ), - }) - .encode(), - ) - }) - .await?; - Ok(()) - } - - pub(crate) async fn update_locked_collateral( - client: &Client, - signer: ::AccountKeyPair, - amount: ::Balance, - ) -> FeemarketResult<()> { - let signer_id = (*signer.public().as_array_ref()).into(); - let genesis_hash = *client.genesis_hash(); - let (spec_version, transaction_version) = client.simple_runtime_version().await?; - client - .submit_signed_extrinsic(signer_id, move |_, transaction_nonce| { - Bytes( - PangolinChain::sign_transaction(SignParam { - spec_version, - transaction_version, - genesis_hash, - signer: signer.clone(), - era: relay_substrate_client::TransactionEra::immortal(), - unsigned: UnsignedTransaction::new( - pangolin_runtime::Call::PangoroFeemarket( - pangolin_runtime::FeemarketCall::update_locked_collateral(amount), - ), - transaction_nonce, - ), - }) - .encode(), - ) - }) - .await?; - Ok(()) - } -} diff --git a/bridges/pangolin-pangoro/bridge/src/chains/pangoro.rs b/bridges/pangolin-pangoro/bridge/src/chains/pangoro.rs deleted file mode 100644 index 312917379..000000000 --- a/bridges/pangolin-pangoro/bridge/src/chains/pangoro.rs +++ /dev/null @@ -1,165 +0,0 @@ -pub use s2s_const::*; -pub use s2s_headers::*; -pub use s2s_messages::*; - -mod s2s_const { - use relay_pangoro_client::PangoroChain; - use sp_version::RuntimeVersion; - - use crate::traits::CliChain; - - // === start const - impl CliChain for PangoroChain { - const RUNTIME_VERSION: RuntimeVersion = bp_pangoro::VERSION; - - type KeyPair = sp_core::sr25519::Pair; - } - - // === end -} - -mod s2s_headers { - use relay_pangolin_client::PangolinChain; - use relay_pangoro_client::PangoroChain; - use substrate_relay_helper::finality_pipeline::SubstrateFinalitySyncPipeline; - - /// Description of Pangoro -> Pangolin finalized headers bridge. - #[derive(Clone, Debug)] - pub struct PangoroFinalityToPangolin; - - substrate_relay_helper::generate_mocked_submit_finality_proof_call_builder!( - PangoroFinalityToPangolin, - PangoroFinalityToPangolinCallBuilder, - relay_pangolin_client::runtime::Call::BridgePangoroGrandpa, - relay_pangolin_client::runtime::BridgePangoroGrandpaCall::submit_finality_proof - ); - - impl SubstrateFinalitySyncPipeline for PangoroFinalityToPangolin { - type SourceChain = PangoroChain; - type TargetChain = PangolinChain; - - type SubmitFinalityProofCallBuilder = PangoroFinalityToPangolinCallBuilder; - type TransactionSignScheme = PangolinChain; - } - - // === end -} - -mod s2s_messages { - use frame_support::weights::Weight; - use relay_pangolin_client::PangolinChain; - use relay_pangoro_client::PangoroChain; - use substrate_relay_helper::messages_lane::SubstrateMessageLane; - - use feemarket_s2s::relay::BasicRelayStrategy; - - use crate::feemarket::PangoroFeemarketApi; - - #[derive(Clone, Debug)] - pub struct PangoroMessagesToPangolin; - - substrate_relay_helper::generate_mocked_receive_message_proof_call_builder!( - PangoroMessagesToPangolin, - PangoroMessagesToPangolinReceiveMessagesProofCallBuilder, - relay_pangolin_client::runtime::Call::BridgePangoroMessages, - relay_pangolin_client::runtime::BridgePangoroMessagesCall::receive_messages_proof - ); - substrate_relay_helper::generate_mocked_receive_message_delivery_proof_call_builder!( - PangoroMessagesToPangolin, - PangoroMessagesToPangolinReceiveMessagesDeliveryProofCallBuilder, - relay_pangoro_client::runtime::Call::BridgePangolinMessages, - relay_pangoro_client::runtime::BridgePangolinMessagesCall::receive_messages_delivery_proof - ); - - impl SubstrateMessageLane for PangoroMessagesToPangolin { - const SOURCE_TO_TARGET_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = None; - const TARGET_TO_SOURCE_CONVERSION_RATE_PARAMETER_NAME: Option<&'static str> = None; - - type SourceChain = PangoroChain; - type TargetChain = PangolinChain; - - type SourceTransactionSignScheme = PangoroChain; - type TargetTransactionSignScheme = PangolinChain; - - type ReceiveMessagesProofCallBuilder = - PangoroMessagesToPangolinReceiveMessagesProofCallBuilder; - type ReceiveMessagesDeliveryProofCallBuilder = - PangoroMessagesToPangolinReceiveMessagesDeliveryProofCallBuilder; - - type RelayStrategy = BasicRelayStrategy; - } -} - -pub mod s2s_feemarket { - use codec::Encode; - use relay_pangoro_client::runtime as pangoro_runtime; - use relay_pangoro_client::PangoroChain; - use relay_substrate_client::{ - ChainBase, Client, SignParam, TransactionSignScheme, UnsignedTransaction, - }; - use sp_core::{Bytes, Pair}; - - use feemarket_s2s::error::FeemarketResult; - - pub(crate) async fn update_relay_fee( - client: &Client, - signer: ::AccountKeyPair, - amount: ::Balance, - ) -> FeemarketResult<()> { - let signer_id = (*signer.public().as_array_ref()).into(); - let genesis_hash = *client.genesis_hash(); - let (spec_version, transaction_version) = client.simple_runtime_version().await?; - client - .submit_signed_extrinsic(signer_id, move |_, transaction_nonce| { - Bytes( - PangoroChain::sign_transaction(SignParam { - spec_version, - transaction_version, - genesis_hash, - signer: signer.clone(), - era: relay_substrate_client::TransactionEra::immortal(), - unsigned: UnsignedTransaction::new( - pangoro_runtime::Call::Feemarket( - pangoro_runtime::FeemarketCall::update_relay_fee(amount), - ), - transaction_nonce, - ), - }) - .encode(), - ) - }) - .await?; - Ok(()) - } - - pub(crate) async fn update_locked_collateral( - client: &Client, - signer: ::AccountKeyPair, - amount: ::Balance, - ) -> FeemarketResult<()> { - let signer_id = (*signer.public().as_array_ref()).into(); - let genesis_hash = *client.genesis_hash(); - let (spec_version, transaction_version) = client.simple_runtime_version().await?; - client - .submit_signed_extrinsic(signer_id, move |_, transaction_nonce| { - Bytes( - PangoroChain::sign_transaction(SignParam { - spec_version, - transaction_version, - genesis_hash, - signer: signer.clone(), - era: relay_substrate_client::TransactionEra::immortal(), - unsigned: UnsignedTransaction::new( - pangoro_runtime::Call::Feemarket( - pangoro_runtime::FeemarketCall::update_locked_collateral(amount), - ), - transaction_nonce, - ), - }) - .encode(), - ) - }) - .await?; - Ok(()) - } -} diff --git a/bridges/pangolin-pangoro/bridge/src/cli.rs b/bridges/pangolin-pangoro/bridge/src/cli.rs index f70ec78f5..90cdb34cc 100644 --- a/bridges/pangolin-pangoro/bridge/src/cli.rs +++ b/bridges/pangolin-pangoro/bridge/src/cli.rs @@ -1,10 +1,10 @@ use crate::command::handler; -use crate::command::types::Opts; +use crate::Opts; /// Execute command pub async fn execute(opts: Opts) -> color_eyre::Result<()> { match opts { - Opts::Start => handler::handle_relay().await, Opts::Init { bridge } => handler::handle_init(bridge).await, + Opts::Start => handler::handle_relay().await, } } diff --git a/bridges/pangolin-pangoro/bridge/src/command/handler/init.rs b/bridges/pangolin-pangoro/bridge/src/command/handler/init.rs index b271e43a0..0c7e5783e 100644 --- a/bridges/pangolin-pangoro/bridge/src/command/handler/init.rs +++ b/bridges/pangolin-pangoro/bridge/src/command/handler/init.rs @@ -1,129 +1,56 @@ -use bp_header_chain::InitializationData; -use bp_runtime::Chain as ChainBase; -use codec::Encode; -use relay_pangolin_client::runtime as pangolin_runtime; -use relay_pangolin_client::PangolinChain; -use relay_pangoro_client::runtime as pangoro_runtime; -use relay_pangoro_client::PangoroChain; -use relay_substrate_client::{ - Chain as RelaySubstrateClientChain, SignParam, TransactionSignScheme, UnsignedTransaction, -}; -use sp_core::{Bytes, Pair}; +use client_pangolin::component::PangolinClientComponent; +use client_pangoro::component::PangoroClientComponent; use support_common::config::{Config, Names}; -use support_common::error::BridgerError; -use support_terminal::output; -use crate::bridge::{ChainInfoConfig, PangolinPangoroConfig}; -use crate::types::{BridgeName, InitBridge}; +use crate::bridge::{BridgeConfig, ChainInfoConfig}; +use crate::types::BridgeName; pub async fn handle_init(bridge: BridgeName) -> color_eyre::Result<()> { tracing::info!(target: "pangolin-pangoro", "Init bridge {:?}", bridge); - let bridge_config: PangolinPangoroConfig = Config::restore(Names::BridgePangolinPangoro)?; + let bridge_config: BridgeConfig = Config::restore(Names::BridgePangolinPangoro)?; let config_pangolin: ChainInfoConfig = bridge_config.pangolin; let config_pangoro: ChainInfoConfig = bridge_config.pangoro; - let (source_chain, target_chain) = match bridge { - BridgeName::PangolinToPangoro => ( - config_pangolin.to_chain_info()?, - config_pangoro.to_chain_info()?, - ), - BridgeName::PangoroToPangolin => ( - config_pangoro.to_chain_info()?, - config_pangolin.to_chain_info()?, - ), - }; - std::thread::spawn(move || { - futures::executor::block_on(init_bridge(InitBridge { - bridge, - source: source_chain, - target: target_chain, - })) - }) - .join() - .map_err(|_| BridgerError::Custom("Failed to join thread handle".to_string()))??; - - output::output_ok(); + init_bridge(bridge, config_pangolin, config_pangoro).await?; Ok(()) } -macro_rules! select_bridge { - ($bridge: expr, $generic: tt) => { - match $bridge { - BridgeName::PangolinToPangoro => { - type Source = PangolinChain; - type Target = PangoroChain; - - fn encode_init_bridge( - init_data: InitializationData<::Header>, - ) -> ::Call { - pangoro_runtime::Call::BridgePangolinGrandpa( - pangoro_runtime::BridgePangolinGrandpaCall::initialize(init_data), - ) - } - - $generic - } - BridgeName::PangoroToPangolin => { - type Source = PangoroChain; - type Target = PangolinChain; - - fn encode_init_bridge( - init_data: InitializationData<::Header>, - ) -> ::Call { - pangolin_runtime::Call::BridgePangoroGrandpa( - pangolin_runtime::BridgePangoroGrandpaCall::initialize(init_data), - ) - } - - $generic - } +async fn init_bridge( + bridge: BridgeName, + config_pangolin: ChainInfoConfig, + config_pangoro: ChainInfoConfig, +) -> color_eyre::Result<()> { + let client_pangolin = PangolinClientComponent::component(config_pangolin.into()).await?; + let client_pangoro = PangoroClientComponent::component(config_pangoro.into()).await?; + let hash = match bridge { + BridgeName::PangolinToPangoro => { + let initialization_data = client_pangolin.prepare_initialization_data().await?; + let encoded = codec::Encode::encode(&initialization_data); + client_pangoro + .runtime() + .tx() + .bridge_pangolin_grandpa() + .initialize(codec::Decode::decode(&mut &encoded[..])?) + .sign_and_submit(client_pangoro.account().signer()) + .await? + } + BridgeName::PangoroToPangolin => { + let initialization_data = client_pangoro.prepare_initialization_data().await?; + let encoded = codec::Encode::encode(&initialization_data); + client_pangolin + .runtime() + .tx() + .bridge_pangoro_grandpa() + .initialize(codec::Decode::decode(&mut &encoded[..])?) + .sign_and_submit(client_pangolin.account().signer()) + .await? } }; -} - -async fn init_bridge(init_bridge: InitBridge) -> color_eyre::Result<()> { - let bridge = init_bridge.bridge; - let source_chain = init_bridge.source; - let target_chain = init_bridge.target; - select_bridge!(bridge, { - let source_client = source_chain.to_substrate_relay_chain::().await?; - let target_client = target_chain.to_substrate_relay_chain::().await?; - let target_sign = target_chain.to_keypair::()?; - tracing::debug!( - target: "pangolin-pangoro", - "source client -> {:?}", - source_client - ); - tracing::debug!( - target: "pangolin-pangoro", - "target client -> {:?}", - target_client - ); - - let (spec_version, transaction_version) = target_client.simple_runtime_version().await?; - substrate_relay_helper::headers_initialize::initialize( - source_client, - target_client.clone(), - target_sign.public().into(), - move |transaction_nonce, initialization_data| { - Bytes( - Target::sign_transaction(SignParam { - spec_version, - transaction_version, - genesis_hash: *target_client.genesis_hash(), - signer: target_sign.clone(), - era: relay_substrate_client::TransactionEra::immortal(), - unsigned: UnsignedTransaction::new( - encode_init_bridge(initialization_data), - transaction_nonce, - ), - }) - .encode(), - ) - }, - ) - .await; - }); + tracing::info!( + target: "pangolin-pangoro", + "Successes to sent init transaction: {:?}", + hash, + ); Ok(()) } diff --git a/bridges/pangolin-pangoro/bridge/src/command/handler/relay.rs b/bridges/pangolin-pangoro/bridge/src/command/handler/relay.rs index 9682e17b9..ea56e9fbb 100644 --- a/bridges/pangolin-pangoro/bridge/src/command/handler/relay.rs +++ b/bridges/pangolin-pangoro/bridge/src/command/handler/relay.rs @@ -1,12 +1,12 @@ use support_common::config::{Config, Names}; -use crate::bridge::{PangolinPangoroConfig, PangolinPangoroTask}; +use crate::bridge::{BridgeConfig, BridgeTask}; pub async fn handle_relay() -> color_eyre::Result<()> { tracing::info!(target: "pangolin-pangoro", "Start bridge pangolin-pangoro"); // check config - let _bridge_config: PangolinPangoroConfig = Config::restore(Names::BridgePangolinPangoro)?; - let _task = PangolinPangoroTask::new().await?; + let _bridge_config: BridgeConfig = Config::restore(Names::BridgePangolinPangoro)?; + let _task = BridgeTask::new().await?; loop { tokio::time::sleep(std::time::Duration::from_secs(1)).await; } diff --git a/bridges/pangolin-pangoro/bridge/src/command/types.rs b/bridges/pangolin-pangoro/bridge/src/command/types.rs index 84b1e4a1e..c9ce90109 100644 --- a/bridges/pangolin-pangoro/bridge/src/command/types.rs +++ b/bridges/pangolin-pangoro/bridge/src/command/types.rs @@ -2,16 +2,16 @@ use structopt::StructOpt; use crate::types::BridgeName; -/// Bridge pangolin-pangoro options +/// Bridge template options #[derive(Debug, StructOpt)] -#[structopt(name = "pangolin-pangoro", about = "Bridge pangolin-pangoro")] +#[structopt(name = "bridge-template", about = "Bridge template")] pub enum Opts { - /// Start bridge pangolin-pangoro - Start, /// Init bridge pangolin-pangoro Init { /// Bridge, support pangolin-to-pangoro pangoro-to-pangolin #[structopt()] bridge: BridgeName, }, + /// Start bridge template + Start, } diff --git a/bridges/pangolin-pangoro/bridge/src/feemarket/mod.rs b/bridges/pangolin-pangoro/bridge/src/feemarket/mod.rs deleted file mode 100644 index 188ff46a4..000000000 --- a/bridges/pangolin-pangoro/bridge/src/feemarket/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub use self::pangolin::*; -pub use self::pangoro::*; - -mod pangolin; -mod pangoro; diff --git a/bridges/pangolin-pangoro/bridge/src/feemarket/pangolin.rs b/bridges/pangolin-pangoro/bridge/src/feemarket/pangolin.rs deleted file mode 100644 index e512cc460..000000000 --- a/bridges/pangolin-pangoro/bridge/src/feemarket/pangolin.rs +++ /dev/null @@ -1,173 +0,0 @@ -use bp_messages::{LaneId, MessageNonce}; -use codec::Encode; -use pallet_fee_market::types::{Order, Relayer}; -use frame_support::Blake2_128Concat; -use relay_pangolin_client::PangolinChain; -use relay_substrate_client::{ChainBase, Client, TransactionSignScheme}; -use relay_utils::relay_loop::Client as RelayLoopClient; -use sp_core::storage::StorageKey; -use sp_core::Pair; - -use feemarket_s2s::api::FeemarketApi; -use feemarket_s2s::error::FeemarketResult; - -#[derive(Clone)] -pub struct PangolinFeemarketApi { - client: Client, - lane_id: LaneId, - signer: ::AccountKeyPair, -} - -impl PangolinFeemarketApi { - pub fn new( - client: Client, - lane_id: LaneId, - signer: ::AccountKeyPair, - ) -> Self { - Self { - client, - lane_id, - signer, - } - } -} - -#[async_trait::async_trait] -impl FeemarketApi for PangolinFeemarketApi { - type Chain = PangolinChain; - - async fn reconnect(&mut self) -> FeemarketResult<()> { - Ok(self.client.reconnect().await?) - } - - fn lane_id(&self) -> LaneId { - self.lane_id - } - - async fn best_finalized_header_number( - &self, - ) -> FeemarketResult<::BlockNumber> { - Ok(self.client.best_finalized_header_number().await?) - } - - async fn assigned_relayers( - &self, - ) -> FeemarketResult< - Vec::AccountId, ::Balance>>, - > { - let storage_key = StorageKey( - feemarket_s2s::helpers::storage_prefix( - "FeeMarket".as_bytes(), - "AssignedRelayers".as_bytes(), - ) - .to_vec(), - ); - Ok(self - .client - .storage_value(storage_key, None) - .await? - .unwrap_or_default()) - } - - async fn my_assigned_info( - &self, - ) -> FeemarketResult< - Option<( - usize, - Relayer<::AccountId, ::Balance>, - )>, - > { - let signer_id = (*self.signer.public().as_array_ref()).into(); - let assigned_relayers = self.assigned_relayers().await?; - let ret = assigned_relayers - .iter() - .position(|item| item.id == signer_id) - // .map(|position| position as u32) - .map(|position| { - ( - position, - assigned_relayers - .get(position) - .cloned() - .expect("Unreachable"), - ) - }); - Ok(ret) - } - - async fn order( - &self, - laned_id: LaneId, - message_nonce: MessageNonce, - ) -> FeemarketResult< - Option< - Order< - ::AccountId, - ::BlockNumber, - ::Balance, - >, - >, - > { - let storage_key = bp_runtime::storage_map_final_key::( - "FeeMarket", - "Orders", - (laned_id, message_nonce).encode().as_slice(), - ); - Ok(self.client.storage_value(storage_key.clone(), None).await?) - } - - async fn relayers(&self) -> FeemarketResult::AccountId>> { - let storage_key = StorageKey( - feemarket_s2s::helpers::storage_prefix("FeeMarket".as_bytes(), "Relayers".as_bytes()) - .to_vec(), - ); - Ok(self - .client - .storage_value(storage_key, None) - .await? - .unwrap_or_default()) - } - - async fn relayer( - &self, - account: ::AccountId, - ) -> FeemarketResult< - Option::AccountId, ::Balance>>, - > { - let storage_key = bp_runtime::storage_map_final_key::( - "FeeMarket", - "RelayersMap", - account.encode().as_slice(), - ); - Ok(self.client.storage_value(storage_key.clone(), None).await?) - } - - async fn is_relayer(&self) -> FeemarketResult { - let signer_id = (*self.signer.public().as_array_ref()).into(); - self.relayer(signer_id).await.map(|item| item.is_some()) - } - - async fn update_relay_fee( - &self, - amount: ::Balance, - ) -> FeemarketResult<()> { - crate::chains::pangolin::s2s_feemarket::update_relay_fee( - &self.client, - self.signer.clone(), - amount, - ) - .await - } - - async fn update_locked_collateral( - &self, - amount: ::Balance, - ) -> FeemarketResult<()> { - crate::chains::pangolin::s2s_feemarket::update_locked_collateral( - &self.client, - self.signer.clone(), - amount, - ) - .await - } -} diff --git a/bridges/pangolin-pangoro/bridge/src/feemarket/pangoro.rs b/bridges/pangolin-pangoro/bridge/src/feemarket/pangoro.rs deleted file mode 100644 index e9bf869cf..000000000 --- a/bridges/pangolin-pangoro/bridge/src/feemarket/pangoro.rs +++ /dev/null @@ -1,172 +0,0 @@ -use bp_messages::{LaneId, MessageNonce}; -use codec::Encode; -use pallet_fee_market::types::{Order, Relayer}; -use frame_support::Blake2_128Concat; -use relay_pangoro_client::PangoroChain; -use relay_substrate_client::{ChainBase, Client, TransactionSignScheme}; -use relay_utils::relay_loop::Client as RelayLoopClient; -use sp_core::storage::StorageKey; -use sp_core::Pair; - -use feemarket_s2s::api::FeemarketApi; -use feemarket_s2s::error::FeemarketResult; - -#[derive(Clone)] -pub struct PangoroFeemarketApi { - client: Client, - lane_id: LaneId, - signer: ::AccountKeyPair, -} - -impl PangoroFeemarketApi { - pub fn new( - client: Client, - lane_id: LaneId, - signer: ::AccountKeyPair, - ) -> Self { - Self { - client, - lane_id, - signer, - } - } -} - -#[async_trait::async_trait] -impl FeemarketApi for PangoroFeemarketApi { - type Chain = PangoroChain; - - async fn reconnect(&mut self) -> FeemarketResult<()> { - Ok(self.client.reconnect().await?) - } - - fn lane_id(&self) -> LaneId { - self.lane_id - } - - async fn best_finalized_header_number( - &self, - ) -> FeemarketResult<::BlockNumber> { - Ok(self.client.best_finalized_header_number().await?) - } - - async fn assigned_relayers( - &self, - ) -> FeemarketResult< - Vec::AccountId, ::Balance>>, - > { - let storage_key = StorageKey( - feemarket_s2s::helpers::storage_prefix( - "FeeMarket".as_bytes(), - "AssignedRelayers".as_bytes(), - ) - .to_vec(), - ); - Ok(self - .client - .storage_value(storage_key, None) - .await? - .unwrap_or_default()) - } - - async fn my_assigned_info( - &self, - ) -> FeemarketResult< - Option<( - usize, - Relayer<::AccountId, ::Balance>, - )>, - > { - let signer_id = (*self.signer.public().as_array_ref()).into(); - let assigned_relayers = self.assigned_relayers().await?; - let ret = assigned_relayers - .iter() - .position(|item| item.id == signer_id) - .map(|position| { - ( - position, - assigned_relayers - .get(position) - .cloned() - .expect("Unreachable"), - ) - }); - Ok(ret) - } - - async fn order( - &self, - laned_id: LaneId, - message_nonce: MessageNonce, - ) -> FeemarketResult< - Option< - Order< - ::AccountId, - ::BlockNumber, - ::Balance, - >, - >, - > { - let storage_key = bp_runtime::storage_map_final_key::( - "FeeMarket", - "Orders", - (laned_id, message_nonce).encode().as_slice(), - ); - Ok(self.client.storage_value(storage_key.clone(), None).await?) - } - - async fn relayers(&self) -> FeemarketResult::AccountId>> { - let storage_key = StorageKey( - feemarket_s2s::helpers::storage_prefix("FeeMarket".as_bytes(), "Relayers".as_bytes()) - .to_vec(), - ); - Ok(self - .client - .storage_value(storage_key, None) - .await? - .unwrap_or_default()) - } - - async fn relayer( - &self, - account: ::AccountId, - ) -> FeemarketResult< - Option::AccountId, ::Balance>>, - > { - let storage_key = bp_runtime::storage_map_final_key::( - "FeeMarket", - "RelayersMap", - account.encode().as_slice(), - ); - Ok(self.client.storage_value(storage_key.clone(), None).await?) - } - - async fn is_relayer(&self) -> FeemarketResult { - let signer_id = (*self.signer.public().as_array_ref()).into(); - self.relayer(signer_id).await.map(|item| item.is_some()) - } - - async fn update_relay_fee( - &self, - amount: ::Balance, - ) -> FeemarketResult<()> { - crate::chains::pangoro::s2s_feemarket::update_relay_fee( - &self.client, - self.signer.clone(), - amount, - ) - .await - } - - async fn update_locked_collateral( - &self, - amount: ::Balance, - ) -> FeemarketResult<()> { - crate::chains::pangoro::s2s_feemarket::update_locked_collateral( - &self.client, - self.signer.clone(), - amount, - ) - .await - } -} diff --git a/bridges/pangolin-pangoro/bridge/src/main.rs b/bridges/pangolin-pangoro/bridge/src/main.rs index 23c5a87c9..198a7c071 100644 --- a/bridges/pangolin-pangoro/bridge/src/main.rs +++ b/bridges/pangolin-pangoro/bridge/src/main.rs @@ -3,12 +3,9 @@ use structopt::StructOpt; use crate::command::types::Opts; mod bridge; -mod chains; mod cli; mod command; -mod feemarket; mod service; -mod traits; mod types; #[tokio::main] diff --git a/bridges/pangolin-pangoro/bridge/src/service/fee.rs b/bridges/pangolin-pangoro/bridge/src/service/fee.rs deleted file mode 100644 index bc4304fea..000000000 --- a/bridges/pangolin-pangoro/bridge/src/service/fee.rs +++ /dev/null @@ -1,130 +0,0 @@ -use bp_messages::LaneId; -use lifeline::{Lifeline, Service, Task}; -use relay_pangolin_client::PangolinChain; -use relay_pangoro_client::PangoroChain; - -use feemarket_s2s::fee::{CrazyStrategy, NothingStrategy, ReasonableStrategy, UpdateFeeStrategy}; -use support_common::config::{Config, Names}; -use support_common::error::BridgerError; -use support_lifeline::service::BridgeService; - -use crate::bridge::{ChainInfoConfig, PangolinPangoroTask, RelayConfig}; -use crate::bridge::{PangolinPangoroBus, PangolinPangoroConfig}; -use crate::bridge::{TaskConfig, UpdateFeeStrategyType}; -use crate::feemarket::{PangolinFeemarketApi, PangoroFeemarketApi}; - -#[derive(Debug)] -pub struct UpdateFeeService { - _greet: Lifeline, -} - -impl BridgeService for UpdateFeeService {} - -impl Service for UpdateFeeService { - type Bus = PangolinPangoroBus; - type Lifeline = color_eyre::Result; - - fn spawn(_bus: &Self::Bus) -> Self::Lifeline { - let _greet = Self::try_task( - &format!("{}-update-fee", PangolinPangoroTask::name()), - async move { - if let Err(e) = start() { - tracing::error!(target: "pangolin-pangoro", "{:?}", e); - return Err( - BridgerError::Custom("Failed to start fee service".to_string()).into(), - ); - } - Ok(()) - }, - ); - Ok(Self { _greet }) - } -} - -fn start() -> color_eyre::Result<()> { - let bridge_config: PangolinPangoroConfig = Config::restore(Names::BridgePangolinPangoro)?; - let config_task: TaskConfig = bridge_config.task; - std::thread::spawn(move || futures::executor::block_on(cron_update_fee(config_task))) - .join() - .map_err(|_| BridgerError::Custom("Failed to join thread handle".to_string()))??; - Ok(()) -} - -async fn cron_update_fee(config_task: TaskConfig) -> color_eyre::Result<()> { - tracing::info!( - target: "pangolin-pangoro", - "Use update fee strategy: {:?}", - config_task.update_fee_strategy - ); - loop { - if let Err(e) = run_update_fee(config_task.clone()).await { - tracing::error!( - target: "pangolin-pangoro", - "Failed to update fee: {:?}", - e - ); - } - - futures_timer::Delay::new(std::time::Duration::from_secs( - config_task.interval_update_fee, - )) - .await; - } -} - -async fn run_update_fee(config_task: TaskConfig) -> color_eyre::Result<()> { - let bridge_config: PangolinPangoroConfig = Config::restore(Names::BridgePangolinPangoro)?; - - let config_relay: RelayConfig = bridge_config.relay; - - let config_pangolin: ChainInfoConfig = bridge_config.pangolin; - let config_pangoro: ChainInfoConfig = bridge_config.pangoro; - let (pangolin_chain, pangoro_chain) = ( - config_pangolin.to_chain_info_with_expect_signer(config_relay.signer_pangolin.clone())?, - config_pangoro.to_chain_info_with_expect_signer(config_relay.signer_pangoro.clone())?, - ); - - let pangolin_client = pangolin_chain - .to_substrate_relay_chain::() - .await?; - let pangoro_client = pangoro_chain - .to_substrate_relay_chain::() - .await?; - - let pangolin_signer = pangolin_chain.to_keypair::()?; - let pangoro_signer = pangoro_chain.to_keypair::()?; - - // todo: If there are multiple lanes, support is also required here - let lanes = config_relay.lanes; - let lane: LaneId = lanes - .get(0) - .cloned() - .ok_or_else(|| BridgerError::Custom("Missing lane id".to_string()))? - .into(); - - let pangolin_feemarket_api = - PangolinFeemarketApi::new(pangolin_client.clone(), lane, pangolin_signer.clone()); - let pangoro_feemarket_api = - PangoroFeemarketApi::new(pangoro_client.clone(), lane, pangoro_signer.clone()); - - match config_task.update_fee_strategy { - UpdateFeeStrategyType::Nothing => Ok(NothingStrategy.handle().await?), - UpdateFeeStrategyType::Crazy => { - let strategy = CrazyStrategy::new(pangolin_feemarket_api, pangoro_feemarket_api); - Ok(strategy.handle().await?) - } - UpdateFeeStrategyType::Reasonable => { - if let Some(feemarket_config) = bridge_config.feemarket { - let strategy = ReasonableStrategy::new( - feemarket_config, - pangolin_feemarket_api, - pangoro_feemarket_api, - 15 * 1000000000, - 15 * 1000000000, - )?; - return Ok(strategy.handle().await?); - } - Err(BridgerError::Custom("Missing feemarket config".to_string()).into()) - } - } -} diff --git a/bridges/pangolin-pangoro/bridge/src/service/feemarket.rs b/bridges/pangolin-pangoro/bridge/src/service/feemarket.rs new file mode 100644 index 000000000..3b9983967 --- /dev/null +++ b/bridges/pangolin-pangoro/bridge/src/service/feemarket.rs @@ -0,0 +1,22 @@ +use lifeline::{Lifeline, Service, Task}; + +use support_lifeline::service::BridgeService; + +use crate::bridge::BridgeBus; + +#[derive(Debug)] +pub struct FeemarketService { + _greet: Lifeline, +} + +impl BridgeService for FeemarketService {} + +impl Service for FeemarketService { + type Bus = BridgeBus; + type Lifeline = color_eyre::Result; + + fn spawn(_bus: &Self::Bus) -> Self::Lifeline { + let _greet = Self::try_task("feemarket-service", async move { Ok(()) }); + Ok(Self { _greet }) + } +} diff --git a/bridges/pangolin-pangoro/bridge/src/service/header.rs b/bridges/pangolin-pangoro/bridge/src/service/header.rs new file mode 100644 index 000000000..32ec5479b --- /dev/null +++ b/bridges/pangolin-pangoro/bridge/src/service/header.rs @@ -0,0 +1,2 @@ +pub mod pangolin_to_pangoro; +pub mod pangoro_to_pangolin; diff --git a/bridges/pangolin-pangoro/bridge/src/service/header/pangolin_to_pangoro.rs b/bridges/pangolin-pangoro/bridge/src/service/header/pangolin_to_pangoro.rs new file mode 100644 index 000000000..973919db3 --- /dev/null +++ b/bridges/pangolin-pangoro/bridge/src/service/header/pangolin_to_pangoro.rs @@ -0,0 +1,287 @@ +use std::str::FromStr; + +use client_pangolin::client::PangolinClient; +use client_pangolin::component::PangolinClientComponent; +use client_pangolin::types::runtime_types::bp_header_chain::justification::GrandpaJustification; +use client_pangolin::types::runtime_types::sp_runtime::generic::header::Header; +use client_pangolin::types::runtime_types::sp_runtime::traits::BlakeTwo256; +use client_pangoro::client::PangoroClient; +use client_pangoro::component::PangoroClientComponent; +use client_pangoro::types::runtime_types::sp_runtime::generic::header::Header as FinalityTarget; +use codec::{Decode, Encode}; +use lifeline::{Lifeline, Service, Task}; +use subquery_s2s::types::{BridgeName, OriginType}; +use subquery_s2s::{Subquery, SubqueryComponent}; + +use support_common::config::{Config, Names}; +use support_common::error::BridgerError; +use support_lifeline::service::BridgeService; + +use crate::bridge::{BridgeBus, BridgeConfig}; +use crate::service::subscribe::PANGOLIN_JUSTIFICATIONS; + +#[derive(Debug)] +pub struct PangolinToPangoroHeaderRelayService { + _greet: Lifeline, +} + +impl BridgeService for PangolinToPangoroHeaderRelayService {} + +impl Service for PangolinToPangoroHeaderRelayService { + type Bus = BridgeBus; + type Lifeline = color_eyre::Result; + + fn spawn(_bus: &Self::Bus) -> Self::Lifeline { + let _greet = Self::try_task("pangolin-to-pangoro-header-relay-service", async move { + start().await.map_err(|e| { + BridgerError::Custom(format!( + "Failed to start pangolin-to-pangoro header relay: {:?}", + e + )) + })?; + Ok(()) + }); + Ok(Self { _greet }) + } +} + +struct HeaderRelay { + client_pangolin: PangolinClient, + client_pangoro: PangoroClient, + subquery_pangolin: Subquery, +} + +impl HeaderRelay { + async fn new() -> color_eyre::Result { + let bridge_config: BridgeConfig = Config::restore(Names::BridgePangolinPangoro)?; + + let config_pangolin = bridge_config.pangolin; + let config_pangoro = bridge_config.pangoro; + + let client_pangolin = + PangolinClientComponent::component(config_pangolin.to_pangolin_client_config()?) + .await?; + let client_pangoro = + PangoroClientComponent::component(config_pangoro.to_pangoro_client_config()?).await?; + + let config_index = bridge_config.index; + let subquery_pangolin = + SubqueryComponent::component(config_index.pangolin, BridgeName::PangolinPangoro); + Ok(Self { + client_pangolin, + client_pangoro, + subquery_pangolin, + }) + } +} + +async fn start() -> color_eyre::Result<()> { + tracing::info!( + target: "pangolin-pangoro", + "[header-pangolin-to-pangoro] SERVICE RESTARTING..." + ); + let mut header_relay = HeaderRelay::new().await?; + loop { + match run(&header_relay).await { + Ok(_) => {} + Err(err) => { + header_relay = HeaderRelay::new().await?; + tracing::error!( + target: "pangolin-pangoro", + "[header-pangolin-to-pangoro] Failed to relay header: {:?}", + err + ); + } + } + tokio::time::sleep(std::time::Duration::from_secs(5)).await; + } +} + +async fn run(header_relay: &HeaderRelay) -> color_eyre::Result<()> { + let last_relayed_pangolin_hash_in_pangoro = header_relay + .client_pangoro + .runtime() + .storage() + .bridge_pangolin_grandpa() + .best_finalized(None) + .await?; + let last_relayed_pangolin_block_in_pangoro = header_relay + .client_pangolin + .subxt() + .rpc() + .block(Some(last_relayed_pangolin_hash_in_pangoro)) + .await? + .ok_or_else(|| { + BridgerError::Custom(format!( + "Failed to query block by [{}] in pangolin", + last_relayed_pangolin_hash_in_pangoro + )) + })?; + let block_number = last_relayed_pangolin_block_in_pangoro.block.header.number; + tracing::trace!( + target: "pangolin-pangoro", + "[header-pangolin-to-pangoro] The latest relayed pangolin block is: {:?}", + block_number + ); + + if try_to_relay_mandatory(header_relay, block_number) + .await? + .is_none() + { + try_to_relay_header_on_demand(header_relay, block_number).await?; + } + + Ok(()) +} + +/// Try to relay mandatory headers, return Ok(Some(block_number)) if success, else Ok(None) +async fn try_to_relay_mandatory( + header_relay: &HeaderRelay, + last_block_number: u32, +) -> color_eyre::Result> { + let next_mandatory_block = header_relay + .subquery_pangolin + .next_mandatory_header(last_block_number) + .await?; + if let Some(block_to_relay) = next_mandatory_block { + tracing::info!( + target: "pangolin-pangoro", + "[header-pangolin-to-pangoro] Next mandatory block: {:?} ", + &block_to_relay.block_number + ); + let justification = header_relay + .subquery_pangolin + .find_justification(block_to_relay.block_hash.clone(), true) + .await? + .ok_or_else(|| { + BridgerError::Custom(format!( + "Failed to query justification for block hash: {:?}", + &block_to_relay.block_hash + )) + })?; + submit_finality( + header_relay, + block_to_relay.block_hash, + justification.justification, + ) + .await?; + + return Ok(Some(block_to_relay.block_number)); + } + tracing::info!( + target: "pangolin-pangoro", + "[header-pangolin-to-pangoro] Next mandatory block not found", + ); + Ok(None) +} + +async fn try_to_relay_header_on_demand( + header_relay: &HeaderRelay, + last_block_number: u32, +) -> color_eyre::Result<()> { + let next_header = match header_relay + .subquery_pangolin + .next_needed_header(OriginType::BridgePangoro) + .await? + { + Some(v) => { + if v.block_number <= last_block_number { + tracing::debug!( + target: "pangolin-pangoro", + "[header-pangolin-to-pangoro] The last storage block ({}) is less or equal last relayed block ({}). nothing to do.", + v.block_number, + last_block_number, + ); + return Ok(()); + } + v + } + None => { + tracing::debug!( + target: "pangolin-pangoro", + "[header-pangolin-to-pangoro] Try relay header on-demand, but not found any on-demand block", + ); + return Ok(()); + } + }; + tracing::debug!( + target: "pangolin-pangoro", + "[header-pangolin-to-pangoro] Try relay header on-demand, the on-demand block is {}", + next_header.block_number, + ); + + let pangolin_justification_queue = PANGOLIN_JUSTIFICATIONS.lock().await; + match pangolin_justification_queue.back().cloned() { + Some(justification) => { + tracing::trace!( + target: "pangolin-pangoro", + "[header-pangoro-to-pangolin] Found on-demand block {}, and found new justification, ready to relay header", + next_header.block_number, + ); + let grandpa_justification = GrandpaJustification::>::decode( + &mut justification.as_ref(), + ) + .map_err(|err| { + BridgerError::Custom(format!( + "Failed to decode justification of pangolin: {:?}", + err + )) + })?; + if grandpa_justification.commit.target_number > last_block_number { + submit_finality( + header_relay, + array_bytes::bytes2hex("", grandpa_justification.commit.target_hash.0), + justification.to_vec(), + ) + .await?; + } + } + None => { + tracing::warn!( + target: "pangolin-pangoro", + "[header-pangoro-to-pangolin] Found on-demand block {}, but not have justification to relay.", + next_header.block_number, + ); + } + } + + Ok(()) +} + +async fn submit_finality( + header_relay: &HeaderRelay, + block_hash: impl AsRef, + justification: Vec, +) -> color_eyre::Result<()> { + let header = header_relay + .client_pangolin + .subxt() + .rpc() + .header(Some(sp_core::H256::from_str(block_hash.as_ref()).unwrap())) + .await? + .unwrap(); + let finality_target = FinalityTarget { + parent_hash: header.parent_hash, + number: header.number, + state_root: header.state_root, + extrinsics_root: header.extrinsics_root, + digest: Decode::decode(&mut header.digest.encode().as_slice())?, + __subxt_unused_type_params: Default::default(), + }; + let grandpa_justification = Decode::decode(&mut justification.as_slice())?; + let runtime = header_relay.client_pangoro.runtime(); + let track = runtime + .tx() + .bridge_pangolin_grandpa() + .submit_finality_proof(finality_target, grandpa_justification) + .sign_and_submit_then_watch(header_relay.client_pangoro.account().signer()) + .await?; + + let events = track.wait_for_finalized_success().await?; + tracing::info!( + target: "pangolin-pangoro", + "[header-pangolin-to-pangoro] Header relayed: {:?}", + events.extrinsic_hash() + ); + Ok(()) +} diff --git a/bridges/pangolin-pangoro/bridge/src/service/header/pangoro_to_pangolin.rs b/bridges/pangolin-pangoro/bridge/src/service/header/pangoro_to_pangolin.rs new file mode 100644 index 000000000..083f7d1e8 --- /dev/null +++ b/bridges/pangolin-pangoro/bridge/src/service/header/pangoro_to_pangolin.rs @@ -0,0 +1,288 @@ +use std::str::FromStr; + +use client_pangolin::client::PangolinClient; +use client_pangolin::component::PangolinClientComponent; +use client_pangolin::types::runtime_types::sp_runtime::generic::header::Header as FinalityTarget; +use client_pangoro::client::PangoroClient; +use client_pangoro::component::PangoroClientComponent; +use client_pangoro::types::runtime_types::bp_header_chain::justification::GrandpaJustification; +use client_pangoro::types::runtime_types::sp_runtime::generic::header::Header; +use client_pangoro::types::runtime_types::sp_runtime::traits::BlakeTwo256; +use codec::{Decode, Encode}; +use lifeline::{Lifeline, Service, Task}; +use subquery_s2s::types::{BridgeName, OriginType}; +use subquery_s2s::{Subquery, SubqueryComponent}; + +use support_common::config::{Config, Names}; +use support_common::error::BridgerError; +use support_lifeline::service::BridgeService; + +use crate::bridge::{BridgeBus, BridgeConfig}; +use crate::service::subscribe::PANGORO_JUSTIFICATIONS; + +#[derive(Debug)] +pub struct PangoroToPangolinHeaderRelayService { + _greet: Lifeline, +} + +impl BridgeService for PangoroToPangolinHeaderRelayService {} + +impl Service for PangoroToPangolinHeaderRelayService { + type Bus = BridgeBus; + type Lifeline = color_eyre::Result; + + fn spawn(_bus: &Self::Bus) -> Self::Lifeline { + let _greet = Self::try_task("pangoro-to-pangolin-header-relay-service", async move { + start().await.map_err(|e| { + BridgerError::Custom(format!( + "Failed to start pangoro-to-pangolin header relay: {:?}", + e + )) + })?; + Ok(()) + }); + Ok(Self { _greet }) + } +} + +struct HeaderRelay { + client_pangoro: PangoroClient, + client_pangolin: PangolinClient, + subquery_pangoro: Subquery, +} + +impl HeaderRelay { + async fn new() -> color_eyre::Result { + let bridge_config: BridgeConfig = Config::restore(Names::BridgePangolinPangoro)?; + + let config_pangoro = bridge_config.pangoro; + let config_pangolin = bridge_config.pangolin; + + let client_pangoro = + PangoroClientComponent::component(config_pangoro.to_pangoro_client_config()?).await?; + let client_pangolin = + PangolinClientComponent::component(config_pangolin.to_pangolin_client_config()?) + .await?; + + let config_index = bridge_config.index; + let subquery_pangoro = + SubqueryComponent::component(config_index.pangoro, BridgeName::PangolinPangoro); + Ok(Self { + client_pangoro, + client_pangolin, + subquery_pangoro, + }) + } +} + +async fn start() -> color_eyre::Result<()> { + tracing::info!( + target: "pangolin-pangoro", + "[header-pangoro-to-pangolin] SERVICE RESTARTING..." + ); + let mut header_relay = HeaderRelay::new().await?; + loop { + match run(&header_relay).await { + Ok(_) => {} + Err(err) => { + header_relay = HeaderRelay::new().await?; + tracing::error!( + target: "pangolin-pangoro", + "[header-pangoro-to-pangolin] Failed to relay header: {:?}", + err + ); + } + } + tokio::time::sleep(std::time::Duration::from_secs(5)).await; + } +} + +async fn run(header_relay: &HeaderRelay) -> color_eyre::Result<()> { + let last_relayed_pangoro_hash_in_pangolin = header_relay + .client_pangolin + .runtime() + .storage() + .bridge_pangoro_grandpa() + .best_finalized(None) + .await?; + let last_relayed_pangoro_block_in_pangolin = header_relay + .client_pangoro + .subxt() + .rpc() + .block(Some(last_relayed_pangoro_hash_in_pangolin)) + .await? + .ok_or_else(|| { + BridgerError::Custom(format!( + "Failed to query block by [{}] in pangoro", + last_relayed_pangoro_hash_in_pangolin + )) + })?; + let block_number = last_relayed_pangoro_block_in_pangolin.block.header.number; + tracing::trace!( + target: "pangolin-pangoro", + "[header-pangoro-to-pangolin] The latest relayed pangoro block is: {:?}", + block_number + ); + + if try_to_relay_mandatory(header_relay, block_number) + .await? + .is_none() + { + try_to_relay_header_on_demand(header_relay, block_number).await?; + } + + Ok(()) +} + +/// Try to relay mandatory headers, return Ok(Some(block_number)) if success, else Ok(None) +async fn try_to_relay_mandatory( + header_relay: &HeaderRelay, + last_block_number: u32, +) -> color_eyre::Result> { + let next_mandatory_block = header_relay + .subquery_pangoro + .next_mandatory_header(last_block_number) + .await?; + if let Some(block_to_relay) = next_mandatory_block { + tracing::info!( + target: "pangolin-pangoro", + "[header-pangoro-to-pangolin] Next mandatory block: {:?} ", + &block_to_relay.block_number + ); + let justification = header_relay + .subquery_pangoro + .find_justification(block_to_relay.block_hash.clone(), true) + .await? + .ok_or_else(|| { + BridgerError::Custom(format!( + "Failed to query justification for block hash: {:?}", + &block_to_relay.block_hash + )) + })?; + submit_finality( + header_relay, + block_to_relay.block_hash, + justification.justification, + ) + .await?; + + return Ok(Some(block_to_relay.block_number)); + } + tracing::info!( + target: "pangolin-pangoro", + "[header-pangoro-to-pangolin] Next mandatory block not found", + ); + Ok(None) +} + +async fn try_to_relay_header_on_demand( + header_relay: &HeaderRelay, + last_block_number: u32, +) -> color_eyre::Result<()> { + let next_header = match header_relay + .subquery_pangoro + .next_needed_header(OriginType::BridgePangolin) + .await? + { + Some(v) => { + if v.block_number <= last_block_number { + tracing::debug!( + target: "pangolin-pangoro", + "[header-pangoro-to-pangolin] The last storage block ({}) is less or equal last relayed block ({}). nothing to do.", + v.block_number, + last_block_number, + ); + return Ok(()); + } + v + } + None => { + tracing::debug!( + target: "pangolin-pangoro", + "[header-pangoro-to-pangolin] Try relay header on-demand, but not found any on-demand block", + ); + return Ok(()); + } + }; + + tracing::debug!( + target: "pangolin-pangoro", + "[header-pangoro-to-pangolin] Try relay header on-demand, the on-demand block is {}", + next_header.block_number, + ); + + let pangoro_justification_queue = PANGORO_JUSTIFICATIONS.lock().await; + match pangoro_justification_queue.back().cloned() { + Some(justification) => { + tracing::trace!( + target: "pangolin-pangoro", + "[header-pangoro-to-pangolin] Found on-demand block {}, and found new justification, ready to relay header", + next_header.block_number, + ); + let grandpa_justification = GrandpaJustification::>::decode( + &mut justification.as_ref(), + ) + .map_err(|err| { + BridgerError::Custom(format!( + "Failed to decode justification of pangoro: {:?}", + err + )) + })?; + if grandpa_justification.commit.target_number > last_block_number { + submit_finality( + header_relay, + array_bytes::bytes2hex("", grandpa_justification.commit.target_hash.0), + justification.to_vec(), + ) + .await?; + } + } + None => { + tracing::warn!( + target: "pangolin-pangoro", + "[header-pangoro-to-pangolin] Found on-demand block {}, but not have justification to relay.", + next_header.block_number, + ); + } + } + + Ok(()) +} + +async fn submit_finality( + header_relay: &HeaderRelay, + block_hash: impl AsRef, + justification: Vec, +) -> color_eyre::Result<()> { + let header = header_relay + .client_pangoro + .subxt() + .rpc() + .header(Some(sp_core::H256::from_str(block_hash.as_ref()).unwrap())) + .await? + .unwrap(); + let finality_target = FinalityTarget { + parent_hash: header.parent_hash, + number: header.number, + state_root: header.state_root, + extrinsics_root: header.extrinsics_root, + digest: Decode::decode(&mut header.digest.encode().as_slice())?, + __subxt_unused_type_params: Default::default(), + }; + let grandpa_justification = Decode::decode(&mut justification.as_slice())?; + let runtime = header_relay.client_pangolin.runtime(); + let track = runtime + .tx() + .bridge_pangoro_grandpa() + .submit_finality_proof(finality_target, grandpa_justification) + .sign_and_submit_then_watch(header_relay.client_pangolin.account().signer()) + .await?; + + let events = track.wait_for_finalized_success().await?; + tracing::info!( + target: "pangolin-pangoro", + "[header-pangoro-to-pangolin] Header relayed: {:?}", + events.extrinsic_hash() + ); + Ok(()) +} diff --git a/bridges/pangolin-pangoro/bridge/src/service/message.rs b/bridges/pangolin-pangoro/bridge/src/service/message.rs new file mode 100644 index 000000000..79837e1a3 --- /dev/null +++ b/bridges/pangolin-pangoro/bridge/src/service/message.rs @@ -0,0 +1,4 @@ +pub mod pangolin_to_pangoro; +pub mod pangoro_to_pangolin; + +mod types; diff --git a/bridges/pangolin-pangoro/bridge/src/service/message/pangolin_to_pangoro.rs b/bridges/pangolin-pangoro/bridge/src/service/message/pangolin_to_pangoro.rs new file mode 100644 index 000000000..e257f1a9f --- /dev/null +++ b/bridges/pangolin-pangoro/bridge/src/service/message/pangolin_to_pangoro.rs @@ -0,0 +1,70 @@ +use lifeline::{Lifeline, Service, Task}; + +use support_lifeline::service::BridgeService; + +use crate::bridge::BridgeBus; +use crate::service::message::pangolin_to_pangoro::delivery_relay::DeliveryRunner; +use crate::service::message::pangolin_to_pangoro::receiving_relay::ReceivingRunner; + +mod delivery_relay; +mod receiving_relay; + +#[derive(Debug)] +pub struct PangolinToPangoroMessageRelayService { + _greet_delivery: Lifeline, + _greet_receiving: Lifeline, +} + +impl BridgeService for PangolinToPangoroMessageRelayService {} + +impl Service for PangolinToPangoroMessageRelayService { + type Bus = BridgeBus; + type Lifeline = color_eyre::Result; + + fn spawn(_bus: &Self::Bus) -> Self::Lifeline { + let _greet_delivery = Self::try_task( + "pangolin-to-pangoro-message-delivery-service", + async move { + while let Err(e) = start_delivery_runner().await { + tracing::error!( + target: "pangolin-pangoro", + "[delivery-pangolin-to-pangoro] Failed to start pangolin-to-pangoro message delivery relay, \ + wait some seconds try again: {:?}", + e, + ); + tokio::time::sleep(std::time::Duration::from_secs(5)).await; + } + Ok(()) + }, + ); + let _greet_receiving = Self::try_task( + "pangolin-to-pangoro-message-receiving-service", + async move { + while let Err(e) = start_receiving_runner().await { + tracing::error!( + target: "pangolin-pangoro", + "[receiving-pangolin-pangoro] Failed to start pangolin-to-pangoro message confirm relay, \ + wait some seconds try again: {:?}", + e, + ); + tokio::time::sleep(std::time::Duration::from_secs(5)).await; + } + Ok(()) + }, + ); + Ok(Self { + _greet_delivery, + _greet_receiving, + }) + } +} + +async fn start_delivery_runner() -> color_eyre::Result<()> { + let mut runner = DeliveryRunner::new().await?; + runner.start().await +} + +async fn start_receiving_runner() -> color_eyre::Result<()> { + let mut runner = ReceivingRunner::new().await?; + runner.start().await +} diff --git a/bridges/pangolin-pangoro/bridge/src/service/message/pangolin_to_pangoro/delivery_relay.rs b/bridges/pangolin-pangoro/bridge/src/service/message/pangolin_to_pangoro/delivery_relay.rs new file mode 100644 index 000000000..0c3124db5 --- /dev/null +++ b/bridges/pangolin-pangoro/bridge/src/service/message/pangolin_to_pangoro/delivery_relay.rs @@ -0,0 +1,298 @@ +use std::ops::RangeInclusive; + +use client_pangolin::subxt_runtime::api::bridge_pangoro_messages::storage::{ + OutboundLanes, OutboundMessages, +}; +use client_pangolin::types::runtime_types as pangolin_runtime_types; +use client_pangolin::types::runtime_types::bp_messages::{MessageKey, OutboundLaneData}; +use client_pangoro::types::runtime_types::bridge_runtime_common::messages::target::FromBridgedChainMessagesProof; +use subquery_s2s::types::RelayBlockOrigin; +use subxt::storage::StorageKeyPrefix; +use subxt::StorageEntry; + +use support_common::error::BridgerError; + +use crate::service::message::types::MessageRelay; + +/// Message payload for This -> Bridged chain messages. +type FromThisChainMessagePayload = pangolin_runtime_types::bp_message_dispatch::MessagePayload< + sp_core::crypto::AccountId32, + pangolin_runtime_types::sp_runtime::MultiSigner, + pangolin_runtime_types::sp_runtime::MultiSignature, + Vec, +>; + +pub struct DeliveryRunner { + message_relay: MessageRelay, + last_relayed_nonce: Option, +} + +impl DeliveryRunner { + pub async fn new() -> color_eyre::Result { + let message_relay = MessageRelay::new().await?; + Ok(Self { + message_relay, + last_relayed_nonce: None, + }) + } +} + +// defined +impl DeliveryRunner { + async fn source_outbound_lane_data(&self) -> color_eyre::Result { + let lane = self.message_relay.lane()?; + let outbound_lane_data = self + .message_relay + .client_pangolin + .runtime() + .storage() + .bridge_pangoro_messages() + .outbound_lanes(lane.0, None) + .await?; + Ok(outbound_lane_data) + } + + async fn assemble_nonces( + &self, + limit: u64, + outbound_lane_data: &OutboundLaneData, + ) -> color_eyre::Result>> { + let (latest_confirmed_nonce, latest_generated_nonce) = ( + outbound_lane_data.latest_received_nonce, + outbound_lane_data.latest_generated_nonce, + ); + if latest_confirmed_nonce == latest_generated_nonce { + return Ok(None); + } + + // assemble nonce range + let start: u64 = latest_confirmed_nonce + 1; + if let Some(last_relayed_nonce) = self.last_relayed_nonce { + if last_relayed_nonce >= start { + tracing::warn!( + target: "pangolin-pangoro", + "[delivery-pangolin-to-pangoro] There is already a batch of transactions in progress. \ + Will wait for the previous batch to complete. last relayed noce is {} and expect to start with {}. \ + please wait receiving.", + last_relayed_nonce, + start, + ); + return Ok(None); + } + } + + let inclusive_limit = limit - 1; + tracing::info!( + target: "pangolin-pangoro", + "[delivery-pangolin-to-pangoro] Assemble nonces, start from {} and last generated is {}", + start, + latest_generated_nonce, + ); + let end: u64 = if latest_generated_nonce - start > inclusive_limit { + start + inclusive_limit + } else { + latest_generated_nonce + }; + let nonces = start..=end; + Ok(Some(nonces)) + } +} + +impl DeliveryRunner { + pub async fn start(&mut self) -> color_eyre::Result<()> { + tracing::info!( + target: "pangolin-pangoro", + "[delivery-pangolin-to-pangoro] SERVICE RESTARTING..." + ); + loop { + match self.run(10).await { + Ok(last_relayed_nonce) => { + if last_relayed_nonce.is_some() { + self.last_relayed_nonce = last_relayed_nonce; + } + } + Err(err) => { + tracing::error!( + target: "pangolin-pangoro", + "[delivery-pangolin-to-pangoro] Failed to delivery message: {:?}", + err + ); + self.message_relay = MessageRelay::new().await?; + } + } + tokio::time::sleep(std::time::Duration::from_secs(5)).await; + } + } + + async fn run(&self, limit: u64) -> color_eyre::Result> { + let lane = self.message_relay.lane()?; + let source_outbound_lane_data = self.source_outbound_lane_data().await?; + + // alias + let client_pangolin = &self.message_relay.client_pangolin; + let client_pangoro = &self.message_relay.client_pangoro; + let subquery_pangolin = &self.message_relay.subquery_pangolin; + + let nonces = match self + .assemble_nonces(limit, &source_outbound_lane_data) + .await? + { + Some(v) => v, + None => { + tracing::info!( + target: "pangolin-pangoro", + "[delivery-pangolin-to-pangoro] All nonces delivered, nothing to do." + ); + return Ok(None); + } + }; + tracing::info!( + target: "pangolin-pangoro", + "[delivery-pangolin-to-pangoro] Assembled nonces {:?}", + nonces, + ); + + // query last nonce block information + let last_relay = match subquery_pangolin + .query_need_relay(RelayBlockOrigin::BridgePangoro, lane.0, *nonces.end()) + .await? + { + Some(v) => v, + None => { + tracing::warn!( + target: "pangolin-pangoro", + "[delivery-pangolin-to-pangoro] The last nonce({}) isn't storage by indexer", + nonces.end(), + ); + return Ok(None); + } + }; + + // query last relayed header + let last_relayed_pangolin_hash_in_pangoro = client_pangoro + .runtime() + .storage() + .bridge_pangolin_grandpa() + .best_finalized(None) + .await?; + let last_relayed_pangolin_block_in_pangoro = client_pangolin + .subxt() + .rpc() + .block(Some(last_relayed_pangolin_hash_in_pangoro)) + .await? + .ok_or_else(|| { + BridgerError::Custom(format!( + "Failed to query block by [{}] in pangolin", + last_relayed_pangolin_hash_in_pangoro + )) + })?; + + // compare last nonce block with last relayed header + let relayed_block_number = last_relayed_pangolin_block_in_pangoro.block.header.number; + if relayed_block_number < last_relay.block_number { + tracing::warn!( + target: "pangolin-pangoro", + "[delivery-pangolin-to-pangoro] The last nonce({}) at block {} is less then last relayed header {}, \ + please wait header relay.", + nonces.end(), + last_relay.block_number, + relayed_block_number, + ); + return Ok(None); + } + + // read proof + let mut storage_keys = Vec::with_capacity((nonces.end() - nonces.start()) as usize + 1); + let mut message_nonce = *nonces.start(); + while message_nonce <= *nonces.end() { + let prefix = StorageKeyPrefix::new::(); + let message_key = OutboundMessages(MessageKey { + lane_id: lane.0, + nonce: message_nonce, + }) + .key() + .final_key(prefix); + storage_keys.push(message_key); + message_nonce += 1; + } + + //- query inbound land data + let target_inbound_lane_data = client_pangoro + .runtime() + .storage() + .bridge_pangolin_messages() + .inbound_lanes(lane.0, None) + .await?; + let outbound_state_proof_required = target_inbound_lane_data.last_confirmed_nonce + < source_outbound_lane_data.latest_received_nonce; + if outbound_state_proof_required { + storage_keys.push( + OutboundLanes(lane.0) + .key() + .final_key(StorageKeyPrefix::new::()), + ); + } + + // fill delivery data + let mut total_weight = 0u64; + for message_nonce in nonces.clone() { + let message_data = client_pangolin + .runtime() + .storage() + .bridge_pangoro_messages() + .outbound_messages( + MessageKey { + lane_id: lane.0, + nonce: message_nonce, + }, + None, + ) + .await? + .ok_or_else(|| { + BridgerError::Custom(format!( + "Can not read message data by nonce {} in pangolin", + message_nonce + )) + })?; + let decoded_payload: FromThisChainMessagePayload = + codec::Decode::decode(&mut &message_data.payload[..])?; + total_weight += decoded_payload.weight; + } + + // query last relayed header + let read_proof = client_pangolin + .subxt() + .rpc() + .read_proof(storage_keys, Some(last_relayed_pangolin_hash_in_pangoro)) + .await?; + let proof: Vec> = read_proof.proof.into_iter().map(|item| item.0).collect(); + let proof = FromBridgedChainMessagesProof { + bridged_header_hash: last_relayed_pangolin_hash_in_pangoro, + storage_proof: proof, + lane: lane.0, + nonces_start: *nonces.start(), + nonces_end: *nonces.end(), + }; + + let hash = client_pangoro + .runtime() + .tx() + .bridge_pangolin_messages() + .receive_messages_proof( + client_pangoro.account().account_id().clone(), + proof, + (nonces.end() - nonces.start() + 1) as _, + total_weight, + ) + .sign_and_submit(client_pangoro.account().signer()) + .await?; + + tracing::debug!( + target: "pangolin-pangoro", + "[delivery-pangolin-to-pangoro] The nonces {:?} in pangolin delivered to pangoro -> {}", + nonces, + array_bytes::bytes2hex("0x", hash.0), + ); + Ok(Some(*nonces.end())) + } +} diff --git a/bridges/pangolin-pangoro/bridge/src/service/message/pangolin_to_pangoro/receiving_relay.rs b/bridges/pangolin-pangoro/bridge/src/service/message/pangolin_to_pangoro/receiving_relay.rs new file mode 100644 index 000000000..5fc22b268 --- /dev/null +++ b/bridges/pangolin-pangoro/bridge/src/service/message/pangolin_to_pangoro/receiving_relay.rs @@ -0,0 +1,230 @@ +use std::collections::VecDeque; + +use client_pangolin::types::runtime_types::bp_messages::{ + OutboundLaneData, UnrewardedRelayersState, +}; +use client_pangolin::types::runtime_types::bridge_runtime_common::messages::source::FromBridgedChainMessagesDeliveryProof; +use client_pangoro::subxt_runtime::api::bridge_pangolin_messages::storage::InboundLanes; +use subxt::storage::StorageKeyPrefix; +use subxt::StorageEntry; + +use crate::service::message::types::MessageRelay; + +pub struct ReceivingRunner { + message_relay: MessageRelay, + last_relayed_nonce: Option, +} + +impl ReceivingRunner { + pub async fn new() -> color_eyre::Result { + let message_relay = MessageRelay::new().await?; + Ok(Self { + message_relay, + last_relayed_nonce: None, + }) + } +} + +impl ReceivingRunner { + async fn source_outbound_lane_data(&self) -> color_eyre::Result { + let lane = self.message_relay.lane()?; + let outbound_lane_data = self + .message_relay + .client_pangolin + .runtime() + .storage() + .bridge_pangoro_messages() + .outbound_lanes(lane.0, None) + .await?; + Ok(outbound_lane_data) + } + + async fn target_unrewarded_relayers_state( + &self, + at_block: sp_core::H256, + source_outbound_lane_data: &OutboundLaneData, + ) -> color_eyre::Result> { + let block_hex = array_bytes::bytes2hex("0x", at_block.0); + let lane = self.message_relay.lane()?; + let inbound_lane_data = self + .message_relay + .client_pangoro + .runtime() + .storage() + .bridge_pangolin_messages() + .inbound_lanes(lane.0, Some(at_block)) + .await?; + let max_confirm_end_at_target = inbound_lane_data + .relayers + .iter() + .map(|item| item.messages.end) + .max() + .unwrap_or(0u64); + tracing::trace!( + target: "pangolin-pangoro", + "[receiving-pangolin-to-pangoro] max dispatch nonce({}) at target and last received nonce from source is {}. \ + queried by relayed block {}", + max_confirm_end_at_target, + source_outbound_lane_data.latest_received_nonce, + block_hex, + ); + if max_confirm_end_at_target == source_outbound_lane_data.latest_received_nonce { + tracing::info!( + target: "pangolin-pangoro", + "[receiving-pangolin-to-pangoro] max dispatch nonce({}) at target is same with last received nonce({}) at source. \ + queried by relayed block {}. nothing to do.", + max_confirm_end_at_target, + source_outbound_lane_data.latest_received_nonce, + block_hex, + ); + return Ok(None); + } + if let Some(last_relayed_nonce) = self.last_relayed_nonce { + if last_relayed_nonce >= max_confirm_end_at_target { + tracing::warn!( + target: "pangolin-pangoro", + "[receiving-pangolin-to-pangoro] This nonce({}) is being processed. Please waiting for the processing to finish.", + max_confirm_end_at_target, + ); + return Ok(None); + } + } + let relayers = VecDeque::from_iter(inbound_lane_data.relayers.as_slice()); + let total_unrewarded_messages = match (relayers.front(), relayers.back()) { + (Some(front), Some(back)) => { + if back.messages.end < front.messages.begin { + Some(0) + } else { + let difference = back.messages.end - front.messages.begin; + Some(difference + 1) + } + } + _ => Some(0), + }; + if total_unrewarded_messages.is_none() { + tracing::info!( + target: "pangolin-pangoro", + "[receiving-pangolin-to-pangoro] Not have unrewarded message. nothing to do.", + ); + return Ok(None); + } + Ok(Some(( + max_confirm_end_at_target, + UnrewardedRelayersState { + unrewarded_relayer_entries: relayers.len() as _, + messages_in_oldest_entry: relayers + .front() + .map(|entry| 1 + entry.messages.end - entry.messages.begin) + .unwrap_or(u64::MAX), + total_messages: total_unrewarded_messages.expect("Unreachable"), + }, + ))) + } +} + +impl ReceivingRunner { + pub async fn start(&mut self) -> color_eyre::Result<()> { + tracing::info!( + target: "pangolin-pangoro", + "[receiving-pangolin-to-pangoro] SERVICE RESTARTING..." + ); + loop { + match self.run().await { + Ok(last_relayed_nonce) => { + if last_relayed_nonce.is_some() { + self.last_relayed_nonce = last_relayed_nonce; + } + } + Err(err) => { + tracing::error!( + target: "pangolin-pangoro", + "[receiving-pangolin-to-pangoro] Failed to receiving message: {:?}", + err + ); + self.message_relay = MessageRelay::new().await?; + } + } + tokio::time::sleep(std::time::Duration::from_secs(5)).await; + } + } + + async fn run(&self) -> color_eyre::Result> { + let lane = self.message_relay.lane()?; + + // alias + let client_pangolin = &self.message_relay.client_pangolin; + let client_pangoro = &self.message_relay.client_pangoro; + + let source_outbound_lane_data = self.source_outbound_lane_data().await?; + if source_outbound_lane_data.latest_received_nonce + == source_outbound_lane_data.latest_generated_nonce + { + tracing::info!( + target: "pangolin-pangoro", + "[receiving-pangolin-to-pangoro] All nonces received, nothing to do.", + ); + return Ok(None); + } + + // query last relayed header + let last_relayed_pangoro_hash_in_pangolin = client_pangolin + .runtime() + .storage() + .bridge_pangoro_grandpa() + .best_finalized(None) + .await?; + + // assemble unrewarded relayers state + let (max_confirmed_nonce_at_target, relayers_state) = match self + .target_unrewarded_relayers_state( + last_relayed_pangoro_hash_in_pangolin, + &source_outbound_lane_data, + ) + .await? + { + Some(v) => v, + None => { + tracing::warn!( + target: "pangolin-pangoro", + "[receiving-pangolin-to-pangoro] No unrewarded relayers state found by pangoro", + ); + return Ok(None); + } + }; + + // read proof + let inbound_data_key = InboundLanes(lane.0) + .key() + .final_key(StorageKeyPrefix::new::()); + let read_proof = client_pangoro + .subxt() + .rpc() + .read_proof( + vec![inbound_data_key], + Some(last_relayed_pangoro_hash_in_pangolin), + ) + .await?; + let proof: Vec> = read_proof.proof.into_iter().map(|item| item.0).collect(); + let proof = FromBridgedChainMessagesDeliveryProof { + bridged_header_hash: last_relayed_pangoro_hash_in_pangolin, + storage_proof: proof, + lane: lane.0, + }; + + // send proof + let hash = client_pangolin + .runtime() + .tx() + .bridge_pangoro_messages() + .receive_messages_delivery_proof(proof, relayers_state) + .sign_and_submit(client_pangolin.account().signer()) + .await?; + + tracing::debug!( + target: "pangolin-pangoro", + "[receiving-pangolin-to-pangoro] receiving extensics sent successful: {}", + array_bytes::bytes2hex("0x", hash.0), + ); + Ok(Some(max_confirmed_nonce_at_target)) + } +} diff --git a/bridges/pangolin-pangoro/bridge/src/service/message/pangoro_to_pangolin.rs b/bridges/pangolin-pangoro/bridge/src/service/message/pangoro_to_pangolin.rs new file mode 100644 index 000000000..1ed64e6b1 --- /dev/null +++ b/bridges/pangolin-pangoro/bridge/src/service/message/pangoro_to_pangolin.rs @@ -0,0 +1,70 @@ +use lifeline::{Lifeline, Service, Task}; + +use support_lifeline::service::BridgeService; + +use crate::bridge::BridgeBus; +use crate::service::message::pangoro_to_pangolin::delivery_relay::DeliveryRunner; +use crate::service::message::pangoro_to_pangolin::receiving_relay::ReceivingRunner; + +mod delivery_relay; +mod receiving_relay; + +#[derive(Debug)] +pub struct PangoroToPangolinMessageRelayService { + _greet_delivery: Lifeline, + _greet_receiving: Lifeline, +} + +impl BridgeService for PangoroToPangolinMessageRelayService {} + +impl Service for PangoroToPangolinMessageRelayService { + type Bus = BridgeBus; + type Lifeline = color_eyre::Result; + + fn spawn(_bus: &Self::Bus) -> Self::Lifeline { + let _greet_delivery = Self::try_task( + "pangoro-to-pangolin-message-delivery-service", + async move { + while let Err(e) = start_delivery_runner().await { + tracing::error!( + target: "pangolin-pangoro", + "[delivery-pangoro-to-pangolin] Failed to start pangoro-to-pangolin message delivery relay, \ + wait some seconds try again: {:?}", + e, + ); + tokio::time::sleep(std::time::Duration::from_secs(5)).await; + } + Ok(()) + }, + ); + let _greet_receiving = Self::try_task( + "pangoro-to-pangolin-message-receiving-service", + async move { + while let Err(e) = start_receiving_runner().await { + tracing::error!( + target: "pangolin-pangoro", + "[receiving-pangoro-to-pangolin] Failed to start pangoro-to-pangolin message confirm relay, \ + wait some seconds try again: {:?}", + e, + ); + tokio::time::sleep(std::time::Duration::from_secs(5)).await; + } + Ok(()) + }, + ); + Ok(Self { + _greet_delivery, + _greet_receiving, + }) + } +} + +async fn start_delivery_runner() -> color_eyre::Result<()> { + let mut runner = DeliveryRunner::new().await?; + runner.start().await +} + +async fn start_receiving_runner() -> color_eyre::Result<()> { + let mut runner = ReceivingRunner::new().await?; + runner.start().await +} diff --git a/bridges/pangolin-pangoro/bridge/src/service/message/pangoro_to_pangolin/delivery_relay.rs b/bridges/pangolin-pangoro/bridge/src/service/message/pangoro_to_pangolin/delivery_relay.rs new file mode 100644 index 000000000..858c81efd --- /dev/null +++ b/bridges/pangolin-pangoro/bridge/src/service/message/pangoro_to_pangolin/delivery_relay.rs @@ -0,0 +1,298 @@ +use std::ops::RangeInclusive; + +use client_pangolin::types::runtime_types::bridge_runtime_common::messages::target::FromBridgedChainMessagesProof; +use client_pangoro::subxt_runtime::api::bridge_pangolin_messages::storage::{ + OutboundLanes, OutboundMessages, +}; +use client_pangoro::types::runtime_types as pangoro_runtime_types; +use client_pangoro::types::runtime_types::bp_messages::{MessageKey, OutboundLaneData}; +use subquery_s2s::types::RelayBlockOrigin; +use subxt::storage::StorageKeyPrefix; +use subxt::StorageEntry; + +use support_common::error::BridgerError; + +use crate::service::message::types::MessageRelay; + +/// Message payload for This -> Bridged chain messages. +type FromThisChainMessagePayload = pangoro_runtime_types::bp_message_dispatch::MessagePayload< + sp_core::crypto::AccountId32, + pangoro_runtime_types::sp_runtime::MultiSigner, + pangoro_runtime_types::sp_runtime::MultiSignature, + Vec, +>; + +pub struct DeliveryRunner { + message_relay: MessageRelay, + last_relayed_nonce: Option, +} + +impl DeliveryRunner { + pub async fn new() -> color_eyre::Result { + let message_relay = MessageRelay::new().await?; + Ok(Self { + message_relay, + last_relayed_nonce: None, + }) + } +} + +// defined +impl DeliveryRunner { + async fn source_outbound_lane_data(&self) -> color_eyre::Result { + let lane = self.message_relay.lane()?; + let outbound_lane_data = self + .message_relay + .client_pangoro + .runtime() + .storage() + .bridge_pangolin_messages() + .outbound_lanes(lane.0, None) + .await?; + Ok(outbound_lane_data) + } + + async fn assemble_nonces( + &self, + limit: u64, + outbound_lane_data: &OutboundLaneData, + ) -> color_eyre::Result>> { + let (latest_confirmed_nonce, latest_generated_nonce) = ( + outbound_lane_data.latest_received_nonce, + outbound_lane_data.latest_generated_nonce, + ); + if latest_confirmed_nonce == latest_generated_nonce { + return Ok(None); + } + + // assemble nonce range + let start: u64 = latest_confirmed_nonce + 1; + if let Some(last_relayed_nonce) = self.last_relayed_nonce { + if last_relayed_nonce >= start { + tracing::warn!( + target: "pangolin-pangoro", + "[delivery-pangoro-to-pangolin] There is already a batch of transactions in progress. \ + Will wait for the previous batch to complete. last relayed noce is {} and expect to start with {}. \ + please wait receiving.", + last_relayed_nonce, + start, + ); + return Ok(None); + } + } + + let inclusive_limit = limit - 1; + tracing::info!( + target: "pangolin-pangoro", + "[delivery-pangoro-to-pangolin] Assemble nonces, start from {} and last generated is {}", + start, + latest_generated_nonce, + ); + let end: u64 = if latest_generated_nonce - start > inclusive_limit { + start + inclusive_limit + } else { + latest_generated_nonce + }; + let nonces = start..=end; + Ok(Some(nonces)) + } +} + +impl DeliveryRunner { + pub async fn start(&mut self) -> color_eyre::Result<()> { + tracing::info!( + target: "pangolin-pangoro", + "[delivery-pangoro-to-pangolin] SERVICE RESTARTING..." + ); + loop { + match self.run(10).await { + Ok(last_relayed_nonce) => { + if last_relayed_nonce.is_some() { + self.last_relayed_nonce = last_relayed_nonce; + } + } + Err(err) => { + tracing::error!( + target: "pangolin-pangoro", + "[delivery-pangoro-to-pangolin] Failed to delivery message: {:?}", + err + ); + self.message_relay = MessageRelay::new().await?; + } + } + tokio::time::sleep(std::time::Duration::from_secs(5)).await; + } + } + + async fn run(&self, limit: u64) -> color_eyre::Result> { + let lane = self.message_relay.lane()?; + let source_outbound_lane_data = self.source_outbound_lane_data().await?; + + // alias + let client_pangoro = &self.message_relay.client_pangoro; + let client_pangolin = &self.message_relay.client_pangolin; + let subquery_pangoro = &self.message_relay.subquery_pangoro; + + let nonces = match self + .assemble_nonces(limit, &source_outbound_lane_data) + .await? + { + Some(v) => v, + None => { + tracing::info!( + target: "pangolin-pangoro", + "[delivery-pangoro-to-pangolin] All nonces delivered, nothing to do." + ); + return Ok(None); + } + }; + tracing::info!( + target: "pangolin-pangoro", + "[delivery-pangoro-to-pangolin] Assembled nonces {:?}", + nonces, + ); + + // query last nonce block information + let last_relay = match subquery_pangoro + .query_need_relay(RelayBlockOrigin::BridgePangolin, lane.0, *nonces.end()) + .await? + { + Some(v) => v, + None => { + tracing::warn!( + target: "pangolin-pangoro", + "[delivery-pangoro-to-pangolin] The last nonce({}) isn't storage by indexer", + nonces.end(), + ); + return Ok(None); + } + }; + + // query last relayed header + let last_relayed_pangoro_hash_in_pangolin = client_pangolin + .runtime() + .storage() + .bridge_pangoro_grandpa() + .best_finalized(None) + .await?; + let last_relayed_pangoro_block_in_pangolin = client_pangoro + .subxt() + .rpc() + .block(Some(last_relayed_pangoro_hash_in_pangolin)) + .await? + .ok_or_else(|| { + BridgerError::Custom(format!( + "Failed to query block by [{}] in pangoro", + last_relayed_pangoro_hash_in_pangolin + )) + })?; + + // compare last nonce block with last relayed header + let relayed_block_number = last_relayed_pangoro_block_in_pangolin.block.header.number; + if relayed_block_number < last_relay.block_number { + tracing::warn!( + target: "pangolin-pangoro", + "[delivery-pangoro-to-pangolin] The last nonce({}) at block {} is less then last relayed header {}, \ + please wait header relay.", + nonces.end(), + last_relay.block_number, + relayed_block_number, + ); + return Ok(None); + } + + // read proof + let mut storage_keys = Vec::with_capacity((nonces.end() - nonces.start()) as usize + 1); + let mut message_nonce = *nonces.start(); + while message_nonce <= *nonces.end() { + let prefix = StorageKeyPrefix::new::(); + let message_key = OutboundMessages(MessageKey { + lane_id: lane.0, + nonce: message_nonce, + }) + .key() + .final_key(prefix); + storage_keys.push(message_key); + message_nonce += 1; + } + + //- query inbound land data + let target_inbound_lane_data = client_pangolin + .runtime() + .storage() + .bridge_pangoro_messages() + .inbound_lanes(lane.0, None) + .await?; + let outbound_state_proof_required = target_inbound_lane_data.last_confirmed_nonce + < source_outbound_lane_data.latest_received_nonce; + if outbound_state_proof_required { + storage_keys.push( + OutboundLanes(lane.0) + .key() + .final_key(StorageKeyPrefix::new::()), + ); + } + + // fill delivery data + let mut total_weight = 0u64; + for message_nonce in nonces.clone() { + let message_data = client_pangoro + .runtime() + .storage() + .bridge_pangolin_messages() + .outbound_messages( + MessageKey { + lane_id: lane.0, + nonce: message_nonce, + }, + None, + ) + .await? + .ok_or_else(|| { + BridgerError::Custom(format!( + "Can not read message data by nonce {} in pangoro", + message_nonce + )) + })?; + let decoded_payload: FromThisChainMessagePayload = + codec::Decode::decode(&mut &message_data.payload[..])?; + total_weight += decoded_payload.weight; + } + + // query last relayed header + let read_proof = client_pangoro + .subxt() + .rpc() + .read_proof(storage_keys, Some(last_relayed_pangoro_hash_in_pangolin)) + .await?; + let proof: Vec> = read_proof.proof.into_iter().map(|item| item.0).collect(); + let proof = FromBridgedChainMessagesProof { + bridged_header_hash: last_relayed_pangoro_hash_in_pangolin, + storage_proof: proof, + lane: lane.0, + nonces_start: *nonces.start(), + nonces_end: *nonces.end(), + }; + + let hash = client_pangolin + .runtime() + .tx() + .bridge_pangoro_messages() + .receive_messages_proof( + client_pangolin.account().account_id().clone(), + proof, + (nonces.end() - nonces.start() + 1) as _, + total_weight, + ) + .sign_and_submit(client_pangolin.account().signer()) + .await?; + + tracing::debug!( + target: "pangolin-pangoro", + "[delivery-pangoro-to-pangolin] The nonces {:?} in pangoro delivered to pangolin -> {}", + nonces, + array_bytes::bytes2hex("0x", hash.0), + ); + Ok(Some(*nonces.end())) + } +} diff --git a/bridges/pangolin-pangoro/bridge/src/service/message/pangoro_to_pangolin/receiving_relay.rs b/bridges/pangolin-pangoro/bridge/src/service/message/pangoro_to_pangolin/receiving_relay.rs new file mode 100644 index 000000000..5e1987037 --- /dev/null +++ b/bridges/pangolin-pangoro/bridge/src/service/message/pangoro_to_pangolin/receiving_relay.rs @@ -0,0 +1,230 @@ +use std::collections::VecDeque; + +use client_pangolin::subxt_runtime::api::bridge_pangoro_messages::storage::InboundLanes; +use client_pangoro::types::runtime_types::bp_messages::{ + OutboundLaneData, UnrewardedRelayersState, +}; +use client_pangoro::types::runtime_types::bridge_runtime_common::messages::source::FromBridgedChainMessagesDeliveryProof; +use subxt::storage::StorageKeyPrefix; +use subxt::StorageEntry; + +use crate::service::message::types::MessageRelay; + +pub struct ReceivingRunner { + message_relay: MessageRelay, + last_relayed_nonce: Option, +} + +impl ReceivingRunner { + pub async fn new() -> color_eyre::Result { + let message_relay = MessageRelay::new().await?; + Ok(Self { + message_relay, + last_relayed_nonce: None, + }) + } +} + +impl ReceivingRunner { + async fn source_outbound_lane_data(&self) -> color_eyre::Result { + let lane = self.message_relay.lane()?; + let outbound_lane_data = self + .message_relay + .client_pangoro + .runtime() + .storage() + .bridge_pangolin_messages() + .outbound_lanes(lane.0, None) + .await?; + Ok(outbound_lane_data) + } + + async fn target_unrewarded_relayers_state( + &self, + at_block: sp_core::H256, + source_outbound_lane_data: &OutboundLaneData, + ) -> color_eyre::Result> { + let block_hex = array_bytes::bytes2hex("0x", at_block.0); + let lane = self.message_relay.lane()?; + let inbound_lane_data = self + .message_relay + .client_pangolin + .runtime() + .storage() + .bridge_pangoro_messages() + .inbound_lanes(lane.0, Some(at_block)) + .await?; + let max_confirm_end_at_target = inbound_lane_data + .relayers + .iter() + .map(|item| item.messages.end) + .max() + .unwrap_or(0u64); + tracing::trace!( + target: "pangolin-pangoro", + "[receiving-pangoro-to-pangolin] max dispatch nonce({}) at target and last received nonce from source is {}. \ + queried by relayed block {}", + max_confirm_end_at_target, + source_outbound_lane_data.latest_received_nonce, + block_hex, + ); + if max_confirm_end_at_target == source_outbound_lane_data.latest_received_nonce { + tracing::info!( + target: "pangolin-pangoro", + "[receiving-pangoro-to-pangolin] max dispatch nonce({}) at target is same with last received nonce({}) at source. \ + queried by relayed block {}. nothing to do.", + max_confirm_end_at_target, + source_outbound_lane_data.latest_received_nonce, + block_hex, + ); + return Ok(None); + } + if let Some(last_relayed_nonce) = self.last_relayed_nonce { + if last_relayed_nonce >= max_confirm_end_at_target { + tracing::warn!( + target: "pangolin-pangoro", + "[receiving-pangoro-to-pangolin] This nonce({}) is being processed. Please waiting for the processing to finish.", + max_confirm_end_at_target, + ); + return Ok(None); + } + } + let relayers = VecDeque::from_iter(inbound_lane_data.relayers.as_slice()); + let total_unrewarded_messages = match (relayers.front(), relayers.back()) { + (Some(front), Some(back)) => { + if back.messages.end < front.messages.begin { + Some(0) + } else { + let difference = back.messages.end - front.messages.begin; + Some(difference + 1) + } + } + _ => Some(0), + }; + if total_unrewarded_messages.is_none() { + tracing::info!( + target: "pangolin-pangoro", + "[receiving-pangoro-to-pangolin] Not have unrewarded message. nothing to do.", + ); + return Ok(None); + } + Ok(Some(( + max_confirm_end_at_target, + UnrewardedRelayersState { + unrewarded_relayer_entries: relayers.len() as _, + messages_in_oldest_entry: relayers + .front() + .map(|entry| 1 + entry.messages.end - entry.messages.begin) + .unwrap_or(u64::MAX), + total_messages: total_unrewarded_messages.expect("Unreachable"), + }, + ))) + } +} + +impl ReceivingRunner { + pub async fn start(&mut self) -> color_eyre::Result<()> { + tracing::info!( + target: "pangolin-pangoro", + "[receiving-pangoro-to-pangolin] SERVICE RESTARTING..." + ); + loop { + match self.run().await { + Ok(last_relayed_nonce) => { + if last_relayed_nonce.is_some() { + self.last_relayed_nonce = last_relayed_nonce; + } + } + Err(err) => { + tracing::error!( + target: "pangolin-pangoro", + "[receiving-pangoro-to-pangolin] Failed to receiving message: {:?}", + err + ); + self.message_relay = MessageRelay::new().await?; + } + } + tokio::time::sleep(std::time::Duration::from_secs(5)).await; + } + } + + async fn run(&self) -> color_eyre::Result> { + let lane = self.message_relay.lane()?; + + // alias + let client_pangoro = &self.message_relay.client_pangoro; + let client_pangolin = &self.message_relay.client_pangolin; + + let source_outbound_lane_data = self.source_outbound_lane_data().await?; + if source_outbound_lane_data.latest_received_nonce + == source_outbound_lane_data.latest_generated_nonce + { + tracing::info!( + target: "pangolin-pangoro", + "[receiving-pangoro-to-pangolin] All nonces received, nothing to do.", + ); + return Ok(None); + } + + // query last relayed header + let last_relayed_pangolin_hash_in_pangoro = client_pangoro + .runtime() + .storage() + .bridge_pangolin_grandpa() + .best_finalized(None) + .await?; + + // assemble unrewarded relayers state + let (max_confirmed_nonce_at_target, relayers_state) = match self + .target_unrewarded_relayers_state( + last_relayed_pangolin_hash_in_pangoro, + &source_outbound_lane_data, + ) + .await? + { + Some(v) => v, + None => { + tracing::warn!( + target: "pangolin-pangoro", + "[receiving-pangoro-to-pangolin] No unrewarded relayers state found by pangolin", + ); + return Ok(None); + } + }; + + // read proof + let inbound_data_key = InboundLanes(lane.0) + .key() + .final_key(StorageKeyPrefix::new::()); + let read_proof = client_pangolin + .subxt() + .rpc() + .read_proof( + vec![inbound_data_key], + Some(last_relayed_pangolin_hash_in_pangoro), + ) + .await?; + let proof: Vec> = read_proof.proof.into_iter().map(|item| item.0).collect(); + let proof = FromBridgedChainMessagesDeliveryProof { + bridged_header_hash: last_relayed_pangolin_hash_in_pangoro, + storage_proof: proof, + lane: lane.0, + }; + + // send proof + let hash = client_pangoro + .runtime() + .tx() + .bridge_pangolin_messages() + .receive_messages_delivery_proof(proof, relayers_state) + .sign_and_submit(client_pangoro.account().signer()) + .await?; + + tracing::debug!( + target: "pangolin-pangoro", + "[receiving-pangoro-to-pangolin] receiving extensics sent successful: {}", + array_bytes::bytes2hex("0x", hash.0), + ); + Ok(Some(max_confirmed_nonce_at_target)) + } +} diff --git a/bridges/pangolin-pangoro/bridge/src/service/message/types.rs b/bridges/pangolin-pangoro/bridge/src/service/message/types.rs new file mode 100644 index 000000000..b3e90c42e --- /dev/null +++ b/bridges/pangolin-pangoro/bridge/src/service/message/types.rs @@ -0,0 +1,58 @@ +use client_pangolin::client::PangolinClient; +use client_pangolin::component::PangolinClientComponent; +use client_pangoro::client::PangoroClient; +use client_pangoro::component::PangoroClientComponent; +use subquery_s2s::types::BridgeName; +use subquery_s2s::{Subquery, SubqueryComponent}; + +use support_common::config::{Config, Names}; +use support_common::error::BridgerError; + +use crate::bridge::{BridgeConfig, RelayConfig}; +use crate::types::HexLaneId; + +pub(crate) struct MessageRelay { + pub relay_config: RelayConfig, + pub client_pangolin: PangolinClient, + pub client_pangoro: PangoroClient, + pub subquery_pangoro: Subquery, + pub subquery_pangolin: Subquery, +} + +impl MessageRelay { + pub async fn new() -> color_eyre::Result { + let bridge_config: BridgeConfig = Config::restore(Names::BridgePangolinPangoro)?; + + let index_config = bridge_config.index; + let config_pangolin = bridge_config.pangolin; + let config_pangoro = bridge_config.pangoro; + + let client_pangolin = + PangolinClientComponent::component(config_pangolin.to_pangolin_client_config()?) + .await?; + let client_pangoro = + PangoroClientComponent::component(config_pangoro.to_pangoro_client_config()?).await?; + let subquery_pangoro = + SubqueryComponent::component(index_config.pangoro, BridgeName::PangolinPangoro); + let subquery_pangolin = + SubqueryComponent::component(index_config.pangolin, BridgeName::PangolinPangoro); + Ok(Self { + relay_config: bridge_config.relay, + client_pangolin, + client_pangoro, + subquery_pangoro, + subquery_pangolin, + }) + } +} + +impl MessageRelay { + pub fn lane(&self) -> Result { + self.relay_config + .lanes + .clone() + .get(0) + .cloned() + .ok_or_else(|| BridgerError::Custom("Missing lane id".to_string())) + } +} diff --git a/bridges/pangolin-pangoro/bridge/src/service/mod.rs b/bridges/pangolin-pangoro/bridge/src/service/mod.rs index 5c19fdff3..d110a5f9e 100644 --- a/bridges/pangolin-pangoro/bridge/src/service/mod.rs +++ b/bridges/pangolin-pangoro/bridge/src/service/mod.rs @@ -1,3 +1,4 @@ -pub mod fee; -// pub mod init; -pub mod relay; +pub mod feemarket; +pub mod header; +pub mod message; +pub mod subscribe; diff --git a/bridges/pangolin-pangoro/bridge/src/service/relay.rs b/bridges/pangolin-pangoro/bridge/src/service/relay.rs deleted file mode 100644 index 342851bad..000000000 --- a/bridges/pangolin-pangoro/bridge/src/service/relay.rs +++ /dev/null @@ -1,284 +0,0 @@ -use bp_darwinia_core::AccountId; -use bp_messages::LaneId; -use futures::{FutureExt, TryFutureExt}; -use lifeline::{Lifeline, Service, Task}; -use relay_pangolin_client::PangolinChain; -use relay_pangoro_client::PangoroChain; -use relay_substrate_client::{AccountIdOf, Chain, Client, TransactionSignScheme}; -use relay_utils::metrics::MetricsParams; -use sp_core::Pair; -use substrate_relay_helper::messages_lane::MessagesRelayParams; -use substrate_relay_helper::on_demand_headers::OnDemandHeadersRelay; -use substrate_relay_helper::TransactionParams; - -use feemarket_s2s::relay::BasicRelayStrategy; -use support_common::config::{Config, Names}; -use support_common::error::BridgerError; -use support_lifeline::service::BridgeService; - -use crate::bridge::PangolinPangoroTask; -use crate::bridge::{ChainInfoConfig, RelayConfig}; -use crate::bridge::{PangolinPangoroBus, PangolinPangoroConfig}; -use crate::chains::pangolin::{PangolinFinalityToPangoro, PangolinMessagesToPangoro}; -use crate::chains::pangoro::{PangoroFinalityToPangolin, PangoroMessagesToPangolin}; -use crate::feemarket::{PangolinFeemarketApi, PangoroFeemarketApi}; -use crate::types::{MessagesPalletOwnerSigningParams, RelayHeadersAndMessagesInfo}; - -// /// Maximal allowed conversion rate error ratio (abs(real - stored) / stored) that we allow. -// /// -// /// If it is zero, then transaction will be submitted every time we see difference between -// /// stored and real conversion rates. If it is large enough (e.g. > than 10 percents, which is 0.1), -// /// then rational relayers may stop relaying messages because they were submitted using -// /// lesser conversion rate. -// const CONVERSION_RATE_ALLOWED_DIFFERENCE_RATIO: f64 = 0.05; - -#[derive(Debug)] -pub struct RelayService { - _greet: Lifeline, -} - -impl BridgeService for RelayService {} - -impl Service for RelayService { - type Bus = PangolinPangoroBus; - type Lifeline = color_eyre::Result; - - fn spawn(_bus: &Self::Bus) -> Self::Lifeline { - let _greet = Self::try_task( - &format!("{}-relay", PangolinPangoroTask::name()), - async move { - if let Err(e) = start() { - tracing::error!(target: "pangolin-pangoro", "{:?}", e); - return Err( - BridgerError::Custom("Failed to start relay service".to_string()).into(), - ); - } - Ok(()) - }, - ); - Ok(Self { _greet }) - } -} - -fn start() -> color_eyre::Result<()> { - let bridge_config: PangolinPangoroConfig = Config::restore(Names::BridgePangolinPangoro)?; - let config_pangolin: ChainInfoConfig = bridge_config.pangolin; - let config_pangoro: ChainInfoConfig = bridge_config.pangoro; - let config_relay: RelayConfig = bridge_config.relay; - - let (source_chain, target_chain) = ( - config_pangolin.to_chain_info_with_expect_signer(config_relay.signer_pangolin.clone())?, - config_pangoro.to_chain_info_with_expect_signer(config_relay.signer_pangoro.clone())?, - ); - - let relay_info = RelayHeadersAndMessagesInfo { - source: source_chain, - target: target_chain, - lanes: config_relay.lanes.clone(), - prometheus_params: config_relay.prometheus_params.clone(), - create_relayers_fund_accounts: config_relay.create_relayers_fund_accounts, - only_mandatory_headers: config_relay.only_mandatory_headers, - pangolin_messages_pallet_owner_signing: MessagesPalletOwnerSigningParams { - messages_pallet_owner: config_relay.pangolin_messages_pallet_owner.clone(), - messages_pallet_owner_password: config_relay - .pangolin_messages_pallet_owner_password - .clone(), - }, - pangoro_messages_pallet_owner_signing: MessagesPalletOwnerSigningParams { - messages_pallet_owner: config_relay.pangoro_messages_pallet_owner.clone(), - messages_pallet_owner_password: config_relay.pangoro_messages_pallet_owner_password, - }, - }; - - std::thread::spawn(move || futures::executor::block_on(bridge_relay(relay_info))) - .join() - .map_err(|_| BridgerError::Custom("Failed to join thread handle".to_string()))??; - - // bridge_relay(relay_info).await?; - Ok(()) -} - -async fn bridge_relay(relay_info: RelayHeadersAndMessagesInfo) -> color_eyre::Result<()> { - let pangolin_chain = relay_info.source; - let pangoro_chain = relay_info.target; - - let pangolin_client = pangolin_chain - .to_substrate_relay_chain::() - .await?; - let pangoro_client = pangoro_chain - .to_substrate_relay_chain::() - .await?; - - let pangolin_signer = pangolin_chain.to_keypair::()?; - let pangoro_signer = pangoro_chain.to_keypair::()?; - let pangolin_transactions_mortality = pangolin_chain.transactions_mortality()?; - let pangoro_transactions_mortality = pangoro_chain.transactions_mortality()?; - - let lanes = relay_info.lanes; - - let metrics_params: MetricsParams = relay_info.prometheus_params.clone().into(); - let metrics_params = relay_utils::relay_metrics(metrics_params).into_params(); - - // const METRIC_IS_SOME_PROOF: &str = "it is `None` when metric has been already registered; \ - // this is the command entrypoint, so nothing has been registered yet; \ - // qed"; - - if relay_info.create_relayers_fund_accounts { - let relayer_fund_acount_id = pallet_bridge_messages::relayer_fund_account_id::< - AccountIdOf, - bp_darwinia_core::AccountIdConverter, - >(); - let relayers_fund_account_balance = pangolin_client - .free_native_balance(relayer_fund_acount_id.clone()) - .await; - if let Err(relay_substrate_client::Error::AccountDoesNotExist) = - relayers_fund_account_balance - { - tracing::info!(target: "bridge", "Going to create relayers fund account at {}.", PangolinChain::NAME); - create_pangolin_account( - pangolin_client.clone(), - pangolin_signer.clone(), - relayer_fund_acount_id, - ) - .await?; - } - - let relayer_fund_acount_id = pallet_bridge_messages::relayer_fund_account_id::< - AccountIdOf, - bp_darwinia_core::AccountIdConverter, - >(); - let relayers_fund_account_balance = pangoro_client - .free_native_balance(relayer_fund_acount_id.clone()) - .await; - if let Err(relay_substrate_client::Error::AccountDoesNotExist) = - relayers_fund_account_balance - { - tracing::info!(target: "bridge", "Going to create relayers fund account at {}.", PangoroChain::NAME); - create_pangoro_account( - pangoro_client.clone(), - pangoro_signer.clone(), - relayer_fund_acount_id, - ) - .await?; - } - } - - // start on-demand header relays - let pangolin_to_pangoro_transaction_params = TransactionParams { - mortality: pangoro_transactions_mortality, - signer: pangoro_signer.clone(), - }; - let pangoro_to_pangolin_transaction_params = TransactionParams { - mortality: pangolin_transactions_mortality, - signer: pangolin_signer.clone(), - }; - - let pangolin_to_pangoro_on_demand_headers = - OnDemandHeadersRelay::new::( - pangolin_client.clone(), - pangoro_client.clone(), - pangolin_to_pangoro_transaction_params, - bp_pangolin::SESSION_LENGTH, - relay_info.only_mandatory_headers, - ); - let pangoro_to_pangolin_on_demand_headers = - OnDemandHeadersRelay::new::( - pangoro_client.clone(), - pangolin_client.clone(), - pangoro_to_pangolin_transaction_params, - bp_pangoro::SESSION_LENGTH, - relay_info.only_mandatory_headers, - ); - - // Need 2x capacity since we consider both directions for each lane - let mut message_relays = Vec::with_capacity(lanes.len() * 2); - for lane in lanes { - let lane: LaneId = lane.into(); - let pangolin_feemarket_api = - PangolinFeemarketApi::new(pangolin_client.clone(), lane, pangolin_signer.clone()); - let pangoro_feemarket_api = - PangoroFeemarketApi::new(pangoro_client.clone(), lane, pangoro_signer.clone()); - - let pangolin_to_pangoro_messages = substrate_relay_helper::messages_lane::run::< - PangolinMessagesToPangoro, - >(MessagesRelayParams { - source_client: pangolin_client.clone(), - source_transaction_params: TransactionParams { - signer: pangolin_signer.clone(), - mortality: pangolin_transactions_mortality, - }, - target_client: pangoro_client.clone(), - target_transaction_params: TransactionParams { - signer: pangoro_signer.clone(), - mortality: pangoro_transactions_mortality, - }, - source_to_target_headers_relay: Some(pangolin_to_pangoro_on_demand_headers.clone()), - target_to_source_headers_relay: Some(pangoro_to_pangolin_on_demand_headers.clone()), - lane_id: lane, - metrics_params: metrics_params.clone().disable(), - standalone_metrics: None, - relay_strategy: BasicRelayStrategy::new( - pangolin_feemarket_api, - AccountId::from(pangolin_signer.public().0), - ), - }) - .map_err(|e| format!("{}", e)) - .boxed(); - - let pangoro_to_pangolin_messages = substrate_relay_helper::messages_lane::run::< - PangoroMessagesToPangolin, - >(MessagesRelayParams { - source_client: pangoro_client.clone(), - source_transaction_params: TransactionParams { - signer: pangoro_signer.clone(), - mortality: pangoro_transactions_mortality, - }, - target_client: pangolin_client.clone(), - target_transaction_params: TransactionParams { - signer: pangolin_signer.clone(), - mortality: pangolin_transactions_mortality, - }, - source_to_target_headers_relay: Some(pangoro_to_pangolin_on_demand_headers.clone()), - target_to_source_headers_relay: Some(pangolin_to_pangoro_on_demand_headers.clone()), - lane_id: lane, - metrics_params: metrics_params.clone().disable(), - standalone_metrics: None, - relay_strategy: BasicRelayStrategy::new( - pangoro_feemarket_api, - AccountId::from(pangoro_signer.public().0), - ), - }) - .map_err(|e| format!("{}", e)) - .boxed(); - - message_relays.push(pangolin_to_pangoro_messages); - message_relays.push(pangoro_to_pangolin_messages); - } - - relay_utils::relay_metrics(metrics_params) - .expose() - .await - .map_err(|e| BridgerError::Custom(format!("{:?}", e)))?; - - if let Err(e) = futures::future::select_all(message_relays).await.0 { - tracing::error!(target: "pangolin-pangoro", "{:?}", e); - return Err(BridgerError::Custom("Failed to start relay".to_string()).into()); - } - Ok(()) -} - -async fn create_pangolin_account( - _left_client: Client, - _left_sign: ::AccountKeyPair, - _account_id: AccountIdOf, -) -> color_eyre::Result<()> { - Err(BridgerError::Custom("Account creation is not supported by this bridge".to_string()).into()) -} - -async fn create_pangoro_account( - _left_client: Client, - _left_sign: ::AccountKeyPair, - _account_id: AccountIdOf, -) -> color_eyre::Result<()> { - Err(BridgerError::Custom("Account creation is not supported by this bridge".to_string()).into()) -} diff --git a/bridges/pangolin-pangoro/bridge/src/service/subscribe.rs b/bridges/pangolin-pangoro/bridge/src/service/subscribe.rs new file mode 100644 index 000000000..3b3e87dc9 --- /dev/null +++ b/bridges/pangolin-pangoro/bridge/src/service/subscribe.rs @@ -0,0 +1,110 @@ +use client_pangolin::{client::PangolinClient, component::PangolinClientComponent}; +use client_pangoro::{client::PangoroClient, component::PangoroClientComponent}; +use lifeline::{Lifeline, Service, Task}; +use once_cell::sync::Lazy; +use std::collections::VecDeque; +// use std::sync::Mutex; +use futures::lock::Mutex; +// use subxt::rpc::Subscription; +use support_common::config::{Config, Names}; +use support_lifeline::service::BridgeService; + +use crate::bridge::{BridgeBus, BridgeConfig, BridgeTask}; + +pub static PANGOLIN_JUSTIFICATIONS: Lazy>> = Lazy::new(|| { + let d = VecDeque::with_capacity(100); + Mutex::new(d) +}); + +pub static PANGORO_JUSTIFICATIONS: Lazy>> = Lazy::new(|| { + let d = VecDeque::with_capacity(100); + Mutex::new(d) +}); + +#[derive(Debug)] +pub struct SubscribeService { + _greet: Lifeline, +} + +impl BridgeService for SubscribeService {} + +impl Service for SubscribeService { + type Bus = BridgeBus; + type Lifeline = color_eyre::Result; + + fn spawn(_bus: &Self::Bus) -> Self::Lifeline { + let _greet = Self::try_task(&format!("{}-relay", BridgeTask::name()), async move { + while let Err(e) = start().await { + tracing::error!(target: "pangolin-pangoro", "[subscribe] Failed to start subscribe {:?}", e); + tokio::time::sleep(std::time::Duration::from_secs(5)).await; + tracing::info!(target: "pangolin-pangoro", "[subscribe] Try to restart subscription service."); + } + Ok(()) + }); + Ok(Self { _greet }) + } +} + +async fn start() -> color_eyre::Result<()> { + let bridge_config: BridgeConfig = Config::restore(Names::BridgePangolinPangoro)?; + + let client_pangolin = + PangolinClientComponent::component(bridge_config.pangolin.to_pangolin_client_config()?) + .await?; + let client_pangoro = + PangoroClientComponent::component(bridge_config.pangoro.to_pangoro_client_config()?) + .await?; + + let pangolin_handle = tokio::spawn(run_until_pangolin_connection_lost(client_pangolin)); + let pangoro_handle = tokio::spawn(run_until_pangoro_connection_lost(client_pangoro)); + let (_result_p, _result_r) = (pangolin_handle.await, pangoro_handle.await); + Ok(()) +} + +async fn run_until_pangolin_connection_lost(mut client: PangolinClient) -> color_eyre::Result<()> { + while let Err(err) = subscribe_pangolin(&client).await { + tracing::error!(target: "pangolin-pangoro", "[subscribe] [pangolin] Failed to get justification from pangolin: {:?}", err); + let bridge_config: BridgeConfig = Config::restore(Names::BridgePangolinPangoro)?; + let client_pangolin = + PangolinClientComponent::component(bridge_config.pangolin.to_pangolin_client_config()?) + .await?; + client = client_pangolin; + } + Ok(()) +} + +async fn run_until_pangoro_connection_lost(mut client: PangoroClient) -> color_eyre::Result<()> { + while let Err(err) = subscribe_pangoro(&client).await { + tracing::error!(target: "pangolin-pangoro", "[subscribe] [pangoro] Failed to get justification from pangoro: {:?}", err); + let bridge_config: BridgeConfig = Config::restore(Names::BridgePangolinPangoro)?; + let client_pangoro = + PangoroClientComponent::component(bridge_config.pangoro.to_pangoro_client_config()?) + .await?; + client = client_pangoro; + } + Ok(()) +} + +async fn subscribe_pangolin(client: &PangolinClient) -> color_eyre::Result<()> { + let mut subscribe = client.subscribe_grandpa_justifications().await?; + while let Some(justification) = subscribe.next().await { + let mut data = PANGOLIN_JUSTIFICATIONS.lock().await; + data.push_back(justification?); + if data.len() >= 100 { + data.pop_front(); + } + } + Ok(()) +} + +async fn subscribe_pangoro(client: &PangoroClient) -> color_eyre::Result<()> { + let mut subscribe = client.subscribe_grandpa_justifications().await?; + while let Some(justification) = subscribe.next().await { + let mut data = PANGORO_JUSTIFICATIONS.lock().await; + data.push_back(justification?); + if data.len() >= 100 { + data.pop_front(); + } + } + Ok(()) +} diff --git a/bridges/pangolin-pangoro/bridge/src/traits.rs b/bridges/pangolin-pangoro/bridge/src/traits.rs deleted file mode 100644 index 15543d204..000000000 --- a/bridges/pangolin-pangoro/bridge/src/traits.rs +++ /dev/null @@ -1,12 +0,0 @@ -/// Bridge-supported network definition. -/// -/// Used to abstract away CLI commands. -pub trait CliChain: relay_substrate_client::Chain { - /// Chain's current version of the runtime. - const RUNTIME_VERSION: sp_version::RuntimeVersion; - - /// Crypto keypair type used to send messages. - /// - /// In case of chains supporting multiple cryptos, pick one used by the CLI. - type KeyPair: sp_core::crypto::Pair; -} diff --git a/bridges/pangolin-pangoro/bridge/src/types.rs b/bridges/pangolin-pangoro/bridge/src/types.rs index aa0384e4b..ecc8a8f24 100644 --- a/bridges/pangolin-pangoro/bridge/src/types.rs +++ b/bridges/pangolin-pangoro/bridge/src/types.rs @@ -1,16 +1,10 @@ use std::fmt::{Display, Formatter}; use std::str::FromStr; -use bp_messages::LaneId; -use relay_substrate_client::ChainRuntimeVersion; use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use sp_core::crypto::Pair; use support_common::error::BridgerError; -use crate::bridge::RuntimeVersionMode; -use crate::traits::CliChain; - #[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize, strum::EnumString)] #[strum(serialize_all = "kebab_case")] pub enum BridgeName { @@ -18,117 +12,31 @@ pub enum BridgeName { PangoroToPangolin, } -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct ChainInfo { - pub host: String, - pub port: u16, - pub signer: Option, - pub secure: bool, - pub signer_password: Option, - pub transactions_mortality: Option, - pub runtime_version_mode: Option, - pub spec_version: Option, - pub transaction_version: Option, -} - -impl ChainInfo { - /// Convert connection params into Substrate client. - pub async fn to_substrate_relay_chain( - &self, - ) -> color_eyre::Result> { - let chain_runtime_version = match self.runtime_version_mode { - Some(RuntimeVersionMode::Auto) => ChainRuntimeVersion::Auto, - Some(RuntimeVersionMode::Custom) => { - let spec_version = self.spec_version.ok_or_else(|| { - BridgerError::Custom("Missing spec_version config".to_string()) - })?; - let transaction_version = self.transaction_version.ok_or_else(|| { - BridgerError::Custom("Missing transaction_version config".to_string()) - })?; - ChainRuntimeVersion::Custom(spec_version, transaction_version) - } - Some(RuntimeVersionMode::Bundle) | None => ChainRuntimeVersion::Custom( - C::RUNTIME_VERSION.spec_version, - C::RUNTIME_VERSION.transaction_version, - ), - }; - Ok( - relay_substrate_client::Client::new(relay_substrate_client::ConnectionParams { - host: self.host.clone(), - port: self.port, - secure: self.secure, - chain_runtime_version, - }) - .await, - ) - } - - /// Parse signing params into chain-specific KeyPair. - pub fn to_keypair(&self) -> color_eyre::Result { - let signer = match self.signer.clone() { - Some(v) => v, - None => { - return Err(BridgerError::Custom(format!( - "The chain [{}:{}] not set signer", - self.host, self.port, - )) - .into()); - } - }; - C::KeyPair::from_string(&signer, self.signer_password.as_deref()) - .map_err(|e| BridgerError::Custom(format!("Secret string error: {:?}", e)).into()) - } - - pub fn transactions_mortality(&self) -> color_eyre::Result> { - self.transactions_mortality - .map(|transactions_mortality| { - if !(4..=65536).contains(&transactions_mortality) - || !transactions_mortality.is_power_of_two() - { - Err(BridgerError::Custom(format!( - "Transactions mortality {} is not a power of two in a [4; 65536] range", - transactions_mortality, - )) - .into()) - } else { - Ok(transactions_mortality) - } - }) - .transpose() - } -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct InitBridge { - pub bridge: BridgeName, - pub source: ChainInfo, - pub target: ChainInfo, -} +// #[derive(Debug, Clone, Serialize, Deserialize)] +// pub struct InitBridge { +// pub bridge: BridgeName, +// pub source: ChainInfoConfig, +// pub target: ChainInfoConfig, +// } #[derive(Debug, Clone, PartialEq, Eq, Default)] -pub struct HexLaneId(pub LaneId); - -impl From for LaneId { - fn from(lane_id: HexLaneId) -> LaneId { - lane_id.0 - } -} +pub struct HexLaneId(pub [u8; 4]); -impl std::str::FromStr for HexLaneId { - type Err = hex::FromHexError; +impl FromStr for HexLaneId { + type Err = BridgerError; fn from_str(s: &str) -> Result { - let mut lane_id = LaneId::default(); - hex::decode_to_slice(s, &mut lane_id)?; - Ok(HexLaneId(lane_id)) + let hex = array_bytes::hex2array(s) + .map_err(|e| BridgerError::Hex(format!("Failed to parse lane id: {:?}", e)))?; + Ok(HexLaneId(hex)) } } impl Display for HexLaneId { fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { let lane_id = self.0; - let hex_text = hex::encode(lane_id); - f.write_str(&hex_text[..]) + let hex = array_bytes::bytes2hex("0x", lane_id); + f.write_str(&hex[..]) } } @@ -152,66 +60,3 @@ impl Serialize for HexLaneId { serializer.serialize_str(&hex_text[..]) } } - -#[derive(Debug, Clone, Default, Serialize, Deserialize)] -pub struct PrometheusParamsInfo { - /// Do not expose a Prometheus metric endpoint. - pub no_prometheus: bool, - /// Expose Prometheus endpoint at given interface. - #[serde(skip_serializing_if = "String::is_empty")] - #[serde(default)] - pub prometheus_host: String, - /// Expose Prometheus endpoint at given port. - pub prometheus_port: u16, -} - -impl From for relay_utils::metrics::MetricsParams { - fn from(cli_params: PrometheusParamsInfo) -> relay_utils::metrics::MetricsParams { - if !cli_params.no_prometheus { - Some(relay_utils::metrics::MetricsAddress { - host: cli_params.prometheus_host, - port: cli_params.prometheus_port, - }) - .into() - } else { - None.into() - } - } -} - -#[derive(Debug, Clone)] -pub struct RelayHeadersAndMessagesInfo { - pub source: ChainInfo, - pub target: ChainInfo, - - pub lanes: Vec, - pub prometheus_params: PrometheusParamsInfo, - pub create_relayers_fund_accounts: bool, - pub only_mandatory_headers: bool, - - pub pangolin_messages_pallet_owner_signing: MessagesPalletOwnerSigningParams, - pub pangoro_messages_pallet_owner_signing: MessagesPalletOwnerSigningParams, -} - -#[derive(Debug, Clone)] -pub struct MessagesPalletOwnerSigningParams { - pub messages_pallet_owner: Option, - pub messages_pallet_owner_password: Option, -} - -#[allow(dead_code)] -impl MessagesPalletOwnerSigningParams { - /// Parse signing params into chain-specific KeyPair. - pub fn to_keypair(&self) -> color_eyre::Result> { - let messages_pallet_owner = match self.messages_pallet_owner { - Some(ref messages_pallet_owner) => messages_pallet_owner, - None => return Ok(None), - }; - Chain::KeyPair::from_string( - messages_pallet_owner, - self.messages_pallet_owner_password.as_deref(), - ) - .map_err(|e| BridgerError::Custom(format!("Secret string error: {:?}", e)).into()) - .map(Some) - } -} diff --git a/bridges/pangolin-pangoro/docs/Guide.md b/bridges/pangolin-pangoro/docs/Guide.md deleted file mode 100644 index 7f76ca68a..000000000 --- a/bridges/pangolin-pangoro/docs/Guide.md +++ /dev/null @@ -1,28 +0,0 @@ -Bridge of pangolin-pangoro -=== - -## Prepare - -1. Read [Usage](../../../docs/Usage.md) -2. `cp .maintain/config/bridge-pangolin-pangoro.toml ~/.bridger` - - Copy config to default config path `~/.bridger` and fill the content. - -> About start `pangolin` and `pangoro` chain you can read [darwinia-common](https://github.com/darwinia-network/darwinia-common/#development). -> In addition, we also deployed two public test chains -> - `pangolin`: wss://pangolin-rpc.darwinia.network -> - `pangoro`: wss://pangoro-rpc.darwinia.network - -## Init - -```bash -bridger pangolin-pangoro init pangolin-to-pangoro -bridger pangolin-pangoro init pangoro-to-pangolin -``` - -## Start - - -```bash -bridger pangolin-pangoro start -``` diff --git a/bridges/pangolin-pangoro/rust-toolchain.toml b/bridges/pangolin-pangoro/rust-toolchain.toml index c03819d86..7f5079439 100644 --- a/bridges/pangolin-pangoro/rust-toolchain.toml +++ b/bridges/pangolin-pangoro/rust-toolchain.toml @@ -1,5 +1,4 @@ [toolchain] -channel = "nightly-2021-12-07" +channel = "stable" components = ["cargo", "clippy", "rustc", "rustfmt", "rust-src"] profile = "minimal" -targets = ["wasm32-unknown-unknown"] diff --git a/bridges/pangolin-ropsten/Cargo.lock b/bridges/pangolin-ropsten/Cargo.lock index 50c9af0b6..9dab4903e 100644 --- a/bridges/pangolin-ropsten/Cargo.lock +++ b/bridges/pangolin-ropsten/Cargo.lock @@ -395,14 +395,11 @@ name = "client-pangolin" version = "0.5.7" dependencies = [ "array-bytes", - "futures-util", - "jsonrpsee", "parity-scale-codec", "secp256k1", "serde 1.0.136", "serde_json", "shadow-liketh", - "sp-core", "subxt", "support-toolkit", "thiserror", diff --git a/bridges/pangolin-ropsten/bridge/src/service/extrinsics/handler.rs b/bridges/pangolin-ropsten/bridge/src/service/extrinsics/handler.rs index 3ca1545cc..f092a2379 100644 --- a/bridges/pangolin-ropsten/bridge/src/service/extrinsics/handler.rs +++ b/bridges/pangolin-ropsten/bridge/src/service/extrinsics/handler.rs @@ -293,27 +293,26 @@ impl ExtrinsicsHandler { match self.send_extrinsic(ex.clone()).await { Ok(_) => self.message_kv.delete(&key)?, Err(err) => { + tracing::error!( + target: "pangolin-pangoro", + "[pangolin] [extrinsics] [{}] Failed to send extrinsic {:?} err: {:?}", + times, + ex, + err, + ); if let Some(client_error) = err.downcast_ref::() { if client_error.is_restart_need() { tracing::error!( target: "pangolin-pangoro", - "[pangolin] [extrinsics] [{}] Connection Error. Try to resend later. extrinsic: {:?}", + "[pangolin] [extrinsics] [{}] Connection Error. Try to resend later.", times, - ex, ); tokio::time::sleep(std::time::Duration::from_secs(5)).await; return Err(err); } } - tracing::error!( - target: "pangolin-pangoro", - "[pangolin] [extrinsics] [{}] Failed to send extrinsic {:?} err: {:?}", - times, - ex, - err - ); tokio::time::sleep(std::time::Duration::from_secs(5)).await; if times > 5 { self.message_kv.delete(&key)?; diff --git a/bridges/pangoro-chapel/Cargo.lock b/bridges/pangoro-chapel/Cargo.lock index 493a5ab4b..721453e06 100644 --- a/bridges/pangoro-chapel/Cargo.lock +++ b/bridges/pangoro-chapel/Cargo.lock @@ -355,16 +355,13 @@ name = "client-pangoro" version = "0.5.7" dependencies = [ "array-bytes", - "color-eyre", "parity-scale-codec", - "secp256k1 0.20.3", "serde 1.0.136", "serde_json", "subxt", "support-toolkit", "thiserror", "tracing", - "web3", ] [[package]] @@ -2526,15 +2523,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "secp256k1" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d03ceae636d0fed5bae6a7f4f664354c5f4fcedf6eef053fef17e49f837d0a" -dependencies = [ - "secp256k1-sys", -] - [[package]] name = "secp256k1" version = "0.21.2" @@ -3642,7 +3630,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ee73e6e4924fe940354b8d4d98cad5231175d615cd855b758adc658c0aac6a0" dependencies = [ "cfg-if 1.0.0", - "rand 0.7.3", + "rand 0.8.4", "static_assertions", ] @@ -3884,7 +3872,7 @@ dependencies = [ "pin-project 1.0.10", "reqwest", "rlp", - "secp256k1 0.21.2", + "secp256k1", "serde 1.0.136", "serde_json", "soketto", diff --git a/frame/assistants/client-darwinia/src/client.rs b/frame/assistants/client-darwinia/src/client.rs index 47e840af5..606aeab5a 100644 --- a/frame/assistants/client-darwinia/src/client.rs +++ b/frame/assistants/client-darwinia/src/client.rs @@ -1,10 +1,9 @@ -use crate::subxt_runtime::api::RuntimeApi; -use subxt::sp_runtime::traits::Header; use subxt::Client; use crate::config::DarwiniaSubxtConfig; -use crate::error::{ClientError, ClientResult}; -use crate::ethereum::EthereumApi; +#[cfg(feature = "ethlike-v1")] +use crate::fastapi::ethereum::EthereumApi; +use crate::subxt_runtime::api::RuntimeApi; use crate::types::{DarwiniaAccount, NodeRuntimeSignedExtra}; /// Darwinia client @@ -43,109 +42,8 @@ impl DarwiniaClient { } /// Ethereum api + #[cfg(feature = "ethlike-v1")] pub fn ethereum(&self) -> EthereumApi { EthereumApi::new(self) } } - -impl DarwiniaClient { - /// get mmr root - pub async fn get_mmr_root(&self, leaf_index: u32) -> ClientResult { - let block_number = leaf_index + 1; - let header = self.header_by_number(block_number).await?; - - let mmr_root = if let Some(header) = header { - // get digest_item from header - let log = header - .digest() - .logs() - .iter() - .find(|&x| x.as_other().is_some()); - if let Some(digest_item) = log { - // get mmr_root from log - let parent_mmr_root = digest_item.as_other().unwrap().to_vec(); - let parent_mmr_root = &parent_mmr_root[4..]; - if parent_mmr_root.len() != 32 { - return Err(ClientError::WrongMmrRootInDarwiniaHeader( - array_bytes::bytes2hex("", &parent_mmr_root), - block_number, - )); - } - let mut mmr_root: [u8; 32] = [0; 32]; - mmr_root.copy_from_slice(parent_mmr_root); - subxt::sp_core::H256(mmr_root) - } else { - return Err(ClientError::NoMmrRootInDarwiniaHeader(block_number)); - } - } else { - return Err(ClientError::FailedToFetchDarwiniaHeader(block_number)); - }; - Ok(mmr_root) - } - - /// Query spec name - pub async fn spec_name(&self) -> ClientResult { - let runtime_version = self.subxt().rpc().runtime_version(None).await?; - let spec_name = runtime_version - .other - .get("specName") - .ok_or_else(|| ClientError::Other("Failed to query spec name".to_string()))? - .as_str() - .ok_or_else(|| { - ClientError::Other("The spec name not found in runtime version".to_string()) - })?; - Ok(spec_name.to_string()) - } - - /// is_tech_comm_member - pub async fn is_tech_comm_member( - &self, - block_number: Option, - account: Option, - ) -> ClientResult { - let block_hash = self - .subxt() - .rpc() - .block_hash(block_number.map(|block| block.into())) - .await?; - let members = self - .runtime() - .storage() - .technical_committee() - .members(block_hash) - .await?; - let account = account.unwrap_or_else(|| self.account.clone()); - Ok(members.contains(account.real_account())) - } - - /// query header by block number - pub async fn header_by_number( - &self, - number: u32, - ) -> ClientResult::Header>> { - match self.subxt().rpc().block_hash(Some(number.into())).await? { - Some(hash) => Ok(self.subxt().rpc().header(Some(hash)).await?), - None => Ok(None), - } - } - - // /// get mmr root of darwinia - // pub async fn header_mmr_gen_proof( - // &self, - // block_number_of_member_leaf: u64, - // block_number_of_last_leaf: u64, - // hash: H256, - // ) -> ClientResult<()> { - // let params = &[ - // serde_json::to_value(block_number_of_member_leaf)?, - // serde_json::to_value(block_number_of_last_leaf)?, - // ]; - // let v: HeaderMMRRpc = self - // .client - // .rpc() - // .client - // .request("headerMMR_genProof", params) - // .await?; - // Ok(()) - // } -} diff --git a/frame/assistants/client-darwinia/src/ethereum/mod.rs b/frame/assistants/client-darwinia/src/ethereum/mod.rs deleted file mode 100644 index 77436ef77..000000000 --- a/frame/assistants/client-darwinia/src/ethereum/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub use self::api::*; - -mod api; diff --git a/frame/assistants/client-darwinia/src/ethereum/api.rs b/frame/assistants/client-darwinia/src/fastapi/ethereum.rs similarity index 100% rename from frame/assistants/client-darwinia/src/ethereum/api.rs rename to frame/assistants/client-darwinia/src/fastapi/ethereum.rs index b940652d1..e622e2a52 100644 --- a/frame/assistants/client-darwinia/src/ethereum/api.rs +++ b/frame/assistants/client-darwinia/src/fastapi/ethereum.rs @@ -1,15 +1,15 @@ use std::collections::HashMap; -use crate::subxt_runtime::api::runtime_types; -use crate::subxt_runtime::api::runtime_types::darwinia_bridge_ethereum::EthereumRelayHeaderParcel; -use crate::subxt_runtime::api::runtime_types::darwinia_runtime::pallets::proxy::ProxyType; -use crate::subxt_runtime::api::runtime_types::to_ethereum_backing::pallet::RedeemFor; use subxt::{BasicError, MetadataError}; use crate::client::DarwiniaClient; use crate::config::DarwiniaSubxtConfig; use crate::error::{ClientError, ClientResult}; use crate::helpers; +use crate::subxt_runtime::api::runtime_types; +use crate::subxt_runtime::api::runtime_types::darwinia_bridge_ethereum::EthereumRelayHeaderParcel; +use crate::subxt_runtime::api::runtime_types::darwinia_runtime::pallets::proxy::ProxyType; +use crate::subxt_runtime::api::runtime_types::to_ethereum_backing::pallet::RedeemFor; use crate::types::{ AffirmationsReturn, BetterRelayAffirmation, EcdsaMessage, EthereumAccount, EthereumReceiptProofThing, diff --git a/frame/assistants/client-darwinia/src/fastapi/generic.rs b/frame/assistants/client-darwinia/src/fastapi/generic.rs new file mode 100644 index 000000000..af6a76efa --- /dev/null +++ b/frame/assistants/client-darwinia/src/fastapi/generic.rs @@ -0,0 +1,108 @@ +use subxt::sp_runtime::traits::Header; + +use crate::client::DarwiniaClient; +use crate::config::DarwiniaSubxtConfig; +use crate::error::{ClientError, ClientResult}; +use crate::types::DarwiniaAccount; + +impl DarwiniaClient { + /// get mmr root + pub async fn get_mmr_root(&self, leaf_index: u32) -> ClientResult { + let block_number = leaf_index + 1; + let header = self.header_by_number(block_number).await?; + + let mmr_root = if let Some(header) = header { + // get digest_item from header + let log = header + .digest() + .logs() + .iter() + .find(|&x| x.as_other().is_some()); + if let Some(digest_item) = log { + // get mmr_root from log + let parent_mmr_root = digest_item.as_other().unwrap().to_vec(); + let parent_mmr_root = &parent_mmr_root[4..]; + if parent_mmr_root.len() != 32 { + return Err(ClientError::WrongMmrRootInDarwiniaHeader( + array_bytes::bytes2hex("", &parent_mmr_root), + block_number, + )); + } + let mut mmr_root: [u8; 32] = [0; 32]; + mmr_root.copy_from_slice(parent_mmr_root); + subxt::sp_core::H256(mmr_root) + } else { + return Err(ClientError::NoMmrRootInDarwiniaHeader(block_number)); + } + } else { + return Err(ClientError::FailedToFetchDarwiniaHeader(block_number)); + }; + Ok(mmr_root) + } + + /// Query spec name + pub async fn spec_name(&self) -> ClientResult { + let runtime_version = self.subxt().rpc().runtime_version(None).await?; + let spec_name = runtime_version + .other + .get("specName") + .ok_or_else(|| ClientError::Other("Failed to query spec name".to_string()))? + .as_str() + .ok_or_else(|| { + ClientError::Other("The spec name not found in runtime version".to_string()) + })?; + Ok(spec_name.to_string()) + } + + /// is_tech_comm_member + pub async fn is_tech_comm_member( + &self, + block_number: Option, + account: Option, + ) -> ClientResult { + let block_hash = self + .subxt() + .rpc() + .block_hash(block_number.map(|block| block.into())) + .await?; + let members = self + .runtime() + .storage() + .technical_committee() + .members(block_hash) + .await?; + let account = account.unwrap_or_else(|| self.account().clone()); + Ok(members.contains(account.real_account())) + } + + /// query header by block number + pub async fn header_by_number( + &self, + number: u32, + ) -> ClientResult::Header>> { + match self.subxt().rpc().block_hash(Some(number.into())).await? { + Some(hash) => Ok(self.subxt().rpc().header(Some(hash)).await?), + None => Ok(None), + } + } + + // /// get mmr root of darwinia + // pub async fn header_mmr_gen_proof( + // &self, + // block_number_of_member_leaf: u64, + // block_number_of_last_leaf: u64, + // hash: H256, + // ) -> ClientResult<()> { + // let params = &[ + // serde_json::to_value(block_number_of_member_leaf)?, + // serde_json::to_value(block_number_of_last_leaf)?, + // ]; + // let v: HeaderMMRRpc = self + // .client + // .rpc() + // .client + // .request("headerMMR_genProof", params) + // .await?; + // Ok(()) + // } +} diff --git a/frame/assistants/client-darwinia/src/fastapi/mod.rs b/frame/assistants/client-darwinia/src/fastapi/mod.rs new file mode 100644 index 000000000..d3078abbe --- /dev/null +++ b/frame/assistants/client-darwinia/src/fastapi/mod.rs @@ -0,0 +1,3 @@ +#[cfg(feature = "ethlike-v1")] +pub mod ethereum; +pub mod generic; diff --git a/frame/assistants/client-darwinia/src/lib.rs b/frame/assistants/client-darwinia/src/lib.rs index 1a5b88a76..09bc09668 100644 --- a/frame/assistants/client-darwinia/src/lib.rs +++ b/frame/assistants/client-darwinia/src/lib.rs @@ -2,8 +2,7 @@ pub mod client; pub mod component; pub mod config; pub mod error; -#[cfg(feature = "ethlike-v1")] -pub mod ethereum; +pub mod fastapi; pub mod helpers; -pub mod types; pub mod subxt_runtime; +pub mod types; diff --git a/frame/assistants/client-pangolin/Cargo.toml b/frame/assistants/client-pangolin/Cargo.toml index 0d4e56ce8..7e58d99ab 100644 --- a/frame/assistants/client-pangolin/Cargo.toml +++ b/frame/assistants/client-pangolin/Cargo.toml @@ -16,23 +16,34 @@ version = "0.5.7" thiserror = "1" tracing = "0.1" -serde = { version = "1", features = ["derive"] } -serde_json = "1" - -array-bytes = "1.4" -codec = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full"] } -futures-util = "0.3.14" -jsonrpsee = { version = "0.8.0", features = ["async-client", "client-ws-transport"] } -secp256k1 = { version = "0.20", features = ["recovery"], optional = true } -shadow-liketh = { path = "../shadow-liketh", optional = true } -sp-core = { git = "https://github.com/darwinia-network/substrate.git", branch = "darwinia-v0.12.2" } -subxt = { git = "https://github.com/darwinia-network/subxt.git", branch = "darwinia-v0.12.2" } -support-toolkit = { path = "../../../frame/supports/support-toolkit" } -web3 = { git = "https://github.com/wuminzhe/rust-web3.git", branch = "master", features = ["signing"], optional = true } +serde = { version = "1", features = ["derive"] } +serde_json = "1" + +array-bytes = "1.4" +codec = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full"] } +subxt = { git = "https://github.com/darwinia-network/subxt.git", branch = "darwinia-v0.12.2" } + +web3 = { git = "https://github.com/wuminzhe/rust-web3.git", branch = "master", features = ["signing"], optional = true } +secp256k1 = { version = "0.20", features = ["recovery"], optional = true } +shadow-liketh = { path = "../shadow-liketh", optional = true } + +finality-grandpa = { version = "0.14.0", optional = true } +bp-header-chain = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2", optional = true } +sp-finality-grandpa = { git = "https://github.com/darwinia-network/substrate.git", branch = "darwinia-v0.12.2", optional = true } +sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", branch = "darwinia-v0.12.2", optional = true } + +support-toolkit = { path = "../../../frame/supports/support-toolkit" } [dev-dependencies] tokio = { version = "1", features = ["full"] } [features] -default = [] -ethlike-v1 = ["web3", "secp256k1", "shadow-liketh"] +default = [] +ethlike-v1 = ["web3", "secp256k1", "shadow-liketh"] +s2s = [ + "finality-grandpa", + "bp-header-chain", + "sp-finality-grandpa", + "sp-runtime" +] +s2s-pangoro = ["s2s"] diff --git a/frame/assistants/client-pangolin/src/client.rs b/frame/assistants/client-pangolin/src/client.rs index b44ca3954..34f621de6 100644 --- a/frame/assistants/client-pangolin/src/client.rs +++ b/frame/assistants/client-pangolin/src/client.rs @@ -1,12 +1,9 @@ -use crate::subxt_runtime::api::RuntimeApi; -use subxt::rpc::{Subscription, SubscriptionClientT}; -use subxt::sp_runtime::traits::Header; use subxt::Client; use crate::config::PangolinSubxtConfig; -use crate::error::{ClientError, ClientResult}; #[cfg(feature = "ethlike-v1")] -use crate::ethereum::EthereumApi; +use crate::fastapi::ethereum::EthereumApi; +use crate::subxt_runtime::api::RuntimeApi; use crate::types::{DarwiniaAccount, NodeRuntimeSignedExtra}; /// Pangolin client @@ -50,114 +47,3 @@ impl PangolinClient { EthereumApi::new(self) } } - -impl PangolinClient { - /// get mmr root - pub async fn get_mmr_root(&self, leaf_index: u32) -> ClientResult { - let block_number = leaf_index + 1; - let header = self.header_by_number(block_number).await?; - - let mmr_root = if let Some(header) = header { - // get digest_item from header - let log = header - .digest() - .logs() - .iter() - .find(|&x| x.as_other().is_some()); - if let Some(digest_item) = log { - // get mmr_root from log - let parent_mmr_root = digest_item.as_other().unwrap().to_vec(); - let parent_mmr_root = &parent_mmr_root[4..]; - if parent_mmr_root.len() != 32 { - return Err(ClientError::WrongMmrRootInDarwiniaHeader( - array_bytes::bytes2hex("", &parent_mmr_root), - block_number, - )); - } - let mut mmr_root: [u8; 32] = [0; 32]; - mmr_root.copy_from_slice(parent_mmr_root); - subxt::sp_core::H256(mmr_root) - } else { - return Err(ClientError::NoMmrRootInDarwiniaHeader(block_number)); - } - } else { - return Err(ClientError::FailedToFetchDarwiniaHeader(block_number)); - }; - Ok(mmr_root) - } - - /// Query spec name - pub async fn spec_name(&self) -> ClientResult { - let runtime_version = self.subxt().rpc().runtime_version(None).await?; - let spec_name = runtime_version - .other - .get("specName") - .ok_or_else(|| ClientError::Other("Failed to query spec name".to_string()))? - .as_str() - .ok_or_else(|| { - ClientError::Other("The spec name not found in runtime version".to_string()) - })?; - Ok(spec_name.to_string()) - } - - /// is_tech_comm_member - pub async fn is_tech_comm_member( - &self, - block_number: Option, - account: Option, - ) -> ClientResult { - let block_hash = self - .subxt() - .rpc() - .block_hash(block_number.map(|block| block.into())) - .await?; - let members = self - .runtime() - .storage() - .technical_committee() - .members(block_hash) - .await?; - let account = account.unwrap_or_else(|| self.account.clone()); - Ok(members.contains(account.real_account())) - } - - /// query header by block number - pub async fn header_by_number( - &self, - number: u32, - ) -> ClientResult::Header>> { - match self.subxt().rpc().block_hash(Some(number.into())).await? { - Some(hash) => Ok(self.subxt().rpc().header(Some(hash)).await?), - None => Ok(None), - } - } - - pub async fn subscribe_grandpa_justifications(&self) -> ClientResult> { - let sub = self.client.rpc().client.subscribe( - "grandpa_subscribeJustifications", - None, - "grandpa_unsubscribeJustifications", - ).await?; - Ok(sub) - } - - // /// get mmr root of darwinia - // pub async fn header_mmr_gen_proof( - // &self, - // block_number_of_member_leaf: u64, - // block_number_of_last_leaf: u64, - // hash: H256, - // ) -> ClientResult<()> { - // let params = &[ - // serde_json::to_value(block_number_of_member_leaf)?, - // serde_json::to_value(block_number_of_last_leaf)?, - // ]; - // let v: HeaderMMRRpc = self - // .client - // .rpc() - // .client - // .request("headerMMR_genProof", params) - // .await?; - // Ok(()) - // } -} diff --git a/frame/assistants/client-pangolin/src/error.rs b/frame/assistants/client-pangolin/src/error.rs index a8030214a..e2a9cc2c5 100644 --- a/frame/assistants/client-pangolin/src/error.rs +++ b/frame/assistants/client-pangolin/src/error.rs @@ -2,7 +2,6 @@ use support_toolkit::error::TkError; use thiserror::Error as ThisError; -use jsonrpsee::core::error::Error as RpcError; pub type ClientResult = Result; @@ -12,20 +11,23 @@ pub enum ClientError { #[error(transparent)] SubxtBasicError(subxt::BasicError), - #[error(transparent)] - RpcBasicError(RpcError), - #[error("Please reconnect to rpc server")] ClientRestartNeed, + #[error(transparent)] + Codec(#[from] codec::Error), + #[error("No header hash in EthereumReceiptProofOfThing")] NoHeaderHashInEthereumReceiptProofOfThing, #[error("Wrong seed: {0}")] Seed(String), - #[error("Other error: {0}")] - Other(String), + #[error("Bytes error: {0}")] + Bytes(String), + + #[error("Custom error: {0}")] + Custom(String), #[error("Io error: {0}")] Io(#[from] std::io::Error), @@ -87,12 +89,14 @@ impl From for ClientError { } } +impl From for ClientError { + fn from(error: subxt::rpc::RpcError) -> Self { + Self::SubxtBasicError(subxt::BasicError::Rpc(error)) + } +} -impl From for ClientError { - fn from(error: RpcError) -> Self { - if let RpcError::RestartNeeded(_) = &error { - return Self::ClientRestartNeed; - } - Self::RpcBasicError(error) +impl From for ClientError { + fn from(error: array_bytes::Error) -> Self { + Self::Bytes(format!("{:?}", error)) } } diff --git a/frame/assistants/client-pangolin/src/ethereum/mod.rs b/frame/assistants/client-pangolin/src/ethereum/mod.rs deleted file mode 100644 index 77436ef77..000000000 --- a/frame/assistants/client-pangolin/src/ethereum/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub use self::api::*; - -mod api; diff --git a/frame/assistants/client-pangolin/src/ethereum/api.rs b/frame/assistants/client-pangolin/src/fastapi/ethereum.rs similarity index 100% rename from frame/assistants/client-pangolin/src/ethereum/api.rs rename to frame/assistants/client-pangolin/src/fastapi/ethereum.rs diff --git a/frame/assistants/client-pangolin/src/fastapi/generic.rs b/frame/assistants/client-pangolin/src/fastapi/generic.rs new file mode 100644 index 000000000..869daa757 --- /dev/null +++ b/frame/assistants/client-pangolin/src/fastapi/generic.rs @@ -0,0 +1,108 @@ +use subxt::sp_runtime::traits::Header; + +use crate::client::PangolinClient; +use crate::config::PangolinSubxtConfig; +use crate::error::{ClientError, ClientResult}; +use crate::types::DarwiniaAccount; + +impl PangolinClient { + /// get mmr root + pub async fn get_mmr_root(&self, leaf_index: u32) -> ClientResult { + let block_number = leaf_index + 1; + let header = self.header_by_number(block_number).await?; + + let mmr_root = if let Some(header) = header { + // get digest_item from header + let log = header + .digest() + .logs() + .iter() + .find(|&x| x.as_other().is_some()); + if let Some(digest_item) = log { + // get mmr_root from log + let parent_mmr_root = digest_item.as_other().unwrap().to_vec(); + let parent_mmr_root = &parent_mmr_root[4..]; + if parent_mmr_root.len() != 32 { + return Err(ClientError::WrongMmrRootInDarwiniaHeader( + array_bytes::bytes2hex("", &parent_mmr_root), + block_number, + )); + } + let mut mmr_root: [u8; 32] = [0; 32]; + mmr_root.copy_from_slice(parent_mmr_root); + subxt::sp_core::H256(mmr_root) + } else { + return Err(ClientError::NoMmrRootInDarwiniaHeader(block_number)); + } + } else { + return Err(ClientError::FailedToFetchDarwiniaHeader(block_number)); + }; + Ok(mmr_root) + } + + /// Query spec name + pub async fn spec_name(&self) -> ClientResult { + let runtime_version = self.subxt().rpc().runtime_version(None).await?; + let spec_name = runtime_version + .other + .get("specName") + .ok_or_else(|| ClientError::Custom("Failed to query spec name".to_string()))? + .as_str() + .ok_or_else(|| { + ClientError::Custom("The spec name not found in runtime version".to_string()) + })?; + Ok(spec_name.to_string()) + } + + /// is_tech_comm_member + pub async fn is_tech_comm_member( + &self, + block_number: Option, + account: Option, + ) -> ClientResult { + let block_hash = self + .subxt() + .rpc() + .block_hash(block_number.map(|block| block.into())) + .await?; + let members = self + .runtime() + .storage() + .technical_committee() + .members(block_hash) + .await?; + let account = account.unwrap_or_else(|| self.account().clone()); + Ok(members.contains(account.real_account())) + } + + /// query header by block number + pub async fn header_by_number( + &self, + number: u32, + ) -> ClientResult::Header>> { + match self.subxt().rpc().block_hash(Some(number.into())).await? { + Some(hash) => Ok(self.subxt().rpc().header(Some(hash)).await?), + None => Ok(None), + } + } + + // /// get mmr root of darwinia + // pub async fn header_mmr_gen_proof( + // &self, + // block_number_of_member_leaf: u64, + // block_number_of_last_leaf: u64, + // hash: H256, + // ) -> ClientResult<()> { + // let params = &[ + // serde_json::to_value(block_number_of_member_leaf)?, + // serde_json::to_value(block_number_of_last_leaf)?, + // ]; + // let v: HeaderMMRRpc = self + // .client + // .rpc() + // .client + // .request("headerMMR_genProof", params) + // .await?; + // Ok(()) + // } +} diff --git a/frame/assistants/client-pangolin/src/fastapi/mod.rs b/frame/assistants/client-pangolin/src/fastapi/mod.rs new file mode 100644 index 000000000..3f0a61bee --- /dev/null +++ b/frame/assistants/client-pangolin/src/fastapi/mod.rs @@ -0,0 +1,5 @@ +#[cfg(feature = "ethlike-v1")] +pub mod ethereum; +pub mod generic; +#[cfg(feature = "s2s")] +pub mod s2s; diff --git a/frame/assistants/client-pangolin/src/fastapi/s2s/generic.rs b/frame/assistants/client-pangolin/src/fastapi/s2s/generic.rs new file mode 100644 index 000000000..482f25162 --- /dev/null +++ b/frame/assistants/client-pangolin/src/fastapi/s2s/generic.rs @@ -0,0 +1,207 @@ +use finality_grandpa::voter_set::VoterSet; +use sp_finality_grandpa::{AuthorityList, ConsensusLog, ScheduledChange}; +use sp_runtime::{ConsensusEngineId, DigestItem}; +use subxt::rpc::{ClientT, Subscription, SubscriptionClientT}; +use subxt::{sp_core, sp_runtime}; + +use crate::client::PangolinClient; +use crate::error::{ClientError, ClientResult}; +use crate::types::runtime_types::bp_header_chain::InitializationData; + +const GRANDPA_ENGINE_ID: ConsensusEngineId = *b"FRNK"; + +type BundleHeader = crate::types::runtime_types::sp_runtime::generic::header::Header< + u32, + crate::types::runtime_types::sp_runtime::traits::BlakeTwo256, +>; +type SpHeader = sp_runtime::generic::Header; + +impl PangolinClient { + pub async fn subscribe_grandpa_justifications(&self) -> ClientResult> { + Ok(self + .subxt() + .rpc() + .client + .subscribe( + "grandpa_subscribeJustifications", + None, + "grandpa_unsubscribeJustifications", + ) + .await?) + } + + pub async fn prepare_initialization_data( + &self, + ) -> ClientResult> { + let mut subscription = self.subscribe_grandpa_justifications().await?; + let justification = subscription + .next() + .await + .ok_or_else(|| ClientError::Custom("The subscribe is closed".to_string()))??; + let justification: bp_header_chain::justification::GrandpaJustification = + codec::Decode::decode(&mut &justification.0[..]) + .map_err(|err| ClientError::Custom(format!("Wrong justification: {:?}", err)))?; + + let (initial_header_hash, initial_header_number) = ( + justification.commit.target_hash, + justification.commit.target_number, + ); + let initial_header = self + .subxt() + .rpc() + .header(Some(initial_header_hash)) + .await? + .ok_or_else(|| { + ClientError::Custom(format!( + "Can not get initial header by hash: {:?}", + initial_header_hash + )) + })?; + tracing::trace!(target: "client-pangolin", "Selected initial header [{}]: {}", + initial_header_number, + initial_header_hash, + ); + let initial_authorities_set = self.grandpa_authorities(initial_header_hash).await?; + tracing::trace!(target: "client-pangolin", "Selected initial authorities set: {:?}", + initial_authorities_set, + ); + + // If initial header changes the GRANDPA authorities set, then we need previous authorities + // to verify justification. + let mut authorities_for_verification = initial_authorities_set.clone(); + let scheduled_change = self.find_grandpa_authorities_scheduled_change(&initial_header); + if scheduled_change + .as_ref() + .map(|c| c.delay == 0) + .unwrap_or(false) + { + return Err(ClientError::Custom(format!( + "GRANDPA authorities change at {} scheduled to happen in {:?} blocks. \ + We expect regular hange to have zero delay", + initial_header_hash, + scheduled_change.as_ref().map(|c| c.delay), + ))); + } + let schedules_change = scheduled_change.is_some(); + if schedules_change { + authorities_for_verification = + self.grandpa_authorities(initial_header.parent_hash).await?; + tracing::trace!( + target: "client-pangolin", + "Selected header is scheduling GRANDPA authorities set changes. Using previous set: {:?}", + authorities_for_verification, + ); + } + + // Now let's try to guess authorities set id by verifying justification. + let mut initial_authorities_set_id = 0; + let mut min_possible_block_number = 0; + let authorities_for_verification = VoterSet::new(authorities_for_verification.clone()) + .ok_or(ClientError::Custom(format!( + "[ReadInvalidAuthorities]: {:?}", + authorities_for_verification, + )))?; + loop { + tracing::trace!( + target: "client-pangolin", + "Trying GRANDPA authorities set id: {}", + initial_authorities_set_id, + ); + + let is_valid_set_id = bp_header_chain::justification::verify_justification::( + (initial_header_hash, initial_header_number), + initial_authorities_set_id, + &authorities_for_verification, + &justification, + ) + .is_ok(); + + if is_valid_set_id { + break; + } + + initial_authorities_set_id += 1; + min_possible_block_number += 1; + if min_possible_block_number > initial_header_number { + // there can't be more authorities set changes than headers => if we have reached + // `initial_block_number` and still have not found correct value of + // `initial_authorities_set_id`, then something else is broken => fail + return Err(ClientError::Custom(format!( + "[GuessInitialAuthorities]: {}", + initial_header_number + ))); + } + } + + let initialization_data = bp_header_chain::InitializationData { + header: Box::new(initial_header), + authority_list: initial_authorities_set, + set_id: if schedules_change { + initial_authorities_set_id + 1 + } else { + initial_authorities_set_id + }, + is_halted: false, + }; + let bytes = codec::Encode::encode(&initialization_data); + Ok(codec::Decode::decode(&mut &bytes[..]).map_err(|e| { + ClientError::Custom(format!("Failed to decode initialization data: {:?}", e)) + })?) + } +} + +impl PangolinClient { + async fn grandpa_authorities(&self, at: sp_core::H256) -> ClientResult { + let params = subxt::rpc::rpc_params![ + "GrandpaApi_grandpa_authorities", + sp_core::Bytes(Vec::new()), + at + ]; + let hex: String = self + .subxt() + .rpc() + .client + .request("state_call", params) + .await?; + let raw_authorities_set = array_bytes::hex2bytes(hex)?; + let authorities = codec::Decode::decode(&mut &raw_authorities_set[..]).map_err(|err| { + ClientError::Custom(format!( + "[DecodeAuthorities] Can not decode authorities: {:?}", + err + )) + })?; + Ok(authorities) + } + + /// Find header digest that schedules next GRANDPA authorities set. + fn find_grandpa_authorities_scheduled_change( + &self, + header: &SpHeader, + ) -> Option> { + let filter_log = |log: ConsensusLog| match log { + ConsensusLog::ScheduledChange(change) => Some(change), + _ => None, + }; + + // find the first consensus digest with the right ID which converts to + // the right kind of consensus log. + header + .digest + .logs + .iter() + .filter_map(|item| match item { + DigestItem::Consensus(engine, logs) => { + if engine == &GRANDPA_ENGINE_ID { + Some(&logs[..]) + } else { + None + } + } + _ => None, + }) + .find_map(|mut l| { + let log = codec::Decode::decode(&mut l).ok(); + log.and_then(filter_log) + }) + } +} diff --git a/frame/assistants/client-pangolin/src/fastapi/s2s/mod.rs b/frame/assistants/client-pangolin/src/fastapi/s2s/mod.rs new file mode 100644 index 000000000..0add7dbc2 --- /dev/null +++ b/frame/assistants/client-pangolin/src/fastapi/s2s/mod.rs @@ -0,0 +1 @@ +pub mod generic; diff --git a/frame/assistants/client-pangolin/src/lib.rs b/frame/assistants/client-pangolin/src/lib.rs index 991270598..09bc09668 100644 --- a/frame/assistants/client-pangolin/src/lib.rs +++ b/frame/assistants/client-pangolin/src/lib.rs @@ -2,8 +2,7 @@ pub mod client; pub mod component; pub mod config; pub mod error; -pub mod subxt_runtime; -#[cfg(feature = "ethlike-v1")] -pub mod ethereum; +pub mod fastapi; pub mod helpers; +pub mod subxt_runtime; pub mod types; diff --git a/frame/assistants/client-pangolin/src/subxt_runtime/error.rs b/frame/assistants/client-pangolin/src/subxt_runtime/error.rs index 3e1a05878..719b5a38f 100644 --- a/frame/assistants/client-pangolin/src/subxt_runtime/error.rs +++ b/frame/assistants/client-pangolin/src/subxt_runtime/error.rs @@ -3,8 +3,8 @@ use thiserror::Error as ThisError; /// Bridge ethereum error #[derive(ThisError, Debug)] pub enum ConvertTypeError { - #[error("Other error: {0}")] - Other(String), + #[error("Custom error: {0}")] + Custom(String), #[error("Array bytes error: {0}")] ArrayBytes(String), diff --git a/frame/assistants/client-pangolin/src/subxt_runtime/x_shadow.rs b/frame/assistants/client-pangolin/src/subxt_runtime/x_shadow.rs index 95132da6b..45cd4312a 100644 --- a/frame/assistants/client-pangolin/src/subxt_runtime/x_shadow.rs +++ b/frame/assistants/client-pangolin/src/subxt_runtime/x_shadow.rs @@ -27,7 +27,7 @@ impl TryFrom> for ethereum_primitives::hea timestamp: value.timestamp.as_u64(), number: value .number - .ok_or_else(|| Self::Error::Other(format!("Missing ethereum block number")))? + .ok_or_else(|| Self::Error::Custom(format!("Missing ethereum block number")))? .as_u64(), author: runtime_types::primitive_types::H160(value.author.to_fixed_bytes()), transactions_root: subxt::sp_core::H256(value.transactions_root.to_fixed_bytes()), @@ -38,7 +38,7 @@ impl TryFrom> for ethereum_primitives::hea log_bloom: runtime_types::ethbloom::Bloom( value .logs_bloom - .ok_or_else(|| Self::Error::Other("The `logs_bloom` is required".to_string()))? + .ok_or_else(|| Self::Error::Custom("The `logs_bloom` is required".to_string()))? .to_fixed_bytes(), ), gas_used: runtime_types::primitive_types::U256(value.gas_used.0), diff --git a/frame/assistants/client-pangoro/Cargo.toml b/frame/assistants/client-pangoro/Cargo.toml index ab073e106..225583435 100644 --- a/frame/assistants/client-pangoro/Cargo.toml +++ b/frame/assistants/client-pangoro/Cargo.toml @@ -19,21 +19,32 @@ edition = "2021" [dependencies] tracing = "0.1" -color-eyre = "0.5" thiserror = "1" serde = { version = "1", features = ["derive"] } serde_json = "1" array-bytes = "1.4" - codec = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full"] } -secp256k1 = { version = "0.20", features = ["recovery"] } -subxt = { git = "https://github.com/darwinia-network/subxt.git", branch = "darwinia-v0.12.2" } -web3 = { git = "https://github.com/tomusdrw/rust-web3", branch = "master", features = ["signing"] } +subxt = { git = "https://github.com/darwinia-network/subxt.git", branch = "darwinia-v0.12.2" } + +finality-grandpa = { version = "0.14.0", optional = true } +bp-header-chain = { git = "https://github.com/darwinia-network/darwinia-bridges-substrate.git", branch = "darwinia-v0.12.2", optional = true } +sp-finality-grandpa = { git = "https://github.com/darwinia-network/substrate.git", branch = "darwinia-v0.12.2", optional = true } +sp-runtime = { git = "https://github.com/darwinia-network/substrate.git", branch = "darwinia-v0.12.2", optional = true } support-toolkit = { path = "../../../frame/supports/support-toolkit" } +[features] +default = [] +s2s = [ + "finality-grandpa", + "bp-header-chain", + "sp-finality-grandpa", + "sp-runtime" +] +s2s-pangolin = ["s2s"] + [dev-dependencies] tokio = { version = "1", features = ["full"] } diff --git a/frame/assistants/client-pangoro/src/client.rs b/frame/assistants/client-pangoro/src/client.rs index 973d4ad1f..167ea1a55 100644 --- a/frame/assistants/client-pangoro/src/client.rs +++ b/frame/assistants/client-pangoro/src/client.rs @@ -1,9 +1,7 @@ -use crate::subxt_runtime::api::runtime_types::bsc_primitives::BscHeader; -use crate::subxt_runtime::api::runtime_types::primitive_types::H160; -use crate::subxt_runtime::api::RuntimeApi; -use subxt::{Client, TransactionEvents}; +use subxt::Client; use crate::config::PangoroSubxtConfig; +use crate::subxt_runtime::api::RuntimeApi; use crate::types::{DarwiniaAccount, NodeRuntimeSignedExtra}; /// Pangoro client @@ -40,40 +38,4 @@ impl PangoroClient { pub fn runtime(&self) -> RuntimeApi { self.client.clone().to_runtime_api() } - - /// Get finalized checkpoint of chapel header - pub async fn finalized_checkpoint(&self) -> color_eyre::Result { - Ok(self - .runtime() - .storage() - .bsc() - .finalized_checkpoint(None) - .await?) - } - - /// Get finalized authority set - pub async fn finalized_authority_set(&self) -> color_eyre::Result> { - Ok(self - .runtime() - .storage() - .bsc() - .finalized_authorities(None) - .await?) - } - - /// Relay headers to Pangoro - pub async fn relay_finalized_epoch_header( - &self, - headers: Vec, - ) -> color_eyre::Result> { - Ok(self - .runtime() - .tx() - .bsc() - .relay_finalized_epoch_header(headers) - .sign_and_submit_then_watch(self.account().signer()) - .await? - .wait_for_finalized_success() - .await?) - } } diff --git a/frame/assistants/client-pangoro/src/component.rs b/frame/assistants/client-pangoro/src/component.rs index 24f1f58f2..c5e41256c 100644 --- a/frame/assistants/client-pangoro/src/component.rs +++ b/frame/assistants/client-pangoro/src/component.rs @@ -4,6 +4,7 @@ use subxt::ClientBuilder; use crate::client::PangoroClient; use crate::config::ClientConfig; +use crate::error::ClientResult; use crate::types::DarwiniaAccount; const MAX_ATTEMPTS: u32 = 1; @@ -13,7 +14,7 @@ pub struct PangoroClientComponent; impl PangoroClientComponent { /// Get subxt client instance - pub async fn component(config: ClientConfig) -> color_eyre::Result { + pub async fn component(config: ClientConfig) -> ClientResult { let mut attempts = 1; let mut wait_secs = 1; let endpoint = support_toolkit::url::correct_endpoint(&config.endpoint)?; diff --git a/frame/assistants/client-pangoro/src/error.rs b/frame/assistants/client-pangoro/src/error.rs index 0cf85b027..6bd833309 100644 --- a/frame/assistants/client-pangoro/src/error.rs +++ b/frame/assistants/client-pangoro/src/error.rs @@ -9,55 +9,57 @@ pub type ClientResult = Result; #[derive(ThisError, Debug)] pub enum ClientError { #[error(transparent)] - SubxtBasicError(#[from] subxt::BasicError), + SubxtBasicError(subxt::BasicError), - #[error("No header hash in EthereumReceiptProofOfThing")] - NoHeaderHashInEthereumReceiptProofOfThing, + #[error("Subxt Runtime Error: {0}")] + SubxtRuntime(String), + + #[error("Please reconnect to rpc server")] + ClientRestartNeed, + + #[error(transparent)] + Codec(#[from] codec::Error), #[error("Wrong seed: {0}")] Seed(String), - #[error("Other error: {0}")] - Other(String), + #[error("Bytes error: {0}")] + Bytes(String), + + #[error("Custom error: {0}")] + Custom(String), #[error("Io error: {0}")] Io(#[from] std::io::Error), - // #[error("Rpc error: {0}")] - // Rpc(#[from] jsonrpsee_types::error::Error), - #[error("Serde json error: {0}")] - Serialization(#[from] serde_json::error::Error), - - #[error("Failed to build SecretKey from authority's private key")] - FailedToBuildSecretKey(#[from] secp256k1::Error), - - #[error("Failed to connect ethereum rpc http endpoint")] - CannotConnectToWeb3(#[from] web3::Error), - - #[error("No signer seed set for authority, please check your config.toml")] - NoAuthoritySignerSeed, - - #[error("`bytes2hex` - FAILED: {0}")] - Bytes2Hex(String), - - #[error("`hex2bytes` - FAILED: {0}")] - Hex2Bytes(String), - - #[error("Wrong mmr_root({0}) in Darwinia header({1})")] - WrongMmrRootInDarwiniaHeader(String, u32), - - #[error("No mmr_root in Darwinia header({0})")] - NoMmrRootInDarwiniaHeader(u32), + #[error(transparent)] + Tk(#[from] TkError), +} - #[error("Failed to fetch Darwinia header({0})")] - FailedToFetchDarwiniaHeader(u32), +impl ClientError { + /// Is restart need error + pub fn is_restart_need(&self) -> bool { + matches!(self, Self::ClientRestartNeed) + } +} - #[error("No storage data found by {0} {1}")] - NoStorageDataFound(String, String), +impl From for ClientError { + fn from(error: subxt::BasicError) -> Self { + if let subxt::BasicError::Rpc(_) = &error { + return Self::ClientRestartNeed; + } + Self::SubxtBasicError(error) + } +} - #[error("Not technical committee member")] - NotTechnicalCommitteeMember, +impl From for ClientError { + fn from(error: subxt::rpc::RpcError) -> Self { + Self::SubxtBasicError(subxt::BasicError::Rpc(error)) + } +} - #[error(transparent)] - Tk(#[from] TkError), +impl From for ClientError { + fn from(error: array_bytes::Error) -> Self { + Self::Bytes(format!("{:?}", error)) + } } diff --git a/frame/assistants/client-pangoro/src/fastapi/generic.rs b/frame/assistants/client-pangoro/src/fastapi/generic.rs new file mode 100644 index 000000000..e1a864dd2 --- /dev/null +++ b/frame/assistants/client-pangoro/src/fastapi/generic.rs @@ -0,0 +1,47 @@ +use subxt::TransactionEvents; + +use crate::client::PangoroClient; +use crate::config::PangoroSubxtConfig; +use crate::error::{ClientError, ClientResult}; +use crate::subxt_runtime::api::runtime_types::bsc_primitives::BscHeader; +use crate::subxt_runtime::api::runtime_types::primitive_types::H160; + +/// patch rpc api +impl PangoroClient { + /// Get finalized checkpoint of chapel header + pub async fn finalized_checkpoint(&self) -> ClientResult { + Ok(self + .runtime() + .storage() + .bsc() + .finalized_checkpoint(None) + .await?) + } + + /// Get finalized authority set + pub async fn finalized_authority_set(&self) -> ClientResult> { + Ok(self + .runtime() + .storage() + .bsc() + .finalized_authorities(None) + .await?) + } + + /// Relay headers to Pangoro + pub async fn relay_finalized_epoch_header( + &self, + headers: Vec, + ) -> ClientResult> { + Ok(self + .runtime() + .tx() + .bsc() + .relay_finalized_epoch_header(headers) + .sign_and_submit_then_watch(self.account().signer()) + .await? + .wait_for_finalized_success() + .await + .map_err(|e| ClientError::SubxtRuntime(format!("{:?}", e)))?) + } +} diff --git a/frame/assistants/client-pangoro/src/fastapi/mod.rs b/frame/assistants/client-pangoro/src/fastapi/mod.rs new file mode 100644 index 000000000..e53441e18 --- /dev/null +++ b/frame/assistants/client-pangoro/src/fastapi/mod.rs @@ -0,0 +1,3 @@ +pub mod generic; +#[cfg(feature = "s2s")] +pub mod s2s; diff --git a/frame/assistants/client-pangoro/src/fastapi/s2s/generic.rs b/frame/assistants/client-pangoro/src/fastapi/s2s/generic.rs new file mode 100644 index 000000000..33107fd2a --- /dev/null +++ b/frame/assistants/client-pangoro/src/fastapi/s2s/generic.rs @@ -0,0 +1,207 @@ +use finality_grandpa::voter_set::VoterSet; +use sp_finality_grandpa::{AuthorityList, ConsensusLog, ScheduledChange}; +use sp_runtime::{ConsensusEngineId, DigestItem}; +use subxt::rpc::{ClientT, Subscription, SubscriptionClientT}; +use subxt::{sp_core, sp_runtime}; + +use crate::client::PangoroClient; +use crate::error::{ClientError, ClientResult}; +use crate::types::runtime_types::bp_header_chain::InitializationData; + +const GRANDPA_ENGINE_ID: ConsensusEngineId = *b"FRNK"; + +type BundleHeader = crate::types::runtime_types::sp_runtime::generic::header::Header< + u32, + crate::types::runtime_types::sp_runtime::traits::BlakeTwo256, +>; +type SpHeader = sp_runtime::generic::Header; + +impl PangoroClient { + pub async fn subscribe_grandpa_justifications(&self) -> ClientResult> { + Ok(self + .subxt() + .rpc() + .client + .subscribe( + "grandpa_subscribeJustifications", + None, + "grandpa_unsubscribeJustifications", + ) + .await?) + } + + pub async fn prepare_initialization_data( + &self, + ) -> ClientResult> { + let mut subscription = self.subscribe_grandpa_justifications().await?; + let justification = subscription + .next() + .await + .ok_or_else(|| ClientError::Custom("The subscribe is closed".to_string()))??; + let justification: bp_header_chain::justification::GrandpaJustification = + codec::Decode::decode(&mut &justification.0[..]) + .map_err(|err| ClientError::Custom(format!("Wrong justification: {:?}", err)))?; + + let (initial_header_hash, initial_header_number) = ( + justification.commit.target_hash, + justification.commit.target_number, + ); + let initial_header = self + .subxt() + .rpc() + .header(Some(initial_header_hash)) + .await? + .ok_or_else(|| { + ClientError::Custom(format!( + "Can not get initial header by hash: {:?}", + initial_header_hash + )) + })?; + tracing::trace!(target: "client-pangoro", "Selected initial header [{}]: {}", + initial_header_number, + initial_header_hash, + ); + let initial_authorities_set = self.grandpa_authorities(initial_header_hash).await?; + tracing::trace!(target: "client-pangoro", "Selected initial authorities set: {:?}", + initial_authorities_set, + ); + + // If initial header changes the GRANDPA authorities set, then we need previous authorities + // to verify justification. + let mut authorities_for_verification = initial_authorities_set.clone(); + let scheduled_change = self.find_grandpa_authorities_scheduled_change(&initial_header); + if scheduled_change + .as_ref() + .map(|c| c.delay == 0) + .unwrap_or(false) + { + return Err(ClientError::Custom(format!( + "GRANDPA authorities change at {} scheduled to happen in {:?} blocks. \ + We expect regular hange to have zero delay", + initial_header_hash, + scheduled_change.as_ref().map(|c| c.delay), + ))); + } + let schedules_change = scheduled_change.is_some(); + if schedules_change { + authorities_for_verification = + self.grandpa_authorities(initial_header.parent_hash).await?; + tracing::trace!( + target: "client-pangoro", + "Selected header is scheduling GRANDPA authorities set changes. Using previous set: {:?}", + authorities_for_verification, + ); + } + + // Now let's try to guess authorities set id by verifying justification. + let mut initial_authorities_set_id = 0; + let mut min_possible_block_number = 0; + let authorities_for_verification = VoterSet::new(authorities_for_verification.clone()) + .ok_or(ClientError::Custom(format!( + "[ReadInvalidAuthorities]: {:?}", + authorities_for_verification, + )))?; + loop { + tracing::trace!( + target: "client-pangoro", + "Trying GRANDPA authorities set id: {}", + initial_authorities_set_id, + ); + + let is_valid_set_id = bp_header_chain::justification::verify_justification::( + (initial_header_hash, initial_header_number), + initial_authorities_set_id, + &authorities_for_verification, + &justification, + ) + .is_ok(); + + if is_valid_set_id { + break; + } + + initial_authorities_set_id += 1; + min_possible_block_number += 1; + if min_possible_block_number > initial_header_number { + // there can't be more authorities set changes than headers => if we have reached + // `initial_block_number` and still have not found correct value of + // `initial_authorities_set_id`, then something else is broken => fail + return Err(ClientError::Custom(format!( + "[GuessInitialAuthorities]: {}", + initial_header_number + ))); + } + } + + let initialization_data = bp_header_chain::InitializationData { + header: Box::new(initial_header), + authority_list: initial_authorities_set, + set_id: if schedules_change { + initial_authorities_set_id + 1 + } else { + initial_authorities_set_id + }, + is_halted: false, + }; + let bytes = codec::Encode::encode(&initialization_data); + Ok(codec::Decode::decode(&mut &bytes[..]).map_err(|e| { + ClientError::Custom(format!("Failed to decode initialization data: {:?}", e)) + })?) + } +} + +impl PangoroClient { + async fn grandpa_authorities(&self, at: sp_core::H256) -> ClientResult { + let params = subxt::rpc::rpc_params![ + "GrandpaApi_grandpa_authorities", + sp_core::Bytes(Vec::new()), + at + ]; + let hex: String = self + .subxt() + .rpc() + .client + .request("state_call", params) + .await?; + let raw_authorities_set = array_bytes::hex2bytes(hex)?; + let authorities = codec::Decode::decode(&mut &raw_authorities_set[..]).map_err(|err| { + ClientError::Custom(format!( + "[DecodeAuthorities] Can not decode authorities: {:?}", + err + )) + })?; + Ok(authorities) + } + + /// Find header digest that schedules next GRANDPA authorities set. + fn find_grandpa_authorities_scheduled_change( + &self, + header: &SpHeader, + ) -> Option> { + let filter_log = |log: ConsensusLog| match log { + ConsensusLog::ScheduledChange(change) => Some(change), + _ => None, + }; + + // find the first consensus digest with the right ID which converts to + // the right kind of consensus log. + header + .digest + .logs + .iter() + .filter_map(|item| match item { + DigestItem::Consensus(engine, logs) => { + if engine == &GRANDPA_ENGINE_ID { + Some(&logs[..]) + } else { + None + } + } + _ => None, + }) + .find_map(|mut l| { + let log = codec::Decode::decode(&mut l).ok(); + log.and_then(filter_log) + }) + } +} diff --git a/frame/assistants/client-pangoro/src/fastapi/s2s/mod.rs b/frame/assistants/client-pangoro/src/fastapi/s2s/mod.rs new file mode 100644 index 000000000..0add7dbc2 --- /dev/null +++ b/frame/assistants/client-pangoro/src/fastapi/s2s/mod.rs @@ -0,0 +1 @@ +pub mod generic; diff --git a/frame/assistants/client-pangoro/src/lib.rs b/frame/assistants/client-pangoro/src/lib.rs index dc23406c2..b1a51addf 100644 --- a/frame/assistants/client-pangoro/src/lib.rs +++ b/frame/assistants/client-pangoro/src/lib.rs @@ -1,6 +1,7 @@ pub mod client; pub mod component; pub mod config; -pub mod types; pub mod error; +pub mod fastapi; pub mod subxt_runtime; +pub mod types; diff --git a/frame/assistants/subquery-s2s/Cargo.toml b/frame/assistants/subquery-s2s/Cargo.toml index f2502ec48..2a9f7544d 100644 --- a/frame/assistants/subquery-s2s/Cargo.toml +++ b/frame/assistants/subquery-s2s/Cargo.toml @@ -23,5 +23,6 @@ serde = { version = "1.0", features = ["derive"] } serde-aux = "0.6" serde-hex = "0.1" strum = { version = "0.21", features = ["derive"] } +array-bytes = "1.4" gql_client = "1" diff --git a/frame/assistants/subquery-s2s/src/error.rs b/frame/assistants/subquery-s2s/src/error.rs index e660772ed..f928be567 100644 --- a/frame/assistants/subquery-s2s/src/error.rs +++ b/frame/assistants/subquery-s2s/src/error.rs @@ -8,6 +8,9 @@ pub type SubqueryComponentResult = Result; pub enum SubqueryComponentError { #[error("Failed to send query request to subquery: {0}")] GraphQL(String), + + #[error("Bytes error: {0}")] + Bytes(String), } impl From for SubqueryComponentError { @@ -15,3 +18,9 @@ impl From for SubqueryComponentError { Self::GraphQL(format!("{:?}", error)) } } + +impl From for SubqueryComponentError { + fn from(error: array_bytes::Error) -> Self { + Self::Bytes(format!("{:?}", error)) + } +} diff --git a/frame/assistants/subquery-s2s/src/graphql/generic/next_header.query.graphql b/frame/assistants/subquery-s2s/src/graphql/generic/next_header.query.graphql index 8a673bf60..27ec8552d 100644 --- a/frame/assistants/subquery-s2s/src/graphql/generic/next_header.query.graphql +++ b/frame/assistants/subquery-s2s/src/graphql/generic/next_header.query.graphql @@ -23,6 +23,8 @@ query queryNextRelayBlock($block: Int!) { stateRoot extrinsicsRoot digest + onDemandType + additional timestamp } } diff --git a/frame/assistants/subquery-s2s/src/graphql/generic/next_needed_header.query.graphql b/frame/assistants/subquery-s2s/src/graphql/generic/next_needed_header.query.graphql index 6787618e6..e88a80dfa 100644 --- a/frame/assistants/subquery-s2s/src/graphql/generic/next_needed_header.query.graphql +++ b/frame/assistants/subquery-s2s/src/graphql/generic/next_needed_header.query.graphql @@ -23,6 +23,8 @@ query queryNextRelayBlock($origin: String!) { stateRoot extrinsicsRoot digest + onDemandType + additional timestamp } } diff --git a/frame/assistants/subquery-s2s/src/graphql/generic/query_need_relay.graphql b/frame/assistants/subquery-s2s/src/graphql/generic/query_need_relay.graphql new file mode 100644 index 000000000..0f9de5ca6 --- /dev/null +++ b/frame/assistants/subquery-s2s/src/graphql/generic/query_need_relay.graphql @@ -0,0 +1,36 @@ +query queryNeedRelay($origin: String!, $lane: String!, $nonce: Int!) { + needRelayBlocks( + first: 1 + filter: { + type: { + equalTo: "on-demand" + } + origin: { + equalTo: $origin + } + laneId: { + equalTo: $lane + } + messageNonce: { + equalTo: $nonce + } + } + ) { + nodes { + id + blockNumber + blockHash + type + origin + laneId + messageNonce + parentHash + stateRoot + extrinsicsRoot + digest + onDemandType + additional + timestamp + } + } +} diff --git a/frame/assistants/subquery-s2s/src/subquery.rs b/frame/assistants/subquery-s2s/src/subquery.rs index d62fd55f4..c3451074d 100644 --- a/frame/assistants/subquery-s2s/src/subquery.rs +++ b/frame/assistants/subquery-s2s/src/subquery.rs @@ -6,7 +6,8 @@ use include_dir::{include_dir, Dir}; use crate::error::SubqueryComponentError; use crate::types::{ BridgeName, DataWrapper, FindJustificationVars, JustificationMapping, NeedRelayBlock, - OriginType, QueryNextOnDemandBlockVars, QueryNextRelayBlockVars, + OriginType, QueryNeedRelay, QueryNextOnDemandBlockVars, QueryNextRelayBlockVars, + RelayBlockOrigin, }; use crate::SubqueryComponentResult; @@ -42,6 +43,7 @@ impl Subquery { } impl Subquery { + /// Query next mandatory header pub async fn next_mandatory_header( &self, block_number: u32, @@ -64,14 +66,13 @@ impl Subquery { Ok(blocks.get(0).cloned()) } + /// Query next needed header (on-demand) pub async fn next_needed_header( &self, origin: OriginType, ) -> SubqueryComponentResult> { let query = self.read_graphql("next_needed_header.query.graphql")?; - let vars = QueryNextOnDemandBlockVars { - origin, - }; + let vars = QueryNextOnDemandBlockVars { origin }; let data = self .client .query_with_vars_unwrap::>, QueryNextOnDemandBlockVars>(query, vars) @@ -84,6 +85,7 @@ impl Subquery { Ok(blocks.get(0).cloned()) } + /// Find justification pub async fn find_justification( &self, block_hash: impl AsRef, @@ -107,4 +109,32 @@ impl Subquery { .unwrap_or_default(); Ok(justifications.get(0).cloned()) } + + /// Query relay info by nonce + pub async fn query_need_relay( + &self, + origin: RelayBlockOrigin, + lane: [u8; 4], + nonce: u64, + ) -> SubqueryComponentResult> { + let query = self.read_graphql("query_need_relay.graphql")?; + let lane_hex = array_bytes::bytes2hex("", lane); + let vars = QueryNeedRelay { + origin, + lane: lane_hex, + nonce, + }; + let data = self + .client + .query_with_vars_unwrap::>, QueryNeedRelay>( + query, vars, + ) + .await + .map_err(SubqueryComponentError::from)?; + let blocks = data + .get("needRelayBlocks") + .map(|item| item.nodes.clone()) + .unwrap_or_default(); + Ok(blocks.get(0).cloned()) + } } diff --git a/frame/assistants/subquery-s2s/src/types/mark.rs b/frame/assistants/subquery-s2s/src/types/mark.rs index b325ada7b..00973869f 100644 --- a/frame/assistants/subquery-s2s/src/types/mark.rs +++ b/frame/assistants/subquery-s2s/src/types/mark.rs @@ -5,6 +5,8 @@ use serde::{Deserialize, Serialize}; pub enum BridgeName { /// bridge pangolin<>pangolin-parachain PangolinParachain, + /// bridge pangolin<>pangoro + PangolinPangoro, /// bridge pangolin<>pangolin-parachain CrabParachain, } @@ -14,6 +16,7 @@ impl BridgeName { pub(crate) fn directory(&self) -> &str { match self { Self::PangolinParachain => "pangolin-parachain", + Self::PangolinPangoro => "pangolin-pangoro", Self::CrabParachain => "crab-parachain", } } diff --git a/frame/assistants/subquery-s2s/src/types/s2s.rs b/frame/assistants/subquery-s2s/src/types/s2s.rs index b4c52f70c..a47641b26 100644 --- a/frame/assistants/subquery-s2s/src/types/s2s.rs +++ b/frame/assistants/subquery-s2s/src/types/s2s.rs @@ -1,6 +1,8 @@ use serde::{Deserialize, Serialize}; use serde_hex::{SerHex, SerHexSeq, StrictPfx}; +use crate::SubqueryComponentResult; + /// need relay block #[derive(Clone, Debug, Deserialize, Serialize)] pub struct NeedRelayBlock { @@ -36,6 +38,10 @@ impl NeedRelayBlock { pub fn is_mandatory(&self) -> bool { matches!(self.type_, RelayBlockType::Mandatory) } + + pub fn block_hash_bytes(&self) -> SubqueryComponentResult> { + Ok(array_bytes::hex2bytes(&self.block_hash)?) + } } #[derive( diff --git a/frame/assistants/subquery-s2s/src/types/subquery.rs b/frame/assistants/subquery-s2s/src/types/subquery.rs index 250b89364..9e4419ebd 100644 --- a/frame/assistants/subquery-s2s/src/types/subquery.rs +++ b/frame/assistants/subquery-s2s/src/types/subquery.rs @@ -1,5 +1,7 @@ use serde::{Deserialize, Serialize}; +use crate::types::RelayBlockOrigin; + #[derive(Clone, Debug, Serialize)] pub(crate) struct EmptyQueryVar; @@ -8,7 +10,6 @@ pub(crate) struct QueryNextRelayBlockVars { pub(crate) block: u32, } - #[derive(Clone, Debug, Serialize)] pub enum OriginType { #[serde(rename = "mandatory")] @@ -40,6 +41,13 @@ pub(crate) struct QueryBlockVars { pub(crate) block_number: u32, } +#[derive(Clone, Debug, Serialize)] +pub(crate) struct QueryNeedRelay { + pub origin: RelayBlockOrigin, + pub lane: String, + pub nonce: u64, +} + #[derive(Clone, Debug, Serialize, Deserialize)] pub struct DataWrapper { pub nodes: Vec, diff --git a/frame/components/ethereum/src/ethereum/client.rs b/frame/components/ethereum/src/ethereum/client.rs index f47aaf40f..398a8a0f6 100644 --- a/frame/components/ethereum/src/ethereum/client.rs +++ b/frame/components/ethereum/src/ethereum/client.rs @@ -104,7 +104,7 @@ impl EthereumClient { beneficiary_buffer.copy_from_slice(&beneficiary); // debug - tracing::debug!(target: "component-ethereum", "message: {}", array_bytes::bytes2hex("0x", message.clone())); + tracing::debug!(target: "component-ethereum", "message: {}", array_bytes::bytes2hex("0x", &message.clone())); for (i, signature) in signature_list.clone().iter().enumerate() { tracing::debug!( target: "component-ethereum", @@ -116,7 +116,7 @@ impl EthereumClient { tracing::debug!( target: "component-ethereum", "beneficiary: {}", - array_bytes::bytes2hex("0x", beneficiary_buffer) + array_bytes::bytes2hex("0x", &beneficiary_buffer) ); // gas price @@ -129,7 +129,7 @@ impl EthereumClient { "updateRelayer", input, Options::with(|options| { - options.gas = Some(150_000.into()); + options.gas = Some(150_000u64.into()); options.gas_price = gas_price; }), key_ref, diff --git a/frame/supports/support-common/src/initialize.rs b/frame/supports/support-common/src/initialize.rs index 88472f39e..01d24966e 100644 --- a/frame/supports/support-common/src/initialize.rs +++ b/frame/supports/support-common/src/initialize.rs @@ -31,6 +31,7 @@ fn init_log() -> color_eyre::Result<()> { "darwinia-ethereum=trace", "darwinia-crab=trace", "client-pangolin=trace", + "client-pangoro=trace", "feemarket=trace", "shadow=trace", ] diff --git a/subql/s2s/pangolin/project.yaml b/subql/s2s/pangolin/project.yaml index 7a9efa22d..b13779022 100644 --- a/subql/s2s/pangolin/project.yaml +++ b/subql/s2s/pangolin/project.yaml @@ -14,20 +14,41 @@ network: dataSources: - name: main kind: substrate/Runtime - startBlock: 2304500 + startBlock: 2719453 mapping: file: ./dist/index.js handlers: - handler: handleBlock kind: substrate/BlockHandler + + - handler: handleCall + kind: substrate/CallHandler + - handler: handleEvent kind: substrate/EventHandler filter: - - module: grandpa - method: NewAuthorities - - module: bridgePangoroMessages - method: MessageAccepted - - module: bridgePangoroParachainMessages - method: MessageAccepted - - handler: handleCall - kind: substrate/CallHandler + module: grandpa + method: NewAuthorities + + - handler: handleEvent + kind: substrate/EventHandler + filter: + module: bridgePangoroMessages + method: MessageAccepted + + - handler: handleEvent + kind: substrate/EventHandler + filter: + module: bridgePangoroParachainMessages + method: MessageAccepted + + - handler: handleEvent + kind: substrate/EventHandler + filter: + module: bridgePangoroDispatch + + - handler: handleEvent + kind: substrate/EventHandler + filter: + module: bridgePangoroParachainDispatch + diff --git a/subql/s2s/pangolin/schema.graphql b/subql/s2s/pangolin/schema.graphql index e05dab4ec..407b588c0 100644 --- a/subql/s2s/pangolin/schema.graphql +++ b/subql/s2s/pangolin/schema.graphql @@ -22,6 +22,10 @@ type NeedRelayBlock @entity { extrinsicsRoot: String! digest: String! + onDemandType: String, + + additional: String + timestamp: Date } diff --git a/subql/s2s/pangolin/src/handler/event.ts b/subql/s2s/pangolin/src/handler/event.ts index 776e05f51..bf34742eb 100644 --- a/subql/s2s/pangolin/src/handler/event.ts +++ b/subql/s2s/pangolin/src/handler/event.ts @@ -1,6 +1,6 @@ import {FastEvent} from '../helpers'; import * as storage from '../storage'; -import {RelayBlockOrigin} from "../storage"; +import {OnDemandType, RelayBlockOrigin} from '../storage'; import {BlockHandler} from "./block"; export class EventHandler { @@ -21,18 +21,50 @@ export class EventHandler { logger.info(`[event] Received event: [${eventKey}] [${eventId}] in block ${blockNumber}`); switch (eventKey) { case 'grandpa:NewAuthorities': { - await storage.storeNeedRelayBlock(this.event, RelayBlockOrigin.Mandatory); + await storage.storeNeedRelayBlock( + this.event, + RelayBlockOrigin.Mandatory, + ); return; } case 'bridgePangoroMessages:MessageAccepted': { - await storage.storeNeedRelayBlock(this.event, RelayBlockOrigin.BridgePangoro); + await storage.storeNeedRelayBlock( + this.event, + RelayBlockOrigin.BridgePangoro, + OnDemandType.SendMessage, + ); return; } case 'bridgePangolinParachainMessages:MessageAccepted': { - await storage.storeNeedRelayBlock(this.event, RelayBlockOrigin.BridgePangolinParachain); + await storage.storeNeedRelayBlock( + this.event, + RelayBlockOrigin.BridgePangolinParachain, + OnDemandType.SendMessage, + ); return; } } + // dispatch + + if (eventSection === 'bridgePangoroDispatch') { + await storage.storeNeedRelayBlock( + this.event, + RelayBlockOrigin.BridgePangoro, + OnDemandType.Dispatch, + eventMethod, + ); + return; + } + if (eventSection === 'bridgePangoroParachainDispatch') { + await storage.storeNeedRelayBlock( + this.event, + RelayBlockOrigin.BridgePangolinParachain, + OnDemandType.Dispatch, + eventMethod, + ); + return; + } + } } diff --git a/subql/s2s/pangolin/src/storage/event.ts b/subql/s2s/pangolin/src/storage/event.ts index b9cb5ed4b..91650ebdb 100644 --- a/subql/s2s/pangolin/src/storage/event.ts +++ b/subql/s2s/pangolin/src/storage/event.ts @@ -7,6 +7,11 @@ export enum RelayBlockType { OnDemand = 'on-demand', } +export enum OnDemandType { + SendMessage = 'send-message', + Dispatch = 'dispatch', +} + export enum RelayBlockOrigin { Mandatory = 'mandatory', BridgePangoro = 'bridge-pangoro', @@ -16,13 +21,17 @@ export enum RelayBlockOrigin { export async function storeNeedRelayBlock( event: FastEvent, - origin: RelayBlockOrigin + origin: RelayBlockOrigin, + onDemandType?: OnDemandType, + additional?: string, ) { const _event = new NeedRelayBlock(event.id); _event.blockNumber = event.blockNumber; _event.blockHash = event.blockHash; _event.type = origin == RelayBlockOrigin.Mandatory ? RelayBlockType.Mandatory : RelayBlockType.OnDemand; _event.origin = origin; + _event.onDemandType = onDemandType; + _event.additional = additional; const block = new FastBlock(event.block); const header = block.raw.block.header; @@ -31,12 +40,19 @@ export async function storeNeedRelayBlock( _event.extrinsicsRoot = header.extrinsicsRoot.toString(); _event.digest = header.digest.toHex(); - if (_event.type == RelayBlockType.OnDemand) { + if (_event.type == RelayBlockType.OnDemand && onDemandType == OnDemandType.SendMessage) { const data = event.data; const [laneId, messageNonce] = data as unknown as [string, number]; _event.laneId = laneId.toString().replace('0x', ''); _event.messageNonce = messageNonce; } + if (_event.type == RelayBlockType.OnDemand && onDemandType == OnDemandType.Dispatch) { + const data = event.data; + const [chainId, bridgeMessageIdOf] = data as unknown as [string, any]; + const [laneId, messageNonce] = bridgeMessageIdOf as unknown as [string, number]; + _event.laneId = laneId.toString().replace('0x', ''); + _event.messageNonce = messageNonce; + } if (_event.type == RelayBlockType.Mandatory) { let justificationMapping = await JustificationMapping.get(block.number.toString()); if (!justificationMapping) { diff --git a/subql/s2s/pangoro/.gitignore b/subql/s2s/pangoro/.gitignore new file mode 100644 index 000000000..f032df436 --- /dev/null +++ b/subql/s2s/pangoro/.gitignore @@ -0,0 +1,55 @@ +# These are some examples of commonly ignored file patterns. +# You should customize this list as applicable to your project. +# Learn more about .gitignore: +# https://www.atlassian.com/git/tutorials/saving-changes/gitignore + +# Node artifact files +node_modules/ +dist/ + +# lock files +yarn.lock +package-lock.json + +# Compiled Java class files +*.class + +# Compiled Python bytecode +*.py[cod] + +# Log files +*.log + +# Package files +*.jar + +# Maven +target/ +dist/ +src/types + +# JetBrains IDE +.idea/ + +# Unit test reports +TEST*.xml + +# Generated by MacOS +.DS_Store + +# Generated by Windows +Thumbs.db + +# Applications +*.app +*.exe +*.war + +# Large media files +*.mp4 +*.tiff +*.avi +*.flv +*.mov +*.wmv + diff --git a/subql/s2s/pangoro/LICENSE b/subql/s2s/pangoro/LICENSE new file mode 100644 index 000000000..3c806ae55 --- /dev/null +++ b/subql/s2s/pangoro/LICENSE @@ -0,0 +1,21 @@ +MIT LICENSE + +Copyright 2020-2021 OnFinality Limited authors & contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/subql/s2s/pangoro/README.md b/subql/s2s/pangoro/README.md new file mode 100644 index 000000000..e21cd2bab --- /dev/null +++ b/subql/s2s/pangoro/README.md @@ -0,0 +1,102 @@ +# SubQuery - Starter Package + + +The Starter Package is an example that you can use as a starting point for developing your SubQuery project. +A SubQuery package defines which data The SubQuery will index from the Substrate blockchain, and how it will store it. + +## Preparation + +#### Environment + +- [Typescript](https://www.typescriptlang.org/) are required to compile project and define types. + +- Both SubQuery CLI and generated Project have dependencies and require [Node](https://nodejs.org/en/). + + +#### Install the SubQuery CLI + +Install SubQuery CLI globally on your terminal by using NPM: + +``` +npm install -g @subql/cli +``` + +Run help to see available commands and usage provide by CLI +``` +subql help +``` + +## Initialize the starter package + +Inside the directory in which you want to create the SubQuery project, simply replace `project-name` with your project name and run the command: +``` +subql init --starter project-name +``` +Then you should see a folder with your project name has been created inside the directory, you can use this as the start point of your project. And the files should be identical as in the [Directory Structure](https://doc.subquery.network/directory_structure.html). + +Last, under the project directory, run following command to install all the dependency. +``` +yarn install +``` + + +## Configure your project + +In the starter package, we have provided a simple example of project configuration. You will be mainly working on the following files: + +- The Manifest in `project.yaml` +- The GraphQL Schema in `schema.graphql` +- The Mapping functions in `src/mappings/` directory + +For more information on how to write the SubQuery, +check out our doc section on [Define the SubQuery](https://doc.subquery.network/define_a_subquery.html) + +#### Code generation + +In order to index your SubQuery project, it is mandatory to build your project first. +Run this command under the project directory. + +```` +yarn codegen +```` + +## Build the project + +In order to deploy your SubQuery project to our hosted service, it is mandatory to pack your configuration before upload. +Run pack command from root directory of your project will automatically generate a `your-project-name.tgz` file. + +``` +yarn build +``` + +## Indexing and Query + +#### Run required systems in docker + + +Under the project directory run following command: + +``` +docker-compose pull && docker-compose up +``` +#### Query the project + +Open your browser and head to `http://localhost:3000`. + +Finally, you should see a GraphQL playground is showing in the explorer and the schemas that ready to query. + +For the `subql-starter` project, you can try to query with the following code to get a taste of how it works. + +````graphql +{ + query{ + starterEntities(first:10){ + nodes{ + field1, + field2, + field3 + } + } + } +} +```` diff --git a/subql/s2s/pangoro/docker-compose.yml b/subql/s2s/pangoro/docker-compose.yml new file mode 100644 index 000000000..5e73f7e93 --- /dev/null +++ b/subql/s2s/pangoro/docker-compose.yml @@ -0,0 +1,60 @@ +version: "3" + +services: + postgres: + image: postgres:12-alpine + # ports: + # - 5432:5432 + volumes: + - .data/postgres:/var/lib/postgresql/data + environment: + POSTGRES_PASSWORD: postgres + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 5s + timeout: 5s + retries: 5 + + subquery-node: + image: onfinality/subql-node:v1.0.0 + depends_on: + "postgres": + condition: service_healthy + restart: always + environment: + DB_USER: postgres + DB_PASS: postgres + DB_DATABASE: postgres + DB_HOST: postgres + DB_PORT: 5432 + volumes: + - ./:/app + command: + - -f=/app + - --db-schema=app + healthcheck: + test: ["CMD", "curl", "-f", "http://subquery-node:3000/ready"] + interval: 3s + timeout: 5s + retries: 10 + + graphql-engine: + image: onfinality/subql-query:v1.0.0 + ports: + - 3000:3000 + depends_on: + "postgres": + condition: service_healthy + "subquery-node": + condition: service_healthy + restart: always + environment: + DB_USER: postgres + DB_PASS: postgres + DB_DATABASE: postgres + DB_HOST: postgres + DB_PORT: 5432 + command: + - --name=app + - --playground + - --indexer=http://subquery-node:3000 diff --git a/subql/s2s/pangoro/examples/need_relay_block.query.txt b/subql/s2s/pangoro/examples/need_relay_block.query.txt new file mode 100644 index 000000000..0dd15ebb4 --- /dev/null +++ b/subql/s2s/pangoro/examples/need_relay_block.query.txt @@ -0,0 +1,30 @@ + +query queryNeedRelayBlockPage { + justificationMappings ( + first: 5 + orderBy: BLOCK_NUMBER_DESC + ) { + nodes { + id + blockNumber + blockHash + mandatory + justification + } + } + needRelayBlocks ( + first: 5 + orderBy: BLOCK_NUMBER_ASC + ) { + nodes { + id + blockNumber + blockHash + type + origin + laneId + messageNonce + timestamp + } + } +} diff --git a/subql/s2s/pangoro/package.json b/subql/s2s/pangoro/package.json new file mode 100644 index 000000000..b537f6f48 --- /dev/null +++ b/subql/s2s/pangoro/package.json @@ -0,0 +1,29 @@ +{ + "name": "subql-s2s-pangoro", + "version": "0.5.5", + "description": "This SubQuery project can be use as a starting point for Pangoro network", + "main": "dist/index.js", + "scripts": { + "build": "tsc -b", + "prepack": "rm -rf dist && npm build", + "test": "jest", + "codegen": "./node_modules/.bin/subql codegen" + }, + "homepage": "https://github.com/darwinia-network/bridger", + "repository": "https://github.com/darwinia-network/bridger", + "files": [ + "dist", + "schema.graphql", + "project.yaml" + ], + "author": "Darwinia Network", + "devDependencies": { + "@polkadot/api": "^7", + "@subql/types": "latest", + "typescript": "^4.2.4", + "@subql/cli": "latest" + }, + "resolutions": { + "ipfs-unixfs": "6.0.6" + } +} diff --git a/subql/s2s/pangoro/project.yaml b/subql/s2s/pangoro/project.yaml new file mode 100644 index 000000000..836b16381 --- /dev/null +++ b/subql/s2s/pangoro/project.yaml @@ -0,0 +1,43 @@ +specVersion: 0.2.0 +name: bridge-s2s-pangoro +version: 0.0.4 +description: S2S bridge pangoro subql +repository: https://github.com/darwinia-network/bridger +schema: + file: ./schema.graphql + +network: + genesisHash: '0xf37f31c4481e3c937ad40b672c561d0c0b1fb70b40e51a0d56dad30d60e4db58' + endpoint: wss://pangoro-rpc.darwinia.network + dictionary: https://api.subquery.network/sq/darwinia-network/pangoro-dictionary + +dataSources: + - name: main + kind: substrate/Runtime + startBlock: 2742860 + mapping: + file: ./dist/index.js + handlers: + - handler: handleBlock + kind: substrate/BlockHandler + + - handler: handleCall + kind: substrate/CallHandler + + - handler: handleEvent + kind: substrate/EventHandler + filter: + module: grandpa + method: NewAuthorities + + - handler: handleEvent + kind: substrate/EventHandler + filter: + module: bridgePangolinMessages + method: MessageAccepted + + - handler: handleEvent + kind: substrate/EventHandler + filter: + module: bridgePangolinDispatch + diff --git a/subql/s2s/pangoro/schema.graphql b/subql/s2s/pangoro/schema.graphql new file mode 100644 index 000000000..407b588c0 --- /dev/null +++ b/subql/s2s/pangoro/schema.graphql @@ -0,0 +1,40 @@ + +type Block @entity { + id: ID! + + number: Int + timestamp: Date + parentHash: String + specVersion: Int +} + +type NeedRelayBlock @entity { + id: ID! + + blockNumber: Int! + blockHash: String! + type: String! + origin: String! + laneId: String + messageNonce: Int + parentHash: String! + stateRoot: String! + extrinsicsRoot: String! + digest: String! + + onDemandType: String, + + additional: String + + timestamp: Date +} + +type JustificationMapping @entity { + id: ID! + + blockNumber: Int! + blockHash: String! + mandatory: Boolean! + justification: String! + +} diff --git a/subql/s2s/pangoro/src/handler/block.ts b/subql/s2s/pangoro/src/handler/block.ts new file mode 100644 index 000000000..bce029bff --- /dev/null +++ b/subql/s2s/pangoro/src/handler/block.ts @@ -0,0 +1,25 @@ +import {SubstrateBlock} from '@subql/types'; +import * as storage from '../storage'; +import {Block} from '../types'; +import {FastBlock} from "../helpers"; + +export class BlockHandler { + private readonly block: SubstrateBlock; + + static async ensureBlock(id: string): Promise { + const block = await Block.get(id); + + if (!block) { + await new Block(id).save(); + } + } + + constructor(block: SubstrateBlock) { + this.block = block; + } + + public async save() { + const fastBlock = new FastBlock(this.block); + await storage.storeJustification(fastBlock); + } +} diff --git a/subql/s2s/pangoro/src/handler/event.ts b/subql/s2s/pangoro/src/handler/event.ts new file mode 100644 index 000000000..405dc4169 --- /dev/null +++ b/subql/s2s/pangoro/src/handler/event.ts @@ -0,0 +1,52 @@ +import {FastEvent} from '../helpers'; +import * as storage from '../storage'; +import {OnDemandType, RelayBlockOrigin} from '../storage'; +import {BlockHandler} from "./block"; + +export class EventHandler { + private readonly event: FastEvent; + + constructor(event: FastEvent) { + this.event = event; + } + + public async save() { + await BlockHandler.ensureBlock(this.event.blockHash); + + const eventId = this.event.id; + const eventSection = this.event.section; + const eventMethod = this.event.method; + const blockNumber = this.event.blockNumber; + const eventKey = `${eventSection}:${eventMethod}`; + logger.info(`[event] Received event: [${eventKey}] [${eventId}] in block ${blockNumber}`); + switch (eventKey) { + case 'grandpa:NewAuthorities': { + await storage.storeNeedRelayBlock( + this.event, + RelayBlockOrigin.Mandatory, + ); + return; + } + case 'bridgePangolinMessages:MessageAccepted': { + await storage.storeNeedRelayBlock( + this.event, + RelayBlockOrigin.BridgePangolin, + OnDemandType.SendMessage, + ); + return; + } + } + + // dispatch + + if (eventSection === 'bridgePangolinDispatch') { + await storage.storeNeedRelayBlock( + this.event, + RelayBlockOrigin.BridgePangolin, + OnDemandType.Dispatch, + eventMethod, + ); + return; + } + } +} diff --git a/subql/s2s/pangoro/src/helpers/block.ts b/subql/s2s/pangoro/src/helpers/block.ts new file mode 100644 index 000000000..5d811254c --- /dev/null +++ b/subql/s2s/pangoro/src/helpers/block.ts @@ -0,0 +1,42 @@ +import { Block } from '@polkadot/types/interfaces/runtime'; +import {SubstrateBlock} from "@subql/types"; + +export const getBlockTimestamp = (block: Block): Date => { + const extrinsicForSetTimestamp = block.extrinsics.find((item) => { + return item.method.method === 'set' && item.method.section === 'timestamp'; + }); + + if (extrinsicForSetTimestamp) { + return new Date(Number(extrinsicForSetTimestamp?.args?.[0].toString())); + } + + return new Date(); +}; + +export class FastBlock { + private readonly block: SubstrateBlock; + + constructor(block: SubstrateBlock) { + this.block = block; + } + + get raw() { + return this.block; + } + + get number() { + return this.block.block.header.number.toNumber() || Number(0); + } + + get hash() { + return this.block.block.hash.toString(); + } + + get specVersion() { + return this.block.specVersion; + } + + get parentHash() { + return this.block.block.header.parentHash.toString(); + } +} diff --git a/subql/s2s/pangoro/src/helpers/event.ts b/subql/s2s/pangoro/src/helpers/event.ts new file mode 100644 index 000000000..dad2eafc2 --- /dev/null +++ b/subql/s2s/pangoro/src/helpers/event.ts @@ -0,0 +1,60 @@ +import {SubstrateEvent} from "@subql/types"; + +export class FastEvent { + private readonly event: SubstrateEvent; + + constructor(event: SubstrateEvent) { + this.event = event; + } + + get raw() { + return this.event; + } + + get index() { + return this.event.idx; + } + + get block() { + return this.event.block + } + + get blockNumber() { + return this.event.block.block.header.number.toNumber(); + } + + get blockHash() { + return this.event.block.block.hash.toString(); + } + + get events() { + return this.event.block.events; + } + + get section() { + return this.event.event.section; + } + + get method() { + return this.event.event.method; + } + + get data() { + return this.event.event.data; + } + + get extrinsicHash() { + const i = this.event?.extrinsic?.extrinsic?.hash?.toString(); + + return i === 'null' ? undefined : i; + } + + get id() { + return `${this.blockNumber}-${this.index}`; + } + + get timestamp() { + return this.event.block.timestamp; + } + +} diff --git a/subql/s2s/pangoro/src/helpers/index.ts b/subql/s2s/pangoro/src/helpers/index.ts new file mode 100644 index 000000000..1b59dc413 --- /dev/null +++ b/subql/s2s/pangoro/src/helpers/index.ts @@ -0,0 +1,2 @@ +export * from './block' +export * from './event' diff --git a/subql/s2s/pangoro/src/index.ts b/subql/s2s/pangoro/src/index.ts new file mode 100644 index 000000000..69d499bb2 --- /dev/null +++ b/subql/s2s/pangoro/src/index.ts @@ -0,0 +1,3 @@ +//Exports all handler functions +export * from './mappings/mappingHandlers' +import "@polkadot/api-augment" diff --git a/subql/s2s/pangoro/src/mappings/mappingHandlers.ts b/subql/s2s/pangoro/src/mappings/mappingHandlers.ts new file mode 100644 index 000000000..c85480169 --- /dev/null +++ b/subql/s2s/pangoro/src/mappings/mappingHandlers.ts @@ -0,0 +1,21 @@ +import {SubstrateExtrinsic, SubstrateEvent, SubstrateBlock} from '@subql/types'; +import {FastEvent} from '../helpers'; +import {EventHandler} from "../handler/event"; +import {BlockHandler} from "../handler/block"; + + +export async function handleBlock(block: SubstrateBlock): Promise { + const handler = new BlockHandler(block); + await handler.save(); +} + +export async function handleEvent(event: SubstrateEvent): Promise { + const fastEvent = new FastEvent(event); + const handler = new EventHandler(fastEvent); + await handler.save(); +} + +export async function handleCall(extrinsic: SubstrateExtrinsic): Promise { +} + + diff --git a/subql/s2s/pangoro/src/storage/block.ts b/subql/s2s/pangoro/src/storage/block.ts new file mode 100644 index 000000000..aa96c794a --- /dev/null +++ b/subql/s2s/pangoro/src/storage/block.ts @@ -0,0 +1,29 @@ +import {Justifications} from "@polkadot/types/interfaces/runtime/types"; +import {JustificationMapping} from "../types"; +import {FastBlock} from "../helpers"; + + + +export async function storeJustification( + block: FastBlock, +) { + const rawBlock = block.raw; + if (rawBlock.justifications.isNone) { + return; + } + const justifications = rawBlock.justifications.value as unknown as Justifications; + + for (const justification of justifications) { + const [consensusEngineId, encodedJustification] = justification; + if (!consensusEngineId.isGrandpa) continue; + + const _justification = new JustificationMapping(block.number.toString()); + _justification.blockNumber = block.number; + _justification.blockHash = block.hash; + _justification.mandatory = false; + _justification.justification = encodedJustification.toString(); + await _justification.save(); + break; + } + +} diff --git a/subql/s2s/pangoro/src/storage/event.ts b/subql/s2s/pangoro/src/storage/event.ts new file mode 100644 index 000000000..f6f6017d3 --- /dev/null +++ b/subql/s2s/pangoro/src/storage/event.ts @@ -0,0 +1,67 @@ +import {FastBlock, FastEvent} from '../helpers'; +import {JustificationMapping, NeedRelayBlock} from '../types'; +import {storeJustification} from "./block"; + +export enum RelayBlockType { + Mandatory = 'mandatory', + OnDemand = 'on-demand', +} + +export enum OnDemandType { + SendMessage = 'send-message', + Dispatch = 'dispatch', +} + +export enum RelayBlockOrigin { + Mandatory = 'mandatory', + BridgePangolin = 'bridge-pangolin', +} + + +export async function storeNeedRelayBlock( + event: FastEvent, + origin: RelayBlockOrigin, + onDemandType?: OnDemandType, + additional?: string, +) { + const _event = new NeedRelayBlock(event.id); + _event.blockNumber = event.blockNumber; + _event.blockHash = event.blockHash; + _event.type = origin == RelayBlockOrigin.Mandatory ? RelayBlockType.Mandatory : RelayBlockType.OnDemand; + _event.origin = origin; + _event.onDemandType = onDemandType; + _event.additional = additional; + + const block = new FastBlock(event.block); + const header = block.raw.block.header; + _event.parentHash = header.parentHash.toString(); + _event.stateRoot = header.stateRoot.toString(); + _event.extrinsicsRoot = header.extrinsicsRoot.toString(); + _event.digest = header.digest.toHex(); + + if (_event.type == RelayBlockType.OnDemand && onDemandType == OnDemandType.SendMessage) { + const data = event.data; + const [laneId, messageNonce] = data as unknown as [string, number]; + _event.laneId = laneId.toString().replace('0x', ''); + _event.messageNonce = messageNonce; + } + if (_event.type == RelayBlockType.OnDemand && onDemandType == OnDemandType.Dispatch) { + const data = event.data; + const [chainId, bridgeMessageIdOf] = data as unknown as [string, any]; + const [laneId, messageNonce] = bridgeMessageIdOf as unknown as [string, number]; + _event.laneId = laneId.toString().replace('0x', ''); + _event.messageNonce = messageNonce; + } + if (_event.type == RelayBlockType.Mandatory) { + let justificationMapping = await JustificationMapping.get(block.number.toString()); + if (!justificationMapping) { + await storeJustification(block); + justificationMapping = await JustificationMapping.get(block.number.toString()); + } + justificationMapping.mandatory = true; + await justificationMapping.save(); + } + + _event.timestamp = event.timestamp; + await _event.save(); +} diff --git a/subql/s2s/pangoro/src/storage/index.ts b/subql/s2s/pangoro/src/storage/index.ts new file mode 100644 index 000000000..b9ab01ced --- /dev/null +++ b/subql/s2s/pangoro/src/storage/index.ts @@ -0,0 +1,2 @@ +export * from './event' +export * from './block' diff --git a/subql/s2s/pangoro/tsconfig.json b/subql/s2s/pangoro/tsconfig.json new file mode 100644 index 000000000..9b95212d1 --- /dev/null +++ b/subql/s2s/pangoro/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "esModuleInterop": true, + "declaration": true, + "importHelpers": true, + "resolveJsonModule": true, + "module": "commonjs", + "outDir": "dist", + "rootDir": "src", + "target": "es2017" + }, + "include": [ + "src/**/*", + "node_modules/@subql/types/dist/global.d.ts" + ] +}