diff --git a/.editorconfig b/.editorconfig index 37b55e053..9fb23ce69 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,19 +1,13 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + root = true [*] -charset=utf-8 -end_of_line=lf -indent_size=tab -indent_style=tab -insert_final_newline=true -max_line_length=100 -tab_width=4 -trim_trailing_whitespace=true - -[*.{sh,yml,yaml}] -indent_size=2 -indent_style=space - -[*.md] -indent_size=4 -indent_style=space +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 4 diff --git a/.maintain/config/mainnet.sample.yml b/.maintain/config/mainnet.sample.yml deleted file mode 100644 index 3fbf53056..000000000 --- a/.maintain/config/mainnet.sample.yml +++ /dev/null @@ -1,77 +0,0 @@ -encrypted: false -ethereum: - # ethereum json-rpc endpoint - rpc: https://mainnet.infura.io/v3/ - contract: - ring: - # erc20 contract of ring - address: 0x9469d013805bffb7d3debe5e7839237e535ec483 - topics: - # cross transfer topic - - 0xc9dcda609937876978d7e0aa29857cb187aea06ad9e843fd23fd32108da73f10 - kton: - # erc20 contract of kton - address: 0x9f284e1337a815fe77d2ff4ae46544645b20c5ff - topics: - # cross transfer topic - - 0xc9dcda609937876978d7e0aa29857cb187aea06ad9e843fd23fd32108da73f10 - bank: - # gringotts bank contract - address: 0x649fdf6ee483a96e020b889571e93700fbd82d88 - topics: - # cross transfer topic - - 0xe77bf2fa8a25e63c1e5e29e1b2fcb6586d673931e020c4e3ffede453b830fb12 - issuing: - # erc20 ring and kton issuing contract - address: 0xea7938985898af7fd945b03b7bc2e405e744e913 - relay: - # ethereum relay contract for darwinia to ethereum - address: 0x5cde5Aafeb8E06Ce9e4F94c2406d3B6CB7098E49 - topics: - # set authorities topic - - 0x91d6d149c7e5354d1c671fe15a5a3332c47a38e15e8ac0339b24af3c1090690f - # (optional) the person who will relay darwinia data to ethereum - # Disable by removing or commenting - relayer: - # private key of relayer - private_key: 0x... - # the darwinia account public key who will get the reward - # when send authorities to ethereum - beneficiary_darwinia_account: 0x... - # (optional) the person who will ecdsa sign new mmr root or new authority set - # Disable by removing or commenting - authority: - # private key to sign ecdsa messages - # the signature will be submitted to Darwinia by darwinia.relayer - private_key: 0x... - -darwinia: - # darwinia node websocket json-rpc endpoint - rpc: wss://rpc.darwinia.network - # the person who will relay ethereum data to darwinia - relayer: - # private key of relayer, or, private key of proxy - private_key: 0x... - # (optional) real account public key - # allowing `real` account to give permission to `proxy` account to dispatch calls - # The account (32 bytes) that the proxy will make a call on behalf of - # Disable by removing or commenting - real_account: 0x... - -shadow: - # shadow http restful endpoint, refer https://github.com/darwinia-network/shadow - endpoint: https://shadow.darwinia.network - -services: - ethereum: - # ethereum service polling interval in seconds - step: 120 - relay: - # relay service polling interval in seconds - step: 60 - redeem: - # redeem service polling interval in seconds - step: 150 - guard: - # guard service polling interval in seconds - step: 30 diff --git a/.maintain/config/ropsten_crab.sample.yml b/.maintain/config/ropsten_crab.sample.yml deleted file mode 100644 index 4cc950bf0..000000000 --- a/.maintain/config/ropsten_crab.sample.yml +++ /dev/null @@ -1,77 +0,0 @@ -encrypted: false -ethereum: - # ethereum json-rpc endpoint - rpc: https://ropsten.infura.io/v3/ - contract: - ring: - # erc20 contract of ring - address: 0xb52FBE2B925ab79a821b261C82c5Ba0814AAA5e0 - topics: - # cross transfer topic - - 0xc9dcda609937876978d7e0aa29857cb187aea06ad9e843fd23fd32108da73f10 - kton: - # erc20 contract of kton - address: 0x1994100c58753793D52c6f457f189aa3ce9cEe94 - topics: - # cross transfer topic - - 0xc9dcda609937876978d7e0aa29857cb187aea06ad9e843fd23fd32108da73f10 - bank: - # gringotts bank contract - address: 0x6EF538314829EfA8386Fc43386cB13B4e0A67D1e - topics: - # cross transfer topic - - 0xe77bf2fa8a25e63c1e5e29e1b2fcb6586d673931e020c4e3ffede453b830fb12 - issuing: - # erc20 ring and kton issuing contract - address: 0x49262B932E439271d05634c32978294C7Ea15d0C - relay: - # ethereum relay contract for darwinia to ethereum - address: 0xd374292D512281b56198F0401b149370D680b89F - topics: - # set authorities topic - - 0x91d6d149c7e5354d1c671fe15a5a3332c47a38e15e8ac0339b24af3c1090690f - # (optional) the person who will relay darwinia data to ethereum - # Disable by removing or commenting - relayer: - # private key of relayer - private_key: 0x... - # the darwinia account public key who will get the reward - # when send authorities to ethereum - beneficiary_darwinia_account: 0x... - # (optional) the person who will ecdsa sign new mmr root or new authority set - # Disable by removing or commenting - authority: - # private key to sign ecdsa messages - # the signature will be submitted to Darwinia by darwinia.relayer - private_key: 0x... - -darwinia: - # darwinia node websocket json-rpc endpoint - rpc: wss://crab-rpc.darwinia.network - # the person who will relay ethereum data to darwinia - relayer: - # private key of relayer, or, private key of proxy - private_key: 0x... - # (optional) real account public key - # allowing `real` account to give permission to `proxy` account to dispatch calls - # The account (32 bytes) that the proxy will make a call on behalf of - # Disable by removing or commenting - real_account: 0x... - -shadow: - # shadow http restful endpoint, refer https://github.com/darwinia-network/shadow - endpoint: https://testnet.shadow.darwinia.network - -services: - ethereum: - # ethereum service polling interval in seconds - step: 30 - relay: - # relay service polling interval in seconds - step: 60 - redeem: - # redeem service polling interval in seconds - step: 90 - guard: - # guard service polling interval in seconds - step: 30 diff --git a/.maintain/config/ropsten_pangolin.sample.yml b/.maintain/config/ropsten_pangolin.sample.yml deleted file mode 100644 index 6d3e6332b..000000000 --- a/.maintain/config/ropsten_pangolin.sample.yml +++ /dev/null @@ -1,85 +0,0 @@ -encrypted: false -ethereum: - # ethereum json-rpc endpoint - rpc: https://ropsten.infura.io/v3/ - contract: - ring: - # erc20 contract of ring - address: 0xb52FBE2B925ab79a821b261C82c5Ba0814AAA5e0 - topics: - # cross transfer topic - - 0xc9dcda609937876978d7e0aa29857cb187aea06ad9e843fd23fd32108da73f10 - kton: - # erc20 contract of kton - address: 0x1994100c58753793D52c6f457f189aa3ce9cEe94 - topics: - # cross transfer topic - - 0xc9dcda609937876978d7e0aa29857cb187aea06ad9e843fd23fd32108da73f10 - bank: - # gringotts bank contract - address: 0x6EF538314829EfA8386Fc43386cB13B4e0A67D1e - topics: - # cross transfer topic - - 0xe77bf2fa8a25e63c1e5e29e1b2fcb6586d673931e020c4e3ffede453b830fb12 - issuing: - # erc20 ring and kton issuing contract - address: 0x8f889dDC6AF3BF4C8950fB9b1492C0a949686909 - relay: - # ethereum relay contract for darwinia to ethereum - address: 0x524Fa00eBD22DE069553F72d15A1d064e9025713 - topics: - # set authorities topic - - 0x91d6d149c7e5354d1c671fe15a5a3332c47a38e15e8ac0339b24af3c1090690f - backing: - address: "0xd5FC8F2eB94fE6AAdeE91c561818e1fF4ea2C041" - topics: - - "0x0c403c4583ff520bad94bf49975b3547a573f7157070022cf8c9a023498d4d11" - - "0xf70fbddcb43e433da621898f5f2628b0a644a77a4389ac2580c5b1de06382fe2" - # (optional) the person who will relay darwinia data to ethereum - # Disable by removing or commenting - relayer: - # private key of relayer - # alice - private_key: 0xe5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a - # the darwinia account public key who will get the reward - # when send authorities to ethereum - # alice - beneficiary_darwinia_account: 0xd6c71059dbbe9ad2b0ed3f289738b800836eb425544ce694825285b958ca755e - # (optional) the person who will ecdsa sign new mmr root or new authority set - # Disable by removing or commenting - authority: - # private key to sign ecdsa messages - # the signature will be submitted to Darwinia by darwinia.relayer - private_key: 0x8bd012fd2433d4fea852f437d6bb22d1e57dee7657cc1e703460ddeaae1a67ca - -darwinia: - # darwinia node websocket json-rpc endpoint - rpc: wss://pangolin-rpc.darwinia.network - # the person who will relay ethereum data to darwinia - relayer: - # private key of relayer, or, private key of proxy - # alice - private_key: 0xe5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a - # (optional) real account public key - # allowing `real` account to give permission to `proxy` account to dispatch calls - # The account (32 bytes) that the proxy will make a call on behalf of - # Disable by removing or commenting - # real_account: 0x... - -shadow: - # shadow http restful endpoint, refer https://github.com/darwinia-network/shadow - endpoint: https://ropsten.shadow.darwinia.network - -services: - ethereum: - # ethereum service polling interval in seconds - step: 30 - relay: - # relay service polling interval in seconds - step: 60 - redeem: - # redeem service polling interval in seconds - step: 90 - guard: - # guard service polling interval in seconds - step: 30 diff --git a/.maintain/config/task-pangolin-millau.toml b/.maintain/config/task-pangolin-millau.toml new file mode 100644 index 000000000..030fd9d26 --- /dev/null +++ b/.maintain/config/task-pangolin-millau.toml @@ -0,0 +1,14 @@ +[pangolin] +endpoint = "ws://127.0.0.1:23044" +signer = "//Alice" + +[millau] +endpoint = "ws://127.0.0.1:13044" +signer = "//Alice" + +[relay] +lanes = [ "00000000" ] +auto_start = false +signer_pangolin = "//Alice" +signer_millau = "//Millau" +prometheus_params = { no_prometheus = false, prometheus_host = "127.0.0.1", prometheus_port = 9616 } diff --git a/.maintain/systemd/bridger.service.sample b/.maintain/systemd/bridger.service.sample deleted file mode 100644 index 35a4c8f78..000000000 --- a/.maintain/systemd/bridger.service.sample +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Darwinia relayer client and watchtower in rust -After=network.target - -[Service] -ExecStart=/usr/local/bin/bridger -Restart=always -RestartSec=10s - -[Install] -WantedBy=multi-user.target diff --git a/.rustfmt.toml b/.rustfmt.toml index 9305ff16b..b5efea506 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,4 +1,4 @@ -hard_tabs = true +hard_tabs = false max_width = 100 newline_style = "Unix" reorder_imports = true diff --git a/Cargo.lock b/Cargo.lock index 0e2db1630..3901eb74d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,82 +12,6 @@ dependencies = [ "regex", ] -[[package]] -name = "actix" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be241f88f3b1e7e9a3fbe3b5a8a0f6915b5a1d7ee0d9a248d3376d01068cc60" -dependencies = [ - "actix-rt", - "actix_derive", - "bitflags", - "bytes 0.5.6", - "crossbeam-channel 0.4.4", - "derive_more", - "futures-channel", - "futures-util", - "log", - "once_cell", - "parking_lot 0.11.1", - "pin-project 0.4.28", - "smallvec", - "tokio 0.2.25", - "tokio-util 0.3.1", - "trust-dns-proto", - "trust-dns-resolver", -] - -[[package]] -name = "actix-macros" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ca8ce00b267af8ccebbd647de0d61e0674b6e61185cc7a592ff88772bed655" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "actix-rt" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143fcc2912e0d1de2bcf4e2f720d2a60c28652ab4179685a1ee159e0fb3db227" -dependencies = [ - "actix-macros", - "actix-threadpool", - "copyless", - "futures-channel", - "futures-util", - "smallvec", - "tokio 0.2.25", -] - -[[package]] -name = "actix-threadpool" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d209f04d002854b9afd3743032a27b066158817965bf5d036824d19ac2cc0e30" -dependencies = [ - "derive_more", - "futures-channel", - "lazy_static", - "log", - "num_cpus", - "parking_lot 0.11.1", - "threadpool", -] - -[[package]] -name = "actix_derive" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b95aceadaf327f18f0df5962fedc1bde2f870566a0b9f65c89508a3b1f79334c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "addr2line" version = "0.15.2" @@ -289,16 +213,6 @@ dependencies = [ "event-listener", ] -[[package]] -name = "async-macros" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644a5a8de80f2085a1e7e57cd1544a2a7438f6e003c0790999bd43b92a77cdb2" -dependencies = [ - "futures-core", - "pin-utils", -] - [[package]] name = "async-mutex" version = "1.4.0" @@ -348,7 +262,7 @@ dependencies = [ "async-io", "async-lock", "async-process", - "crossbeam-utils 0.8.5", + "crossbeam-utils", "futures-channel", "futures-core", "futures-io", @@ -684,27 +598,6 @@ dependencies = [ "sp-std 3.0.0 (git+https://github.com/darwinia-network/substrate.git?branch=main)", ] -[[package]] -name = "bridge-client-darwinia" -version = "0.1.0" -dependencies = [ - "anyhow", - "array-bytes", - "darwinia-bridge-primitives", - "jsonrpsee-http-client", - "jsonrpsee-types", - "jsonrpsee-ws-client", - "log", - "parity-scale-codec", - "secp256k1", - "serde 1.0.126", - "serde_json", - "sp-keyring 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-subxt", - "thiserror", - "web3", -] - [[package]] name = "bridge-primitives" version = "0.3.3" @@ -742,7 +635,7 @@ version = "0.3.3" dependencies = [ "anyhow", "async-trait", - "config 0.11.0", + "config", "futures 0.3.15", "lifeline", "log", @@ -1137,22 +1030,6 @@ dependencies = [ "cache-padded", ] -[[package]] -name = "config" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b076e143e1d9538dde65da30f8481c2a6c44040edb8e02b9bf1351edb92ce3" -dependencies = [ - "lazy_static", - "nom", - "rust-ini", - "serde 1.0.126", - "serde-hjson", - "serde_json", - "toml", - "yaml-rust", -] - [[package]] name = "config" version = "0.11.0" @@ -1187,12 +1064,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" -[[package]] -name = "copyless" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2df960f5d869b2dd8532793fde43eb5427cceb126c929747a26823ab0eeb536" - [[package]] name = "core-foundation" version = "0.9.1" @@ -1218,16 +1089,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crossbeam-channel" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" -dependencies = [ - "crossbeam-utils 0.7.2", - "maybe-uninit", -] - [[package]] name = "crossbeam-channel" version = "0.5.1" @@ -1235,7 +1096,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.5", + "crossbeam-utils", ] [[package]] @@ -1246,7 +1107,7 @@ checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" dependencies = [ "cfg-if 1.0.0", "crossbeam-epoch", - "crossbeam-utils 0.8.5", + "crossbeam-utils", ] [[package]] @@ -1256,7 +1117,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.5", + "crossbeam-utils", "lazy_static", "memoffset", "scopeguard", @@ -1269,18 +1130,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b10ddc024425c88c2ad148c1b0fd53f4c6d38db9697c9f1588381212fa657c9" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils 0.8.5", -] - -[[package]] -name = "crossbeam-utils" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg", - "cfg-if 0.1.10", - "lazy_static", + "crossbeam-utils", ] [[package]] @@ -1437,67 +1287,6 @@ dependencies = [ "sp-std 3.0.0 (git+https://github.com/darwinia-network/substrate.git?branch=main)", ] -[[package]] -name = "darwinia-bridge-primitives" -version = "0.3.3" -dependencies = [ - "async-trait", - "frame-support 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pallet-im-online 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pallet-indices", - "parity-scale-codec", - "reqwest 0.10.10", - "rlp 0.4.6", - "serde 1.0.126", - "serde_json", - "substrate-subxt", - "substrate-subxt-proc-macro", - "thiserror", - "tokio 0.2.25", - "uint 0.8.5", -] - -[[package]] -name = "darwinia-bridger" -version = "0.3.3" -dependencies = [ - "actix", - "actix-rt", - "anyhow", - "array-bytes", - "async-io", - "async-macros", - "async-trait", - "base64 0.13.0", - "bridge-client-darwinia", - "colored", - "config 0.10.1", - "darwinia-bridge-primitives", - "dirs", - "env_logger 0.7.1", - "etc", - "futures 0.3.15", - "jsonrpsee-http-client", - "jsonrpsee-types", - "jsonrpsee-ws-client", - "log", - "parity-scale-codec", - "reqwest 0.10.10", - "rpassword", - "rust-crypto", - "secp256k1", - "serde 1.0.126", - "serde_json", - "serde_yaml", - "sp-keyring 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-version 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt", - "substrate-subxt", - "thiserror", - "tokio 0.2.25", - "web3", -] - [[package]] name = "darwinia-claims" version = "2.5.0" @@ -2007,26 +1796,6 @@ dependencies = [ "generic-array 0.14.4", ] -[[package]] -name = "dirs" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" -dependencies = [ - "libc", - "redox_users", - "winapi 0.3.9", -] - [[package]] name = "discard" version = "1.0.4" @@ -2242,18 +2011,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "enum-as-inner" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c5f0096a91d210159eceb2ff5e1c4da18388a170e1e3ce948aac9c8fdbbf595" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "enumflags2" version = "0.6.4" @@ -2315,12 +2072,6 @@ dependencies = [ "serde 1.0.126", ] -[[package]] -name = "etc" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f7935cc590ee512e8073c4fe82b85e056216324e65aed24459204e3f6d9f72e" - [[package]] name = "ethabi" version = "13.0.0" @@ -3027,12 +2778,6 @@ dependencies = [ "sp-std 3.0.0 (git+https://github.com/darwinia-network/substrate.git?branch=main)", ] -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -3178,12 +2923,6 @@ dependencies = [ "slab", ] -[[package]] -name = "gcc" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" - [[package]] name = "generic-array" version = "0.12.4" @@ -3350,7 +3089,7 @@ dependencies = [ "async-trait", "backoff", "futures 0.3.15", - "linked-hash-map 0.5.4", + "linked-hash-map", "log", "num-traits 0.2.14", "parking_lot 0.11.1", @@ -3423,17 +3162,6 @@ 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 0.3.9", -] - [[package]] name = "http" version = "0.2.4" @@ -3688,18 +3416,6 @@ dependencies = [ "libc", ] -[[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 0.3.9", - "winreg 0.6.2", -] - [[package]] name = "ipnet" version = "2.3.1" @@ -3713,7 +3429,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81c01404730bb4574bbacb59ca0855f969f8eabd688ca22866f2cc333f1a4f69" dependencies = [ "async-channel", - "crossbeam-utils 0.8.5", + "crossbeam-utils", "curl", "curl-sys", "encoding_rs", @@ -4229,16 +3945,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "linked-hash-map" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd" -dependencies = [ - "serde 0.8.23", - "serde_test", -] - [[package]] name = "linked-hash-map" version = "0.5.4" @@ -4309,21 +4015,6 @@ dependencies = [ "hashbrown 0.9.1", ] -[[package]] -name = "lru-cache" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" -dependencies = [ - "linked-hash-map 0.5.4", -] - -[[package]] -name = "match_cfg" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" - [[package]] name = "matchers" version = "0.0.1" @@ -4348,12 +4039,6 @@ dependencies = [ "rawpointer", ] -[[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.0" @@ -4575,29 +4260,6 @@ dependencies = [ "slab", ] -[[package]] -name = "mio-named-pipes" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" -dependencies = [ - "log", - "mio 0.6.23", - "miow 0.3.7", - "winapi 0.3.9", -] - -[[package]] -name = "mio-uds" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" -dependencies = [ - "iovec", - "libc", - "mio 0.6.23", -] - [[package]] name = "miow" version = "0.2.2" @@ -6137,29 +5799,6 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" -[[package]] -name = "rand" -version = "0.3.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" -dependencies = [ - "libc", - "rand 0.4.6", -] - -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi 0.3.9", -] - [[package]] name = "rand" version = "0.7.3" @@ -6206,21 +5845,6 @@ dependencies = [ "rand_core 0.6.3", ] -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.5.1" @@ -6300,22 +5924,13 @@ version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" dependencies = [ - "crossbeam-channel 0.5.1", + "crossbeam-channel", "crossbeam-deque", - "crossbeam-utils 0.8.5", + "crossbeam-utils", "lazy_static", "num_cpus", ] -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "redox_syscall" version = "0.1.57" @@ -6331,16 +5946,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "redox_users" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" -dependencies = [ - "getrandom 0.2.3", - "redox_syscall 0.2.9", -] - [[package]] name = "ref-cast" version = "1.0.6" @@ -6483,7 +6088,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg 0.7.0", + "winreg", ] [[package]] @@ -6518,17 +6123,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg 0.7.0", -] - -[[package]] -name = "resolv-conf" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" -dependencies = [ - "hostname", - "quick-error", + "winreg", ] [[package]] @@ -6600,29 +6195,6 @@ dependencies = [ "regex", ] -[[package]] -name = "rpassword" -version = "5.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc936cf8a7ea60c58f030fd36a612a48f440610214dc54bc36431f9ea0c3efb" -dependencies = [ - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "rust-crypto" -version = "0.2.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" -dependencies = [ - "gcc", - "libc", - "rand 0.3.23", - "rustc-serialize", - "time 0.1.43", -] - [[package]] name = "rust-ini" version = "0.13.0" @@ -6647,12 +6219,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" -[[package]] -name = "rustc-serialize" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" - [[package]] name = "rustc_version" version = "0.2.3" @@ -6936,7 +6502,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a3a4e0ea8a88553209f6cc6cfe8724ecad22e1acf372793c27d995290fe74f8" dependencies = [ "lazy_static", - "linked-hash-map 0.3.0", "num-traits 0.1.43", "regex", "serde 0.8.23", @@ -6965,15 +6530,6 @@ dependencies = [ "serde 1.0.126", ] -[[package]] -name = "serde_test" -version = "0.8.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "110b3dbdf8607ec493c22d5d947753282f3bae73c0f56d322af1e8c78e4c23d5" -dependencies = [ - "serde 0.8.23", -] - [[package]] name = "serde_urlencoded" version = "0.7.0" @@ -6993,7 +6549,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15654ed4ab61726bf918a39cb8d98a2e2995b002387807fa6ba58fdf7f59bb23" dependencies = [ "dtoa", - "linked-hash-map 0.5.4", + "linked-hash-map", "serde 1.0.126", "yaml-rust", ] @@ -9243,15 +8799,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "threadpool" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" -dependencies = [ - "num_cpus", -] - [[package]] name = "time" version = "0.1.43" @@ -9353,17 +8900,10 @@ dependencies = [ "futures-core", "iovec", "lazy_static", - "libc", "memchr", "mio 0.6.23", - "mio-named-pipes", - "mio-uds", - "num_cpus", "pin-project-lite 0.1.12", - "signal-hook-registry", "slab", - "tokio-macros 0.2.6", - "winapi 0.3.9", ] [[package]] @@ -9382,21 +8922,10 @@ dependencies = [ "parking_lot 0.11.1", "pin-project-lite 0.2.7", "signal-hook-registry", - "tokio-macros 1.3.0", + "tokio-macros", "winapi 0.3.9", ] -[[package]] -name = "tokio-macros" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "tokio-macros" version = "1.3.0" @@ -9458,7 +8987,6 @@ checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" dependencies = [ "bytes 0.5.6", "futures-core", - "futures-io", "futures-sink", "log", "pin-project-lite 0.1.12", @@ -9613,45 +9141,6 @@ dependencies = [ "rlp 0.5.0", ] -[[package]] -name = "trust-dns-proto" -version = "0.19.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cad71a0c0d68ab9941d2fb6e82f8fb2e86d9945b94e1661dd0aaea2b88215a9" -dependencies = [ - "async-trait", - "cfg-if 1.0.0", - "enum-as-inner", - "futures 0.3.15", - "idna 0.2.3", - "lazy_static", - "log", - "rand 0.7.3", - "smallvec", - "thiserror", - "tokio 0.2.25", - "url 2.2.2", -] - -[[package]] -name = "trust-dns-resolver" -version = "0.19.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "710f593b371175db53a26d0b38ed2978fafb9e9e8d3868b1acd753ea18df0ceb" -dependencies = [ - "cfg-if 0.1.10", - "futures 0.3.15", - "ipconfig", - "lazy_static", - "log", - "lru-cache", - "resolv-conf", - "smallvec", - "thiserror", - "tokio 0.2.25", - "trust-dns-proto", -] - [[package]] name = "try-lock" version = "0.2.3" @@ -10084,12 +9573,6 @@ dependencies = [ "libc", ] -[[package]] -name = "widestring" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" - [[package]] name = "winapi" version = "0.2.8" @@ -10133,15 +9616,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "winreg" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "winreg" version = "0.7.0" @@ -10192,7 +9666,7 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" dependencies = [ - "linked-hash-map 0.5.4", + "linked-hash-map", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 388eb213f..2d4bf39c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,13 +1,11 @@ [workspace] members = [ "primitives", - "darwinia", - "provider/darwinia-bridger", - "bridger/bin", - "bridger/components/*", - "bridger/primitives", - "bridger/supports/*", - "bridger/task/*", - "bridger/traits", + "bin", + "components/*", + "primitives", + "supports/*", + "task/*", + "traits", ] diff --git a/bridger/bin/Cargo.toml b/bin/Cargo.toml similarity index 100% rename from bridger/bin/Cargo.toml rename to bin/Cargo.toml diff --git a/bridger/bin/src/handler/handle_kv.rs b/bin/src/handler/handle_kv.rs similarity index 100% rename from bridger/bin/src/handler/handle_kv.rs rename to bin/src/handler/handle_kv.rs diff --git a/bridger/bin/src/handler/handle_server.rs b/bin/src/handler/handle_server.rs similarity index 100% rename from bridger/bin/src/handler/handle_server.rs rename to bin/src/handler/handle_server.rs diff --git a/bridger/bin/src/handler/handle_task.rs b/bin/src/handler/handle_task.rs similarity index 100% rename from bridger/bin/src/handler/handle_task.rs rename to bin/src/handler/handle_task.rs diff --git a/bridger/bin/src/handler/mod.rs b/bin/src/handler/mod.rs similarity index 100% rename from bridger/bin/src/handler/mod.rs rename to bin/src/handler/mod.rs diff --git a/bridger/bin/src/initialize.rs b/bin/src/initialize.rs similarity index 100% rename from bridger/bin/src/initialize.rs rename to bin/src/initialize.rs diff --git a/bridger/bin/src/main.rs b/bin/src/main.rs similarity index 100% rename from bridger/bin/src/main.rs rename to bin/src/main.rs diff --git a/bridger/bin/src/patch/bridger.rs b/bin/src/patch/bridger.rs similarity index 100% rename from bridger/bin/src/patch/bridger.rs rename to bin/src/patch/bridger.rs diff --git a/bridger/bin/src/patch/hyper.rs b/bin/src/patch/hyper.rs similarity index 100% rename from bridger/bin/src/patch/hyper.rs rename to bin/src/patch/hyper.rs diff --git a/bridger/bin/src/patch/mod.rs b/bin/src/patch/mod.rs similarity index 100% rename from bridger/bin/src/patch/mod.rs rename to bin/src/patch/mod.rs diff --git a/bridger/bin/src/route/kv.rs b/bin/src/route/kv.rs similarity index 100% rename from bridger/bin/src/route/kv.rs rename to bin/src/route/kv.rs diff --git a/bridger/bin/src/route/mod.rs b/bin/src/route/mod.rs similarity index 100% rename from bridger/bin/src/route/mod.rs rename to bin/src/route/mod.rs diff --git a/bridger/bin/src/route/task.rs b/bin/src/route/task.rs similarity index 100% rename from bridger/bin/src/route/task.rs rename to bin/src/route/task.rs diff --git a/bridger/bin/src/route/task_manager.rs b/bin/src/route/task_manager.rs similarity index 100% rename from bridger/bin/src/route/task_manager.rs rename to bin/src/route/task_manager.rs diff --git a/bridger/bin/src/types/command.rs b/bin/src/types/command.rs similarity index 100% rename from bridger/bin/src/types/command.rs rename to bin/src/types/command.rs diff --git a/bridger/bin/src/types/mod.rs b/bin/src/types/mod.rs similarity index 100% rename from bridger/bin/src/types/mod.rs rename to bin/src/types/mod.rs diff --git a/bridger/bin/src/types/server.rs b/bin/src/types/server.rs similarity index 100% rename from bridger/bin/src/types/server.rs rename to bin/src/types/server.rs diff --git a/bridger/bin/src/types/transfer.rs b/bin/src/types/transfer.rs similarity index 100% rename from bridger/bin/src/types/transfer.rs rename to bin/src/types/transfer.rs diff --git a/bridger/.editorconfig b/bridger/.editorconfig deleted file mode 100644 index 9fb23ce69..000000000 --- a/bridger/.editorconfig +++ /dev/null @@ -1,13 +0,0 @@ -# EditorConfig helps developers define and maintain consistent -# coding styles between different editors and IDEs -# editorconfig.org - -root = true - -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true -indent_style = space -indent_size = 4 diff --git a/bridger/.rustfmt.toml b/bridger/.rustfmt.toml deleted file mode 100644 index b5efea506..000000000 --- a/bridger/.rustfmt.toml +++ /dev/null @@ -1,7 +0,0 @@ -hard_tabs = false -max_width = 100 -newline_style = "Unix" -reorder_imports = true -reorder_modules = true -tab_spaces = 4 -use_field_init_shorthand = true diff --git a/bridger/primitives/Cargo.toml b/bridger/primitives/Cargo.toml deleted file mode 100644 index 5b42b5dd0..000000000 --- a/bridger/primitives/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "bridge-primitives" -version = "0.3.3" -authors = ["Darwinia Network "] -description = "Darwinia bridger" -repository = "https://github.com/darwinia-network/bridger" -license = "MIT" -documentation = "https://docs.rs/bridger" -homepage = "https://github.com/darwinia-network/bridger" -include = [ - "Cargo.toml", - "**/*.rs", - "README.md", - "LICENSE" -] -keywords = ["substrate", "darwinia"] -readme = 'README.md' -edition = "2018" - -[dependencies] - -uint = "0.8.5" -rlp = "0.4.4" - -serde = { version = "1", features = ["derive"] } -codec = { package = "parity-scale-codec", version = "2.1", features = ["derive", "full"] } diff --git a/bridger/primitives/src/array.rs b/bridger/primitives/src/array.rs deleted file mode 100644 index bf360c0fe..000000000 --- a/bridger/primitives/src/array.rs +++ /dev/null @@ -1,65 +0,0 @@ -//! Custom byte array - -use std::{ - fmt::{self, Debug, Display, Formatter, Result as FmtResult}, - marker::PhantomData, -}; - -use codec::{Decode, Encode}; -use serde::{ - de::{Deserialize, Deserializer, Error, SeqAccess, Visitor}, - ser::{Serialize, SerializeTuple, Serializer}, -}; -use uint::construct_uint; - -/// Big Array Serde -pub trait BigArray<'de>: Sized { - /// Serialize big array - fn serialize(&self, serializer: S) -> Result - where - S: Serializer; - /// Deserialize big array - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>; -} - -// shared -construct_uint! { - #[derive(Encode, Decode, Serialize, Deserialize)] - pub struct U256(4); -} - -crate::construct_hash_bytes! { - #[derive(Clone)] - pub struct H128(16); -} - -crate::construct_hash_bytes! { - #[derive(Clone)] - pub struct H160(20); -} - -crate::construct_hash_bytes! { - #[derive(Clone)] - pub struct H256(32); -} - -crate::construct_hash_bytes! { - #[derive(Clone)] - pub struct H512(64); -} - -crate::construct_hash_bytes! { - #[derive(Clone)] - pub struct H1024(128); -} - -crate::construct_hash_bytes! { - #[derive(Clone)] - pub struct Bloom(256); -} - -crate::impl_hash_rlp!(Bloom, 256); -crate::impl_hash_rlp!(H256, 32); -crate::impl_hash_rlp!(H160, 20); diff --git a/bridger/primitives/src/byte.rs b/bridger/primitives/src/byte.rs deleted file mode 100644 index 2e253b092..000000000 --- a/bridger/primitives/src/byte.rs +++ /dev/null @@ -1,168 +0,0 @@ -#![macro_use] - -/// Doc with expr -#[macro_export] -macro_rules! doc_comment { - ($x:expr, $($tt:tt)*) => { - #[doc = $x] - $($tt)* - }; -} - -/// Convert bytes to hex -#[macro_export] -macro_rules! hex { - ($bytes:expr) => {{ - let mut s = String::new(); - for i in $bytes { - s.push_str(&format!("{:02x}", i)); - } - s - }}; -} - -/// Convert hex string to `Vec` or `[u8; n]` -#[macro_export] -macro_rules! bytes { - // Convert hex to Vec - ($hex:expr) => {{ - let mut h = $hex; - if h.starts_with("0x") { - h = &h[2..]; - } - - (0..h.len()) - .step_by(2) - .map(|i| u8::from_str_radix(&h[i..i + 2], 16)) - .collect::, _>>() - .unwrap_or_default() - }}; - - // Convert hex to [u8; $bits] - ($hex:expr, $bits:expr) => {{ - let mut hash = [0_u8; $bits]; - hash.copy_from_slice(&bytes!($hex)); - hash - }}; -} - -/// Implement serde for big array -#[macro_export] -macro_rules! serde_array { - ($len:expr) => { - impl<'de, T> BigArray<'de> for [T; $len] - where - T: Default + Copy + Serialize + Deserialize<'de>, - { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut seq = serializer.serialize_tuple(self.len())?; - for elem in &self[..] { - seq.serialize_element(elem)?; - } - seq.end() - } - - fn deserialize(deserializer: D) -> Result<[T; $len], D::Error> - where - D: Deserializer<'de>, - { - struct ArrayVisitor { - element: PhantomData, - } - - impl<'de, T> Visitor<'de> for ArrayVisitor - where - T: Default + Copy + Deserialize<'de>, - { - type Value = [T; $len]; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str(concat!("an array of length ", $len)) - } - - fn visit_seq(self, mut seq: A) -> Result<[T; $len], A::Error> - where - A: SeqAccess<'de>, - { - let mut arr = [T::default(); $len]; - for i in 0..$len { - arr[i] = seq - .next_element()? - .ok_or_else(|| Error::invalid_length(i, &self))?; - } - Ok(arr) - } - } - - let visitor = ArrayVisitor { - element: PhantomData, - }; - deserializer.deserialize_tuple($len, visitor) - } - } - }; -} - -/// Construct hash bytes -#[macro_export] -macro_rules! construct_hash_bytes { - ( $(#[$attr:meta])* $visibility:vis struct $name:ident ( $len:tt ); ) => { - crate::serde_array!($len); - - crate::doc_comment!{ - concat!("The ", stringify!($len), "-bit hash type."), - $(#[$attr])* - #[derive(Decode, Encode, Serialize, Deserialize)] - $visibility struct $name ( - #[serde(with = "BigArray")] - pub [u8; $len] - ); - } - - impl Display for $name { - fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { - f.write_str(&crate::hex!(self.0.as_ref())) - } - } - - impl Debug for $name { - fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { - f.debug_list().entries(self.0.iter()).finish() - } - } - - impl Default for $name { - fn default() -> $name { - $name([0; $len]) - } - } - - impl PartialEq for $name { - fn eq(&self, other: &Self) -> bool { - for i in 0..self.0.len() { - if self.0[i] != other.0[i] { - return false; - } - } - true - } - } - - impl Eq for $name {} - }; -} - -/// Add RLP serialization support to a hash type. -#[macro_export] -macro_rules! impl_hash_rlp { - ($name: ident, $size: expr) => { - impl rlp::Encodable for $name { - fn rlp_append(&self, s: &mut rlp::RlpStream) { - s.encoder().encode_value(&self.0); - } - } - }; -} diff --git a/bridger/primitives/src/lib.rs b/bridger/primitives/src/lib.rs deleted file mode 100644 index 8d340f515..000000000 --- a/bridger/primitives/src/lib.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![allow(clippy::ptr_offset_with_cast)] -#![allow(clippy::assign_op_pattern)] -#![allow(clippy::manual_range_contains)] - -#[macro_use] -extern crate serde; - -pub mod array; -pub mod byte; diff --git a/bridger/components/client-darwinia-subxt/Cargo.toml b/components/client-darwinia-subxt/Cargo.toml similarity index 100% rename from bridger/components/client-darwinia-subxt/Cargo.toml rename to components/client-darwinia-subxt/Cargo.toml diff --git a/bridger/components/client-darwinia-subxt/src/account.rs b/components/client-darwinia-subxt/src/account.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/account.rs rename to components/client-darwinia-subxt/src/account.rs diff --git a/bridger/components/client-darwinia-subxt/src/component.rs b/components/client-darwinia-subxt/src/component.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/component.rs rename to components/client-darwinia-subxt/src/component.rs diff --git a/bridger/components/client-darwinia-subxt/src/config.rs b/components/client-darwinia-subxt/src/config.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/config.rs rename to components/client-darwinia-subxt/src/config.rs diff --git a/bridger/components/client-darwinia-subxt/src/darwinia/client.rs b/components/client-darwinia-subxt/src/darwinia/client.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/darwinia/client.rs rename to components/client-darwinia-subxt/src/darwinia/client.rs diff --git a/bridger/components/client-darwinia-subxt/src/darwinia/mod.rs b/components/client-darwinia-subxt/src/darwinia/mod.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/darwinia/mod.rs rename to components/client-darwinia-subxt/src/darwinia/mod.rs diff --git a/bridger/components/client-darwinia-subxt/src/darwinia/runtime.rs b/components/client-darwinia-subxt/src/darwinia/runtime.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/darwinia/runtime.rs rename to components/client-darwinia-subxt/src/darwinia/runtime.rs diff --git a/bridger/components/client-darwinia-subxt/src/error.rs b/components/client-darwinia-subxt/src/error.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/error.rs rename to components/client-darwinia-subxt/src/error.rs diff --git a/bridger/components/client-darwinia-subxt/src/events/darwinia_events.rs b/components/client-darwinia-subxt/src/events/darwinia_events.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/events/darwinia_events.rs rename to components/client-darwinia-subxt/src/events/darwinia_events.rs diff --git a/bridger/components/client-darwinia-subxt/src/events/mod.rs b/components/client-darwinia-subxt/src/events/mod.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/events/mod.rs rename to components/client-darwinia-subxt/src/events/mod.rs diff --git a/bridger/components/client-darwinia-subxt/src/frame/bridge/mod.rs b/components/client-darwinia-subxt/src/frame/bridge/mod.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/frame/bridge/mod.rs rename to components/client-darwinia-subxt/src/frame/bridge/mod.rs diff --git a/bridger/components/client-darwinia-subxt/src/frame/bridge/relay_authorities.rs b/components/client-darwinia-subxt/src/frame/bridge/relay_authorities.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/frame/bridge/relay_authorities.rs rename to components/client-darwinia-subxt/src/frame/bridge/relay_authorities.rs diff --git a/bridger/components/client-darwinia-subxt/src/frame/ethereum/backing.rs b/components/client-darwinia-subxt/src/frame/ethereum/backing.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/frame/ethereum/backing.rs rename to components/client-darwinia-subxt/src/frame/ethereum/backing.rs diff --git a/bridger/components/client-darwinia-subxt/src/frame/ethereum/game.rs b/components/client-darwinia-subxt/src/frame/ethereum/game.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/frame/ethereum/game.rs rename to components/client-darwinia-subxt/src/frame/ethereum/game.rs diff --git a/bridger/components/client-darwinia-subxt/src/frame/ethereum/issuing.rs b/components/client-darwinia-subxt/src/frame/ethereum/issuing.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/frame/ethereum/issuing.rs rename to components/client-darwinia-subxt/src/frame/ethereum/issuing.rs diff --git a/bridger/components/client-darwinia-subxt/src/frame/ethereum/mod.rs b/components/client-darwinia-subxt/src/frame/ethereum/mod.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/frame/ethereum/mod.rs rename to components/client-darwinia-subxt/src/frame/ethereum/mod.rs diff --git a/bridger/components/client-darwinia-subxt/src/frame/ethereum/relay.rs b/components/client-darwinia-subxt/src/frame/ethereum/relay.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/frame/ethereum/relay.rs rename to components/client-darwinia-subxt/src/frame/ethereum/relay.rs diff --git a/bridger/components/client-darwinia-subxt/src/frame/mod.rs b/components/client-darwinia-subxt/src/frame/mod.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/frame/mod.rs rename to components/client-darwinia-subxt/src/frame/mod.rs diff --git a/bridger/components/client-darwinia-subxt/src/frame/proxy.rs b/components/client-darwinia-subxt/src/frame/proxy.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/frame/proxy.rs rename to components/client-darwinia-subxt/src/frame/proxy.rs diff --git a/bridger/components/client-darwinia-subxt/src/frame/sudo.rs b/components/client-darwinia-subxt/src/frame/sudo.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/frame/sudo.rs rename to components/client-darwinia-subxt/src/frame/sudo.rs diff --git a/bridger/components/client-darwinia-subxt/src/frame/technical_committee.rs b/components/client-darwinia-subxt/src/frame/technical_committee.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/frame/technical_committee.rs rename to components/client-darwinia-subxt/src/frame/technical_committee.rs diff --git a/bridger/components/client-darwinia-subxt/src/from_ethereum/account.rs b/components/client-darwinia-subxt/src/from_ethereum/account.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/from_ethereum/account.rs rename to components/client-darwinia-subxt/src/from_ethereum/account.rs diff --git a/bridger/components/client-darwinia-subxt/src/from_ethereum/api.rs b/components/client-darwinia-subxt/src/from_ethereum/api.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/from_ethereum/api.rs rename to components/client-darwinia-subxt/src/from_ethereum/api.rs diff --git a/bridger/components/client-darwinia-subxt/src/from_ethereum/mod.rs b/components/client-darwinia-subxt/src/from_ethereum/mod.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/from_ethereum/mod.rs rename to components/client-darwinia-subxt/src/from_ethereum/mod.rs diff --git a/bridger/components/client-darwinia-subxt/src/lib.rs b/components/client-darwinia-subxt/src/lib.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/lib.rs rename to components/client-darwinia-subxt/src/lib.rs diff --git a/bridger/components/client-darwinia-subxt/src/rpc/header_mmr.rs b/components/client-darwinia-subxt/src/rpc/header_mmr.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/rpc/header_mmr.rs rename to components/client-darwinia-subxt/src/rpc/header_mmr.rs diff --git a/bridger/components/client-darwinia-subxt/src/rpc/mod.rs b/components/client-darwinia-subxt/src/rpc/mod.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/rpc/mod.rs rename to components/client-darwinia-subxt/src/rpc/mod.rs diff --git a/bridger/components/client-darwinia-subxt/src/to_ethereum/account.rs b/components/client-darwinia-subxt/src/to_ethereum/account.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/to_ethereum/account.rs rename to components/client-darwinia-subxt/src/to_ethereum/account.rs diff --git a/bridger/components/client-darwinia-subxt/src/to_ethereum/api.rs b/components/client-darwinia-subxt/src/to_ethereum/api.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/to_ethereum/api.rs rename to components/client-darwinia-subxt/src/to_ethereum/api.rs diff --git a/bridger/components/client-darwinia-subxt/src/to_ethereum/mod.rs b/components/client-darwinia-subxt/src/to_ethereum/mod.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/to_ethereum/mod.rs rename to components/client-darwinia-subxt/src/to_ethereum/mod.rs diff --git a/bridger/components/client-darwinia-subxt/src/types.rs b/components/client-darwinia-subxt/src/types.rs similarity index 100% rename from bridger/components/client-darwinia-subxt/src/types.rs rename to components/client-darwinia-subxt/src/types.rs diff --git a/bridger/components/client-darwinia/Cargo.toml b/components/client-darwinia/Cargo.toml similarity index 100% rename from bridger/components/client-darwinia/Cargo.toml rename to components/client-darwinia/Cargo.toml diff --git a/bridger/components/client-darwinia/src/component.rs b/components/client-darwinia/src/component.rs similarity index 100% rename from bridger/components/client-darwinia/src/component.rs rename to components/client-darwinia/src/component.rs diff --git a/bridger/components/client-darwinia/src/config.rs b/components/client-darwinia/src/config.rs similarity index 100% rename from bridger/components/client-darwinia/src/config.rs rename to components/client-darwinia/src/config.rs diff --git a/bridger/components/client-darwinia/src/darwinia.rs b/components/client-darwinia/src/darwinia.rs similarity index 100% rename from bridger/components/client-darwinia/src/darwinia.rs rename to components/client-darwinia/src/darwinia.rs diff --git a/bridger/components/client-darwinia/src/lib.rs b/components/client-darwinia/src/lib.rs similarity index 100% rename from bridger/components/client-darwinia/src/lib.rs rename to components/client-darwinia/src/lib.rs diff --git a/bridger/components/client-darwinia/src/types.rs b/components/client-darwinia/src/types.rs similarity index 100% rename from bridger/components/client-darwinia/src/types.rs rename to components/client-darwinia/src/types.rs diff --git a/bridger/components/client-millau/Cargo.toml b/components/client-millau/Cargo.toml similarity index 100% rename from bridger/components/client-millau/Cargo.toml rename to components/client-millau/Cargo.toml diff --git a/bridger/components/client-millau/src/lib.rs b/components/client-millau/src/lib.rs similarity index 100% rename from bridger/components/client-millau/src/lib.rs rename to components/client-millau/src/lib.rs diff --git a/bridger/components/client-pangolin/Cargo.toml b/components/client-pangolin/Cargo.toml similarity index 100% rename from bridger/components/client-pangolin/Cargo.toml rename to components/client-pangolin/Cargo.toml diff --git a/bridger/components/client-pangolin/src/lib.rs b/components/client-pangolin/src/lib.rs similarity index 100% rename from bridger/components/client-pangolin/src/lib.rs rename to components/client-pangolin/src/lib.rs diff --git a/bridger/components/ethereum/Cargo.toml b/components/ethereum/Cargo.toml similarity index 100% rename from bridger/components/ethereum/Cargo.toml rename to components/ethereum/Cargo.toml diff --git a/bridger/components/ethereum/src/config.rs b/components/ethereum/src/config.rs similarity index 100% rename from bridger/components/ethereum/src/config.rs rename to components/ethereum/src/config.rs diff --git a/bridger/components/ethereum/src/error.rs b/components/ethereum/src/error.rs similarity index 100% rename from bridger/components/ethereum/src/error.rs rename to components/ethereum/src/error.rs diff --git a/bridger/components/ethereum/src/ethereum_rpc/block.rs b/components/ethereum/src/ethereum_rpc/block.rs similarity index 100% rename from bridger/components/ethereum/src/ethereum_rpc/block.rs rename to components/ethereum/src/ethereum_rpc/block.rs diff --git a/bridger/components/ethereum/src/ethereum_rpc/mod.rs b/components/ethereum/src/ethereum_rpc/mod.rs similarity index 100% rename from bridger/components/ethereum/src/ethereum_rpc/mod.rs rename to components/ethereum/src/ethereum_rpc/mod.rs diff --git a/bridger/components/ethereum/src/ethereum_rpc/receipt.rs b/components/ethereum/src/ethereum_rpc/receipt.rs similarity index 100% rename from bridger/components/ethereum/src/ethereum_rpc/receipt.rs rename to components/ethereum/src/ethereum_rpc/receipt.rs diff --git a/bridger/components/ethereum/src/ethereum_rpc/rpc.rs b/components/ethereum/src/ethereum_rpc/rpc.rs similarity index 100% rename from bridger/components/ethereum/src/ethereum_rpc/rpc.rs rename to components/ethereum/src/ethereum_rpc/rpc.rs diff --git a/bridger/components/ethereum/src/lib.rs b/components/ethereum/src/lib.rs similarity index 100% rename from bridger/components/ethereum/src/lib.rs rename to components/ethereum/src/lib.rs diff --git a/bridger/components/ethereum/src/web3.rs b/components/ethereum/src/web3.rs similarity index 100% rename from bridger/components/ethereum/src/web3.rs rename to components/ethereum/src/web3.rs diff --git a/bridger/components/http-client/Cargo.toml b/components/http-client/Cargo.toml similarity index 100% rename from bridger/components/http-client/Cargo.toml rename to components/http-client/Cargo.toml diff --git a/bridger/components/http-client/src/lib.rs b/components/http-client/src/lib.rs similarity index 100% rename from bridger/components/http-client/src/lib.rs rename to components/http-client/src/lib.rs diff --git a/bridger/components/shadow/Cargo.toml b/components/shadow/Cargo.toml similarity index 100% rename from bridger/components/shadow/Cargo.toml rename to components/shadow/Cargo.toml diff --git a/bridger/components/shadow/src/config.rs b/components/shadow/src/config.rs similarity index 100% rename from bridger/components/shadow/src/config.rs rename to components/shadow/src/config.rs diff --git a/bridger/components/shadow/src/lib.rs b/components/shadow/src/lib.rs similarity index 100% rename from bridger/components/shadow/src/lib.rs rename to components/shadow/src/lib.rs diff --git a/bridger/components/shadow/src/shadow.rs b/components/shadow/src/shadow.rs similarity index 100% rename from bridger/components/shadow/src/shadow.rs rename to components/shadow/src/shadow.rs diff --git a/bridger/components/state/Cargo.toml b/components/state/Cargo.toml similarity index 100% rename from bridger/components/state/Cargo.toml rename to components/state/Cargo.toml diff --git a/bridger/components/state/src/config.rs b/components/state/src/config.rs similarity index 100% rename from bridger/components/state/src/config.rs rename to components/state/src/config.rs diff --git a/bridger/components/state/src/lib.rs b/components/state/src/lib.rs similarity index 100% rename from bridger/components/state/src/lib.rs rename to components/state/src/lib.rs diff --git a/bridger/components/state/src/state.rs b/components/state/src/state.rs similarity index 100% rename from bridger/components/state/src/state.rs rename to components/state/src/state.rs diff --git a/darwinia/Cargo.toml b/darwinia/Cargo.toml deleted file mode 100644 index 6b45b0913..000000000 --- a/darwinia/Cargo.toml +++ /dev/null @@ -1,33 +0,0 @@ -[package] -name = "bridge-client-darwinia" -version = "0.1.0" -authors = ["xiaocheng "] -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies.serde] -package = "serde" -version = "1" -features = ["derive"] - -[dependencies] -jsonrpsee-types = "=0.2.0-alpha.6" -jsonrpsee-ws-client = "=0.2.0-alpha.6" -jsonrpsee-http-client = "=0.2.0-alpha.6" -serde_json = "1.0" -thiserror = "1.0.20" -array-bytes = "1.1.0" -anyhow = "1.0.34" -log = "0.4.11" -substrate-subxt = { git = "https://github.com/darwinia-network/substrate-subxt.git", tag = "darwinia-v0.15.2" } -sp-keyring = "3.0.0" -codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive", "full"] } -web3 = { version = "0.16.0", git = "https://github.com/wuminzhe/rust-web3.git", branch = "master", features = ["signing"] } -secp256k1 = { version = "0.20", features = ["recovery"] } - -[dependencies.primitives] -package = "darwinia-bridge-primitives" -version = "0.3.2" -path = "../primitives" -features = ["runtime", "rpc"] diff --git a/darwinia/src/account.rs b/darwinia/src/account.rs deleted file mode 100644 index c1db51709..000000000 --- a/darwinia/src/account.rs +++ /dev/null @@ -1,56 +0,0 @@ -use sp_keyring::sr25519::sr25519::Pair; -use substrate_subxt::{sp_core::Pair as PairTrait, system::System, PairSigner}; - -use primitives::runtime::DarwiniaRuntime; - -/// AccountId -pub type AccountId = ::AccountId; - -/// Account -pub struct DarwiniaAccount { - /// Account Id - pub account_id: AccountId, - /// signer of the account - pub signer: PairSigner, - /// proxy real - pub real: Option, -} - -impl Clone for DarwiniaAccount { - fn clone(&self) -> Self { - Self { - account_id: self.account_id.clone(), - signer: self.signer.clone(), - real: self.real.clone(), - } - } -} - -impl DarwiniaAccount { - /// Create a new Account - pub fn new(seed: String, real: Option) -> DarwiniaAccount { - // signer to sign darwinia extrinsic - let pair = Pair::from_string(&seed, None).unwrap(); // if not a valid seed - let signer = PairSigner::::new(pair); - let public = signer.signer().public().0; - let account_id = AccountId::from(public); - - // real account, convert to account id - let real = real.map(|real| AccountId::from(array_bytes::hex2array_unchecked(real))); - - DarwiniaAccount { - account_id, - signer, - real, - } - } - - /// get the real account - pub fn real(&self) -> &AccountId { - if let Some(real_account_id) = &self.real { - real_account_id - } else { - &self.account_id - } - } -} diff --git a/darwinia/src/darwinia.rs b/darwinia/src/darwinia.rs deleted file mode 100644 index 614b2eed3..000000000 --- a/darwinia/src/darwinia.rs +++ /dev/null @@ -1,287 +0,0 @@ -use jsonrpsee_http_client::to_json_value; -use primitives::frame::sudo::KeyStoreExt; -use primitives::{ - //todo move to e2d - frame::ethereum::{backing::VerifiedProofStoreExt, issuing::VerifiedIssuingProofStoreExt}, - runtime::DarwiniaRuntime, -}; -use substrate_subxt::{ - events::Raw, - sp_core::storage::{StorageData, StorageKey}, - sp_core::{twox_128, Bytes, H256}, - sp_runtime::generic::Header, - sp_runtime::traits::{BlakeTwo256, Header as TraitHeader}, - BlockNumber, Client, ClientBuilder, -}; - -use crate::error::{Error, Result}; -use crate::rpc::*; -use crate::{account::DarwiniaAccount, DarwiniaEvents, EventInfo}; - -pub struct Darwinia { - /// client - pub subxt: Client, - /// Event Parser - pub event: DarwiniaEvents, -} - -impl Clone for Darwinia { - fn clone(&self) -> Self { - Self { - subxt: self.subxt.clone(), - event: self.event.clone(), - } - } -} - -impl Darwinia { - pub async fn new(url: &str) -> Result { - let client = ClientBuilder::::new() - .set_url(url) - .skip_type_sizes_check() - .build() - .await?; - let event = DarwiniaEvents::new(client.clone()); - - Ok(Self { - subxt: client, - event, - }) - } - - /// get mmr root of darwinia - pub async fn header_mmr( - &self, - block_number_of_member_leaf: u64, - block_number_of_last_leaf: u64, - hash: H256, - ) -> Result> { - let params = &[ - to_json_value(block_number_of_member_leaf)?, - to_json_value(block_number_of_last_leaf)?, - ]; - let result: HeaderMMRRpc = self - .subxt - .rpc - .client - .request("headerMMR_genProof", params) - .await?; - let header_mmr: Option = result.into(); - if let Some(mut header_proof) = header_mmr { - header_proof.block = block_number_of_member_leaf; - header_proof.hash = hash; - return Ok(Some(header_proof)); - } - Ok(None) - } - - /// get_storage_data - pub async fn get_storage_data( - &self, - module_name: &str, - storage_name: &str, - header_hash: H256, - ) -> Result { - let mut storage_key = twox_128(module_name.as_bytes()).to_vec(); - storage_key.extend(twox_128(storage_name.as_bytes()).to_vec()); - - let keys = vec![StorageKey(storage_key)]; - - let change_sets = self - .subxt - .query_storage(keys, header_hash, Some(header_hash)) - .await?; - for change_set in change_sets { - for (_key, data) in change_set.changes { - if let Some(data) = data { - return Ok(data); - } - } - } - - Err(Error::NoStorageDataFound( - module_name.to_string(), - storage_name.to_string(), - )) - } - - /// get runtime version - pub async fn runtime_version(&self) -> Result { - let version = self.subxt.rpc.runtime_version(None).await?; - Ok(version.spec_name.to_string()) - } - - /// get events from a special block - pub async fn get_events_from_block_hash( - &self, - hash: H256, - ) -> Result>> { - let storage_data = self.get_storage_data("System", "Events", hash).await?; - - let raw_events = self.event.decoder.decode_events(&mut &storage_data.0[..])?; - let mut result = Vec::new(); - for (_, raw) in raw_events { - match raw { - Raw::Event(event) => { - let module = event.module.as_str(); - let variant = event.variant.as_str(); - let event_data = event.data; - let event = self.event.parse_event(module, variant, event_data); - if let EventInfo::Invalid(info) = event { - if module != "System" { - trace!(">> Event - {}", info); - } - } else { - result.push(event); - } - } - Raw::Error(err) => { - error!("Error found in raw events: {:#?}", err); - } - } - } - Ok(result) - } - - /// get events from a special block - pub async fn get_events_from_block_number( - &self, - block: u32, - ) -> Result>> { - let blockno = BlockNumber::from(block); - match self.subxt.block_hash(Some(blockno)).await? { - Some(hash) => return self.get_events_from_block_hash(hash).await, - None => { - info!("error"); - } - } - Ok(vec![]) - } - - /// get mmr root - pub async fn get_mmr_root(&self, leaf_index: u32) -> Result { - let block_number = leaf_index + 1; - - let block_hash = self - .subxt - .block_hash(Some(BlockNumber::from(block_number))) - .await?; - let header = self.subxt.header(block_hash).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(Error::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); - H256(mmr_root) - } else { - return Err(Error::NoMmrRootInDarwiniaHeader(block_number)); - } - } else { - return Err(Error::FailedToFetchDarwiniaHeader(block_number)); - }; - Ok(mmr_root) - } - - /// events proof - pub async fn get_event_proof( - &self, - storage_key: Vec, - block_hash: H256, - ) -> Result> { - let keys = vec![StorageKey(storage_key)]; - Ok(self.subxt.read_proof(keys, Some(block_hash)).await?.proof) - } - - /// get block header by number - pub async fn get_block_by_number(&self, number: u32) -> Result> { - match self - .subxt - .block_hash(Some(BlockNumber::from(number))) - .await? - { - Some(block_hash) => match self.subxt.header(Some(block_hash)).await? { - Some(header) => Ok(header), - None => Err(Error::Other("get header return nil".to_string())), - }, - None => Err(Error::Other("get block hash failed".to_string())), - } - } - - /// block number to hash - pub async fn block_number2hash(&self, block_number: Option) -> Result> { - let block_number = block_number.map(|n| n.into()); - Ok(self.subxt.block_hash(block_number).await?) - } - - /// is_sudo_key - pub async fn is_sudo_key( - &self, - block_number: Option, - account: &DarwiniaAccount, - ) -> Result { - let block_hash = self.block_number2hash(block_number).await?; - let sudo = self.subxt.key(block_hash).await?; - Ok(&sudo == account.real()) - } - - /// role - pub async fn account_role(&self, account: &DarwiniaAccount) -> Result> { - let mut roles = vec!["Normal".to_string()]; - if self.is_sudo_key(None, account).await? { - roles.push("Sudo".to_string()); - } - Ok(roles) - } - - /// finalized_head - pub async fn finalized_head(&self) -> Result { - let hash = self.subxt.finalized_head().await?; - Ok(hash) - } - - /// get block by hash - pub async fn get_block_number_by_hash(&self, block_hash: H256) -> Result> { - let block = self.subxt.block(Some(block_hash)).await?; - if let Some(block) = block { - return Ok(Some(block.block.header.number)); - } - Ok(None) - } - - /// Check if should redeem - pub async fn verified(&self, block_hash: web3::types::H256, tx_index: u64) -> Result { - Ok(self - .subxt - .verified_proof((block_hash.to_fixed_bytes(), tx_index), None) - .await? - .unwrap_or(false)) - } - - /// Check if should issuing sync - pub async fn verified_issuing( - &self, - block_hash: web3::types::H256, - tx_index: u64, - ) -> Result { - Ok(self - .subxt - .verified_issuing_proof((block_hash.to_fixed_bytes(), tx_index), None) - .await? - .unwrap_or(false)) - } -} diff --git a/darwinia/src/error.rs b/darwinia/src/error.rs deleted file mode 100644 index 1d4bd1dd2..000000000 --- a/darwinia/src/error.rs +++ /dev/null @@ -1,57 +0,0 @@ -#![allow(missing_docs)] - -use thiserror::Error as ThisError; - -/// Error enum. -#[derive(ThisError, Debug)] -pub enum Error { - #[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(transparent)] - SubxtError(#[from] substrate_subxt::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("Failed to fetch Darwinia header({0})")] - FailedToFetchDarwiniaHeader(u32), - - #[error("No storage data found by {0} {1}")] - NoStorageDataFound(String, String), - - #[error("Not technical committee member")] - NotTechnicalCommitteeMember, - - #[error("No header hash in EthereumReceiptProofOfThing")] - NoHeaderHashInEthereumReceiptProofOfThing, - - #[error("Other error: {0}")] - Other(String), -} - -pub type Result = anyhow::Result; diff --git a/darwinia/src/events/darwinia_events.rs b/darwinia/src/events/darwinia_events.rs deleted file mode 100644 index f5b4dbe60..000000000 --- a/darwinia/src/events/darwinia_events.rs +++ /dev/null @@ -1,109 +0,0 @@ -use substrate_subxt::{ - events::Raw, sp_core::Decode, Client, EventTypeRegistry, EventsDecoder, RawEvent, -}; - -use crate::error::Result; - -//TODO move here -use primitives::{ - frame::bridge::relay_authorities::{ - AuthoritiesChangeSigned, EthereumRelayAuthorities, MMRRootSigned, - ScheduleAuthoritiesChange, ScheduleMMRRoot, - }, - runtime::DarwiniaRuntime, -}; - -/// Darwinia Event Info -pub enum EventInfo { - MMRRootSignedEvent(MMRRootSigned), - ScheduleMMRRootEvent(ScheduleMMRRoot), - ScheduleAuthoritiesChangeEvent(ScheduleAuthoritiesChange), - AuthoritiesChangeSignedEvent(AuthoritiesChangeSigned), - - RuntimeUpdatedEvent(String), - Invalid(String), -} - -/// Darwinia Events -pub struct DarwiniaEvents { - /// event decoder - pub decoder: EventsDecoder, - client: Client, -} - -impl Clone for DarwiniaEvents { - fn clone(&self) -> Self { - DarwiniaEvents::new(self.client.clone()) - } -} - -impl DarwiniaEvents { - pub fn new(client: Client) -> Self { - let event_type_registry = EventTypeRegistry::::new(); - let decoder = - EventsDecoder::::new(client.metadata().clone(), event_type_registry); - DarwiniaEvents { decoder, client } - } - - pub fn decode_events(&self, input: &mut &[u8]) -> Result> { - let raw_events = self.decoder.decode_events(input)?; - let mut events = vec![]; - for (_, raw) in raw_events { - match raw { - Raw::Event(event) => { - events.push(event); - } - Raw::Error(err) => { - error!("Error found in raw events: {:#?}", err); - } - } - } - Ok(events) - } - - /// parse event - pub fn parse_event( - &self, - module: &str, - variant: &str, - event_data: Vec, - ) -> EventInfo { - match (module, variant) { - ("System", "CodeUpdated") => { - return EventInfo::RuntimeUpdatedEvent("code updated".to_string()); - } - ("EthereumRelayAuthorities", "ScheduleMMRRoot") => { - if let Ok(decoded) = - ScheduleMMRRoot::::decode(&mut &event_data[..]) - { - return EventInfo::ScheduleMMRRootEvent(decoded); - } - } - ("EthereumRelayAuthorities", "MMRRootSigned") => { - MMRRootSigned::::decode(&mut &event_data[..]).unwrap(); - if let Ok(decoded) = MMRRootSigned::::decode(&mut &event_data[..]) - { - return EventInfo::MMRRootSignedEvent(decoded); - } - } - ("EthereumRelayAuthorities", "ScheduleAuthoritiesChange") => { - if let Ok(decoded) = - ScheduleAuthoritiesChange::::decode(&mut &event_data[..]) - { - return EventInfo::ScheduleAuthoritiesChangeEvent(decoded); - } - } - ("EthereumRelayAuthorities", "AuthoritiesChangeSigned") => { - if let Ok(decoded) = - AuthoritiesChangeSigned::::decode(&mut &event_data[..]) - { - return EventInfo::AuthoritiesChangeSignedEvent(decoded); - } - } - _ => { - return EventInfo::Invalid(String::from(module) + "::" + variant); - } - } - EventInfo::Invalid(String::from(module) + "::" + variant) - } -} diff --git a/darwinia/src/events/mod.rs b/darwinia/src/events/mod.rs deleted file mode 100644 index 33f6caef4..000000000 --- a/darwinia/src/events/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod darwinia_events; - -pub use darwinia_events::{DarwiniaEvents, EventInfo}; diff --git a/darwinia/src/from_ethereum/account.rs b/darwinia/src/from_ethereum/account.rs deleted file mode 100644 index 00cf288a5..000000000 --- a/darwinia/src/from_ethereum/account.rs +++ /dev/null @@ -1,12 +0,0 @@ -use crate::DarwiniaAccount; - -/// Account -#[derive(Clone)] -pub struct Account(pub DarwiniaAccount); - -impl Account { - /// Create a new Account - pub fn new(darwinia_account: DarwiniaAccount) -> Self { - Self(darwinia_account) - } -} diff --git a/darwinia/src/from_ethereum/api.rs b/darwinia/src/from_ethereum/api.rs deleted file mode 100644 index c4fd69e33..000000000 --- a/darwinia/src/from_ethereum/api.rs +++ /dev/null @@ -1,379 +0,0 @@ -use crate::Darwinia; - -use crate::error::{Error, Result}; -use std::collections::HashMap; -type PendingRelayHeaderParcel = ::PendingRelayHeaderParcel; -type RelayAffirmation = ::RelayAffirmation; -type AffirmationsReturn = HashMap>>; - -use primitives::{ - chain::{ - ethereum::{EthereumReceiptProofThing, EthereumRelayHeaderParcel, RedeemFor}, - proxy_type::ProxyType, - RelayVotingState, - }, - frame::{ - ethereum::{ - backing::{Redeem, RedeemCallExt}, - game::{AffirmationsStoreExt, EthereumRelayerGame}, - issuing::{RedeemErc20, RedeemErc20CallExt, RegisterErc20, RegisterErc20CallExt}, - relay::{ - Affirm, AffirmCallExt, ConfirmedBlockNumbersStoreExt, EthereumRelay, - PendingRelayHeaderParcelsStoreExt, SetConfirmedParcel, - VotePendingRelayHeaderParcel, VotePendingRelayHeaderParcelCallExt, - }, - }, - proxy::ProxyCallExt, - sudo::SudoCallExt, - technical_committee::MembersStoreExt, - }, - runtime::DarwiniaRuntime, -}; - -use core::marker::PhantomData; -use substrate_subxt::sp_core::H256; - -use super::Account; -use crate::AccountId; - -/// Dawrinia API -#[derive(Clone)] -pub struct Ethereum2Darwinia { - /// darwinia client - pub darwinia: Darwinia, -} - -impl Ethereum2Darwinia { - pub fn new(darwinia: Darwinia) -> Self { - Self { darwinia } - } - - /// Print Detail - pub async fn account_detail(&self, block_number: Option, account: &Account) -> Result<()> { - info!("🧔 ethereum => darwinia account"); - let mut roles = self.darwinia.account_role(&account.0).await?; - if self.is_tech_comm_member(block_number, &account).await? { - roles.push("TechnicalCommittee".to_string()); - } - match &account.0.real { - None => { - info!("🧔 Relayer({:?}): 0x{:?}", roles, &account.0.account_id); - } - Some(real_account_id) => { - info!("🧔 Proxy Relayer: 0x{:?}", &account.0.account_id); - info!("👴 Real Account({:?}): 0x{:?}", roles, real_account_id); - } - } - Ok(()) - } - - /// is_tech_comm_member - pub async fn is_tech_comm_member( - &self, - block_number: Option, - account: &Account, - ) -> Result { - let block_hash = self.darwinia.block_number2hash(block_number).await?; - let tech_comm_members = self.darwinia.subxt.members(block_hash).await?; - Ok(tech_comm_members.contains(account.0.real())) - } - - /// set confirmed with sudo privilege - pub async fn set_confirmed_parcel( - &self, - account: &Account, - parcel: EthereumRelayHeaderParcel, - ) -> Result { - let ex = self.darwinia.subxt.encode(SetConfirmedParcel { - ethereum_relay_header_parcel: parcel, - _runtime: PhantomData::default(), - })?; - Ok(self.darwinia.subxt.sudo(&account.0.signer, &ex).await?) - } - - /// Vote pending relay header parcel - pub async fn vote_pending_relay_header_parcel( - &self, - account: &Account, - pending: u64, - aye: bool, - ) -> Result { - if self.is_tech_comm_member(None, &account).await? { - match &account.0.real { - Some(real) => { - // proxy - trace!("Proxy vote for {:?}", real); - let vote = VotePendingRelayHeaderParcel { - block_number: pending, - aye, - _runtime: PhantomData::default(), - }; - - let ex = self.darwinia.subxt.encode(vote).unwrap(); - let ex_hash = self - .darwinia - .subxt - .proxy( - &account.0.signer, - real.clone(), - Some(ProxyType::EthereumBridge), - &ex, - ) - .await?; - Ok(ex_hash) - } - None => { - // no proxy - let ex_hash = self - .darwinia - .subxt - .vote_pending_relay_header_parcel(&account.0.signer, pending, aye) - .await?; - Ok(ex_hash) - } - } - } else { - Err(Error::NotTechnicalCommitteeMember) - } - } - - /// Get all active games' affirmations - /// games = { - /// game_id: { - /// round_id: [...] - /// } - /// } - pub async fn affirmations(&self) -> Result { - let mut result = HashMap::new(); - let mut iter = self.darwinia.subxt.affirmations_iter(None).await?; - while let Some((mut storage_key, affirmations)) = iter.next().await? { - // get game id - let game_id: &mut [u8] = &mut storage_key.0[32..40]; - game_id.reverse(); - let game_id = - u64::from_str_radix(array_bytes::bytes2hex("", game_id).as_str(), 16).unwrap(); - - // - if result.get(&game_id).is_none() { - result.insert(game_id, HashMap::>::new()); - } - let game = result.get_mut(&game_id).unwrap(); - - // get round id - let round_id: &mut [u8] = &mut storage_key.0[40..44]; - round_id.reverse(); - let round_id = - u32::from_str_radix(array_bytes::bytes2hex("", round_id).as_str(), 16).unwrap(); - - game.insert(round_id, affirmations); - } - Ok(result) - } - - /// affirmations contains block? - pub fn contains(affirmations: &[RelayAffirmation], block: u64) -> bool { - for affirmation in affirmations { - let blocks: &Vec = &affirmation - .relay_header_parcels - .iter() - .map(|bp| bp.header.number) - .collect(); - if blocks.contains(&block) { - return true; - } - } - - // TODO: Checking the equality of the affirmations - - // TODO: If there is an affirmation with larger block number, then agree and join in the game. - - // TODO: How to play and join the game - false - } - - /// Get confirmed block numbers - pub async fn confirmed_block_numbers(&self) -> Result> { - Ok(self.darwinia.subxt.confirmed_block_numbers(None).await?) - } - - /// Get the last confirmed block - pub async fn last_confirmed(&self) -> Result { - Ok( - if let Some(confirmed) = self.confirmed_block_numbers().await?.iter().max() { - *confirmed - } else { - 0 - }, - ) - } - - /// Get pending headers - pub async fn pending_headers(&self) -> Result> { - Ok(self - .darwinia - .subxt - .pending_relay_header_parcels(None) - .await?) - } - - /// Submit affirmation - pub async fn affirm( - &self, - account: &Account, - parcel: EthereumRelayHeaderParcel, - ) -> Result { - match &account.0.real { - Some(real) => { - trace!("Proxy call `affirm` for {:?}", real); - let affirm = Affirm { - _runtime: PhantomData::default(), - ethereum_relay_header_parcel: parcel, - ethereum_relay_proofs: None, - }; - - let ex = self.darwinia.subxt.encode(affirm).unwrap(); - Ok(self - .darwinia - .subxt - .proxy( - &account.0.signer, - real.clone(), - Some(ProxyType::EthereumBridge), - &ex, - ) - .await?) - } - None => Ok(self - .darwinia - .subxt - .affirm(&account.0.signer, parcel, None) - .await?), - } - } - - /// Redeem - pub async fn redeem( - &self, - account: &Account, - redeem_for: RedeemFor, - proof: EthereumReceiptProofThing, - ) -> Result { - let ethereum_tx_hash = proof - .header - .hash - .map(|hash| array_bytes::bytes2hex("", &hash)) - .ok_or(Error::NoHeaderHashInEthereumReceiptProofOfThing)?; - match &account.0.real { - Some(real) => { - trace!( - "Proxy redeem ethereum tx 0x{:?} for real account {:?}", - ethereum_tx_hash, - real - ); - let redeem = Redeem { - _runtime: PhantomData::default(), - act: redeem_for, - proof, - }; - - let ex = self.darwinia.subxt.encode(redeem).unwrap(); - Ok(self - .darwinia - .subxt - .proxy( - &account.0.signer, - real.clone(), - Some(ProxyType::EthereumBridge), - &ex, - ) - .await?) - } - None => { - trace!( - "Redeem ethereum tx {:?} with account {:?}", - ethereum_tx_hash, - &account.0.account_id - ); - Ok(self - .darwinia - .subxt - .redeem(&account.0.signer, redeem_for, proof) - .await?) - } - } - } - - /// has_voted - pub fn has_voted(&self, account: &Account, voting_state: RelayVotingState) -> bool { - match &account.0.real { - None => voting_state.contains(&account.0.account_id), - Some(real) => voting_state.contains(real), - } - } - - /// register erc20 - pub async fn register_erc20( - &self, - account: &Account, - proof: EthereumReceiptProofThing, - ) -> Result { - match &account.0.real { - Some(real) => { - let call = RegisterErc20 { - _runtime: PhantomData::default(), - proof, - }; - - let ex = self.darwinia.subxt.encode(call).unwrap(); - Ok(self - .darwinia - .subxt - .proxy( - &account.0.signer, - real.clone(), - Some(ProxyType::EthereumBridge), - &ex, - ) - .await?) - } - None => Ok(self - .darwinia - .subxt - .register_erc20(&account.0.signer, proof) - .await?), - } - } - - /// redeem erc20 - pub async fn redeem_erc20( - &self, - account: &Account, - proof: EthereumReceiptProofThing, - ) -> Result { - match &account.0.real { - Some(real) => { - let call = RedeemErc20 { - _runtime: PhantomData::default(), - proof, - }; - - let ex = self.darwinia.subxt.encode(call).unwrap(); - Ok(self - .darwinia - .subxt - .proxy( - &account.0.signer, - real.clone(), - Some(ProxyType::EthereumBridge), - &ex, - ) - .await?) - } - None => Ok(self - .darwinia - .subxt - .redeem_erc20(&account.0.signer, proof) - .await?), - } - } -} diff --git a/darwinia/src/from_ethereum/mod.rs b/darwinia/src/from_ethereum/mod.rs deleted file mode 100644 index 322edd757..000000000 --- a/darwinia/src/from_ethereum/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -mod account; -mod api; - -pub use api::Ethereum2Darwinia; - -pub use account::Account; diff --git a/darwinia/src/lib.rs b/darwinia/src/lib.rs deleted file mode 100644 index 5faab6308..000000000 --- a/darwinia/src/lib.rs +++ /dev/null @@ -1,27 +0,0 @@ -pub mod account; -pub mod darwinia; -pub mod error; -pub mod events; -pub mod from_ethereum; -pub mod rpc; -pub mod to_ethereum; -pub mod types; - -#[macro_use] -extern crate log; - -pub use rpc::{FormatedMMR, HeaderMMR}; - -pub use events::{DarwiniaEvents, EventInfo}; - -pub use types::{EcdsaMessage, EcdsaSignature}; - -pub use to_ethereum::{Account as ToEthereumAccount, Darwinia2Ethereum}; - -pub use from_ethereum::{Account as FromEthereumAccount, Ethereum2Darwinia}; - -pub use darwinia::Darwinia; - -pub use account::{AccountId, DarwiniaAccount}; - -pub use error::Error; diff --git a/darwinia/src/rpc/header_mmr.rs b/darwinia/src/rpc/header_mmr.rs deleted file mode 100644 index d6245ba12..000000000 --- a/darwinia/src/rpc/header_mmr.rs +++ /dev/null @@ -1,252 +0,0 @@ -use serde::Deserialize; -use std::str::FromStr; -use substrate_subxt::{ - sp_core::H256, - sp_runtime::traits::{BlakeTwo256, Hash}, -}; - -#[derive(Deserialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct HeaderMMRRpc { - mmr_size: String, - proof: String, -} - -/// Header MMR Info -#[derive(Debug)] -pub struct HeaderMMR { - /// block number - pub block: u64, - /// block hash - pub hash: H256, - /// mmr size of header - pub mmr_size: u64, - /// mmr proof - pub proof: Vec, -} - -/// formated mmr header -#[derive(Debug)] -pub struct FormatedMMR { - /// block number - pub block: u64, - /// block hash - pub hash: H256, - /// mmr size of header - pub mmr_size: u64, - /// peaks in mmr proof - pub peaks: Vec, - /// siblings in mmr proof - pub siblings: Vec, -} - -impl From for Option { - fn from(that: HeaderMMRRpc) -> Self { - let mmr_size = that.mmr_size.parse::(); - if let Err(err) = mmr_size { - println!("parse mmr size failed {}", err); - return None; - } - //let proof = serde_json::from_str(&self.proof); - let trim: &[_] = &['[', ']']; - let proof: Vec = that - .proof - .trim_matches(trim) - .split(',') - .map(|s| String::from(s.trim())) - .collect(); - Some(HeaderMMR { - block: 0, - hash: H256::from_str( - "0000000000000000000000000000000000000000000000000000000000000000", - ) - .unwrap(), - mmr_size: mmr_size.unwrap(), - proof, - }) - } -} - -impl From for Option { - fn from(that: HeaderMMR) -> Self { - let (peaks, siblings) = convert(that.mmr_size, that.block, that.hash, that.proof); - Some(FormatedMMR { - block: that.block, - hash: that.hash, - mmr_size: that.mmr_size, - peaks, - siblings, - }) - } -} - -fn get_peaks(mmr_size: u64) -> Vec { - let mut pos_s = Vec::new(); - let (mut height, mut pos) = left_peak_height_pos(mmr_size); - pos_s.push(pos); - while height > 0 { - let peak = match get_right_peak(height, pos, mmr_size) { - Some(peak) => peak, - None => break, - }; - height = peak.0; - pos = peak.1; - pos_s.push(pos); - } - pos_s -} - -fn get_right_peak(mut height: u32, mut pos: u64, mmr_size: u64) -> Option<(u32, u64)> { - pos += (2 << height) - 1; - while pos > mmr_size - 1 { - if height == 0 { - return None; - } - pos -= 2 << (height - 1); - height -= 1; - } - Some((height, pos)) -} - -fn left_peak_height_pos(mmr_size: u64) -> (u32, u64) { - let mut height = 1; - let mut prev_pos = 0; - let mut pos = (1 << (height + 1)) - 2; - while pos < mmr_size { - height += 1; - prev_pos = pos; - pos = (1 << (height + 1)) - 2; - } - (height - 1, prev_pos) -} - -fn leaf_index_to_mmr_size(index: u64) -> u64 { - let leaves_count = index + 1; - let peak_count = leaves_count.count_ones() as u64; - 2 * leaves_count - peak_count -} - -fn pos_height_in_tree(mut pos: u64) -> u32 { - pos += 1; - fn all_ones(num: u64) -> bool { - num != 0 && num.count_zeros() == num.leading_zeros() - } - fn jump_left(pos: u64) -> u64 { - let bit_length = 64 - pos.leading_zeros(); - let most_significant_bits = 1 << (bit_length - 1); - pos - (most_significant_bits - 1) - } - - while !all_ones(pos) { - pos = jump_left(pos) - } - - 64 - pos.leading_zeros() - 1 -} - -fn get_merkle_root(pos: u64, peak_pos: u64, item: H256, proofs: Vec) -> H256 { - let mut height = 0; - let mut parent = pos; - let mut proofiter = proofs.iter(); - let mut parent_item = item; - while parent != peak_pos { - let next_height = pos_height_in_tree(parent + 1); - let sibling_offset = (2 << height) - 1; - - let (sibling_pos, parent_pos) = { - if next_height > height { - (parent - sibling_offset, parent + 1) - } else { - (parent + sibling_offset, parent + (2 << height)) - } - }; - let sibling_item = { - if parent == sibling_pos { - parent_item - } else { - *proofiter.next().unwrap() - } - }; - let encodable = { - if next_height > height { - (sibling_item, parent_item) - } else { - (parent_item, sibling_item) - } - }; - parent_item = BlakeTwo256::hash_of(&encodable); - parent = parent_pos; - height += 1; - } - parent_item -} - -fn convert( - mmr_size: u64, - block: u64, - block_hash: H256, - mmr_proof: Vec, -) -> (Vec, Vec) { - let mut res_peaks = Vec::new(); - let peaks = get_peaks(mmr_size); - let peaksize = peaks.len(); - let pos = leaf_index_to_mmr_size(block) - (block + 1).trailing_zeros() as u64 - 1; - info!("leaf position is {}", pos); - let mut mmr_proof_iter = mmr_proof.iter(); - for peak in &peaks { - if peak < &pos { - res_peaks.push(String::from(mmr_proof_iter.next().unwrap())); - } else { - break; - } - } - let (peak_pos, last, res_siblings) = if res_peaks.len() + 1 == peaksize { - ( - peaks[res_peaks.len()], - None, - mmr_proof[res_peaks.len()..].to_vec(), - ) - } else { - ( - peaks[res_peaks.len()], - Some(&mmr_proof[mmr_proof.len() - 1]), - mmr_proof[res_peaks.len()..mmr_proof.len() - 1].to_vec(), - ) - }; - let proof: Vec = mmr_proof_iter - .map(|hash| H256::from_str(&hash[2..]).unwrap()) - .collect(); - let root = get_merkle_root(pos, peak_pos, block_hash, proof); - res_peaks.push(array_bytes::bytes2hex("0x", root)); - if let Some(last_hash) = last { - res_peaks.push(String::from(last_hash)); - } - (res_peaks, res_siblings) -} - -#[cfg(test)] -mod mmr_convert_test { - use super::*; - #[test] - fn test_convert() { - let rpcheader = HeaderMMRRpc { - mmr_size: String::from("7261431"), - proof: String::from("[0x100d7b5c325baa1ee0403b9a3f0500c9f1e6a6af796d22f69a5f9326bcaf0768,0x75128e0b7dde0738bc1ec366af6f928d457c25eae091371a0da34261868933ed,0xc046be6fc40bf641c5c00c9b0e5e6c79fc8b1dcc414d0983db5284973503e480,0x3d3dd94c70124c5895648a17eee5d0aba7178303dfa824808787a9ffd3115537,0xf73f4035df1d3799ed26ed2b0e04df8cd262b4762df83c5bdcf41a44895fd6b4,0xb9c761dc3446b3216fae5d003514513cb9fbcf5853025f088df21438f089b434,0x45b2f9ac26928873802dd124ea08c8bc7fa87460d4c5e73db7679a4e6fcdeca4,0xc4905445f8cac409704f76e708ef2bb12d754e270010eab521af6e599f8ecb43,0x153b1f802819948d79dd7ee4a1e2b107fb2211f90d5ee7307cd03867852367d4,0x6b5ea1569b586be1dff789bca89dd3dd6de5f676d090f27ef0cf61aef28f1965,0x7d988132cd401bfcccf9073db3c355b38f32df277d8f541db3df640c5d773176,0x92d453e2cbe3f414e52163cd16da0e95f34dd4bbb005c3bf604416db20765229,0x6a6f39470e6bc4b9fe72b9ca2c403ea85de92e3461e827f6040f90ad90ff647d,0x8e90e065c02c04983db00e667ead2977af2f28ff386b269904d7730340220238,0xd169bed480658089615bd9d0f1ec1b7118d853f6ff706565c3878557bb7408b0,0x7faad6ff144f22d1a8a612de2f4741e751b882d3edb99211cfe4d5da96de20f8,0xb336184cdf4a308623cf13eb859d95e1a602d2a0b93abf919f6afbbb8eb97586]"), - }; - let header_mmr: Option = rpcheader.into(); - let mut header = header_mmr.unwrap(); - header.block = 3630712; - header.hash = - H256::from_str("5431b121fb0549830b7f33865d290eea566cc1ae83b260c2edc8b44cfc9115d3") - .unwrap(); - println!("{:?}", header); - - let formated_mmr: Option = header.into(); - if let Some(mmr_proof) = formated_mmr { - assert_eq!( - "0x1c7d559a2231da8354399af954f8faa205f410995deba7fd25086dcb663a77ec", - mmr_proof.peaks[&mmr_proof.peaks.len() - 2] - ); - } - } -} diff --git a/darwinia/src/rpc/mod.rs b/darwinia/src/rpc/mod.rs deleted file mode 100644 index cab4bcb07..000000000 --- a/darwinia/src/rpc/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod header_mmr; - -pub use header_mmr::{FormatedMMR, HeaderMMR, HeaderMMRRpc}; diff --git a/darwinia/src/to_ethereum/account.rs b/darwinia/src/to_ethereum/account.rs deleted file mode 100644 index 640e700ba..000000000 --- a/darwinia/src/to_ethereum/account.rs +++ /dev/null @@ -1,82 +0,0 @@ -use crate::{error::Result, DarwiniaAccount, Error}; - -use primitives::runtime::EcdsaSignature; -use secp256k1::SecretKey; -use web3::signing::SecretKeyRef; -use web3::transports::Http; -use web3::Web3; - -#[derive(Clone)] -pub struct EthereumAccount { - /// ethereum url - pub ethereum_url: String, - /// authority signer raw ethereum seed - pub ethereum_seed: Option, -} - -/// Account -#[derive(Clone)] -pub struct Account(pub DarwiniaAccount, pub EthereumAccount); - -impl Account { - /// Create a new Account - pub fn new( - darwinia_account: DarwiniaAccount, - ethereum_seed: Option, - ethereum_url: String, - ) -> Account { - Account( - darwinia_account, - EthereumAccount { - ethereum_url, - ethereum_seed, - }, - ) - } - - /// sign - pub fn ecdsa_sign(&self, message: &[u8]) -> Result { - let web3 = Web3::new(Http::new(&self.1.ethereum_url)?); - if let Some(ethereum_seed) = &self.1.ethereum_seed { - let private_key = array_bytes::hex2bytes(ðereum_seed[2..]) - .map_err(|_| Error::Hex2Bytes("ethereum_seed[2..]".into()))?; - let secret_key = SecretKey::from_slice(&private_key)?; - let signature = web3 - .accounts() - .sign(message, SecretKeyRef::new(&secret_key)) - .signature; - let mut buffer = [0u8; 65]; - buffer.copy_from_slice(signature.0.as_slice()); - Ok(EcdsaSignature(buffer)) - } else { - Err(Error::NoAuthoritySignerSeed) - } - } - - /// ethereum seed - pub fn has_ethereum_seed(&self) -> bool { - self.1.ethereum_seed.is_some() - } -} - -#[test] -fn test_ecdsa() { - let hash = - array_bytes::hex2bytes("71e2f60faf6c7264cca14fb1a01260a787b4d18039cd8cd680aaff1e118c711d") - .unwrap(); - let hash = hash.as_slice(); - let web3 = Web3::new( - Http::new("https://ropsten.infura.io/v3/60703fcc6b4e48079cfc5e385ee7af80").unwrap(), - ); - let private_key = - array_bytes::hex2bytes("8bd012fd2433d4fea852f437d6bb22d1e57dee7657cc1e703460ddeaae1a67ca") - .unwrap(); - let secret_key = SecretKey::from_slice(&private_key).unwrap(); - let signature = web3 - .accounts() - .sign(hash, SecretKeyRef::new(&secret_key)) - .signature; - let mut buffer = [0u8; 65]; - buffer.copy_from_slice(signature.0.as_slice()); - println!("{:x?}", buffer); -} diff --git a/darwinia/src/to_ethereum/api.rs b/darwinia/src/to_ethereum/api.rs deleted file mode 100644 index 1dffc2281..000000000 --- a/darwinia/src/to_ethereum/api.rs +++ /dev/null @@ -1,346 +0,0 @@ -use crate::{Darwinia, HeaderMMR}; - -use super::Account; - -use crate::error::Result; - -use codec::Encode; - -use substrate_subxt::sp_core::H256; - -use primitives::{ - chain::{ethereum::EthereumReceiptProofThing, proxy_type::ProxyType}, - frame::{ - bridge::relay_authorities::{ - AuthoritiesStoreExt, AuthoritiesToSignStoreExt, MmrRootsToSignStoreExt, - NextTermStoreExt, SubmitSignedAuthorities, SubmitSignedAuthoritiesCallExt, - SubmitSignedMmrRoot, SubmitSignedMmrRootCallExt, - }, - ethereum::backing::{SyncAuthoritiesChange, SyncAuthoritiesChangeCallExt}, - proxy::ProxyCallExt, - }, - runtime::{EcdsaAddress, EcdsaMessage}, -}; - -use core::marker::PhantomData; - -#[derive(Encode)] -struct _S<_1, _2, _3, _4> -where - _1: Encode, - _2: Encode, - _3: Encode, - _4: Encode, -{ - _1: _1, // spec name - _2: _2, // op code, mmr root: 0x479fbdf9, next authorities: 0xb4bcf497 - #[codec(compact)] - _3: _3, // block_number or term - _4: _4, // mmr_root or next authorities -} - -/// Dawrinia API -#[derive(Clone)] -pub struct Darwinia2Ethereum { - /// darwinia client - pub darwinia: Darwinia, -} - -impl Darwinia2Ethereum { - pub fn new(darwinia: Darwinia) -> Self { - Self { darwinia } - } - - /// header mmr proof - pub async fn get_headermmr_genproof( - &self, - member_leaf: u64, - last_leaf: u64, - hash: H256, - ) -> Result> { - return self.darwinia.header_mmr(member_leaf, last_leaf, hash).await; - } - - /// construct mmr root message - pub fn construct_mmr_root_message( - spec_name: String, - block_number: u32, - mmr_root: H256, - ) -> Vec { - let op_code: [u8; 4] = [71, 159, 189, 249]; - debug!( - "Infos to construct mmr_root message: {}, {}, {}, {:?}", - spec_name, - array_bytes::bytes2hex("", &op_code), - block_number, - mmr_root - ); - // scale encode & sign - let message = _S { - _1: spec_name, - _2: op_code, - _3: block_number, - _4: mmr_root, - }; - let encoded: &[u8] = &message.encode(); - encoded.to_vec() - } - - /// construct_message - pub fn construct_authorities_message( - spec_name: String, - term: u32, - next_authorities: Vec, - ) -> Vec { - let op_code: [u8; 4] = [180, 188, 244, 151]; - debug!( - "Infos to construct eth authorities message: {}, {}, {}, {:?}", - spec_name, - array_bytes::bytes2hex("", &op_code), - term, - next_authorities - .iter() - .map(|a| array_bytes::bytes2hex("", &a)) - .collect::>() - .join(", ") - ); - // scale encode & sign - let message = _S { - _1: spec_name, - _2: op_code, - _3: term, - _4: next_authorities, - }; - let encoded: &[u8] = &message.encode(); - encoded.to_vec() - } - - /// get_current_term - pub async fn get_current_authority_term(&self) -> Result { - Ok(self.darwinia.subxt.next_term(None).await?) - } - - // use account - /// sync authorities change from ethereum to darwinia - pub async fn sync_authorities_change( - &self, - account: &Account, - proof: EthereumReceiptProofThing, - ) -> Result { - match &account.0.real { - Some(real) => { - let call = SyncAuthoritiesChange { - _runtime: PhantomData::default(), - proof, - }; - - let ex = self.darwinia.subxt.encode(call).unwrap(); - Ok(self - .darwinia - .subxt - .proxy( - &account.0.signer, - real.clone(), - Some(ProxyType::EthereumBridge), - &ex, - ) - .await?) - } - None => Ok(self - .darwinia - .subxt - .sync_authorities_change(&account.0.signer, proof) - .await?), - } - } - - /// submit_signed_authorities - pub async fn ecdsa_sign_and_submit_signed_authorities( - &self, - account: &Account, - message: EcdsaMessage, - ) -> Result { - // TODO: check - // .sender - // .need_to_sign_authorities(decoded.message, block) - // .await? - let signature = account.ecdsa_sign(&message)?; - match &account.0.real { - // proxy - Some(real) => { - trace!("Proxyed ecdsa sign and submit authorities to darwinia"); - let submit_signed_authorities = SubmitSignedAuthorities { signature }; - - let ex = self - .darwinia - .subxt - .encode(submit_signed_authorities) - .unwrap(); - let tx_hash = self - .darwinia - .subxt - .proxy( - &account.0.signer, - real.clone(), - Some(ProxyType::EthereumBridge), - &ex, - ) - .await?; - Ok(tx_hash) - } - None => { - trace!("Ecdsa sign and submit authorities to darwinia"); - let tx_hash = self - .darwinia - .subxt - .submit_signed_authorities(&account.0.signer, signature) - .await?; - Ok(tx_hash) - } - } - } - - /// submit_signed_mmr_root - pub async fn ecdsa_sign_and_submit_signed_mmr_root( - &self, - account: &Account, - spec_name: String, - block_number: u32, - ) -> Result { - // get mmr root from darwinia - let leaf_index = block_number; - let mmr_root = self.darwinia.get_mmr_root(leaf_index).await?; - - let encoded = - Darwinia2Ethereum::construct_mmr_root_message(spec_name, block_number, mmr_root); - let hash = web3::signing::keccak256(&encoded); - let signature = account.ecdsa_sign(&hash)?; - - match &account.0.real { - // proxy - Some(real) => { - trace!( - "Proxyed ecdsa sign and submit mmr_root to darwinia, block_number: {}", - block_number - ); - let submit_signed_mmr_root = SubmitSignedMmrRoot { - block_number, - signature, - }; - - let ex = self.darwinia.subxt.encode(submit_signed_mmr_root).unwrap(); - let tx_hash = self - .darwinia - .subxt - .proxy( - &account.0.signer, - real.clone(), - Some(ProxyType::EthereumBridge), - &ex, - ) - .await?; - Ok(tx_hash) - } - None => { - trace!( - "Ecdsa sign and submit mmr_root to darwinia, block_number: {}", - block_number - ); - let tx_hash = self - .darwinia - .subxt - .submit_signed_mmr_root(&account.0.signer, block_number, signature) - .await?; - Ok(tx_hash) - } - } - } - - /// is authority - pub async fn is_authority(&self, block_number: Option, account: &Account) -> Result { - #![allow(clippy::needless_collect)] - let block_hash = self.darwinia.block_number2hash(block_number).await?; - let authorities = self - .darwinia - .subxt - .authorities(block_hash) - .await? - .iter() - .map(|a| a.account_id.clone()) - .collect::>(); - Ok(authorities.contains(account.0.real())) - } - - /// need_to_sign_authorities - pub async fn need_to_sign_authorities( - &self, - block_number: Option, - account: &Account, - message: EcdsaMessage, - ) -> Result { - let block_hash = self.darwinia.block_number2hash(block_number).await?; - let ret = self.darwinia.subxt.authorities_to_sign(block_hash).await?; - match ret { - None => Ok(false), - Some(r) => { - if r.0 == message { - let account_id = account - .0 - .real - .clone() - .unwrap_or_else(|| account.0.account_id.clone()); - let includes = r.1.iter().any(|a| a.0 == account_id); - Ok(!includes) - } else { - Ok(false) - } - } - } - } - - /// need_to_mmr_root_of - pub async fn need_to_sign_mmr_root_of( - &self, - account: &Account, - block_number: u32, - exec_block_number: Option, - ) -> Result { - let exec_block_hash = self.darwinia.block_number2hash(exec_block_number).await?; - match self - .darwinia - .subxt - .mmr_roots_to_sign(block_number, exec_block_hash) - .await? - { - None => Ok(false), - Some(items) => { - let account_id = account - .0 - .real - .clone() - .unwrap_or_else(|| account.0.account_id.clone()); - let includes = items.iter().any(|a| a.0 == account_id); - Ok(!includes) - } - } - } - - /// Print Detail - pub async fn account_detail(&self, block_number: Option, account: &Account) -> Result<()> { - info!("🧔 darwinia => ethereum account"); - let mut roles = self.darwinia.account_role(&account.0).await?; - if self.is_authority(block_number, &account).await? { - roles.push("Authority".to_string()); - } - match &account.0.real { - None => { - info!("🧔 Relayer({:?}): 0x{:?}", roles, account.0.account_id); - } - Some(real_account_id) => { - info!("🧔 Proxy Relayer: 0x{:?}", account.0.account_id); - info!("👴 Real Account({:?}): 0x{:?}", roles, real_account_id); - } - } - Ok(()) - } -} diff --git a/darwinia/src/to_ethereum/mod.rs b/darwinia/src/to_ethereum/mod.rs deleted file mode 100644 index 01443c774..000000000 --- a/darwinia/src/to_ethereum/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -mod account; -mod api; - -pub use api::Darwinia2Ethereum; - -pub use account::Account; diff --git a/darwinia/src/types.rs b/darwinia/src/types.rs deleted file mode 100644 index 35ded50a8..000000000 --- a/darwinia/src/types.rs +++ /dev/null @@ -1,17 +0,0 @@ -use codec::{Decode, Encode}; - -/// EcdsaSignature -#[derive(Clone, Debug, PartialEq, Eq, Encode, Decode)] -pub struct EcdsaSignature(pub [u8; 65]); - -impl Default for EcdsaSignature { - fn default() -> Self { - Self([0u8; 65]) - } -} - -/// EcdsaAddress -pub type EcdsaAddress = [u8; 20]; - -/// EcdsaMessage -pub type EcdsaMessage = [u8; 32]; diff --git a/primitives/Cargo.lock b/primitives/Cargo.lock deleted file mode 100644 index 7005b2fbc..000000000 --- a/primitives/Cargo.lock +++ /dev/null @@ -1,4675 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "Inflector" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -dependencies = [ - "lazy_static", - "regex", -] - -[[package]] -name = "addr2line" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" - -[[package]] -name = "ahash" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29661b60bec623f0586702976ff4d0c9942dcb6723161c2df0eea78455cfedfb" -dependencies = [ - "const-random", -] - -[[package]] -name = "ahash" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" - -[[package]] -name = "aho-corasick" -version = "0.7.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86" -dependencies = [ - "memchr", -] - -[[package]] -name = "alga" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f823d037a7ec6ea2197046bafd4ae150e6bc36f9ca347404f46a46823fa84f2" -dependencies = [ - "approx", - "num-complex", - "num-traits", -] - -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "anyhow" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1fd36ffbb1fb7c834eac128ea8d0e310c5aeb635548f9d58861e1308d46e71c" - -[[package]] -name = "approx" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" -dependencies = [ - "num-traits", -] - -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "arrayvec" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" -dependencies = [ - "nodrop", -] - -[[package]] -name = "arrayvec" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" - -[[package]] -name = "asn1_der" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fce6b6a0ffdafebd82c87e79e3f40e8d2c523e5fea5566ff6b90509bf98d638" -dependencies = [ - "asn1_der_derive", -] - -[[package]] -name = "asn1_der_derive" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d0864d84b8e07b145449be9a8537db86bf9de5ce03b913214694643b4743502" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "async-channel" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59740d83946db6a5af71ae25ddf9562c2b176b2ca42cf99a455f09f4a220d6b9" -dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", -] - -[[package]] -name = "async-executor" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d373d78ded7d0b3fa8039375718cde0aace493f2e34fb60f51cbf567562ca801" -dependencies = [ - "async-task", - "concurrent-queue", - "fastrand", - "futures-lite", - "once_cell", - "vec-arena", -] - -[[package]] -name = "async-global-executor" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fefeb39da249f4c33af940b779a56723ce45809ef5c54dad84bb538d4ffb6d9e" -dependencies = [ - "async-executor", - "async-io", - "futures-lite", - "num_cpus", - "once_cell", -] - -[[package]] -name = "async-io" -version = "1.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a027f4b662e59d7070791e33baafd36affe67388965701b50039db5ebb240d2" -dependencies = [ - "concurrent-queue", - "fastrand", - "futures-lite", - "libc", - "log", - "nb-connect", - "once_cell", - "parking", - "polling", - "vec-arena", - "waker-fn", - "winapi 0.3.9", -] - -[[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-std" -version = "1.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9fa76751505e8df1c7a77762f60486f60c71bbd9b8557f4da6ad47d083732ed" -dependencies = [ - "async-global-executor", - "async-io", - "async-mutex", - "blocking", - "crossbeam-utils", - "futures-channel", - "futures-core", - "futures-io", - "futures-lite", - "gloo-timers", - "kv-log-macro", - "log", - "memchr", - "num_cpus", - "once_cell", - "pin-project-lite", - "pin-utils", - "slab", - "wasm-bindgen-futures", -] - -[[package]] -name = "async-task" -version = "4.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ab27c1aa62945039e44edaeee1dc23c74cc0c303dd5fe0fb462a184f1c3a518" - -[[package]] -name = "async-tls" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce6977f57fa68da77ffe5542950d47e9c23d65f5bc7cb0a9f8700996913eec7" -dependencies = [ - "futures 0.3.6", - "rustls", - "webpki", - "webpki-roots", -] - -[[package]] -name = "async-trait" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "687c230d85c0a52504709705fc8a53e4a692b83a2184f03dae73e38e1e93a783" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "atomic" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64f46ca51dca4837f1520754d1c8c36636356b81553d928dc9c177025369a06e" - -[[package]] -name = "atomic-waker" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" - -[[package]] -name = "autocfg" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" - -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - -[[package]] -name = "backtrace" -version = "0.3.52" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f813291114c186a042350e787af10c26534601062603d888be110f59f85ef8fa" -dependencies = [ - "addr2line", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - -[[package]] -name = "base58" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" - -[[package]] -name = "base64" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -dependencies = [ - "byteorder", -] - -[[package]] -name = "base64" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" - -[[package]] -name = "base64" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "bitmask" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da9b3d9f6f585199287a473f4f8dfab6566cf827d15c00c219f53c645687ead" - -[[package]] -name = "bitvec" -version = "0.17.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41262f11d771fd4a61aa3ce019fca363b4b6c282fca9da2a31186d3965a47a5c" -dependencies = [ - "either", - "radium", -] - -[[package]] -name = "blake2-rfc" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" -dependencies = [ - "arrayvec 0.4.12", - "constant_time_eq", -] - -[[package]] -name = "blake2b_simd" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" -dependencies = [ - "arrayref", - "arrayvec 0.5.1", - "constant_time_eq", -] - -[[package]] -name = "blake2s_simd" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab9e07352b829279624ceb7c64adb4f585dacdb81d35cafae81139ccd617cf44" -dependencies = [ - "arrayref", - "arrayvec 0.5.1", - "constant_time_eq", -] - -[[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", - "byte-tools", - "byteorder", - "generic-array 0.12.3", -] - -[[package]] -name = "block-buffer" -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.4", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -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.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5aba2c74d15fe950254784fe497a999345606169c2288ccb771b72acdf41241" -dependencies = [ - "async-channel", - "async-task", - "atomic-waker", - "fastrand", - "futures-lite", - "once_cell", -] - -[[package]] -name = "bs58" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "476e9cd489f9e121e02ffa6014a8ef220ecb15c05ed23fc34cca13925dc283fb" - -[[package]] -name = "bstr" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31accafdb70df7871592c058eca3985b71104e15ac32f64706022c58867da931" -dependencies = [ - "memchr", -] - -[[package]] -name = "bumpalo" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" - -[[package]] -name = "byte-slice-cast" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0a5e3906bcbf133e33c1d4d95afc664ad37fbdb9f6568d8043e7ea8c27d93d3" - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - -[[package]] -name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" - -[[package]] -name = "bytes" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" - -[[package]] -name = "cache-padded" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" - -[[package]] -name = "cc" -version = "1.0.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef611cc68ff783f18535d77ddd080185275713d852c4f5cbb6122c462a7a825c" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "chrono" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" -dependencies = [ - "libc", - "num-integer", - "num-traits", - "time", - "winapi 0.3.9", -] - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - -[[package]] -name = "cloudabi" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4344512281c643ae7638bbabc3af17a11307803ec8f0fcad9fae512a8bf36467" -dependencies = [ - "bitflags", -] - -[[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 = "const-random" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02dc82c12dc2ee6e1ded861cf7d582b46f66f796d1b6c93fa28b911ead95da02" -dependencies = [ - "const-random-macro", - "proc-macro-hack", -] - -[[package]] -name = "const-random-macro" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc757bbb9544aa296c2ae00c679e81f886b37e28e59097defe0cf524306f6685" -dependencies = [ - "getrandom 0.2.0", - "proc-macro-hack", -] - -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - -[[package]] -name = "core-foundation" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" - -[[package]] -name = "cpuid-bool" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" - -[[package]] -name = "crossbeam-utils" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg 1.0.1", - "cfg-if", - "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.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" -dependencies = [ - "generic-array 0.12.3", - "subtle 1.0.0", -] - -[[package]] -name = "curve25519-dalek" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d85653f070353a16313d0046f173f70d1aadd5b42600a14de626f0dfb3473a5" -dependencies = [ - "byteorder", - "digest 0.8.1", - "rand_core 0.5.1", - "subtle 2.3.0", - "zeroize", -] - -[[package]] -name = "curve25519-dalek" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8492de420e9e60bc9a1d66e2dbb91825390b738a388606600663fc529b4b307" -dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle 2.3.0", - "zeroize", -] - -[[package]] -name = "darwinia-bridge-primitives" -version = "0.0.12" -dependencies = [ - "async-trait", - "frame-support", - "pallet-im-online", - "pallet-indices", - "parity-scale-codec", - "reqwest", - "rlp", - "serde", - "serde_json", - "substrate-subxt", - "substrate-subxt-proc-macro", - "uint", -] - -[[package]] -name = "data-encoding" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d0e2d24e5ee3b23a01de38eefdcd978907890701f08ffffd4cb457ca4ee8d6" - -[[package]] -name = "derive_more" -version = "0.99.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.3", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array 0.14.4", -] - -[[package]] -name = "dtoa" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b" - -[[package]] -name = "dyn-clonable" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e9232f0e607a262ceb9bd5141a3dfb3e4db6994b31989bbfd845878cba59fd4" -dependencies = [ - "dyn-clonable-impl", - "dyn-clone", -] - -[[package]] -name = "dyn-clonable-impl" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "dyn-clone" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c53dc3a653e0f64081026e4bf048d48fec9fce90c66e8326ca7292df0ff2d82" - -[[package]] -name = "ed25519" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07dfc993ea376e864fe29a4099a61ca0bb994c6d7745a61bf60ddb3d64e05237" -dependencies = [ - "signature", -] - -[[package]] -name = "ed25519-dalek" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" -dependencies = [ - "curve25519-dalek 3.0.0", - "ed25519", - "rand 0.7.3", - "serde", - "sha2 0.9.1", - "zeroize", -] - -[[package]] -name = "either" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" - -[[package]] -name = "encoding_rs" -version = "0.8.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a51b8cf747471cb9499b6d59e59b0444f4c90eba8968c4e44874e92b5b64ace2" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "environmental" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6576a1755ddffd988788025e75bce9e74b018f7cc226198fe931d077911c6d7e" - -[[package]] -name = "event-listener" -version = "2.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" - -[[package]] -name = "failure" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "fastrand" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca5faf057445ce5c9d4329e382b2ce7ca38550ef3b73a5348362d5f24e0c7fe3" -dependencies = [ - "instant", -] - -[[package]] -name = "finality-grandpa" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8feb87a63249689640ac9c011742c33139204e3c134293d3054022276869133b" -dependencies = [ - "either", - "futures 0.3.6", - "futures-timer 2.0.2", - "log", - "num-traits", - "parity-scale-codec", - "parking_lot 0.9.0", -] - -[[package]] -name = "fixed-hash" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11498d382790b7a8f2fd211780bec78619bba81cdad3a283997c0c41f836759c" -dependencies = [ - "byteorder", - "rand 0.7.3", - "rustc-hex", - "static_assertions", -] - -[[package]] -name = "fixedbitset" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "frame-benchmarking" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66a5e3fe43568300fdca1c1bfd45ea463a12cca8fbe6172a4f6d58cd54e3fbcc" -dependencies = [ - "frame-support", - "frame-system", - "linregress", - "parity-scale-codec", - "paste", - "sp-api", - "sp-io", - "sp-runtime", - "sp-runtime-interface", - "sp-std", - "sp-storage", -] - -[[package]] -name = "frame-metadata" -version = "12.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b5640bfcb7111643807c63cd38ecdcc923d3253e525f23ab6b366002bf8ecd5" -dependencies = [ - "parity-scale-codec", - "serde", - "sp-core", - "sp-std", -] - -[[package]] -name = "frame-support" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "807c32da14bd0e5fb751095335a07938cda6f1488f57d7b0539118e3434980a8" -dependencies = [ - "bitmask", - "frame-metadata", - "frame-support-procedural", - "impl-trait-for-tuples", - "log", - "once_cell", - "parity-scale-codec", - "paste", - "serde", - "smallvec 1.4.2", - "sp-arithmetic", - "sp-core", - "sp-inherents", - "sp-io", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-tracing", -] - -[[package]] -name = "frame-support-procedural" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "508dc2eb44a802f1876e3dc97a76aed8f18b993f75f6cb1975cb83cf45a5d981" -dependencies = [ - "frame-support-procedural-tools", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "frame-support-procedural-tools" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f6d1dd14477123180c47024bcc24c1a624ea8631b4f00080d14089907397f4" -dependencies = [ - "frame-support-procedural-tools-derive", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "frame-support-procedural-tools-derive" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad38379ecedd632f286c7b94a4b9a15bffb635194de4dbf2b4458bc46cee28f" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "frame-system" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d172404f0e44b867f5fd14465a27f298b8828b53d7a7a555d3759e1dec3c8f0d" -dependencies = [ - "frame-support", - "impl-trait-for-tuples", - "parity-scale-codec", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-version", -] - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - -[[package]] -name = "futures" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7e4c2612746b0df8fed4ce0c69156021b704c9aefa360311c04e6e9e002eed" - -[[package]] -name = "futures" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d8e3078b7b2a8a671cb7a3d17b4760e4181ea243227776ba83fd043b4ca034e" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a4d35f7401e948629c9c3d6638fb9bf94e0b2121e96c3b428cc4e631f3eb74" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d674eaa0056896d5ada519900dbf97ead2e46a7b6621e8160d79e2f2e1e2784b" - -[[package]] -name = "futures-executor" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc709ca1da6f66143b8c9bec8e6260181869893714e9b5a490b169b0414144ab" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", - "num_cpus", -] - -[[package]] -name = "futures-io" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc94b64bb39543b4e432f1790b6bf18e3ee3b74653c5449f63310e9a74b123c" - -[[package]] -name = "futures-lite" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c48d23e382e1f50ad68d16cd23dd3c467f420d4933b629c3f183f33e9f560d8" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] - -[[package]] -name = "futures-macro" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f57ed14da4603b2554682e9f2ff3c65d7567b53188db96cb71538217fc64581b" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-sink" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d8764258ed64ebc5d9ed185cf86a95db5cac810269c5d20ececb32e0088abbd" - -[[package]] -name = "futures-task" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dd26820a9f3637f1302da8bceba3ff33adbe53464b54ca24d4e2d4f1db30f94" -dependencies = [ - "once_cell", -] - -[[package]] -name = "futures-timer" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1de7508b218029b0f01662ed8f61b1c964b3ae99d6f25462d0f55a595109df6" - -[[package]] -name = "futures-timer" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" - -[[package]] -name = "futures-util" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a894a0acddba51a2d49a6f4263b1e64b8c579ece8af50fa86503d52cd1eea34" -dependencies = [ - "futures 0.1.30", - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project", - "pin-utils", - "proc-macro-hack", - "proc-macro-nested", - "slab", -] - -[[package]] -name = "generic-array" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -dependencies = [ - "typenum", -] - -[[package]] -name = "generic-array" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee8025cf36f917e6a52cce185b7c7177689b838b7ec138364e50cc2277a56cf4" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "gimli" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" - -[[package]] -name = "globset" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ad1da430bd7281dde2576f44c84cc3f0f7b475e7202cd503042dff01a8c8120" -dependencies = [ - "aho-corasick", - "bstr", - "fnv", - "log", - "regex", -] - -[[package]] -name = "gloo-timers" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47204a46aaff920a1ea58b11d03dec6f704287d27561724a4631e450654a891f" -dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "h2" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "993f9e0baeed60001cf565546b0d3dbe6a6ad23f2bd31644a133c641eccf6d53" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "hash-db" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" - -[[package]] -name = "hash256-std-hasher" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" -dependencies = [ - "crunchy", -] - -[[package]] -name = "hashbrown" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead" -dependencies = [ - "ahash 0.2.19", - "autocfg 0.1.7", -] - -[[package]] -name = "hashbrown" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96282e96bfcd3da0d3aa9938bedf1e50df3269b6db08b4876d2da0bb1a0841cf" -dependencies = [ - "ahash 0.3.8", - "autocfg 1.0.1", -] - -[[package]] -name = "hashbrown" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25" -dependencies = [ - "ahash 0.3.8", - "autocfg 1.0.1", -] - -[[package]] -name = "hashbrown" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00d63df3d41950fb462ed38308eea019113ad1508da725bbedcd0fa5a85ef5f7" - -[[package]] -name = "heck" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "hermit-abi" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" -dependencies = [ - "libc", -] - -[[package]] -name = "hex" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" - -[[package]] -name = "hmac" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" -dependencies = [ - "crypto-mac", - "digest 0.8.1", -] - -[[package]] -name = "hmac-drbg" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b" -dependencies = [ - "digest 0.8.1", - "generic-array 0.12.3", - "hmac", -] - -[[package]] -name = "http" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" -dependencies = [ - "bytes", - "http", -] - -[[package]] -name = "httparse" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" - -[[package]] -name = "httpdate" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" - -[[package]] -name = "hyper" -version = "0.13.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f3afcfae8af5ad0576a31e768415edb627824129e8e5a29b8bfccb2f234e835" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "hyper-tls" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d979acc56dcb5b8dddba3917601745e877576475aa046df3226eabdecef78eed" -dependencies = [ - "bytes", - "hyper", - "native-tls", - "tokio", - "tokio-tls", -] - -[[package]] -name = "idna" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "idna" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "impl-codec" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be51a921b067b0eaca2fad532d9400041561aa922221cc65f95a85641c6bf53" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "impl-serde" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b47ca4d2b6931707a55fce5cf66aff80e2178c8b63bbb4ecb5695cbc870ddf6f" -dependencies = [ - "serde", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef5550a42e3740a0e71f909d4c861056a284060af885ae7aa6242820f920d9d" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "indexmap" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" -dependencies = [ - "autocfg 1.0.1", - "hashbrown 0.9.0", -] - -[[package]] -name = "instant" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63312a18f7ea8760cdd0a7c5aac1a619752a246b833545e3e36d1f81f7cd9e66" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "integer-sqrt" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" -dependencies = [ - "num-traits", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - -[[package]] -name = "ipnet" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" - -[[package]] -name = "itertools" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" - -[[package]] -name = "js-sys" -version = "0.3.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca059e81d9486668f12d455a4ea6daa600bd408134cd17e3d3fb5a32d1f016f8" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "jsonrpc-client-transports" -version = "15.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "489b9c612e60c766f751ab40fcb43cbb55a1e10bb44a9b4307ed510ca598cbd7" -dependencies = [ - "failure", - "futures 0.1.30", - "jsonrpc-core", - "jsonrpc-pubsub", - "log", - "serde", - "serde_json", - "url 1.7.2", -] - -[[package]] -name = "jsonrpc-core" -version = "15.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0745a6379e3edc893c84ec203589790774e4247420033e71a76d3ab4687991fa" -dependencies = [ - "futures 0.1.30", - "log", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "jsonrpc-core-client" -version = "15.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f764902d7b891344a0acb65625f32f6f7c6db006952143bd650209fbe7d94db" -dependencies = [ - "jsonrpc-client-transports", -] - -[[package]] -name = "jsonrpc-derive" -version = "15.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99a847f9ec7bb52149b2786a17c9cb260d6effc6b8eeb8c16b343a487a7563a3" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "jsonrpc-pubsub" -version = "15.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "639558e0604013be9787ae52f798506ae42bf4220fe587bdc5625871cc8b9c77" -dependencies = [ - "jsonrpc-core", - "log", - "parking_lot 0.10.2", - "rand 0.7.3", - "serde", -] - -[[package]] -name = "jsonrpsee" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc8a1da5a54b417cfb7edb9f932024d833dc333de50c21c0e1b28d0e8b4f853" -dependencies = [ - "async-std", - "async-tls", - "bs58", - "bytes", - "fnv", - "futures 0.3.6", - "futures-timer 3.0.2", - "globset", - "hashbrown 0.7.2", - "hyper", - "jsonrpsee-proc-macros", - "lazy_static", - "log", - "parking_lot 0.10.2", - "pin-project", - "rand 0.7.3", - "serde", - "serde_json", - "smallvec 1.4.2", - "soketto", - "thiserror", - "tokio", - "unicase", - "url 2.1.1", - "webpki", -] - -[[package]] -name = "jsonrpsee-proc-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ed1b5f6937dd2c6c79a9ac6e0e3f41bbc64edb5d443840bdc73e606009ed70" -dependencies = [ - "Inflector", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "keccak" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "kv-log-macro" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" -dependencies = [ - "log", -] - -[[package]] -name = "kvdb" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0315ef2f688e33844400b31f11c263f2b3dc21d8b9355c6891c5f185fae43f9a" -dependencies = [ - "parity-util-mem", - "smallvec 1.4.2", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.77" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235" - -[[package]] -name = "libm" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" - -[[package]] -name = "libp2p" -version = "0.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "571f5a4604c1a40d75651da141dfde29ad15329f537a779528803297d2220274" -dependencies = [ - "atomic", - "bytes", - "futures 0.3.6", - "lazy_static", - "libp2p-core", - "libp2p-core-derive", - "libp2p-swarm", - "multihash", - "parity-multiaddr", - "parking_lot 0.10.2", - "pin-project", - "smallvec 1.4.2", - "wasm-timer", -] - -[[package]] -name = "libp2p-core" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52f13ba8c7df0768af2eb391696d562c7de88cc3a35122531aaa6a7d77754d25" -dependencies = [ - "asn1_der", - "bs58", - "ed25519-dalek", - "either", - "fnv", - "futures 0.3.6", - "futures-timer 3.0.2", - "lazy_static", - "libsecp256k1", - "log", - "multihash", - "multistream-select", - "parity-multiaddr", - "parking_lot 0.10.2", - "pin-project", - "prost", - "prost-build", - "rand 0.7.3", - "ring", - "rw-stream-sink", - "sha2 0.8.2", - "smallvec 1.4.2", - "thiserror", - "unsigned-varint 0.4.0", - "void", - "zeroize", -] - -[[package]] -name = "libp2p-core-derive" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f753d9324cd3ec14bf04b8a8cd0d269c87f294153d6bf2a84497a63a5ad22213" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "libp2p-swarm" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7193e444210132237b81b755ec7fe53f1c4bd2f53cf719729b94c0c72eb6eaa1" -dependencies = [ - "either", - "futures 0.3.6", - "libp2p-core", - "log", - "rand 0.7.3", - "smallvec 1.4.2", - "void", - "wasm-timer", -] - -[[package]] -name = "libsecp256k1" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" -dependencies = [ - "arrayref", - "crunchy", - "digest 0.8.1", - "hmac-drbg", - "rand 0.7.3", - "sha2 0.8.2", - "subtle 2.3.0", - "typenum", -] - -[[package]] -name = "linregress" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9290cf6f928576eeb9c096c6fad9d8d452a0a1a70a2bbffa6e36064eedc0aac9" -dependencies = [ - "failure", - "nalgebra", - "statrs", -] - -[[package]] -name = "lock_api" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" -dependencies = [ - "scopeguard", -] - -[[package]] -name = "lock_api" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28247cc5a5be2f05fbcd76dd0cf2c7d3b5400cb978a28042abcd4fa0b3f8261c" -dependencies = [ - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "lru" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0609345ddee5badacf857d4f547e0e5a2e987db77085c24cd887f73573a04237" -dependencies = [ - "hashbrown 0.6.3", -] - -[[package]] -name = "matchers" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" -dependencies = [ - "regex-automata", -] - -[[package]] -name = "matches" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" - -[[package]] -name = "matrixmultiply" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4f7ec66360130972f34830bfad9ef05c6610a43938a467bcc9ab9369ab3478f" -dependencies = [ - "rawpointer", -] - -[[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.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" - -[[package]] -name = "memory-db" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36f36ddb0b2cdc25d38babba472108798e3477f02be5165f038c5e393e50c57a" -dependencies = [ - "hash-db", - "hashbrown 0.8.2", - "parity-util-mem", -] - -[[package]] -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.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6feca46f4fa3443a01769d768727f10c10a20fdb65e52dc16a81f0c8269bb78" -dependencies = [ - "byteorder", - "keccak", - "rand_core 0.5.1", - "zeroize", -] - -[[package]] -name = "mime" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" - -[[package]] -name = "mime_guess" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" -dependencies = [ - "mime", - "unicase", -] - -[[package]] -name = "miniz_oxide" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" -dependencies = [ - "adler", - "autocfg 1.0.1", -] - -[[package]] -name = "mio" -version = "0.6.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" -dependencies = [ - "cfg-if", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log", - "miow", - "net2", - "slab", - "winapi 0.2.8", -] - -[[package]] -name = "miow" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", -] - -[[package]] -name = "multihash" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567122ab6492f49b59def14ecc36e13e64dca4188196dd0cd41f9f3f979f3df6" -dependencies = [ - "blake2b_simd", - "blake2s_simd", - "digest 0.9.0", - "sha-1", - "sha2 0.9.1", - "sha3", - "unsigned-varint 0.5.1", -] - -[[package]] -name = "multimap" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1255076139a83bb467426e7f8d0134968a8118844faa755985e077cf31850333" - -[[package]] -name = "multistream-select" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9157e87afbc2ef0d84cc0345423d715f445edde00141c93721c162de35a05e5" -dependencies = [ - "bytes", - "futures 0.3.6", - "log", - "pin-project", - "smallvec 1.4.2", - "unsigned-varint 0.4.0", -] - -[[package]] -name = "nalgebra" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaa9fddbc34c8c35dd2108515587b8ce0cab396f17977b8c738568e4edb521a2" -dependencies = [ - "alga", - "approx", - "generic-array 0.12.3", - "matrixmultiply", - "num-complex", - "num-rational", - "num-traits", - "rand 0.6.5", - "typenum", -] - -[[package]] -name = "native-tls" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "nb-connect" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8123a81538e457d44b933a02faf885d3fe8408806b23fa700e8f01c6c3a98998" -dependencies = [ - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "net2" -version = "0.2.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" -dependencies = [ - "cfg-if", - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" - -[[package]] -name = "num-bigint" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" -dependencies = [ - "autocfg 1.0.1", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" -dependencies = [ - "autocfg 1.0.1", - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" -dependencies = [ - "autocfg 1.0.1", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" -dependencies = [ - "autocfg 1.0.1", - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" -dependencies = [ - "autocfg 1.0.1", - "libm", -] - -[[package]] -name = "num_cpus" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "object" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" - -[[package]] -name = "once_cell" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" -dependencies = [ - "parking_lot 0.11.0", -] - -[[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.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4" -dependencies = [ - "bitflags", - "cfg-if", - "foreign-types", - "lazy_static", - "libc", - "openssl-sys", -] - -[[package]] -name = "openssl-probe" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" - -[[package]] -name = "openssl-sys" -version = "0.9.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de" -dependencies = [ - "autocfg 1.0.1", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "pallet-authorship" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65706c382ae14ef2768e7411c5faaf1e0a310b4a86d17c3a93dfacb2c5987576" -dependencies = [ - "frame-support", - "frame-system", - "impl-trait-for-tuples", - "parity-scale-codec", - "sp-authorship", - "sp-inherents", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-im-online" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a29b883f805fa2330742b5d99263eab68583e009be1a2420efab1c3237a08e5" -dependencies = [ - "frame-support", - "frame-system", - "pallet-authorship", - "pallet-session", - "parity-scale-codec", - "serde", - "sp-application-crypto", - "sp-core", - "sp-io", - "sp-runtime", - "sp-staking", - "sp-std", -] - -[[package]] -name = "pallet-indices" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d234bf46076a835b473a987f089299ffa3efd961a92b5be9384cc280fcc8c8f" -dependencies = [ - "frame-support", - "frame-system", - "parity-scale-codec", - "serde", - "sp-core", - "sp-io", - "sp-keyring", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-session" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8abf520fc0c3259be05f164d43d34d52c86aeef8e8c5fded40145394394fc75d" -dependencies = [ - "frame-support", - "frame-system", - "impl-trait-for-tuples", - "pallet-timestamp", - "parity-scale-codec", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "sp-trie", -] - -[[package]] -name = "pallet-staking" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d296b36c5c32d1e480de15d0bf08460bb6d8e1771d928a6017e88a6a1de6bf7" -dependencies = [ - "frame-support", - "frame-system", - "pallet-authorship", - "pallet-session", - "parity-scale-codec", - "serde", - "sp-application-crypto", - "sp-io", - "sp-npos-elections", - "sp-runtime", - "sp-staking", - "sp-std", - "static_assertions", -] - -[[package]] -name = "pallet-timestamp" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccddd55b713f541dff6ccf063cc7ddbc4fc41e92a9fdad8ec9562a0e3b465016" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "impl-trait-for-tuples", - "parity-scale-codec", - "serde", - "sp-inherents", - "sp-runtime", - "sp-std", - "sp-timestamp", -] - -[[package]] -name = "parity-multiaddr" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2165a93382a93de55868dcbfa11e4a8f99676a9164eee6a2b4a9479ad319c257" -dependencies = [ - "arrayref", - "bs58", - "byteorder", - "data-encoding", - "multihash", - "percent-encoding 2.1.0", - "serde", - "static_assertions", - "unsigned-varint 0.4.0", - "url 2.1.1", -] - -[[package]] -name = "parity-scale-codec" -version = "1.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c740e5fbcb6847058b40ac7e5574766c6388f585e184d769910fe0d3a2ca861" -dependencies = [ - "arrayvec 0.5.1", - "bitvec", - "byte-slice-cast", - "parity-scale-codec-derive", - "serde", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "198db82bb1c18fc00176004462dd809b2a6d851669550aa17af6dacd21ae0c14" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "parity-util-mem" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "297ff91fa36aec49ce183484b102f6b75b46776822bd81525bfc4cc9b0dd0f5c" -dependencies = [ - "cfg-if", - "hashbrown 0.8.2", - "impl-trait-for-tuples", - "parity-util-mem-derive", - "parking_lot 0.10.2", - "primitive-types", - "winapi 0.3.9", -] - -[[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.41.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc878dac00da22f8f61e7af3157988424567ab01d9920b962ef7dcbd7cd865" - -[[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.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api 0.3.4", - "parking_lot_core 0.6.2", - "rustc_version", -] - -[[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.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4893845fa2ca272e647da5d0e46660a314ead9c2fdd9a883aabc32e481a8733" -dependencies = [ - "instant", - "lock_api 0.4.1", - "parking_lot_core 0.8.0", -] - -[[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" -dependencies = [ - "cfg-if", - "cloudabi 0.0.3", - "libc", - "redox_syscall", - "rustc_version", - "smallvec 0.6.13", - "winapi 0.3.9", -] - -[[package]] -name = "parking_lot_core" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" -dependencies = [ - "cfg-if", - "cloudabi 0.0.3", - "libc", - "redox_syscall", - "smallvec 1.4.2", - "winapi 0.3.9", -] - -[[package]] -name = "parking_lot_core" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b" -dependencies = [ - "cfg-if", - "cloudabi 0.1.0", - "instant", - "libc", - "redox_syscall", - "smallvec 1.4.2", - "winapi 0.3.9", -] - -[[package]] -name = "paste" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" -dependencies = [ - "paste-impl", - "proc-macro-hack", -] - -[[package]] -name = "paste-impl" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" -dependencies = [ - "proc-macro-hack", -] - -[[package]] -name = "pbkdf2" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" -dependencies = [ - "byteorder", - "crypto-mac", -] - -[[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 = "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.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f48fad7cfbff853437be7cf54d7b993af21f53be7f0988cbfe4a51535aa77205" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "0.4.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24c6d293bdd3ca5a1697997854c6cf7855e43fb6a0ba1c47af57a5bcafd158ae" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-lite" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71f349a4f0e70676ffb2dbafe16d0c992382d02f0a952e3ddf584fc289dac6b3" - -[[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.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" - -[[package]] -name = "polling" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7215a098a80ab8ebd6349db593dc5faf741781bad0c4b7c5701fea6af548d52c" -dependencies = [ - "cfg-if", - "libc", - "log", - "wepoll-sys", - "winapi 0.3.9", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" - -[[package]] -name = "primitive-types" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55c21c64d0eaa4d7ed885d959ef2d62d9e488c27c0e02d9aa5ce6c877b7d5f8" -dependencies = [ - "fixed-hash", - "impl-codec", - "impl-serde", - "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-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.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99c605b9a0adc77b7211c6b1f722dcb613d68d66859a44f3d485a6da332b0598" - -[[package]] -name = "proc-macro-nested" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" - -[[package]] -name = "proc-macro2" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51ef7cd2518ead700af67bf9d1a658d90b6037d77110fd9c0445429d0ba1c6c9" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "prometheus" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d70cf4412832bcac9cffe27906f4a66e450d323525e977168c70d1b36120ae" -dependencies = [ - "cfg-if", - "fnv", - "lazy_static", - "parking_lot 0.11.0", - "regex", - "thiserror", -] - -[[package]] -name = "prost" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce49aefe0a6144a45de32927c77bd2859a5f7677b55f220ae5b744e87389c212" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b10678c913ecbd69350e8535c3aef91a8676c0773fc1d7b95cdd196d7f2f26" -dependencies = [ - "bytes", - "heck", - "itertools", - "log", - "multimap", - "petgraph", - "prost", - "prost-types", - "tempfile", - "which", -] - -[[package]] -name = "prost-derive" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "537aa19b95acde10a12fec4301466386f757403de4cd4e5b4fa78fb5ecb18f72" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "prost-types" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1834f67c0697c001304b75be76f67add9c89742eda3a085ad8ee0bb38c3417aa" -dependencies = [ - "bytes", - "prost", -] - -[[package]] -name = "quote" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radium" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" - -[[package]] -name = "rand" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" -dependencies = [ - "cloudabi 0.0.3", - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "winapi 0.3.9", -] - -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.7", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg 0.1.2", - "rand_xorshift", - "winapi 0.3.9", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.15", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc 0.2.0", - "rand_pcg 0.2.1", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.3.1", -] - -[[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_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.15", -] - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - -[[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_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi 0.3.9", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi 0.0.3", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.9", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.4.2", -] - -[[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 = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rawpointer" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - -[[package]] -name = "ref-cast" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "745c1787167ddae5569661d5ffb8b25ae5fedbf46717eaa92d652221cec72623" -dependencies = [ - "ref-cast-impl", -] - -[[package]] -name = "ref-cast-impl" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d21b475ab879ef0e315ad99067fa25778c3b0377f57f1b00207448dac1a3144" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "regex" -version = "1.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", - "thread_local", -] - -[[package]] -name = "regex-automata" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" -dependencies = [ - "byteorder", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "reqwest" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9eaa17ac5d7b838b7503d118fa16ad88f440498bf9ffe5424e621f93190d61e" -dependencies = [ - "base64 0.12.3", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "http", - "http-body", - "hyper", - "hyper-tls", - "ipnet", - "js-sys", - "lazy_static", - "log", - "mime", - "mime_guess", - "native-tls", - "percent-encoding 2.1.0", - "pin-project-lite", - "serde", - "serde_json", - "serde_urlencoded", - "tokio", - "tokio-tls", - "url 2.1.1", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", -] - -[[package]] -name = "ring" -version = "0.16.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "952cd6b98c85bbc30efa1ba5783b8abf12fec8b3287ffa52605b9432313e34e4" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin", - "untrusted", - "web-sys", - "winapi 0.3.9", -] - -[[package]] -name = "rlp" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a7d3f9bed94764eac15b8f14af59fac420c236adaff743b7bcc88e265cb4345" -dependencies = [ - "rustc-hex", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2610b7f643d18c87dff3b489950269617e6601a51f1f05aa5daefee36f64f0b" - -[[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", -] - -[[package]] -name = "rustls" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b25a18b1bf7387f0145e7f8324e700805aade3842dd3db2e74e4cdeb4677c09e" -dependencies = [ - "base64 0.10.1", - "log", - "ring", - "sct", - "webpki", -] - -[[package]] -name = "rw-stream-sink" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4da5fcb054c46f5a5dff833b129285a93d3f0179531735e6c866e8cc307d2020" -dependencies = [ - "futures 0.3.6", - "pin-project", - "static_assertions", -] - -[[package]] -name = "ryu" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" - -[[package]] -name = "sc-rpc-api" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfb4b79b9b6b410c745a00eb4ead11b2ef0819e6eac970a5ec6415abf82777be" -dependencies = [ - "derive_more", - "futures 0.3.6", - "jsonrpc-core", - "jsonrpc-core-client", - "jsonrpc-derive", - "jsonrpc-pubsub", - "log", - "parity-scale-codec", - "parking_lot 0.10.2", - "serde", - "serde_json", - "sp-chain-spec", - "sp-core", - "sp-rpc", - "sp-runtime", - "sp-transaction-pool", - "sp-version", -] - -[[package]] -name = "schannel" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" -dependencies = [ - "lazy_static", - "winapi 0.3.9", -] - -[[package]] -name = "schnorrkel" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" -dependencies = [ - "arrayref", - "arrayvec 0.5.1", - "curve25519-dalek 2.1.0", - "getrandom 0.1.15", - "merlin", - "rand 0.7.3", - "rand_core 0.5.1", - "sha2 0.8.2", - "subtle 2.3.0", - "zeroize", -] - -[[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.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "secrecy" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9182278ed645df3477a9c27bfee0621c621aa16f6972635f7f795dae3d81070f" -dependencies = [ - "zeroize", -] - -[[package]] -name = "security-framework" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "serde" -version = "1.0.116" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96fe57af81d28386a513cbc6858332abc6117cfdb5999647c6444b8f43a370a5" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.116" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f630a6370fd8e457873b4bd2ffdae75408bc291ba72be773772a4c2a065d9ae8" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "164eacbdb13512ec2745fb09d51fd5b22b0d65ed294a1dcf7285a360c80a675c" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_urlencoded" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" -dependencies = [ - "dtoa", - "itoa", - "serde", - "url 2.1.1", -] - -[[package]] -name = "sha-1" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "170a36ea86c864a3f16dd2687712dd6646f7019f301e57537c7f4dc9f5916770" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpuid-bool", - "digest 0.9.0", - "opaque-debug 0.3.0", -] - -[[package]] -name = "sha1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" - -[[package]] -name = "sha2" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", -] - -[[package]] -name = "sha2" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2933378ddfeda7ea26f48c555bdad8bb446bf8a3d17832dc83e380d444cfb8c1" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpuid-bool", - "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", - "digest 0.9.0", - "keccak", - "opaque-debug 0.3.0", -] - -[[package]] -name = "sharded-slab" -version = "0.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06d5a3f5166fb5b42a5439f2eee8b9de149e235961e3eb21c5808fc3ea17ff3e" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "signature" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" - -[[package]] -name = "smallvec" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" -dependencies = [ - "maybe-uninit", -] - -[[package]] -name = "smallvec" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" - -[[package]] -name = "socket2" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "winapi 0.3.9", -] - -[[package]] -name = "soketto" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c9dab3f95c9ebdf3a88268c19af668f637a3c5039c2c56ff2d40b1b2d64a25b" -dependencies = [ - "base64 0.11.0", - "bytes", - "futures 0.3.6", - "http", - "httparse", - "log", - "rand 0.7.3", - "sha1", - "smallvec 1.4.2", - "static_assertions", - "thiserror", -] - -[[package]] -name = "sp-api" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953a3296335d9761311763dbe6855109ea4bea915e27cf5633d8b01057898302" -dependencies = [ - "hash-db", - "parity-scale-codec", - "sp-api-proc-macro", - "sp-core", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-version", -] - -[[package]] -name = "sp-api-proc-macro" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8247ca24a2a881af2ac675c8ec33584944965d6d45645bbec16fe327ce42dce6" -dependencies = [ - "blake2-rfc", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "sp-application-crypto" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "885eca124aa6ce0bba57c08bc48c4357096996d630a77f572580ef8e2e4df034" -dependencies = [ - "parity-scale-codec", - "serde", - "sp-core", - "sp-io", - "sp-std", -] - -[[package]] -name = "sp-arithmetic" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "667775bc50eb214225df18c92e4ec57acc7e2dc78d7d210eb4dd930db1a73995" -dependencies = [ - "integer-sqrt", - "num-traits", - "parity-scale-codec", - "serde", - "sp-debug-derive", - "sp-std", -] - -[[package]] -name = "sp-authority-discovery" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b7748c0e859bf4c3dda84849a72af83c9f85bb21a7b7c085ed161516fa00d1e" -dependencies = [ - "parity-scale-codec", - "sp-api", - "sp-application-crypto", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "sp-authorship" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58623adee1ed41752d76151762c80801758f88f85e4016d0338f2b01f4e7bd44" -dependencies = [ - "parity-scale-codec", - "sp-inherents", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "sp-block-builder" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07d7fca8aa126a9d295843d592f44b48d8cf93880862baeff2968164598ab26c" -dependencies = [ - "parity-scale-codec", - "sp-api", - "sp-inherents", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "sp-blockchain" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e37387284973e2edceefaa673930282801ea238e5892a2cc6aa02f7f2e7601df" -dependencies = [ - "derive_more", - "log", - "lru", - "parity-scale-codec", - "parking_lot 0.10.2", - "sp-block-builder", - "sp-consensus", - "sp-database", - "sp-runtime", - "sp-state-machine", -] - -[[package]] -name = "sp-chain-spec" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "150ce7661d02d4d0509a4a8364ab3b71a5ef2faf3f97d22d4b76bc0786d9e28b" -dependencies = [ - "serde", - "serde_json", -] - -[[package]] -name = "sp-consensus" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b460103293bbf2f4193e43c4f031fdc099c5e27c782369bbb4dacc7765e84057" -dependencies = [ - "derive_more", - "futures 0.3.6", - "futures-timer 3.0.2", - "libp2p", - "log", - "parity-scale-codec", - "parking_lot 0.10.2", - "serde", - "sp-api", - "sp-core", - "sp-inherents", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-trie", - "sp-utils", - "sp-version", - "substrate-prometheus-endpoint", - "wasm-timer", -] - -[[package]] -name = "sp-consensus-babe" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8050a73302f354f45d0dee610e69ed39aadf43ab8a7528bdf3df8427276dc739" -dependencies = [ - "merlin", - "parity-scale-codec", - "sp-api", - "sp-application-crypto", - "sp-consensus", - "sp-consensus-slots", - "sp-consensus-vrf", - "sp-core", - "sp-inherents", - "sp-runtime", - "sp-std", - "sp-timestamp", -] - -[[package]] -name = "sp-consensus-slots" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83ea323ccf4ec8aad353fbc9016a1cb8cbf0d872d33bc8874cb0753b014fb7fc" -dependencies = [ - "parity-scale-codec", - "sp-runtime", -] - -[[package]] -name = "sp-consensus-vrf" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3345ee42ea5319bd6e3329bc3b5ee68b09f14d677378b27409a3a52d5ebe9990" -dependencies = [ - "parity-scale-codec", - "schnorrkel", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "sp-core" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e92ac5c674ee2cd9219d084301b4cbb82b28a94a0f3087bf4bea0ef3067ebb5c" -dependencies = [ - "base58", - "blake2-rfc", - "byteorder", - "derive_more", - "dyn-clonable", - "ed25519-dalek", - "futures 0.3.6", - "hash-db", - "hash256-std-hasher", - "hex", - "impl-serde", - "lazy_static", - "libsecp256k1", - "log", - "merlin", - "num-traits", - "parity-scale-codec", - "parity-util-mem", - "parking_lot 0.10.2", - "primitive-types", - "rand 0.7.3", - "regex", - "schnorrkel", - "secrecy", - "serde", - "sha2 0.8.2", - "sp-debug-derive", - "sp-externalities", - "sp-runtime-interface", - "sp-std", - "sp-storage", - "substrate-bip39", - "tiny-bip39", - "tiny-keccak", - "twox-hash", - "wasmi", - "zeroize", -] - -[[package]] -name = "sp-database" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c1c352eceefe5bcdfc27f13a2fd038fc571b7aca5146f2cd651d40e9d2457dd" -dependencies = [ - "kvdb", - "parking_lot 0.10.2", -] - -[[package]] -name = "sp-debug-derive" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a3750b084e0f4677f6e834a974f30b1ba97fc2fe00185c9d03611a2228446dc" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "sp-externalities" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d87fcd0e0fc5e025459cfe769803488d4894e36d0f8cef80b5239d2e7ef6580" -dependencies = [ - "environmental", - "parity-scale-codec", - "sp-std", - "sp-storage", -] - -[[package]] -name = "sp-finality-grandpa" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "789d960506306f34fb0a2da547956ba1f23d6a29032291a7284c943906feddcb" -dependencies = [ - "finality-grandpa", - "log", - "parity-scale-codec", - "serde", - "sp-api", - "sp-application-crypto", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "sp-inherents" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "365e5aee23640631e63e8634f1d804e33c8fcb521f4052910f29abaa2df1c1cf" -dependencies = [ - "derive_more", - "parity-scale-codec", - "parking_lot 0.10.2", - "sp-core", - "sp-std", -] - -[[package]] -name = "sp-io" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e1dee9244eb6cba1bef9b3a4ec288185e1380e455f1fd348b60252592c1cf0" -dependencies = [ - "futures 0.3.6", - "hash-db", - "libsecp256k1", - "log", - "parity-scale-codec", - "parking_lot 0.10.2", - "sp-core", - "sp-externalities", - "sp-runtime-interface", - "sp-state-machine", - "sp-std", - "sp-tracing", - "sp-trie", - "sp-wasm-interface", - "tracing", - "tracing-core", -] - -[[package]] -name = "sp-keyring" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f76feeb27b218d58523931ea2d708b622c3bd96a3be1c3a5895bba0f7a54c13" -dependencies = [ - "lazy_static", - "sp-core", - "sp-runtime", - "strum", -] - -[[package]] -name = "sp-npos-elections" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54bb6d3d49dccf6ee26586a29ce8aabade8e102e51ed5009660ef7abb973eb7d" -dependencies = [ - "parity-scale-codec", - "serde", - "sp-arithmetic", - "sp-npos-elections-compact", - "sp-std", -] - -[[package]] -name = "sp-npos-elections-compact" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d784c5576824b0ffa4cb359b7eebfd87511c49685b170b8214aabaa5f2454c87" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "sp-panic-handler" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "492126eb766b3b6740e4e4929d6527d37708598b7296a664f3680c0f0c1fc573" -dependencies = [ - "backtrace", - "log", -] - -[[package]] -name = "sp-rpc" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5c6678f4b42421e6dcdf3896a0c81a403c29ef1cf8d74b046d59125d40da911" -dependencies = [ - "serde", - "sp-core", -] - -[[package]] -name = "sp-runtime" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62542f8ce9d5fcb43a4dd3c3a53326d33aacf9b0bc9d353d6fe9fd5ff3031747" -dependencies = [ - "either", - "hash256-std-hasher", - "impl-trait-for-tuples", - "log", - "parity-scale-codec", - "parity-util-mem", - "paste", - "rand 0.7.3", - "serde", - "sp-application-crypto", - "sp-arithmetic", - "sp-core", - "sp-inherents", - "sp-io", - "sp-std", -] - -[[package]] -name = "sp-runtime-interface" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b7e363c480cc8c9019b84f85d10c0b56a184079d5d840d2d1d55087ad835dc6" -dependencies = [ - "parity-scale-codec", - "primitive-types", - "sp-externalities", - "sp-runtime-interface-proc-macro", - "sp-std", - "sp-storage", - "sp-tracing", - "sp-wasm-interface", - "static_assertions", -] - -[[package]] -name = "sp-runtime-interface-proc-macro" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cf56a38544293e54dbe0aa7b6aed1e046bfc704b6fc3de7255897dca98ccb1" -dependencies = [ - "Inflector", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "sp-session" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d138b1f548933003feaa967de49ed87066643073bcc41be45ef2daaa0991c133" -dependencies = [ - "parity-scale-codec", - "sp-api", - "sp-core", - "sp-runtime", - "sp-staking", - "sp-std", -] - -[[package]] -name = "sp-staking" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b06f9839d8b4312486626bde31d6cd7763dd9b7d93ea9e70c01ca30f0998032" -dependencies = [ - "parity-scale-codec", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "sp-state-machine" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f58335de98bca196683a8ef22195a8a43b457b8bc705dba3124138ffc2ee720" -dependencies = [ - "hash-db", - "log", - "num-traits", - "parity-scale-codec", - "parking_lot 0.10.2", - "rand 0.7.3", - "smallvec 1.4.2", - "sp-core", - "sp-externalities", - "sp-panic-handler", - "sp-std", - "sp-trie", - "trie-db", - "trie-root", -] - -[[package]] -name = "sp-std" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa2d6e166cead2d3b1d3d8fe0e787d076b7d0296b1760a0d7d340846d0ba42c5" - -[[package]] -name = "sp-storage" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4625e6f8f40995939560f48f89028f658b7929657c68d01c571c81ab5619ff" -dependencies = [ - "impl-serde", - "parity-scale-codec", - "ref-cast", - "serde", - "sp-debug-derive", - "sp-std", -] - -[[package]] -name = "sp-timestamp" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cb398f0a5d2798ad4e02450b3089534547b448d22ebe6f3b2c03f74170f58d1" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "sp-api", - "sp-inherents", - "sp-runtime", - "sp-std", - "wasm-timer", -] - -[[package]] -name = "sp-tracing" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9a5c42c5450991ca3a28c190e75122f5ccedbcb024953e7c357e7aa2afd8534" -dependencies = [ - "log", - "parity-scale-codec", - "sp-std", - "tracing", - "tracing-core", - "tracing-subscriber", -] - -[[package]] -name = "sp-transaction-pool" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b34ee48341c17c6e2f1e55f6076918f46b0c4505a99ad69ab1edda8b45bbd8" -dependencies = [ - "derive_more", - "futures 0.3.6", - "log", - "parity-scale-codec", - "serde", - "sp-api", - "sp-blockchain", - "sp-runtime", -] - -[[package]] -name = "sp-trie" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3aae57c8ae81ba978503137a8c625d2963eb425dd90dec0d96b4ed18d8bfd55" -dependencies = [ - "hash-db", - "memory-db", - "parity-scale-codec", - "sp-core", - "sp-std", - "trie-db", - "trie-root", -] - -[[package]] -name = "sp-utils" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84310a02e2ac89b5e288d7af980414fd88753e3caba92aab1983cd2819991150" -dependencies = [ - "futures 0.3.6", - "futures-core", - "futures-timer 3.0.2", - "lazy_static", - "prometheus", -] - -[[package]] -name = "sp-version" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21935199c8765f0d02facc718f9c83149a70ea684fb03612e5161c682b38a301" -dependencies = [ - "impl-serde", - "parity-scale-codec", - "serde", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "sp-wasm-interface" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1c28225e8b7ec7e260f8b46443f8731abda206334cb75c740d2407693f38167" -dependencies = [ - "impl-trait-for-tuples", - "parity-scale-codec", - "sp-std", - "wasmi", -] - -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "statrs" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10102ac8d55e35db2b3fafc26f81ba8647da2e15879ab686a67e6d19af2685e8" -dependencies = [ - "rand 0.5.6", -] - -[[package]] -name = "strum" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6138f8f88a16d90134763314e3fc76fa3ed6a7db4725d6acf9a3ef95a3188d22" -dependencies = [ - "strum_macros", -] - -[[package]] -name = "strum_macros" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0054a7df764039a6cd8592b9de84be4bec368ff081d203a7d5371cbfa8e65c81" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "substrate-bip39" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bed6646a0159b9935b5d045611560eeef842b78d7adc3ba36f5ca325a13a0236" -dependencies = [ - "hmac", - "pbkdf2", - "schnorrkel", - "sha2 0.8.2", - "zeroize", -] - -[[package]] -name = "substrate-prometheus-endpoint" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3e361741d066bfc29554b9f1bc8e4ac927eb4bd33dd8bb0486969edd8b0b5a" -dependencies = [ - "async-std", - "derive_more", - "futures-util", - "hyper", - "log", - "prometheus", - "tokio", -] - -[[package]] -name = "substrate-subxt" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed693047c3c907a660aa97a71a30af33cec878316d75df60967d73b673ff4fd3" -dependencies = [ - "frame-metadata", - "frame-support", - "futures 0.3.6", - "hex", - "jsonrpsee", - "log", - "num-traits", - "pallet-im-online", - "pallet-indices", - "pallet-staking", - "parity-scale-codec", - "sc-rpc-api", - "serde", - "serde_json", - "sp-application-crypto", - "sp-authority-discovery", - "sp-consensus-babe", - "sp-core", - "sp-finality-grandpa", - "sp-rpc", - "sp-runtime", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-subxt-proc-macro", - "thiserror", - "url 2.1.1", -] - -[[package]] -name = "substrate-subxt-proc-macro" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74975f373430ec447afaeb2925f2bac77e113733b08263f4df75e0a0e5998090" -dependencies = [ - "heck", - "proc-macro-crate", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", - "synstructure", -] - -[[package]] -name = "subtle" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" - -[[package]] -name = "subtle" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd" - -[[package]] -name = "syn" -version = "1.0.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c51d92969d209b54a98397e1b91c8ae82d8c87a7bb87df0b29aa2ad81454228" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "synstructure" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "unicode-xid", -] - -[[package]] -name = "tempfile" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" -dependencies = [ - "cfg-if", - "libc", - "rand 0.7.3", - "redox_syscall", - "remove_dir_all", - "winapi 0.3.9", -] - -[[package]] -name = "thiserror" -version = "1.0.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "318234ffa22e0920fe9a40d7b8369b5f649d490980cf7aadcf1eb91594869b42" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cae2447b6282786c3493999f40a9be2a6ad20cb8bd268b0a0dbf5a065535c0ab" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "thread_local" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "time" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi 0.3.9", -] - -[[package]] -name = "tiny-bip39" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0165e045cc2ae1660270ca65e1676dbaab60feb0f91b10f7d0665e9b47e31f2" -dependencies = [ - "failure", - "hmac", - "once_cell", - "pbkdf2", - "rand 0.7.3", - "rustc-hash", - "sha2 0.8.2", - "unicode-normalization", -] - -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", -] - -[[package]] -name = "tinyvec" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117" - -[[package]] -name = "tokio" -version = "0.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "iovec", - "lazy_static", - "memchr", - "mio", - "pin-project-lite", - "slab", -] - -[[package]] -name = "tokio-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343" -dependencies = [ - "native-tls", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "log", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "toml" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" -dependencies = [ - "serde", -] - -[[package]] -name = "tower-service" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" - -[[package]] -name = "tracing" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d79ca061b032d6ce30c660fded31189ca0b9922bf483cd70759f13a2d86786c" -dependencies = [ - "cfg-if", - "log", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bcf46c1f1f06aeea2d6b81f3c863d0930a596c86ad1920d4e5bad6dd1d7119a" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "tracing-log" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e0f8c7178e13481ff6765bd169b33e8d554c5d2bbede5e32c356194be02b9b9" -dependencies = [ - "lazy_static", - "log", - "tracing-core", -] - -[[package]] -name = "tracing-serde" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b" -dependencies = [ - "serde", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82bb5079aa76438620837198db8a5c529fb9878c730bc2b28179b0241cf04c10" -dependencies = [ - "ansi_term", - "chrono", - "lazy_static", - "matchers", - "regex", - "serde", - "serde_json", - "sharded-slab", - "smallvec 1.4.2", - "thread_local", - "tracing-core", - "tracing-log", - "tracing-serde", -] - -[[package]] -name = "trie-db" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e55f7ace33d6237e14137e386f4e1672e2a5c6bbc97fef9f438581a143971f0" -dependencies = [ - "hash-db", - "hashbrown 0.8.2", - "log", - "rustc-hex", - "smallvec 1.4.2", -] - -[[package]] -name = "trie-root" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "652931506d2c1244d7217a70b99f56718a7b4161b37f04e7cd868072a99f68cd" -dependencies = [ - "hash-db", -] - -[[package]] -name = "try-lock" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" - -[[package]] -name = "twox-hash" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56" -dependencies = [ - "rand 0.7.3", -] - -[[package]] -name = "typenum" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" - -[[package]] -name = "uint" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9db035e67dfaf7edd9aebfe8676afcd63eed53c8a4044fed514c8cccf1835177" -dependencies = [ - "byteorder", - "crunchy", - "rustc-hex", - "static_assertions", -] - -[[package]] -name = "unicase" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" -dependencies = [ - "version_check", -] - -[[package]] -name = "unicode-bidi" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -dependencies = [ - "matches", -] - -[[package]] -name = "unicode-normalization" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-segmentation" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" - -[[package]] -name = "unicode-xid" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" - -[[package]] -name = "unsigned-varint" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "669d776983b692a906c881fcd0cfb34271a48e197e4d6cb8df32b05bfc3d3fa5" - -[[package]] -name = "unsigned-varint" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fdeedbf205afadfe39ae559b75c3240f24e257d0ca27e85f85cb82aa19ac35" - -[[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.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" -dependencies = [ - "idna 0.2.0", - "matches", - "percent-encoding 2.1.0", -] - -[[package]] -name = "vcpkg" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" - -[[package]] -name = "vec-arena" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eafc1b9b2dfc6f5529177b62cf806484db55b32dc7c9658a118e11bbeb33061d" - -[[package]] -name = "version_check" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" - -[[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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" -dependencies = [ - "log", - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - -[[package]] -name = "wasm-bindgen" -version = "0.2.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42" -dependencies = [ - "cfg-if", - "serde", - "serde_json", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f22b422e2a757c35a73774860af8e112bff612ce6cb604224e8e47641a9e4f68" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7866cab0aa01de1edf8b5d7936938a7e397ee50ce24119aef3e1eaa3b6171da" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b13312a745c08c469f0b292dd2fcd6411dba5f7160f593da6ef69b64e407038" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f249f06ef7ee334cc3b8ff031bfc11ec99d00f34d86da7498396dc1e3b1498fe" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307" - -[[package]] -name = "wasm-timer" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" -dependencies = [ - "futures 0.3.6", - "js-sys", - "parking_lot 0.11.0", - "pin-utils", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - -[[package]] -name = "wasmi" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf617d864d25af3587aa745529f7aaa541066c876d57e050c0d0c85c61c92aff" -dependencies = [ - "libc", - "memory_units", - "num-rational", - "num-traits", - "parity-wasm", - "wasmi-validation", -] - -[[package]] -name = "wasmi-validation" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea78c597064ba73596099281e2f4cfc019075122a65cdda3205af94f0b264d93" -dependencies = [ - "parity-wasm", -] - -[[package]] -name = "web-sys" -version = "0.3.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bf6ef87ad7ae8008e15a355ce696bed26012b7caa21605188cfd8214ab51e2d" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "webpki" -version = "0.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab146130f5f790d45f82aeeb09e55a256573373ec64409fc19a6fb82fb1032ae" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "webpki-roots" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a262ae37dd9d60f60dd473d1158f9fbebf110ba7b6a5051c8160460f6043718b" -dependencies = [ - "webpki", -] - -[[package]] -name = "wepoll-sys" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "142bc2cba3fe88be1a8fcb55c727fa4cd5b0cf2d7438722792e22f26f04bc1e0" -dependencies = [ - "cc", -] - -[[package]] -name = "which" -version = "3.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" -dependencies = [ - "libc", -] - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "winreg" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "zeroize" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f33972566adbd2d3588b0491eb94b98b43695c4ef897903470ede4f3f5a28a" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3f369ddb18862aba61aa49bf31e74d29f0f162dec753063200e1dc084345d16" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 84d9b9c39..5b42b5dd0 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -1,60 +1,26 @@ [package] -name = "darwinia-bridge-primitives" +name = "bridge-primitives" version = "0.3.3" -authors = ["clearloop "] -description = "Darwinia bridge primitives" +authors = ["Darwinia Network "] +description = "Darwinia bridger" repository = "https://github.com/darwinia-network/bridger" -license = "GPL-3.0" -documentation = "https://docs.rs/darwinia-bridge-primitives" -homepage = "https://github.com/darwinia-network/bridger/tree/master/primitives" -include = ["src/**/*", "Cargo.toml", "./README.md"] -keywords = ["blockchain"] -readme = './README.md' +license = "MIT" +documentation = "https://docs.rs/bridger" +homepage = "https://github.com/darwinia-network/bridger" +include = [ + "Cargo.toml", + "**/*.rs", + "README.md", + "LICENSE" +] +keywords = ["substrate", "darwinia"] +readme = 'README.md' edition = "2018" -[package.metadata.docs.rs] -all-features = true - [dependencies] -uint = "0.8.5" -thiserror = "1.0" - -## Optional featrues -async-trait = { version = "0.1.40", optional = true } -frame-support = { version = "3.0.0", optional = true } -pallet-indices = { version = "3.0.0", optional = true } -pallet-im-online = { version = "3.0.0", optional = true } -reqwest = { version = "0.10", features = ["json"], optional = true } -serde_json = { version = "1.0", optional = true } -substrate-subxt = { git = "https://github.com/darwinia-network/substrate-subxt.git", tag = "darwinia-v0.15.2", optional = true } -substrate-subxt-proc-macro = { git = "https://github.com/darwinia-network/substrate-subxt.git", tag = "darwinia-v0.15.2", optional = true } - -[dependencies.rlp] -package = "rlp" -version = "0.4.4" -[dependencies.serde] -package = "serde" -version = "1" -features = ["derive"] - -[dependencies.codec] -package = "parity-scale-codec" -version = "2" -features = ["derive"] - -[dependencies.tokio] -package = "tokio" -version = "0.2.22" -features = ["full"] +uint = "0.8.5" +rlp = "0.4.4" -[features] -rpc = ["async-trait", "reqwest", "serde_json"] -runtime = [ - "substrate-subxt", - "substrate-subxt-proc-macro", - "frame-support", - "pallet-indices", - "pallet-im-online", -] -default = [] +serde = { version = "1", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "2.1", features = ["derive", "full"] } diff --git a/primitives/LICENSE b/primitives/LICENSE deleted file mode 100644 index f288702d2..000000000 --- a/primitives/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/primitives/README.md b/primitives/README.md deleted file mode 100644 index 486081baa..000000000 --- a/primitives/README.md +++ /dev/null @@ -1,31 +0,0 @@ -## Darwinia bridge primitives - -[![bridge-primtives](https://github.com/darwinia-network/bridger/workflows/bridger/badge.svg)](https://github.com/darwinia-network/bridger) -[![crate](https://img.shields.io/crates/v/darwinia-bridge-primitives.svg)](https://crates.io/crates/darwinia-bridge-primitives) -[![doc](https://img.shields.io/badge/current-docs-brightgreen.svg)](https://docs.rs/darwinia-bridge-primitives/) -[![downloads](https://img.shields.io/crates/d/darwinia-bridge-primitives.svg)](https://crates.io/crates/darwinia-bridge-primitives) -[![LICENSE](https://img.shields.io/crates/l/darwinia-bridge-primitives.svg)](https://choosealicense.com/licenses/gpl-3.0/) - -The Darwinia bridge primtives - - -+ [x] [Ethereum](https://github.com/darwinia-network/bridge-primitives/tree/master/src/eth) -+ [ ] [Your chain?](https://github.com/darwinia-network/bridge-primitives/pulls) - -## Features - -### `rpc` - -If you want to trigger rpc feature to get data which described in this repo, please -import `darwinia-bridge-primitives` as below in your `Cargo.toml` - -```toml -[dependencies.darwinia-bridge-primitives] -version = "^0" -features = [ "rpc" ] -``` - - -## LICENSE - -GPL-3.0 diff --git a/primitives/src/array.rs b/primitives/src/array.rs index 125cdd7d2..bf360c0fe 100644 --- a/primitives/src/array.rs +++ b/primitives/src/array.rs @@ -1,64 +1,65 @@ //! Custom byte array +use std::{ + fmt::{self, Debug, Display, Formatter, Result as FmtResult}, + marker::PhantomData, +}; + use codec::{Decode, Encode}; use serde::{ - de::{Deserialize, Deserializer, Error, SeqAccess, Visitor}, - ser::{Serialize, SerializeTuple, Serializer}, -}; -use std::{ - fmt::{self, Debug, Display, Formatter, Result as FmtResult}, - marker::PhantomData, + de::{Deserialize, Deserializer, Error, SeqAccess, Visitor}, + ser::{Serialize, SerializeTuple, Serializer}, }; use uint::construct_uint; /// Big Array Serde pub trait BigArray<'de>: Sized { - /// Serialize big array - fn serialize(&self, serializer: S) -> Result - where - S: Serializer; - /// Deserialize big array - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>; + /// Serialize big array + fn serialize(&self, serializer: S) -> Result + where + S: Serializer; + /// Deserialize big array + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>; } // shared construct_uint! { - #[derive(Encode, Decode, Serialize, Deserialize)] - pub struct U256(4); + #[derive(Encode, Decode, Serialize, Deserialize)] + pub struct U256(4); } -construct_hash_bytes! { - #[derive(Clone)] - pub struct H128(16); +crate::construct_hash_bytes! { + #[derive(Clone)] + pub struct H128(16); } -construct_hash_bytes! { - #[derive(Clone)] - pub struct H160(20); +crate::construct_hash_bytes! { + #[derive(Clone)] + pub struct H160(20); } -construct_hash_bytes! { - #[derive(Clone)] - pub struct H256(32); +crate::construct_hash_bytes! { + #[derive(Clone)] + pub struct H256(32); } -construct_hash_bytes! { - #[derive(Clone)] - pub struct H512(64); +crate::construct_hash_bytes! { + #[derive(Clone)] + pub struct H512(64); } -construct_hash_bytes! { - #[derive(Clone)] - pub struct H1024(128); +crate::construct_hash_bytes! { + #[derive(Clone)] + pub struct H1024(128); } -construct_hash_bytes! { - #[derive(Clone)] - pub struct Bloom(256); +crate::construct_hash_bytes! { + #[derive(Clone)] + pub struct Bloom(256); } -impl_hash_rlp!(Bloom, 256); -impl_hash_rlp!(H256, 32); -impl_hash_rlp!(H160, 20); +crate::impl_hash_rlp!(Bloom, 256); +crate::impl_hash_rlp!(H256, 32); +crate::impl_hash_rlp!(H160, 20); diff --git a/primitives/src/byte.rs b/primitives/src/byte.rs index 47415f5d8..2e253b092 100644 --- a/primitives/src/byte.rs +++ b/primitives/src/byte.rs @@ -12,107 +12,107 @@ macro_rules! doc_comment { /// Convert bytes to hex #[macro_export] macro_rules! hex { - ($bytes:expr) => {{ - let mut s = String::new(); - for i in $bytes { - s.push_str(&format!("{:02x}", i)); - } - s - }}; + ($bytes:expr) => {{ + let mut s = String::new(); + for i in $bytes { + s.push_str(&format!("{:02x}", i)); + } + s + }}; } /// Convert hex string to `Vec` or `[u8; n]` #[macro_export] macro_rules! bytes { - // Convert hex to Vec - ($hex:expr) => {{ - let mut h = $hex; - if h.starts_with("0x") { - h = &h[2..]; - } - - (0..h.len()) - .step_by(2) - .map(|i| u8::from_str_radix(&h[i..i + 2], 16)) - .collect::, _>>() - .unwrap_or_default() - }}; - - // Convert hex to [u8; $bits] - ($hex:expr, $bits:expr) => {{ - let mut hash = [0_u8; $bits]; - hash.copy_from_slice(&bytes!($hex)); - hash - }}; + // Convert hex to Vec + ($hex:expr) => {{ + let mut h = $hex; + if h.starts_with("0x") { + h = &h[2..]; + } + + (0..h.len()) + .step_by(2) + .map(|i| u8::from_str_radix(&h[i..i + 2], 16)) + .collect::, _>>() + .unwrap_or_default() + }}; + + // Convert hex to [u8; $bits] + ($hex:expr, $bits:expr) => {{ + let mut hash = [0_u8; $bits]; + hash.copy_from_slice(&bytes!($hex)); + hash + }}; } /// Implement serde for big array #[macro_export] macro_rules! serde_array { - ($len:expr) => { - impl<'de, T> BigArray<'de> for [T; $len] - where - T: Default + Copy + Serialize + Deserialize<'de>, - { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut seq = serializer.serialize_tuple(self.len())?; - for elem in &self[..] { - seq.serialize_element(elem)?; - } - seq.end() - } - - fn deserialize(deserializer: D) -> Result<[T; $len], D::Error> - where - D: Deserializer<'de>, - { - struct ArrayVisitor { - element: PhantomData, - } - - impl<'de, T> Visitor<'de> for ArrayVisitor - where - T: Default + Copy + Deserialize<'de>, - { - type Value = [T; $len]; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str(concat!("an array of length ", $len)) - } - - fn visit_seq(self, mut seq: A) -> Result<[T; $len], A::Error> - where - A: SeqAccess<'de>, - { - let mut arr = [T::default(); $len]; - for i in 0..$len { - arr[i] = seq - .next_element()? - .ok_or_else(|| Error::invalid_length(i, &self))?; - } - Ok(arr) - } - } - - let visitor = ArrayVisitor { - element: PhantomData, - }; - deserializer.deserialize_tuple($len, visitor) - } - } - }; + ($len:expr) => { + impl<'de, T> BigArray<'de> for [T; $len] + where + T: Default + Copy + Serialize + Deserialize<'de>, + { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut seq = serializer.serialize_tuple(self.len())?; + for elem in &self[..] { + seq.serialize_element(elem)?; + } + seq.end() + } + + fn deserialize(deserializer: D) -> Result<[T; $len], D::Error> + where + D: Deserializer<'de>, + { + struct ArrayVisitor { + element: PhantomData, + } + + impl<'de, T> Visitor<'de> for ArrayVisitor + where + T: Default + Copy + Deserialize<'de>, + { + type Value = [T; $len]; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str(concat!("an array of length ", $len)) + } + + fn visit_seq(self, mut seq: A) -> Result<[T; $len], A::Error> + where + A: SeqAccess<'de>, + { + let mut arr = [T::default(); $len]; + for i in 0..$len { + arr[i] = seq + .next_element()? + .ok_or_else(|| Error::invalid_length(i, &self))?; + } + Ok(arr) + } + } + + let visitor = ArrayVisitor { + element: PhantomData, + }; + deserializer.deserialize_tuple($len, visitor) + } + } + }; } /// Construct hash bytes #[macro_export] macro_rules! construct_hash_bytes { ( $(#[$attr:meta])* $visibility:vis struct $name:ident ( $len:tt ); ) => { - serde_array!($len); + crate::serde_array!($len); - doc_comment!{ + crate::doc_comment!{ concat!("The ", stringify!($len), "-bit hash type."), $(#[$attr])* #[derive(Decode, Encode, Serialize, Deserialize)] @@ -124,7 +124,7 @@ macro_rules! construct_hash_bytes { impl Display for $name { fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { - f.write_str(&hex!(self.0.as_ref())) + f.write_str(&crate::hex!(self.0.as_ref())) } } @@ -158,11 +158,11 @@ macro_rules! construct_hash_bytes { /// Add RLP serialization support to a hash type. #[macro_export] macro_rules! impl_hash_rlp { - ($name: ident, $size: expr) => { - impl rlp::Encodable for $name { - fn rlp_append(&self, s: &mut rlp::RlpStream) { - s.encoder().encode_value(&self.0); - } - } - }; + ($name: ident, $size: expr) => { + impl rlp::Encodable for $name { + fn rlp_append(&self, s: &mut rlp::RlpStream) { + s.encoder().encode_value(&self.0); + } + } + }; } diff --git a/primitives/src/chain/affirmation.rs b/primitives/src/chain/affirmation.rs deleted file mode 100644 index d923d353d..000000000 --- a/primitives/src/chain/affirmation.rs +++ /dev/null @@ -1,43 +0,0 @@ -use codec::{Decode, Encode}; - -/// Game id, round and the index under the round point to a unique affirmation AKA affirmation id -#[derive(Clone, PartialEq, Encode, Decode, Default, Debug)] -pub struct RelayAffirmationId { - /// Relay header id aka game id - pub relay_header_id: RelayHeaderId, - /// Round index - pub round: u32, - /// Index of a affirmation list which under a round - pub index: u32, -} - -/// Relay Affirmations -#[derive(Clone, Encode, Decode, Default, Debug)] -pub struct RelayAffirmation { - /// Relayer - pub relayer: Relayer, - /// Relay header parcels - pub relay_header_parcels: Vec, - /// Stake balance - pub stake: Balance, - /// Affirmation ID - pub maybe_extended_relay_affirmation_id: Option>, - /// Verified - pub verified_on_chain: bool, -} - -/// Info for keeping track of a proposal being voted on. -#[derive(Clone, Encode, Decode, Default, Debug)] -pub struct RelayVotingState { - /// The current set of technical members that approved it. - pub ayes: Vec, - /// The current set of technical members that rejected it. - pub nays: Vec, -} - -impl RelayVotingState { - /// contains the vote of the account - pub fn contains(&self, account: &TechnicalMember) -> bool { - self.ayes.contains(account) || self.nays.contains(account) - } -} diff --git a/primitives/src/chain/ethereum/block.rs b/primitives/src/chain/ethereum/block.rs deleted file mode 100644 index 6d11ffc79..000000000 --- a/primitives/src/chain/ethereum/block.rs +++ /dev/null @@ -1,226 +0,0 @@ -use crate::{ - array::{Bloom, U256}, - hex, -}; -use codec::{Decode, Encode}; -use std::{fmt::Debug, str::FromStr}; -#[cfg(feature = "runtime")] -use substrate_subxt::sp_core::bytes::to_hex; -#[cfg(feature = "runtime")] -use uint::static_assertions::_core::fmt::Formatter; - -/// Raw EthereumBlock from Ethereum rpc -#[derive(Serialize, Deserialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct EthereumBlockRPC { - difficulty: String, - extra_data: String, - gas_limit: String, - gas_used: String, - /// Ethereum header hash - pub hash: String, - logs_bloom: String, - miner: String, - mix_hash: String, - nonce: String, - number: String, - /// Parent hash - pub parent_hash: String, - receipts_root: String, - sha3_uncles: String, - size: String, - state_root: String, - timestamp: String, - total_difficulty: String, - transactions_root: String, - /// Block transactions - pub transactions: Vec, - uncles: Vec, -} - -impl From for EthereumHeader { - fn from(that: EthereumBlockRPC) -> Self { - let seal: Vec> = vec![ - rlp::encode(&bytes!(that.mix_hash.as_str())), - rlp::encode(&bytes!(that.nonce.as_str())), - ]; - EthereumHeader { - parent_hash: bytes!(that.parent_hash.as_str(), 32), - timestamp: u64::from_str_radix(&that.timestamp.as_str()[2..], 16).unwrap_or_default(), - number: u64::from_str_radix(&that.number.as_str()[2..], 16).unwrap_or_default(), - author: bytes!(that.miner.as_str(), 20), - transactions_root: bytes!(that.transactions_root.as_str(), 32), - uncles_hash: bytes!(that.sha3_uncles.as_str(), 32), - extra_data: bytes!(that.extra_data.as_str()), - state_root: bytes!(that.state_root.as_str(), 32), - receipts_root: bytes!(that.receipts_root.as_str(), 32), - log_bloom: Bloom(bytes!(that.logs_bloom.as_str(), 256)), - gas_used: U256::from_str(&that.gas_used[2..]).unwrap_or_default(), - gas_limit: U256::from_str(&that.gas_limit[2..]).unwrap_or_default(), - difficulty: U256::from_str(&that.difficulty[2..]).unwrap_or_default(), - seal, - hash: match that.hash.is_empty() { - true => None, - false => Some(bytes!(that.hash.as_str(), 32)), - }, - } - } -} - -/// Darwinia Eth header -#[derive(Clone, Decode, Encode, Debug, PartialEq, Eq, Serialize, Deserialize, Default)] -pub struct EthereumHeader { - parent_hash: [u8; 32], - timestamp: u64, - /// Block number - pub number: u64, - author: [u8; 20], - transactions_root: [u8; 32], - uncles_hash: [u8; 32], - extra_data: Vec, - state_root: [u8; 32], - receipts_root: [u8; 32], - log_bloom: Bloom, - gas_used: U256, - gas_limit: U256, - difficulty: U256, - seal: Vec>, - /// Ethereum header hash - pub hash: Option<[u8; 32]>, -} - -#[cfg(feature = "runtime")] -impl std::fmt::Display for EthereumHeader { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - let mut msgs = vec![]; - msgs.push(format!( - "{:>19}{}", - "parent_hash: ", - to_hex(&self.parent_hash, false) - )); - msgs.push(format!("{:>19}{}", "timestamp: ", &self.timestamp)); - msgs.push(format!("{:>19}{}", "number: ", &self.number)); - msgs.push(format!("{:>19}{}", "author: ", to_hex(&self.author, false))); - msgs.push(format!( - "{:>19}{}", - "transactions_root: ", - to_hex(&self.transactions_root, false) - )); - msgs.push(format!( - "{:>19}{}", - "uncles_hash: ", - to_hex(&self.uncles_hash, false) - )); - msgs.push(format!( - "{:>19}{}", - "extra_data: ", - to_hex(&self.extra_data, false) - )); - msgs.push(format!( - "{:>19}{}", - "state_root: ", - to_hex(&self.state_root, false) - )); - msgs.push(format!( - "{:>19}{}", - "receipts_root: ", - to_hex(&self.receipts_root, false) - )); - msgs.push(format!( - "{:>19}{}", - "log_bloom: ", - &self.log_bloom.to_string() - )); - msgs.push(format!("{:>19}{}", "gas_used: ", &self.gas_used.as_u128())); - msgs.push(format!( - "{:>19}{}", - "gas_limit: ", - &self.gas_limit.as_u128() - )); - msgs.push(format!( - "{:>19}{}", - "difficulty: ", - &self.difficulty.as_u128() - )); - for (i, item) in self.seal.iter().enumerate() { - if i == 0 { - msgs.push(format!("{:>19}{}", "seal: ", to_hex(item, false))); - } else { - msgs.push(format!("{:>19}{}", "", to_hex(item, false))); - } - } - if let Some(hash) = &self.hash { - msgs.push(format!("{:>19}{}", "hash: ", to_hex(hash, false))); - } - write!(f, "{}", msgs.join("\n")) - } -} - -/// Darwinia Eth header Json foramt -#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Default, Encode, Clone)] -pub struct EthereumHeaderJson { - parent_hash: String, - timestamp: u64, - /// Block Number - pub number: u64, - author: String, - transactions_root: String, - uncles_hash: String, - extra_data: String, - state_root: String, - receipts_root: String, - log_bloom: String, - gas_used: u128, - gas_limit: u128, - difficulty: u128, - seal: Vec, - hash: String, -} - -impl From for EthereumHeaderJson { - fn from(that: EthereumHeader) -> Self { - EthereumHeaderJson { - parent_hash: format!("0x{}", hex!(that.parent_hash.to_vec())), - timestamp: that.timestamp, - number: that.number, - author: format!("0x{}", hex!(that.author.to_vec())), - transactions_root: format!("0x{}", hex!(that.transactions_root.to_vec())), - uncles_hash: format!("0x{}", hex!(that.uncles_hash.to_vec())), - extra_data: format!("0x{}", hex!(that.extra_data.to_vec())), - state_root: format!("0x{}", hex!(that.state_root.to_vec())), - receipts_root: format!("0x{}", hex!(that.receipts_root.to_vec())), - log_bloom: format!("0x{}", hex!(that.log_bloom.0.to_vec())), - gas_used: that.gas_used.as_u128(), - gas_limit: that.gas_limit.as_u128(), - difficulty: that.difficulty.as_u128(), - seal: that - .seal - .iter() - .map(|s| format!("0x{}", hex!(s.to_vec()))) - .collect(), - hash: format!("0x{}", hex!(that.hash.unwrap_or_default().to_vec())), - } - } -} - -impl From for EthereumHeader { - fn from(that: EthereumHeaderJson) -> Self { - EthereumHeader { - parent_hash: bytes!(that.parent_hash.as_str(), 32), - timestamp: that.timestamp, - number: that.number, - author: bytes!(that.author.as_str(), 20), - transactions_root: bytes!(that.transactions_root.as_str(), 32), - uncles_hash: bytes!(that.uncles_hash.as_str(), 32), - extra_data: bytes!(that.extra_data.as_str()), - state_root: bytes!(that.state_root.as_str(), 32), - receipts_root: bytes!(that.receipts_root.as_str(), 32), - log_bloom: Bloom(bytes!(that.log_bloom.as_str(), 256)), - gas_used: U256::from(that.gas_used), - gas_limit: U256::from(that.gas_limit), - difficulty: U256::from(that.difficulty), - seal: that.seal.iter().map(|s| bytes!(s.as_str())).collect(), - hash: Some(bytes!(that.hash.as_str(), 32)), - } - } -} diff --git a/primitives/src/chain/ethereum/ethash.rs b/primitives/src/chain/ethereum/ethash.rs deleted file mode 100644 index dd733520d..000000000 --- a/primitives/src/chain/ethereum/ethash.rs +++ /dev/null @@ -1,73 +0,0 @@ -#![allow(dead_code)] -use crate::{ - array::{H128, H512}, - hex, -}; -use codec::{Decode, Encode}; -use serde::{Deserialize, Serialize}; - -/// Ethash proof -#[derive(Clone, Encode, Decode, Debug, PartialEq, Eq, Deserialize, Serialize, Default)] -pub struct EthashProof { - /// Dag nodes - pub dag_nodes: [H512; 2], - /// Merkle Proofs - pub proof: Vec, -} - -impl EthashProof { - /// Generate EthashProof from hex array - pub fn from_tuple(dag_nodes: [&str; 2], proof: [&str; 23]) -> EthashProof { - EthashProof { - dag_nodes: [ - H512(bytes!(dag_nodes[0], 64)), - H512(bytes!(dag_nodes[1], 64)), - ], - proof: proof - .iter() - .map(|s| H128(bytes!(*s, 16))) - .collect::>(), - } - } -} - -/// Json string format of `EthashProof` -#[derive(Serialize, Encode, Deserialize, PartialEq, Eq, Clone)] -pub struct EthashProofJson { - dag_nodes: Vec, - proof: Vec, -} - -impl From for EthashProofJson { - fn from(that: EthashProof) -> Self { - EthashProofJson { - dag_nodes: that - .dag_nodes - .as_ref() - .iter() - .map(|n| format!("0x{}", hex!(n.0.to_vec()))) - .collect(), - proof: that - .proof - .iter() - .map(|p| format!("0x{}", hex!(p.0.to_vec()))) - .collect(), - } - } -} - -impl From for EthashProof { - fn from(that: EthashProofJson) -> Self { - EthashProof { - dag_nodes: [ - H512(bytes!(that.dag_nodes[0].as_str(), 64)), - H512(bytes!(that.dag_nodes[1].as_str(), 64)), - ], - proof: that - .proof - .iter() - .map(|p| H128(bytes!(p.as_str(), 16))) - .collect(), - } - } -} diff --git a/primitives/src/chain/ethereum/mmr.rs b/primitives/src/chain/ethereum/mmr.rs deleted file mode 100644 index 10e2fdf77..000000000 --- a/primitives/src/chain/ethereum/mmr.rs +++ /dev/null @@ -1,74 +0,0 @@ -use codec::{Decode, Encode}; -use serde::{Deserialize, Serialize}; - -/// Single MMR struct -#[derive(Clone, Decode, Debug, Encode, Default, PartialEq, Eq)] -pub struct MMRRoot { - /// MMR Root - pub mmr_root: [u8; 32], -} - -/// MMR Root Json -#[derive(Clone, Debug, Decode, Encode, Default, Serialize, Deserialize, PartialEq, Eq)] -pub struct MMRRootJson { - /// MMR root string - pub mmr_root: String, -} - -impl From for MMRRoot { - fn from(that: MMRRootJson) -> Self { - MMRRoot { - mmr_root: bytes!(that.mmr_root.as_str(), 32), - } - } -} - -impl From for MMRRootJson { - fn from(that: MMRRoot) -> Self { - MMRRootJson { - mmr_root: hex!(&that.mmr_root), - } - } -} - -/// MMR Proof -#[derive(Clone, Decode, Debug, Encode, Default, PartialEq, Eq)] -pub struct MMRProof { - /// The index of member leaf - pub member_leaf_index: u64, - /// The index of of last leaf - pub last_leaf_index: u64, - /// The mmrProof of two leaves above - pub proof: Vec<[u8; 32]>, -} - -/// MMR Proof Json -#[derive(Clone, Debug, Decode, Encode, Default, Serialize, Deserialize, PartialEq, Eq)] -pub struct MMRProofJson { - /// The index of member leaf - pub member_leaf_index: u64, - /// The index of of last leaf - pub last_leaf_index: u64, - /// The mmr proof of the two leaves above - pub proof: Vec, -} - -impl From for MMRProof { - fn from(that: MMRProofJson) -> Self { - MMRProof { - member_leaf_index: that.member_leaf_index, - last_leaf_index: that.last_leaf_index, - proof: that.proof.iter().map(|p| bytes!(p.as_str(), 32)).collect(), - } - } -} - -impl From for MMRProofJson { - fn from(that: MMRProof) -> Self { - MMRProofJson { - member_leaf_index: that.member_leaf_index, - last_leaf_index: that.last_leaf_index, - proof: that.proof.iter().map(|p| hex!(p)).collect(), - } - } -} diff --git a/primitives/src/chain/ethereum/mod.rs b/primitives/src/chain/ethereum/mod.rs deleted file mode 100644 index aeabe9fe6..000000000 --- a/primitives/src/chain/ethereum/mod.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! Ethereum types -// mod confirmation; -mod block; -mod ethash; -mod mmr; -mod parcel; -mod proof; -mod receipt; - -pub use self::{ - block::{EthereumBlockRPC, EthereumHeader, EthereumHeaderJson}, - ethash::{EthashProof, EthashProofJson}, - mmr::{MMRProof, MMRProofJson, MMRRoot, MMRRootJson}, - parcel::{EthereumRelayHeaderParcel, EthereumRelayHeaderParcelJson}, - proof::{EthereumRelayProofs, EthereumRelayProofsJson}, - receipt::{ - EthReceiptBody, EthereumReceipt, EthereumReceiptProof, EthereumReceiptProofJson, - EthereumReceiptProofThing, EthereumReceiptProofThingJson, RedeemFor, - }, -}; diff --git a/primitives/src/chain/ethereum/parcel.rs b/primitives/src/chain/ethereum/parcel.rs deleted file mode 100644 index faf82c9c8..000000000 --- a/primitives/src/chain/ethereum/parcel.rs +++ /dev/null @@ -1,70 +0,0 @@ -//! Ethereum EthereumRelayHeaderParcel -use crate::{ - bytes, - chain::ethereum::{EthereumHeader, EthereumHeaderJson}, - hex, -}; -use codec::{Decode, Encode}; - -#[cfg(feature = "runtime")] -use uint::static_assertions::_core::fmt::Formatter; - -#[cfg(feature = "runtime")] -use substrate_subxt::sp_core::bytes::to_hex; - -/// Ethereum EthereumRelayHeaderParcel -#[derive(Encode, Decode, Debug, Default, PartialEq, Eq, Clone, Serialize, Deserialize)] -pub struct EthereumRelayHeaderParcel { - /// Ethereum header - pub header: EthereumHeader, - /// MMR root - pub mmr_root: [u8; 32], -} - -impl EthereumRelayHeaderParcel { - /// Is same as another parcel - pub fn is_same_as(&self, another: &EthereumRelayHeaderParcel) -> bool { - self.header.hash == another.header.hash && self.mmr_root == another.mmr_root - } -} - -#[cfg(feature = "runtime")] -impl std::fmt::Display for EthereumRelayHeaderParcel { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - let header = &self.header.to_string(); - let msg = format!( - "{}\n{:>19}{}", - header, - "mmr_root: ", - to_hex(&self.mmr_root, false) - ); - write!(f, "{}", msg) - } -} - -/// Ethereum EthereumRelayHeaderParcel JSON -#[derive(Default, Deserialize, Serialize)] -pub struct EthereumRelayHeaderParcelJson { - /// Ethereum header - pub header: EthereumHeaderJson, - /// MMR root - pub mmr_root: String, -} - -impl From for EthereumRelayHeaderParcel { - fn from(that: EthereumRelayHeaderParcelJson) -> Self { - EthereumRelayHeaderParcel { - header: that.header.into(), - mmr_root: bytes!(that.mmr_root.as_str(), 32), - } - } -} - -impl From for EthereumRelayHeaderParcelJson { - fn from(that: EthereumRelayHeaderParcel) -> Self { - EthereumRelayHeaderParcelJson { - header: that.header.into(), - mmr_root: hex!(&that.mmr_root), - } - } -} diff --git a/primitives/src/chain/ethereum/proof.rs b/primitives/src/chain/ethereum/proof.rs deleted file mode 100644 index 394b07cbd..000000000 --- a/primitives/src/chain/ethereum/proof.rs +++ /dev/null @@ -1,39 +0,0 @@ -//! Ethereum Relay Proof -use crate::chain::ethereum::{EthashProof, EthashProofJson}; -use codec::{Decode, Encode}; -use serde::{Deserialize, Serialize}; - -/// Darwinia eth relay header thing -#[derive(Clone, Debug, Decode, Encode, Default, PartialEq, Eq)] -pub struct EthereumRelayProofs { - /// Ethereum Hash Proof - pub ethash_proof: Vec, - /// MMR Proof - pub mmr_proof: Vec<[u8; 32]>, -} - -/// Shadow Proposal Response -#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Eq)] -pub struct EthereumRelayProofsJson { - /// Ethereum Hash Proof - pub ethash_proof: Vec, - /// MMR Proof - pub mmr_proof: Vec, -} - -impl From for EthereumRelayProofs { - fn from(that: EthereumRelayProofsJson) -> Self { - EthereumRelayProofs { - ethash_proof: that - .ethash_proof - .iter() - .map(|p| Into::::into(p.to_owned())) - .collect(), - mmr_proof: that - .mmr_proof - .iter() - .map(|p| bytes!(p.as_str(), 32)) - .collect(), - } - } -} diff --git a/primitives/src/chain/ethereum/receipt.rs b/primitives/src/chain/ethereum/receipt.rs deleted file mode 100644 index b205efe32..000000000 --- a/primitives/src/chain/ethereum/receipt.rs +++ /dev/null @@ -1,244 +0,0 @@ -//! Ethereum receipt -use crate::{ - array::{Bloom, H160, H256}, - bytes, - chain::ethereum::{EthereumHeader, EthereumHeaderJson, MMRProof, MMRProofJson}, - hex, -}; -use codec::{Decode, Encode}; -use rlp::{Encodable, RlpStream}; -use serde::Deserialize; -use std::fmt::Debug; - -/// Redeem for -#[derive(Clone, Debug, Encode, PartialEq, Eq)] -pub enum RedeemFor { - /// Redeem for token - Token, - /// Redeem for deposit - Deposit, - /// Redeem for set authorities - SetAuthorities, - /// Redeem for register erc20 token - RegisterErc20Token, - /// Redeem for erc20 token - RedeemErc20Token, -} - -impl Default for RedeemFor { - fn default() -> Self { - RedeemFor::Token - } -} - -/// Ethereum Receipt Proof -#[derive(Clone, Debug, Default, Encode, PartialEq, Eq)] -pub struct EthereumReceiptProof { - /// Proof index - pub index: u64, - /// Receipt Proof - pub proof: Vec, - /// Ethereum Header Hash - pub header_hash: [u8; 32], -} - -/// Ethereum Receipt Proof Json -#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] -pub struct EthereumReceiptProofJson { - /// Proof index - pub index: String, - /// Receipt Proof - pub proof: String, - /// Ethereum Header Hash - pub header_hash: String, -} - -impl From for EthereumReceiptProofJson { - fn from(that: EthereumReceiptProof) -> Self { - EthereumReceiptProofJson { - index: format!("{:x}", that.index), - proof: hex!(that.proof), - header_hash: hex!(that.header_hash.to_vec()), - } - } -} - -impl From for EthereumReceiptProof { - fn from(that: EthereumReceiptProofJson) -> Self { - let index = if that.index.starts_with("0x") { - &that.index[2..] - } else { - "00" - }; - - let hash = if !that.header_hash.is_empty() { - bytes!(that.header_hash.as_str(), 32) - } else { - [0; 32] - }; - - EthereumReceiptProof { - index: u64::from_str_radix(index, 16).unwrap_or(0), - proof: bytes!(that.proof.as_str()), - header_hash: hash, - } - } -} - -/// Ethereum ReceiptProofThing -#[derive(Clone, Debug, Default, PartialEq, Eq, Encode)] -pub struct EthereumReceiptProofThing { - /// Ethereum Header - pub header: EthereumHeader, - /// Ethereum Receipt Proof - pub receipt_proof: EthereumReceiptProof, - /// MMR Proof - pub mmr_proof: MMRProof, -} - -/// Ethereum ReceiptProofThing Json -#[derive(Debug, Serialize, Deserialize)] -pub struct EthereumReceiptProofThingJson { - /// Ethereum Header - pub header: EthereumHeaderJson, - /// Ethereum Receipt Proof - pub receipt_proof: EthereumReceiptProofJson, - /// MMR Proof - pub mmr_proof: MMRProofJson, -} - -impl From for EthereumReceiptProofThing { - fn from(that: EthereumReceiptProofThingJson) -> Self { - EthereumReceiptProofThing { - header: that.header.into(), - receipt_proof: that.receipt_proof.into(), - mmr_proof: that.mmr_proof.into(), - } - } -} - -/// Ethereum receipt log entry -#[derive(Clone, PartialEq, Eq, Encode, Decode, Debug)] -pub struct LogEntry { - /// The address of the contract executing at the point of the `LOG` operation. - pub address: H160, - /// The topics associated with the `LOG` operation. - pub topics: Vec, - /// The data associated with the `LOG` operation. - pub data: Vec, -} - -/// Ethereum receipt transaction out come -#[derive(Clone, PartialEq, Eq, Encode, Decode, Debug)] -pub enum TransactionOutcome { - /// Status and state root are unknown under EIP-98 rules. - Unknown, - /// State root is known. Pre EIP-98 and EIP-658 rules. - StateRoot(H256), - /// Status code is known. EIP-658 rules. - StatusCode(u8), -} - -/// Ethereum Receipt -#[derive(Clone, PartialEq, Eq, Encode, Decode, Debug)] -pub struct EthereumReceipt { - /// The total gas used in the block following execution of the transaction. - pub gas_used: u64, - /// The OR-wide combination of all logs' blooms for this transaction. - pub log_bloom: Bloom, - /// The logs stemming from this transaction. - pub logs: Vec, - /// Transaction outcome. - pub outcome: TransactionOutcome, -} - -#[derive(Serialize, Deserialize, Debug)] -pub struct LogJson { - address: String, - topics: Vec, - data: String, -} - -/// Ethereum rsp response body -#[derive(Serialize, Deserialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct EthReceiptBody { - /// the block hash - pub block_hash: String, - block_number: String, - cumulative_gas_used: String, - from: String, - gas_used: String, - logs: Vec, - logs_bloom: String, - #[serde(alias = "root")] - status: String, - to: String, - transaction_hash: String, - /// the transaction index - pub transaction_index: String, -} - -impl From for EthereumReceipt { - fn from(that: EthReceiptBody) -> Self { - EthereumReceipt { - gas_used: u64::from_str_radix(&that.cumulative_gas_used.as_str()[2..], 16) - .unwrap_or_default(), - log_bloom: Bloom(bytes!(that.logs_bloom.as_str(), 256)), - logs: that - .logs - .iter() - .map(|l| -> LogEntry { - LogEntry { - address: H160(bytes!(l.address.as_str(), 20)), - topics: l - .topics - .iter() - .map(|t| H256(bytes!(t.as_str(), 32))) - .collect(), - data: bytes!(l.data.as_str()), - } - }) - .collect(), - outcome: { - if that.status.len() == 66 { - TransactionOutcome::StateRoot(H256(bytes!(that.status.as_str(), 32))) - } else { - TransactionOutcome::StatusCode( - u8::from_str_radix(&that.status.as_str()[2..], 16).unwrap_or(0), - ) - } - }, - } - } -} - -impl Encodable for LogEntry { - fn rlp_append(&self, s: &mut RlpStream) { - s.begin_list(3); - s.append(&self.address); - s.append_list(&self.topics); - s.append_list(&self.data); - } -} - -impl Encodable for EthereumReceipt { - fn rlp_append(&self, s: &mut RlpStream) { - match self.outcome { - TransactionOutcome::Unknown => { - s.begin_list(3); - } - TransactionOutcome::StateRoot(ref root) => { - s.begin_list(4); - s.append(root); - } - TransactionOutcome::StatusCode(ref status_code) => { - s.begin_list(4); - s.append(status_code); - } - } - s.append(&self.gas_used); - s.append(&self.log_bloom); - s.append_list(&self.logs); - } -} diff --git a/primitives/src/chain/ethereum/runtime.rs b/primitives/src/chain/ethereum/runtime.rs deleted file mode 100644 index f170b4ee7..000000000 --- a/primitives/src/chain/ethereum/runtime.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![cfg(features = "runtime")] -use super::EthereumHeader; -use codec::{Codec, Decode}; -use ethereum_primitives::header::EthereumHeader as DarwiniaEthereumHeader; - -impl Into for DarwiniaEthereumHeader { - fn into(self) -> EthereumHeader { - self.encode().decode() - } -} diff --git a/primitives/src/chain/mod.rs b/primitives/src/chain/mod.rs deleted file mode 100644 index 2a6c4f786..000000000 --- a/primitives/src/chain/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! Relayable chains -mod affirmation; -pub mod ethereum; -/// proxy type -pub mod proxy_type; - -pub use self::affirmation::{RelayAffirmation, RelayAffirmationId, RelayVotingState}; diff --git a/primitives/src/chain/proxy_type.rs b/primitives/src/chain/proxy_type.rs deleted file mode 100644 index 0b1697f16..000000000 --- a/primitives/src/chain/proxy_type.rs +++ /dev/null @@ -1,25 +0,0 @@ -use codec::{Decode, Encode}; - -/// A value defining the subset of calls that it is allowed to make. -#[derive(Clone, Encode, Decode)] -pub enum ProxyType { - /// Any - Any, - /// NonTransfer - NonTransfer, - /// Governance - Governance, - /// Staking - Staking, - /// IdentityJudgement - IdentityJudgement, - /// EthereumBridge - EthereumBridge, -} - -/// default value -impl Default for ProxyType { - fn default() -> ProxyType { - ProxyType::Any - } -} diff --git a/primitives/src/frame/bridge/mod.rs b/primitives/src/frame/bridge/mod.rs deleted file mode 100644 index 453b0b804..000000000 --- a/primitives/src/frame/bridge/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -//! Darwinia Frame -#![cfg(feature = "runtime")] - -pub mod relay_authorities; diff --git a/primitives/src/frame/bridge/relay_authorities.rs b/primitives/src/frame/bridge/relay_authorities.rs deleted file mode 100644 index 428a7948c..000000000 --- a/primitives/src/frame/bridge/relay_authorities.rs +++ /dev/null @@ -1,241 +0,0 @@ -//! Darwinia Bridge Relay Authorities -use codec::{Decode, Encode}; -use core::marker::PhantomData; -use frame_support::sp_runtime::app_crypto::sp_core::H256; -use substrate_subxt::sp_core::bytes::to_hex; -use substrate_subxt::system::System; -use substrate_subxt_proc_macro::{module, Call, Event, Store}; - -/// AuthoritiesToSignReturn -pub type AuthoritiesToSignReturn = ( - ::RelayAuthorityMessage, - Vec<( - ::AccountId, - ::RelayAuthoritySignature, - )>, -); - -/// MmrRootsToSignReturn -pub type MmrRootsToSignReturn = Vec<( - ::AccountId, - ::RelayAuthoritySignature, -)>; - -/// Relay Authority -#[derive(Clone, Encode, Decode, Default, Debug)] -pub struct RelayAuthority { - /// account_id - pub account_id: AccountId, - /// signer - pub signer: RelayAuthoritySigner, - /// Stake balance - pub stake: RingBalance, - /// BlockNumber - pub term: BlockNumber, -} - -/// Bridge Relay Authorities Pallet -#[module] -pub trait EthereumRelayAuthorities: System { - /// Relay Authority - type RelayAuthority: 'static + Encode + Decode + Send + Sync + Default; - /// Relay authority signer - type RelayAuthoritySigner: 'static + Encode + Decode + Sync + Send + Default; - /// Relay signature - type RelayAuthoritySignature: 'static + Encode + Decode + Sync + Send + Sync + Default; - /// Relay signature - type RelayAuthorityMessage: 'static + Encode + Decode + Sync + Send + Default; -} - -////// -// Calls -////// - -/// Submit authorities signature -#[derive(Clone, Debug, PartialEq, Call, Encode)] -pub struct SubmitSignedAuthorities { - /// signature - pub signature: T::RelayAuthoritySignature, -} - -/// Submit redeem call -#[derive(Clone, Debug, PartialEq, Call, Encode)] -pub struct SubmitSignedMmrRoot { - /// block_number - pub block_number: ::BlockNumber, - /// signature - pub signature: T::RelayAuthoritySignature, -} - -////// -// Events -////// - -/// A New MMR Root Request to be Signed. [block number] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct ScheduleMMRRoot { - /// BlockNumber - pub block_number: ::BlockNumber, -} - -impl std::fmt::Display for ScheduleMMRRoot { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let msg = format!( - r#" -ScheduleMMRRoot {{ - block_number: {}, -}} -"#, - &self.block_number, - ); - write!(f, "{}", msg) - } -} - -/// Authorities Signed. [term, new authorities, signatures] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct AuthoritiesChangeSigned { - /// term - pub term: u32, - /// new authorities - pub new_authorities: Vec, - /// signatures - pub signatures: Vec<(::AccountId, T::RelayAuthoritySignature)>, -} - -impl std::fmt::Display for AuthoritiesChangeSigned { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let msg = format!( - r#" -AuthoritiesChangeSigned {{ - term: {}, - new_authorities: {:?}, - signatures: {:?} -}} -"#, - &self.term, - &self - .new_authorities - .iter() - .map(|n| to_hex(&n.encode(), false)) - .collect::>(), - &self - .signatures - .iter() - .map(|s| { (to_hex(&s.0.encode(), false), to_hex(&s.1.encode(), false)) }) - .collect::>() - ); - write!(f, "{}", msg) - } -} - -/// MMR Root Signed. [block number, mmr root, message, signatures] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct MMRRootSigned { - /// block number - pub block_number: ::BlockNumber, - /// mmr root - pub mmr_root: H256, - /// The redeemed balance - pub signatures: Vec<(::AccountId, T::RelayAuthoritySignature)>, -} - -/// ScheduleAuthoritiesChange. [message to sign] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct ScheduleAuthoritiesChange { - /// message - pub message: T::RelayAuthorityMessage, -} - -impl std::fmt::Display for ScheduleAuthoritiesChange { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let msg = format!( - r#" -ScheduleAuthoritiesChange {{ - message: {}, -}} -"#, - to_hex(&self.message.encode(), false) - ); - write!(f, "{}", msg) - } -} - -////// -// Store -////// - -/// Relay Authorities Storage -#[derive(Clone, Debug, Eq, PartialEq, Store, Encode)] -pub struct Authorities { - #[store(returns = Vec)] - /// Runtime marker - pub _runtime: PhantomData, -} - -/// AuthoritiesToSign -#[derive(Clone, Debug, Eq, PartialEq, Store, Encode)] -pub struct AuthoritiesToSign { - #[store(returns = Option>)] - /// Runtime marker - pub _runtime: PhantomData, -} - -/// AuthorityTerm -#[derive(Clone, Debug, Eq, PartialEq, Store, Encode)] -pub struct NextTerm { - #[store(returns = u32)] - /// Runtime marker - pub _runtime: PhantomData, -} - -/// AuthorityTerm -#[derive(Clone, Debug, Eq, PartialEq, Store, Encode)] -pub struct MMRRootsToSign { - #[store(returns = Option>)] - /// Block number - pub block_number: ::BlockNumber, - /// Runtime marker - pub _runtime: PhantomData, -} - -/// AuthorityTerm -#[derive(Clone, Debug, Eq, PartialEq, Store, Encode)] -pub struct MMRRootsToSignKeys { - #[store(returns = Vec<::BlockNumber>)] - /// Runtime marker - pub _runtime: PhantomData, -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::runtime::{DarwiniaRuntime, EcdsaMessage, EcdsaSignature}; - use substrate_subxt::sp_runtime::AccountId32; - - #[test] - pub fn test_format_authorities_change_signed() { - let a: AuthoritiesChangeSigned = AuthoritiesChangeSigned { - term: 10, - new_authorities: vec![[0u8; 20], [1; 20]], - signatures: vec![(AccountId32::default(), EcdsaSignature::default())], - }; - println!("{}", a); - } - - #[test] - pub fn test_format_schedule_mmr_root() { - let a: ScheduleMMRRoot = ScheduleMMRRoot { block_number: 10 }; - - println!("{}", a); - } - - #[test] - pub fn test_format_schedule_authorities_change() { - let a: ScheduleAuthoritiesChange = ScheduleAuthoritiesChange { - message: EcdsaMessage::default(), - }; - - println!("{}", a); - } -} diff --git a/primitives/src/frame/ethereum/backing.rs b/primitives/src/frame/ethereum/backing.rs deleted file mode 100644 index 8b8fabe8c..000000000 --- a/primitives/src/frame/ethereum/backing.rs +++ /dev/null @@ -1,118 +0,0 @@ -//! Darwinia Ethereum Backing -use crate::chain::ethereum::{EthereumReceiptProofThing, RedeemFor}; -use codec::{Decode, Encode}; -use core::marker::PhantomData; -use substrate_subxt::balances::Balances; -use substrate_subxt::system::System; -use substrate_subxt_proc_macro::{module, Call, Event, Store}; - -/// Ethereum Relay Pallet -#[module] -pub trait EthereumBacking: System + Balances { - /// Ethereum transaction index - type EthereumTransactionIndex: 'static + Encode + Decode + Send + Default + Clone + Sync; -} - -////// -// Call -////// - -/// Submit redeem call -#[derive(Clone, Debug, PartialEq, Call, Encode)] -pub struct Redeem { - /// Runtime marker - pub _runtime: PhantomData, - /// Token type - pub act: RedeemFor, - /// Ethereum Receipt Proof - pub proof: EthereumReceiptProofThing, -} - -/// Submit SyncAuthoritiesChange call -#[derive(Clone, Debug, PartialEq, Call, Encode)] -pub struct SyncAuthoritiesChange { - /// Runtime marker - pub _runtime: PhantomData, - /// Ethereum Receipt Proof - pub proof: EthereumReceiptProofThing, -} - -////// -// Events -////// - -/// Some one redeem some *RING*. [account, amount, transaction index] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct RedeemRing { - /// Account Id - pub account_id: ::AccountId, - /// The redeemed balance - pub balance: ::Balance, - /// Transaction Id - pub tx_id: u64, -} - -/// Some one redeem some *KTON*. [account, amount, transaction index] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct RedeemKton { - /// Account Id - pub account_id: ::AccountId, - /// The redeemed balance - pub balance: ::Balance, - /// Transaction Id - pub tx_id: u64, -} - -/// Some one redeem a deposit. [account, deposit id, amount, transaction index] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct RedeemDeposit { - /// Account Id - pub account_id: ::AccountId, - /// The redeemed balance - pub balance: ::Balance, - /// Transaction Id - pub tx_id: u64, -} - -/// Ethereum address -pub type EcdsaAddress = [u8; 20]; - -/// Someone lock some *RING*. [account, ecdsa address, asset type, amount] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct LockRing { - /// Account Id - pub account_id: ::AccountId, - /// Ecdsa address - pub ecdsa_address: EcdsaAddress, - /// Asset type - pub asset_type: u8, - /// amount - pub amount: ::Balance, -} - -/// Someone lock some *KTON*. [account, ecdsa address, asset type, amount] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct LockKton { - /// Account Id - pub account_id: ::AccountId, - /// Ecdsa address - pub ecdsa_address: EcdsaAddress, - /// Asset type - pub asset_type: u8, - /// amount - pub amount: ::Balance, -} - -////// -/// Store -////// - -/// PendingHeaders Storage -#[derive(Clone, Debug, Eq, PartialEq, Store, Decode, Encode)] -pub struct VerifiedProof { - #[store(returns = Option)] - /// Receipt tx hash - pub map: ([u8; 32], u64), - /// Runtime marker - pub _runtime: PhantomData, -} diff --git a/primitives/src/frame/ethereum/game.rs b/primitives/src/frame/ethereum/game.rs deleted file mode 100644 index 6b855251a..000000000 --- a/primitives/src/frame/ethereum/game.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! Relayer Game -use codec::{Decode, Encode}; -use core::marker::PhantomData; -use substrate_subxt::system::System; -use substrate_subxt_proc_macro::{module, Store}; - -/// Ethereum Relay Pallet -#[module] -pub trait EthereumRelayerGame: System { - /// Ethereum Relay Affirmation - type RelayAffirmation: 'static + Encode + Decode + Sync + Send + Default; -} - -////// -// Storage -////// - -/// Relay Affirmations Storage -#[derive(Clone, Debug, Eq, PartialEq, Store, Encode)] -pub struct Affirmations { - #[store(returns = Vec)] - - /// game id - pub game_id: u64, - /// round id - pub round_id: u32, - /// Runtime marker - pub _runtime: PhantomData, -} diff --git a/primitives/src/frame/ethereum/issuing.rs b/primitives/src/frame/ethereum/issuing.rs deleted file mode 100644 index 980889dd2..000000000 --- a/primitives/src/frame/ethereum/issuing.rs +++ /dev/null @@ -1,43 +0,0 @@ -//! Darwinia Ethereum Issuing -use crate::chain::ethereum::EthereumReceiptProofThing; -use codec::{Decode, Encode}; -use core::marker::PhantomData; -use substrate_subxt::{balances::Balances, system::System}; -use substrate_subxt_proc_macro::{module, Call, Store}; - -/// Ethereum Issuing Pallet -#[module] -pub trait EthereumIssuing: System + Balances { - /// Ethereum transaction index - type EthereumTransactionIndex: 'static + Encode + Decode + Send + Default + Clone + Sync; -} - -// Call - -/// Submit register erc20 token -#[derive(Clone, Debug, PartialEq, Call, Encode)] -pub struct RegisterErc20 { - /// Runtime marker - pub _runtime: PhantomData, - /// Ethereum Receipt Proof - pub proof: EthereumReceiptProofThing, -} - -/// Submit redeem erc20 token -#[derive(Clone, Debug, PartialEq, Call, Encode)] -pub struct RedeemErc20 { - /// Runtime marker - pub _runtime: PhantomData, - /// Ethereum Receipt Proof - pub proof: EthereumReceiptProofThing, -} - -/// verified proof Storage -#[derive(Clone, Debug, Eq, PartialEq, Store, Decode, Encode)] -pub struct VerifiedIssuingProof { - #[store(returns = Option)] - /// Receipt tx hash - pub map: ([u8; 32], u64), - /// Runtime marker - pub _runtime: PhantomData, -} diff --git a/primitives/src/frame/ethereum/mod.rs b/primitives/src/frame/ethereum/mod.rs deleted file mode 100644 index 8ff0d33f9..000000000 --- a/primitives/src/frame/ethereum/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! Darwinia Frame -#![cfg(feature = "runtime")] - -pub mod backing; -pub mod game; -pub mod issuing; -pub mod relay; diff --git a/primitives/src/frame/ethereum/relay.rs b/primitives/src/frame/ethereum/relay.rs deleted file mode 100644 index dd7cbf030..000000000 --- a/primitives/src/frame/ethereum/relay.rs +++ /dev/null @@ -1,165 +0,0 @@ -//! Ethereum Relay - -use crate::chain::ethereum::{ - EthereumHeader, EthereumReceipt, EthereumRelayHeaderParcel, EthereumRelayProofs, -}; -use codec::{Decode, Encode}; -use core::marker::PhantomData; -use substrate_subxt::system::System; -use substrate_subxt_proc_macro::{module, Call, Event, Store}; - -/// Ethereum Relay Pallet -#[module] -pub trait EthereumRelay: System { - /// RingBalance - type RingBalance: 'static + Encode + Decode + Sync + Send + Default; - /// Ethereum BlockNumber - type EthereumBlockNumber: 'static + Encode + Sync + Decode + Send + Default; - /// Ethereum Pending Header - type PendingRelayHeaderParcel: 'static + Encode + Decode + Sync + Send + Default; - /// Ethereum Relay Header ID - type RelayAffirmationId: 'static + Encode + Decode + Sync + Send + Default + Clone; -} - -////// -// Call -////// - -/// Affirm Call -#[derive(Clone, Debug, PartialEq, Call, Encode)] -pub struct Affirm { - /// Ethereum relay headr parcel - pub ethereum_relay_header_parcel: EthereumRelayHeaderParcel, - /// Ethereum relay proofs - pub ethereum_relay_proofs: Option, - /// Runtime marker - pub _runtime: PhantomData, -} - -/// Set confirmed header parcel -#[derive(Clone, Debug, PartialEq, Call, Encode)] -pub struct SetConfirmedParcel { - /// Ethereum relay headr parcel - pub ethereum_relay_header_parcel: EthereumRelayHeaderParcel, - /// Runtime marker - pub _runtime: PhantomData, -} - -/// Approve pending header call -#[derive(Clone, Debug, PartialEq, Call, Encode)] -pub struct VotePendingRelayHeaderParcel { - /// pending block number - pub block_number: u64, - /// vote - pub aye: bool, - /// Runtime marker - pub _runtime: PhantomData, -} - -////// -// Events -////// - -/// A new relay parcel affirmed. [relayer, relay affirmation id] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct Affirmed { - /// Account Id - pub account_id: ::AccountId, - /// Ethereum Relay Header Id - pub relay_affirmation_id: T::RelayAffirmationId, -} - -/// A different affirmation submitted, dispute found. [relayer, relay affirmation id] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct DisputedAndAffirmed { - /// Account Id - pub account_id: ::AccountId, - /// Ethereum Relay Header Id - pub relay_header_id: T::RelayAffirmationId, -} - -/// An extended affirmation submitted, dispute go on. [relayer, relay affirmation id] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct Extended { - /// Account Id - pub account_id: ::AccountId, - /// Ethereum Relay Header Id - pub relay_header_id: T::RelayAffirmationId, -} - -/// A new round started. [game id, game sample points] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct NewRound { - /// Ethereum Relay Header Id - pub relay_header_id: T::RelayAffirmationId, - /// Required Headers - pub required_headers: Vec, -} - -/// A game has been settled. [game id] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct GameOver { - /// Ethereum Relay Header Id - pub relay_header_id: T::RelayAffirmationId, -} - -/// The specific confirmed parcel removed. [block number] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct RemoveConfirmedParcel { - /// Ethereum Relay Header Id - pub relay_header_id: T::RelayAffirmationId, -} - -/// EthereumReceipt verification. [account, ethereum receipt, ethereum header] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct VerifyReceipt { - /// The block number of Ethereum header parcel - pub account_id: ::AccountId, - /// Ethereum Receipt - pub receipt: EthereumReceipt, - /// Ethereum Header - pub header: EthereumHeader, -} - -/// Pended(EthereumBlockNumber), -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct Pended { - /// Ethereum Relay Header Id - pub relay_header_id: T::RelayAffirmationId, -} - -/// Pending relay header parcel approved. [block number, reason] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct PendingRelayHeaderParcelApproved { - /// Ethereum Relay Header Id - pub relay_header_id: T::RelayAffirmationId, - /// reason - pub reason: Vec, -} - -/// Pending relay header parcel rejected. [block number] -#[derive(Clone, Debug, Eq, PartialEq, Event, Decode)] -pub struct PendingRelayHeaderParcelRejected { - /// Ethereum Relay Header Id - pub relay_header_id: T::RelayAffirmationId, -} - -////// -// Store -////// - -/// Pending Headers Storage -#[derive(Clone, Debug, Eq, PartialEq, Store, Encode)] -pub struct PendingRelayHeaderParcels { - #[store(returns = Vec)] - /// Runtime marker - pub _runtime: PhantomData, -} - -/// PendingHeaders Storage -#[derive(Clone, Debug, Eq, PartialEq, Store, Encode)] -pub struct ConfirmedBlockNumbers { - #[store(returns = Vec)] - /// Runtime marker - pub _runtime: PhantomData, -} diff --git a/primitives/src/frame/mod.rs b/primitives/src/frame/mod.rs deleted file mode 100644 index ee51b4cb8..000000000 --- a/primitives/src/frame/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -//! Darwinia Frame -#![cfg(feature = "runtime")] - -pub mod bridge; -pub mod ethereum; -pub mod proxy; -pub mod sudo; -pub mod technical_committee; diff --git a/primitives/src/frame/proxy.rs b/primitives/src/frame/proxy.rs deleted file mode 100644 index 446b14d4b..000000000 --- a/primitives/src/frame/proxy.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! Frame Proxy -use codec::{Decode, Encode}; -use core::marker::PhantomData; -use substrate_subxt::{system::System, Encoded}; -use substrate_subxt_proc_macro::{module, Call}; - -/// The subset of the `frame_proxy::Trait` that a client must implement. -#[module] -pub trait Proxy: System { - /// A kind of proxy - type ProxyType: 'static + Encode + Decode + Send + Default + Sync; -} - -/// Dispatch the given `call` from an account that the sender is authorised for through -/// `add_proxy` -#[derive(Clone, Debug, Eq, PartialEq, Call, Encode)] -pub struct ProxyCall<'a, T: Proxy> { - /// Runtime marker. - pub _runtime: PhantomData, - /// The account that the proxy will make a call on behalf of. - pub real: ::AccountId, - /// Specify the exact proxy type to be used and checked for this call. - pub force_proxy_type: Option, - /// The call to be made by the `real` account. - pub call: &'a Encoded, -} diff --git a/primitives/src/frame/sudo.rs b/primitives/src/frame/sudo.rs deleted file mode 100644 index 747934a26..000000000 --- a/primitives/src/frame/sudo.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! Darwinia Sudo -use codec::{Decode, Encode}; -use core::marker::PhantomData; -use frame_support::weights::Weight; -use substrate_subxt::{system::System, Encoded}; -use substrate_subxt_proc_macro::{module, Call, Store}; - -/// The subset of the `frame_sudo::Trait` that a client must implement. -#[module] -pub trait Sudo: System {} - -/// Execute a transaction with sudo permissions. -#[derive(Clone, Debug, Eq, PartialEq, Call, Encode)] -pub struct SudoCall<'a, T: Sudo> { - /// Runtime marker. - pub _runtime: PhantomData, - /// Encoded transaction. - pub call: &'a Encoded, -} - -/// Get the sudo AccountId -#[derive(Clone, Debug, Eq, PartialEq, Store, Decode, Encode)] -pub struct Key { - #[store(returns = ::AccountId)] - /// Runtime marker. - pub _runtime: PhantomData, -} - -/// Execute a transaction with sudo permissions without checking the call weight. -#[derive(Clone, Debug, Eq, PartialEq, Call, Encode)] -pub struct SudoUncheckedWeightCall<'a, T: Sudo> { - /// Runtime marker. - pub _runtime: PhantomData, - /// Encoded transaction. - pub call: &'a Encoded, - /// Call weight. - /// - /// This argument is actually unused in runtime, you can pass any value of - /// `Weight` type when using this call. - pub weight: Weight, -} diff --git a/primitives/src/frame/technical_committee.rs b/primitives/src/frame/technical_committee.rs deleted file mode 100644 index 2ddf59210..000000000 --- a/primitives/src/frame/technical_committee.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! Darwinia Collective - -use codec::{Decode, Encode}; -use core::marker::PhantomData; -use substrate_subxt::{system::System, Encoded}; -use substrate_subxt_proc_macro::{module, Call, Store}; - -/// The subset of the `frame_council::Trait` that a client must implement. -#[module] -pub trait TechnicalCommittee: System {} - -/// Get the sudo AccountId -#[derive(Clone, Debug, Eq, PartialEq, Store, Decode, Encode)] -pub struct Members { - #[store(returns = Vec<::AccountId>)] - /// Runtime marker. - pub _runtime: PhantomData, -} - -/// Execute a transaction with sudo permissions. -#[derive(Clone, Debug, Eq, PartialEq, Call, Encode)] -pub struct Execute<'a, T: TechnicalCommittee> { - /// Runtime marker. - pub _runtime: PhantomData, - /// Encoded transaction. - pub proposal: &'a Encoded, - /// Proposal length. - pub bound: u32, -} diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index a17bf570a..8d340f515 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -1,104 +1,9 @@ -//! ## Darwinia bridge primitives -//! -//! [![bridge-primtives](https://github.com/darwinia-network/bridge-primitives/workflows/bridge-primtives/badge.svg)](https://github.com/darwinia-network/bridge-primitives) -//! [![crate](https://img.shields.io/crates/v/darwinia-bridge-primitives.svg)](https://crates.io/crates/darwinia-bridge-pritmives) -//! [![doc](https://img.shields.io/badge/current-docs-brightgreen.svg)](https://docs.rs/darwinia-bridge-pritmives/) -//! [![downloads](https://img.shields.io/crates/d/darwinia-bridge-primitives.svg)](https://crates.io/crates/darwinia-bridge-primitives) -//! [![LICENSE](https://img.shields.io/crates/l/darwinia-bridge-primitives.svg)](https://choosealicense.com/licenses/gpl-3.0/) -//! -//! The Darwinia bridge primtives -//! -//! -//! + [x] [Ethereum](https://github.com/darwinia-network/bridge-primitives/tree/master/src/eth) -//! + [ ] [Your chain?](https://github.com/darwinia-network/bridge-primitives/pulls) -//! -//! ## Features -//! -//! ### `rpc` -//! -//! If you want to trigger rpc feature to get data which described in this repo, please -//! import `darwinia-bridge-primitives` as below in your `Cargo.toml` -//! -//! ```toml -//! [dependencies.darwinia-bridge-primitives] -//! version = "^0" -//! features = [ "rpc" ] -//! ``` -//! -//! -//! ## LICENSE -//! -//! GPL-3.0 #![allow(clippy::ptr_offset_with_cast)] #![allow(clippy::assign_op_pattern)] #![allow(clippy::manual_range_contains)] -#![deny(missing_docs)] + #[macro_use] extern crate serde; -// macros -mod byte; - pub mod array; -pub mod chain; -pub mod frame; -pub mod result; -pub mod rpc; -pub mod runtime; - -#[cfg(test)] -mod tests { - use super::runtime::DarwiniaRuntime; - use substrate_subxt::ClientBuilder; - // use super::frame::ethereum::relay::PendingRelayHeaderParcelsStoreExt; - use super::frame::technical_committee::MembersStoreExt; - - #[tokio::test] - async fn test_rpc() { - let client = ClientBuilder::::new() - .set_url("wss://pangolin-rpc.darwinia.network") - .skip_type_sizes_check() - .build() - .await - .unwrap(); - - println!("-----------"); - let block_number = 1; - let block_hash = client.block_hash(Some(block_number.into())).await.unwrap(); - if let Some(hash) = block_hash { - println!("Block hash for block number {}: {}", block_number, hash); - } else { - println!("Block number {} not found.", block_number); - } - } - - #[tokio::test] - async fn test_storage() { - let client = ClientBuilder::::new() - .set_url("wss://pangolin-rpc.darwinia.network") - .skip_type_sizes_check() - .build() - .await - .unwrap(); - - let members = client.members(None).await.unwrap(); - for member in members { - println!("{:?}", member); - } - } - - #[tokio::test] - async fn test_call() { - let client = ClientBuilder::::new() - .set_url("wss://pangolin-rpc.darwinia.network") - .skip_type_sizes_check() - .build() - .await - .unwrap(); - - let members = client.members(None).await.unwrap(); - for member in members { - println!("{:?}", member); - } - } -} +pub mod byte; diff --git a/primitives/src/result.rs b/primitives/src/result.rs deleted file mode 100644 index e64794411..000000000 --- a/primitives/src/result.rs +++ /dev/null @@ -1,23 +0,0 @@ -//! Bridge Result -#![allow(missing_docs)] -use thiserror::Error as ThisError; - -#[derive(ThisError, Debug)] -pub enum Error { - #[error(transparent)] - Io(#[from] std::io::Error), - - #[cfg(feature = "rpc")] - #[error(transparent)] - Reqwest(#[from] reqwest::Error), - - #[cfg(feature = "rpc")] - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - - #[error("Fail to get ethereum header of block {1}: {0}")] - FailToGetEthereumHeader(String, u64), -} - -/// Sup Result -pub type Result = std::result::Result; diff --git a/primitives/src/rpc/ethereum/block.rs b/primitives/src/rpc/ethereum/block.rs deleted file mode 100644 index 8eb1bb715..000000000 --- a/primitives/src/rpc/ethereum/block.rs +++ /dev/null @@ -1,79 +0,0 @@ -//! Ethereum rpcs -use crate::{chain::ethereum::EthereumBlockRPC, result::Result}; -use reqwest::Client; -use serde_json::Value; - -/// Ethereum JSON rpc response -#[derive(Serialize, Deserialize, Debug)] -pub struct EthBlockRPCResp { - jsonrpc: String, - id: i32, - /// Header Result of RPC - pub result: EthereumBlockRPC, -} - -#[derive(Serialize, Deserialize, Debug)] -pub struct EthSyncingRPCResp { - jsonrpc: String, - id: i32, - /// Header Result of RPC - pub result: Value, -} - -impl EthBlockRPCResp { - /// Get `EthHeader` by number - pub async fn get_by_hash(client: &Client, rpc: &str, block: &str) -> Result { - let map: Value = serde_json::from_str(&format! { - "{{{}}}", vec![ - r#""jsonrpc":"2.0","#, - r#""method":"eth_getBlockByHash","#, - &format!(r#""params":["{}", false],"#, block), - r#""id": 1"#, - ].concat(), - })?; - - Ok(client.post(rpc).json(&map).send().await?.json().await?) - } - - /// Get `EthHeader` by number - pub async fn get(client: &Client, rpc: &str, block: u64) -> Result { - let map: Value = serde_json::from_str(&format! { - "{{{}}}", vec![ - r#""jsonrpc":"2.0","#, - r#""method":"eth_getBlockByNumber","#, - &format!(r#""params":["{:#X}", false],"#, block), - r#""id": 1"#, - ].concat(), - })?; - - Ok(client.post(rpc).json(&map).send().await?.json().await?) - } - - /// Get ethereum block number - pub async fn latest(client: &Client, rpc: &str) -> Result { - let map: Value = serde_json::from_str(&format! { - "{{{}}}", vec![ - r#""jsonrpc":"2.0","#, - r#""method":"eth_getBlockByNumber","#, - r#""params":["latest", false],"#, - r#""id": 1"#, - ].concat(), - })?; - - Ok(client.post(rpc).json(&map).send().await?.json().await?) - } - - /// Get ethereum syncing info - pub async fn syncing(client: &Client, rpc: &str) -> Result { - let map: Value = serde_json::from_str(&format! { - "{{{}}}", vec![ - r#""jsonrpc":"2.0","#, - r#""method":"eth_syncing","#, - r#""params":[],"#, - r#""id": 1"#, - ].concat(), - })?; - - Ok(client.post(rpc).json(&map).send().await?.json().await?) - } -} diff --git a/primitives/src/rpc/ethereum/mod.rs b/primitives/src/rpc/ethereum/mod.rs deleted file mode 100644 index 335f8f679..000000000 --- a/primitives/src/rpc/ethereum/mod.rs +++ /dev/null @@ -1,131 +0,0 @@ -//! Ethereum RPC calls -mod block; -mod receipt; - -use crate::{ - chain::ethereum::{EthReceiptBody, EthereumBlockRPC, EthereumHeader}, - result::{Error, Result}, - rpc::Rpc, -}; -use async_trait::async_trait; -use reqwest::Client; -use std::sync::atomic::{AtomicUsize, Ordering}; - -pub use self::block::EthBlockRPCResp; - -/// Ethereum rpc set -pub struct EthereumRPC { - /// Reqwest client - pub client: Client, - /// Rpc host - pub rpc: Vec, - /// Counter - pub atom: AtomicUsize, -} - -impl EthereumRPC { - /// New EthereumRPC - pub fn new(client: Client, rpc: Vec) -> Self { - EthereumRPC { - client, - rpc, - atom: AtomicUsize::new(0), - } - } - - /// Generate random RPC - /// - /// ``` - /// use darwinia_bridge_primitives::rpc::ethereum::EthereumRPC; - /// use reqwest::Client; - /// - /// let rpc = EthereumRPC::new( - /// Client::new(), - /// vec![ - /// "https://mainnet.infura.io/v3/0bfb9acbb13c426097aabb1d81a9d016".to_string(), - /// "https://mainnet.infura.io/v3/74a9b1b5816b47aa853c23fcc4f2f3b6".to_string(), - /// ], - /// ); - /// - /// assert_ne!(rpc.rpc(), rpc.rpc()); - /// ``` - pub fn rpc(&self) -> &str { - let next = (self.atom.load(Ordering::SeqCst) + 1) % self.rpc.len(); - self.atom.store(next, Ordering::SeqCst); - &self.rpc[next] - } -} - -/// TODO: -/// -/// Verify the result of infura will not response empty header with hash -/// 0x00000... -#[async_trait] -impl Rpc for EthereumRPC { - type Header = EthereumHeader; - type Receipt = EthReceiptBody; - type Block = EthereumBlockRPC; - - async fn get_block_by_hash(&self, block: &str) -> Result { - Ok( - EthBlockRPCResp::get_by_hash(&self.client, &self.rpc(), block) - .await? - .result, - ) - } - - async fn get_block_by_number(&self, block: u64) -> Result { - let result = EthBlockRPCResp::get(&self.client, &self.rpc(), block).await; - result - .map(|resp| resp.result) - .map_err(|err| Error::FailToGetEthereumHeader(format!("{:?}", err), block)) - } - - async fn get_header_by_hash(&self, block: &str) -> Result { - Ok(self.get_block_by_hash(block).await?.into()) - } - - async fn get_header_by_number(&self, block: u64) -> Result { - Ok(self.get_block_by_number(block).await?.into()) - } - - async fn get_receipt(&self, txhash: &str) -> Result { - Ok( - receipt::EthReceiptRPCResp::get(&self.client, &self.rpc(), txhash) - .await? - .result, - ) - } - - async fn block_number(&self) -> Result { - let v: serde_json::Value = EthBlockRPCResp::syncing(&self.client, &self.rpc()) - .await? - .result; - match v { - serde_json::Value::Bool(false) => { - let header: Self::Header = EthBlockRPCResp::latest(&self.client, &self.rpc()) - .await? - .result - .into(); - - Ok(header.number) - } - serde_json::Value::Object(o) => Ok(u64::from_str_radix( - o["currentBlock"] - .as_str() - .unwrap_or_default() - .trim_start_matches("0x"), - 16, - ) - .unwrap_or(0)), - _ => { - let header: Self::Header = EthBlockRPCResp::latest(&self.client, &self.rpc()) - .await? - .result - .into(); - - Ok(header.number) - } - } - } -} diff --git a/primitives/src/rpc/ethereum/receipt.rs b/primitives/src/rpc/ethereum/receipt.rs deleted file mode 100644 index aabb2b8cf..000000000 --- a/primitives/src/rpc/ethereum/receipt.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! Ethereum receipt rpcs -use crate::{chain::ethereum::EthReceiptBody, result::Result}; -use reqwest::Client; -use serde_json::Value; - -/// Ethereum JSON rpc response -#[derive(Serialize, Deserialize, Debug)] -pub struct EthReceiptRPCResp { - jsonrpc: String, - id: i32, - /// Recepit Result of RPC - pub result: EthReceiptBody, -} - -impl EthReceiptRPCResp { - /// Get `EthReceipt` by txhash - pub async fn get(client: &Client, rpc: &str, txhash: &str) -> Result { - let map: Value = serde_json::from_str(&format! { - "{{{}}}", vec![ - r#""jsonrpc":"2.0","#, - r#""method":"eth_getTransactionReceipt","#, - &format!(r#""params":["{}"],"#, txhash), - r#""id": 1"#, - ].concat(), - })?; - - Ok(client.post(rpc).json(&map).send().await?.json().await?) - } -} diff --git a/primitives/src/rpc/mod.rs b/primitives/src/rpc/mod.rs deleted file mode 100644 index af75f80d5..000000000 --- a/primitives/src/rpc/mod.rs +++ /dev/null @@ -1,48 +0,0 @@ -//! RPC calls for primitives -#![cfg(feature = "rpc")] - -pub mod ethereum; - -use crate::result::Result; -use async_trait::async_trait; - -/// RPC trait for bridge primitves -#[async_trait] -pub trait Rpc { - /// Block Header - type Header; - /// Transaction Receipt - type Receipt; - /// Block - type Block; - - /// Get block by block hash hex - async fn get_block_by_hash(&self, block: &str) -> Result - where - Self: Sized; - - /// Get block by block number - async fn get_block_by_number(&self, block: u64) -> Result - where - Self: Sized; - - /// Get header by block hash hex - async fn get_header_by_hash(&self, block: &str) -> Result - where - Self: Sized; - - /// Get header by block number - async fn get_header_by_number(&self, block: u64) -> Result - where - Self: Sized; - - /// Get current highest block - async fn block_number(&self) -> Result; - - /// Get receipt - async fn get_receipt(&self, txhash: &str) -> Result - where - Self: Sized; -} - -pub use ethereum::EthereumRPC; diff --git a/primitives/src/runtime.rs b/primitives/src/runtime.rs deleted file mode 100644 index b45daaafc..000000000 --- a/primitives/src/runtime.rs +++ /dev/null @@ -1,232 +0,0 @@ -//! Darwinia Runtime -#![cfg(feature = "runtime")] - -use crate::{ - chain::{ - ethereum::EthereumRelayHeaderParcel, proxy_type::ProxyType, RelayAffirmation, - RelayAffirmationId, RelayVotingState, - }, - frame::{ - bridge::relay_authorities::EthereumRelayAuthorities, - ethereum::{ - backing::EthereumBacking, game::EthereumRelayerGame, issuing::EthereumIssuing, - relay::EthereumRelay, - }, - proxy::Proxy, - sudo::Sudo, - technical_committee::TechnicalCommittee, - }, -}; - -use crate::frame::bridge::relay_authorities::RelayAuthority; -use substrate_subxt::{ - balances::{AccountData, Balances}, - extrinsic::DefaultExtra, - register_default_type_sizes, sp_core, - sp_runtime::{ - generic::Header, - traits::{BlakeTwo256, IdentifyAccount, Verify}, - MultiAddress, MultiSignature, OpaqueExtrinsic, - }, - system::System, - EventTypeRegistry, Runtime, -}; - -use sp_core::{H160, H256, U256}; - -type SessionIndex = u32; - -#[derive(Clone, Debug, PartialEq, Eq, Encode, Decode)] -struct Log { - address: H160, - topics: Vec, - data: Vec, -} - -/// Darwinia Runtime -#[derive(Debug, Clone, Eq, PartialEq)] -pub struct DarwiniaRuntime; -impl Runtime for DarwiniaRuntime { - type Signature = MultiSignature; - type Extra = DefaultExtra; - - fn register_type_sizes(registry: &mut EventTypeRegistry) { - registry.register_type_size::("Balance"); - registry.register_type_size::("RingBalance"); - registry.register_type_size::("KtonBalance"); - registry.register_type_size::<[u8; 20]>("EthereumAddress"); - registry.register_type_size::<[u8; 20]>("EcdsaAddress"); - registry.register_type_size::("MMRRoot"); - registry.register_type_size::<[u8; 32]>("RelayAuthorityMessage"); - registry.register_type_size::<[u8; 20]>("RelayAuthoritySigner"); - registry.register_type_size::("RelayAuthoritySignature"); - registry.register_type_size::("ElectionCompute"); // just a hack - registry.register_type_size::("Term"); - registry.register_type_size::<(H256, u64)>("EthereumTransactionIndex"); - registry.register_type_size::<(u64, u32, u32)>("RelayAffirmationId"); - registry.register_type_size::("EraIndex"); - registry.register_type_size::("EthereumBlockNumber"); - registry.register_type_size::("BlockNumber"); - registry.register_type_size::("AccountId"); - registry.register_type_size::("SessionIndex"); - registry.register_type_size::("Log"); - registry.register_type_size::("U256"); - registry.register_type_size::("H256"); - registry.register_type_size::("H160"); - registry.register_type_size::("ExitReason"); - register_default_type_sizes(registry); - } -} - -impl Balances for DarwiniaRuntime { - type Balance = u128; -} - -impl System for DarwiniaRuntime { - type Index = u32; - type BlockNumber = u32; - type Hash = sp_core::H256; - type Hashing = BlakeTwo256; - type AccountId = <::Signer as IdentifyAccount>::AccountId; - type Address = MultiAddress; - type Header = Header; - type Extrinsic = OpaqueExtrinsic; - type AccountData = AccountData<::Balance>; -} - -impl TechnicalCommittee for DarwiniaRuntime {} -impl Sudo for DarwiniaRuntime {} -impl EthereumRelay for DarwiniaRuntime { - type RingBalance = u128; - type EthereumBlockNumber = u64; - type PendingRelayHeaderParcel = ( - ::BlockNumber, - EthereumRelayHeaderParcel, - RelayVotingState<::AccountId>, - ); - type RelayAffirmationId = RelayAffirmationId; -} - -impl EthereumRelayerGame for DarwiniaRuntime { - type RelayAffirmation = RelayAffirmation< - EthereumRelayHeaderParcel, - ::AccountId, - ::Balance, - RelayAffirmationId, - >; -} - -impl std::fmt::Display - for RelayAffirmation< - EthereumRelayHeaderParcel, - ::AccountId, - ::Balance, - RelayAffirmationId, - > -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - let msg = format!( - "{{\n relayer: {}\n balance: {}\n relayer_header: [{}\n ]\n id: {:?}\n verified: {}\n}}", - self.relayer, - self.stake, - self.relay_header_parcels.iter().fold(String::from(""), |acc, relay| { - if acc.is_empty() { - format!("\n {{\n{}\n }}", relay) - } else { - format!("{}, \n {{{}\n }}", acc, relay) - } - }), - self.maybe_extended_relay_affirmation_id, - self.verified_on_chain - ); - write!(f, "{}", msg) - } -} - -impl EthereumBacking for DarwiniaRuntime { - type EthereumTransactionIndex = (H256, u64); -} - -impl EthereumIssuing for DarwiniaRuntime { - type EthereumTransactionIndex = (H256, u64); -} - -impl Proxy for DarwiniaRuntime { - type ProxyType = ProxyType; -} - -impl EthereumRelayAuthorities for DarwiniaRuntime { - type RelayAuthority = RelayAuthority< - ::AccountId, - Self::RelayAuthoritySigner, - ::Balance, - ::BlockNumber, - >; - type RelayAuthoritySigner = EcdsaAddress; - type RelayAuthoritySignature = EcdsaSignature; - type RelayAuthorityMessage = EcdsaMessage; -} - -use codec::{Decode, Encode}; - -/// EcdsaAddress -pub type EcdsaAddress = [u8; 20]; - -/// EcdsaSignature -#[derive(Clone, Debug, PartialEq, Eq, Encode, Decode)] -pub struct EcdsaSignature(pub [u8; 65]); - -impl Default for EcdsaSignature { - fn default() -> Self { - Self([0u8; 65]) - } -} - -/// EcdsaMessage -pub type EcdsaMessage = [u8; 32]; - -#[derive(Encode, Decode)] -enum ExitReason { - Succeed(ExitSucceed), - Error(ExitError), - Revert(ExitRevert), - Fatal(ExitFatal), -} - -#[derive(Encode, Decode)] -enum ExitSucceed { - Stopped, - Returned, - Suicided, -} - -#[derive(Encode, Decode)] -enum ExitError { - StackUnderflow, - StackOverflow, - InvalidJump, - InvalidRange, - DesignatedInvalid, - CallTooDeep, - CreateCollision, - CreateContractLimit, - OutOfOffset, - OutOfGas, - OutOfFund, - PCUnderflow, - CreateEmpty, - Other(String), -} - -#[derive(Encode, Decode)] -enum ExitRevert { - Reverted, -} - -#[derive(Encode, Decode)] -enum ExitFatal { - NotSupported, - UnhandledInterrupt, - CallErrorAsFatal(ExitError), - Other(String), -} diff --git a/provider/darwinia-bridger/Cargo.toml b/provider/darwinia-bridger/Cargo.toml deleted file mode 100644 index 7bd42f744..000000000 --- a/provider/darwinia-bridger/Cargo.toml +++ /dev/null @@ -1,79 +0,0 @@ - -[package] -name = "darwinia-bridger" -version = "0.3.3" -authors = ["clearloop "] -description = "Darwinia bridger" -repository = "https://github.com/darwinia-network/bridger" -license = "MIT" -documentation = "https://docs.rs/bridger" -homepage = "https://github.com/darwinia-network/bridger" -include = ["src/**/*", "Cargo.toml", "./README.md"] -keywords = ["substrate", "darwinia"] -readme = './README.md' -edition = "2018" - -[lib] -path = "src/lib.rs" - -[[bin]] -name = "bridger" -path = "src/bin/bridger.rs" - -[dependencies] -jsonrpsee-types = "=0.2.0-alpha.6" -jsonrpsee-ws-client = "=0.2.0-alpha.6" -jsonrpsee-http-client = "=0.2.0-alpha.6" -async-macros = "2.0.0" -async-trait = "0.1.40" -dirs = "3.0.1" -env_logger = "0.7.1" -etc = "0.1.11" -futures = "0.3.5" -log = "0.4.11" -structopt = "0.3.18" -substrate-subxt = { git = "https://github.com/darwinia-network/substrate-subxt.git", tag = "darwinia-v0.15.2" } -sp-keyring = "3.0.0" -sp-version = "3.0.0" -web3 = { version = "0.16.0", git = "https://github.com/wuminzhe/rust-web3.git", branch = "master", features = ["signing"] } -config = "0.10" -serde_json = "1.0" -array-bytes = "1.3.3" -actix = "0.10" -actix-rt = "1.1.1" -async-io = "1.1.10" -thiserror = "1.0" -anyhow = "1.0.34" -parity-scale-codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive", "full"] } -secp256k1 = { version = "0.20", features = ["recovery"] } -rust-crypto = "0.2.36" -colored = "2.0.0" -base64 = "0.13.0" -rpassword = "5.0.1" -serde_yaml = "0.8.15" - -[dependencies.reqwest] -version = "0.10" -features = ["json"] - -[dependencies.tokio] -package = "tokio" -version = "0.2.22" -features = ["full"] - -[dependencies.primitives] -package = "darwinia-bridge-primitives" -version = "0.3.3" -path = "../../primitives" -features = ["runtime", "rpc"] - -[dependencies.darwinia] -package = "bridge-client-darwinia" -version = "0.1.0" -path = "../../darwinia" - -[dependencies.serde] -package = "serde" -version = "1" -features = ["derive"] - diff --git a/provider/darwinia-bridger/src/api/Relay.json b/provider/darwinia-bridger/src/api/Relay.json deleted file mode 100644 index 7f5f1db3a..000000000 --- a/provider/darwinia-bridger/src/api/Relay.json +++ /dev/null @@ -1,610 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "Paused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "index", - "type": "uint256" - } - ], - "name": "ResetRootEvent", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint32", - "name": "nonce", - "type": "uint32" - }, - { - "indexed": false, - "internalType": "address[]", - "name": "authorities", - "type": "address[]" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "beneficiary", - "type": "bytes32" - } - ], - "name": "SetAuthoritiesEvent", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "relayer", - "type": "address" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "index", - "type": "uint256" - } - ], - "name": "SetRootEvent", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "Unpaused", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "message", - "type": "bytes" - }, - { - "internalType": "bytes[]", - "name": "signatures", - "type": "bytes[]" - } - ], - "name": "appendRoot", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "prefix", - "type": "bytes" - } - ], - "name": "checkNetworkPrefix", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint32", - "name": "nonce", - "type": "uint32" - } - ], - "name": "checkRelayerNonce", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "eventsProofStr", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "key", - "type": "bytes" - } - ], - "name": "getLockTokenReceipt", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint32", - "name": "index", - "type": "uint32" - } - ], - "name": "getMMRRoot", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getNetworkPrefix", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getRelayer", - "outputs": [ - { - "internalType": "address[]", - "name": "", - "type": "address[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getRelayerCount", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getRelayerNonce", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "getRelayerThreshold", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint32", - "name": "_MMRIndex", - "type": "uint32" - }, - { - "internalType": "bytes32", - "name": "_genesisMMRRoot", - "type": "bytes32" - }, - { - "internalType": "address[]", - "name": "_relayers", - "type": "address[]" - }, - { - "internalType": "uint32", - "name": "_nonce", - "type": "uint32" - }, - { - "internalType": "uint8", - "name": "_threshold", - "type": "uint8" - }, - { - "internalType": "bytes", - "name": "_prefix", - "type": "bytes" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "addr", - "type": "address" - } - ], - "name": "isRelayer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "name": "mmrRootPool", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "pause", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "paused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "_prefix", - "type": "bytes" - } - ], - "name": "resetNetworkPrefix", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint32", - "name": "nonce", - "type": "uint32" - }, - { - "internalType": "address[]", - "name": "accounts", - "type": "address[]" - } - ], - "name": "resetRelayer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint8", - "name": "_threshold", - "type": "uint8" - } - ], - "name": "resetRelayerThreshold", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint32", - "name": "index", - "type": "uint32" - }, - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - } - ], - "name": "resetRoot", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "unpause", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "message", - "type": "bytes" - }, - { - "internalType": "bytes[]", - "name": "signatures", - "type": "bytes[]" - }, - { - "internalType": "bytes32", - "name": "beneficiary", - "type": "bytes32" - } - ], - "name": "updateRelayer", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint32", - "name": "MMRIndex", - "type": "uint32" - }, - { - "internalType": "uint32", - "name": "blockNumber", - "type": "uint32" - }, - { - "internalType": "bytes", - "name": "blockHeader", - "type": "bytes" - }, - { - "internalType": "bytes32[]", - "name": "peaks", - "type": "bytes32[]" - }, - { - "internalType": "bytes32[]", - "name": "siblings", - "type": "bytes32[]" - } - ], - "name": "verifyBlockProof", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "root", - "type": "bytes32" - }, - { - "internalType": "uint32", - "name": "MMRIndex", - "type": "uint32" - }, - { - "internalType": "uint32", - "name": "blockNumber", - "type": "uint32" - }, - { - "internalType": "bytes", - "name": "blockHeader", - "type": "bytes" - }, - { - "internalType": "bytes32[]", - "name": "peaks", - "type": "bytes32[]" - }, - { - "internalType": "bytes32[]", - "name": "siblings", - "type": "bytes32[]" - }, - { - "internalType": "bytes", - "name": "eventsProofStr", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "key", - "type": "bytes" - } - ], - "name": "verifyRootAndDecodeReceipt", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/provider/darwinia-bridger/src/api/darwinia_api.rs b/provider/darwinia-bridger/src/api/darwinia_api.rs deleted file mode 100644 index b4e62b581..000000000 --- a/provider/darwinia-bridger/src/api/darwinia_api.rs +++ /dev/null @@ -1,47 +0,0 @@ -use crate::{error::Result, Settings}; -use darwinia::{ - Darwinia, Darwinia2Ethereum, DarwiniaAccount, Ethereum2Darwinia, FromEthereumAccount, - ToEthereumAccount, -}; - -/// get darwinia api instance -pub async fn get_darwinia_instance(config: &Settings) -> Result { - Ok(Darwinia::new(&config.darwinia.rpc).await?) -} - -/// get ethereum to darwinia api instance -pub fn get_e2d_instance(darwinia: Darwinia) -> Ethereum2Darwinia { - Ethereum2Darwinia::new(darwinia) -} - -/// get darwinia to ethereum api instance -pub fn get_d2e_instance(darwinia: Darwinia) -> Darwinia2Ethereum { - Darwinia2Ethereum::new(darwinia) -} - -/// get darwinia relayer account -pub fn get_darwinia_account(config: &Settings) -> DarwiniaAccount { - DarwiniaAccount::new( - config.darwinia.relayer.private_key.clone(), - config - .darwinia - .relayer - .real_account - .clone() - .map(|real| real[2..].to_string()), - ) -} - -/// get ethereum to darwinia account -pub fn get_e2d_account(account: DarwiniaAccount) -> FromEthereumAccount { - FromEthereumAccount::new(account) -} - -/// get darwinia to ethereum account -pub fn get_d2e_account(account: DarwiniaAccount, config: &Settings) -> ToEthereumAccount { - ToEthereumAccount::new( - account, - config.ethereum.authority.clone().map(|a| a.private_key), - config.ethereum.rpc.to_string(), - ) -} diff --git a/provider/darwinia-bridger/src/api/ethereum.rs b/provider/darwinia-bridger/src/api/ethereum.rs deleted file mode 100644 index 4c63b654c..000000000 --- a/provider/darwinia-bridger/src/api/ethereum.rs +++ /dev/null @@ -1,221 +0,0 @@ -//! Ethereum API -use crate::{error::Error, error::Result, Settings}; - -use primitives::runtime::EcdsaSignature; -use secp256k1::SecretKey; -use serde::{Deserialize, Serialize}; -use std::time::Duration; -use web3::contract::{Contract, Options}; -use web3::signing::SecretKeyRef; -use web3::transports::Http; -use web3::types::{Address, H160, H256, U256}; -use web3::Web3; - -#[derive(Debug, Serialize, Deserialize)] -struct GasPrice { - code: i32, - data: GasPriceData, -} - -#[derive(Debug, Serialize, Deserialize)] -struct GasPriceData { - rapid: u64, - fast: u64, - slow: u64, - standard: u64, - timestamp: u64, -} - -/// Ethereum -pub struct Ethereum { - web3: Web3, - relay_contract_address: Address, - /// secret_key to send ethereum tx - pub secret_key: Option, - beneficiary: Option, -} - -impl Ethereum { - /// new - pub fn new(web3: Web3, config: &Settings) -> Result { - let relay_contract_address = - Ethereum::build_address(&config.ethereum.contract.relay.address)?; - - let secret_key = if let Some(seed) = config.ethereum.relayer.clone().map(|r| r.private_key) - { - let private_key = array_bytes::hex2bytes(&seed[2..]) - .map_err(|_| Error::Hex2Bytes("seed[2..]".into()))?; - Some(SecretKey::from_slice(&private_key)?) - } else { - None - }; - - Ok(Ethereum { - web3, - relay_contract_address, - secret_key, - beneficiary: config - .ethereum - .relayer - .clone() - .map(|r| r.beneficiary_darwinia_account), - }) - } - - /// new2 - pub fn new2( - web3: Web3, - relay_contract_address: String, - seed: Option, - beneficiary: Option, - ) -> Result { - let relay_contract_address = Ethereum::build_address(&relay_contract_address)?; - - let secret_key = if let Some(seed) = seed { - let private_key = array_bytes::hex2bytes(&seed[2..]) - .map_err(|_| Error::Hex2Bytes("seed[2..]".into()))?; - Some(SecretKey::from_slice(&private_key)?) - } else { - None - }; - - Ok(Ethereum { - web3, - relay_contract_address, - secret_key, - beneficiary, - }) - } - - /// is relayer - pub fn is_relayer(&self) -> bool { - self.beneficiary != None - } - - /// submit_authorities_set - pub async fn submit_authorities_set( - &self, - message: Vec, - signatures: Vec, - ) -> Result { - if let Some(beneficiary) = &self.beneficiary { - if let Some(secret_key) = &self.secret_key { - let key_ref = SecretKeyRef::new(secret_key); - - let contract = Contract::from_json( - self.web3.eth(), - self.relay_contract_address, - include_bytes!("Relay.json"), - )?; - - // signatures - let signature_list = signatures - .iter() - .map(|item| item.0.to_vec()) - .collect::>(); - - // beneficiary account id - let beneficiary = array_bytes::hex2bytes(&beneficiary[2..]) - .map_err(|_| Error::Hex2Bytes("beneficiary[2..]".into()))?; - let mut beneficiary_buffer = [0u8; 32]; - beneficiary_buffer.copy_from_slice(&beneficiary); - - // debug - debug!("message: {}", array_bytes::bytes2hex("0x", message.clone())); - for (i, signature) in signature_list.clone().iter().enumerate() { - debug!( - "signature {}: {}", - i + 1, - array_bytes::bytes2hex("0x", signature) - ); - } - debug!( - "beneficiary: {}", - array_bytes::bytes2hex("0x", beneficiary_buffer) - ); - - // gas price - // TODO: do not need to get gas_price if ropsten - let gas_price = Ethereum::fast_gas_price().await.ok(); - - let input = (message, signature_list, beneficiary_buffer); - let txhash = contract - .signed_call( - "updateRelayer", - input, - Options::with(|options| { - options.gas = Some(150_000.into()); - options.gas_price = gas_price; - }), - key_ref, - ) - .await?; - Ok(txhash) - } else { - anyhow::bail!("You have no ethereum private key configured.") - } - } else { - anyhow::bail!("You have no beneficiary configured.") - } - } - - fn build_address(str: &str) -> Result { - let address = - array_bytes::hex2bytes(&str[2..]).map_err(|_| Error::Hex2Bytes("str[2..]".into()))?; - let mut address_buffer = [0u8; 20]; - address_buffer.copy_from_slice(&address); - Ok(Address::from(address_buffer)) - } - - async fn fast_gas_price() -> Result { - let gasnow_url = "https://gasnow.sparkpool.com/api/v3/gas/price?utm_source=DarwiniaBridger"; - let client = reqwest::Client::builder() - .timeout(Duration::from_secs(15)) - .build()?; - let gas_price: GasPrice = client.get(gasnow_url).send().await?.json().await?; - Ok(gas_price.data.fast.into()) - } -} - -#[test] -fn test_load_abi() { - let web3 = Web3::new( - Http::new("https://ropsten.infura.io/v3/60703fcc6b4e48079cfc5e385ee7af80").unwrap(), - ); - let relay_contract_address = - Ethereum::build_address("0xeb931f1a197f3a230d2dfe220ac6674880f827d6").unwrap(); - let contract = Contract::from_json( - web3.eth(), - relay_contract_address, - include_bytes!("Relay.json"), - ) - .unwrap(); - println!("{:?}", contract); -} - -// #[actix_rt::test] -// async fn test_submit_authorities_set() { -// let web3 = Web3::new( -// Http::new("https://ropsten.infura.io/v3/60703fcc6b4e48079cfc5e385ee7af80").unwrap(), -// ); -// -// let ethereum = Ethereum::new2( -// web3, -// "0xc8d6c331030886716f6e323ACB795077eB530E36".to_string(), -// Some("0x2f460a73df143256460ebb319b171a4024db8ce2d42bb83a42930814a50d2b71".to_string()), -// Some("0x129f002b1c0787ea72c31b2dc986e66911fe1b4d6dc16f83a1127f33e5a74c7d".to_string()), -// ) -// .unwrap(); -// -// let txhash = ethereum -// .submit_authorities_set(vec![0u8], vec![EcdsaSignature::default()]) -// .await -// .unwrap(); -// -// println!("{:?}", txhash); -// } -// -// #[actix_rt::test] -// async fn test_calc_gas_price() { -// println!("{}", Ethereum::fast_gas_price().await.unwrap()); -// } diff --git a/provider/darwinia-bridger/src/api/mod.rs b/provider/darwinia-bridger/src/api/mod.rs deleted file mode 100644 index 152325dc8..000000000 --- a/provider/darwinia-bridger/src/api/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! Briger APIs -/// Bridger darwinia apis -pub mod darwinia_api; -mod ethereum; -mod shadow; - -pub use self::{ethereum::Ethereum, shadow::Shadow}; diff --git a/provider/darwinia-bridger/src/api/shadow.rs b/provider/darwinia-bridger/src/api/shadow.rs deleted file mode 100644 index 8d248bc57..000000000 --- a/provider/darwinia-bridger/src/api/shadow.rs +++ /dev/null @@ -1,153 +0,0 @@ -//! Darwinia shadow API -use crate::error::Error; -use crate::{ - error::{BizError, Result}, - Settings, -}; -use anyhow::Context as AnyhowContext; -use primitives::{ - chain::ethereum::{ - EthereumReceiptProofThing, EthereumReceiptProofThingJson, EthereumRelayHeaderParcel, - EthereumRelayProofs, EthereumRelayProofsJson, MMRRoot, MMRRootJson, - }, - rpc::{EthereumRPC, Rpc}, -}; -use reqwest::{Client, StatusCode}; -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; -use std::time::Duration; - -#[derive(Serialize)] -struct Proposal { - pub member: u64, - pub target: u64, - pub last_leaf: u64, -} - -/// Parent mmr root result -#[derive(Serialize, Deserialize)] -#[serde(untagged)] -enum ParentMmrRootResult { - Result(MMRRootJson), - Error { error: String }, -} - -/// Proof result -#[derive(Serialize, Deserialize)] -#[serde(untagged)] -enum ProofResult { - Result(EthereumRelayProofsJson), - Error { error: String }, -} - -/// Shadow API -pub struct Shadow { - /// Shadow API - pub api: String, - /// Ethereum RPC - pub eth: EthereumRPC, - /// HTTP Client - pub http: Client, -} - -impl Shadow { - /// Init Shadow API from config - pub fn new(config: &Settings) -> Shadow { - let http = reqwest::Client::builder() - .timeout(Duration::from_secs(30)) - .build() - .unwrap(); - Shadow { - api: config.shadow.endpoint.clone(), - eth: EthereumRPC::new(http.clone(), vec![config.ethereum.rpc.clone()]), - http, - } - } - - /// Get mmr - pub async fn get_parent_mmr_root(&self, block_number: usize) -> Result { - let url = &format!("{}/ethereum/parent_mmr_root/{}", &self.api, block_number); - let resp = self.http.get(url).send().await?; - if resp.status() == StatusCode::INTERNAL_SERVER_ERROR { - Err(Error::ShadowInternalServerError(resp.text().await?).into()) - } else { - let result: ParentMmrRootResult = resp - .json() - .await - .context(format!("Fail to parse json to MMRRootJson: {}", url))?; - match result { - ParentMmrRootResult::Result(json) => Ok(json.into()), - ParentMmrRootResult::Error { error } => { - Err(BizError::BlankEthereumMmrRoot(block_number, error).into()) - } - } - } - } - - /// Get HeaderParcel - pub async fn parcel(&self, number: usize) -> Result { - let mmr_root = self.get_parent_mmr_root(number).await?; - let header = self.eth.get_header_by_number(number as u64).await?; - - Ok(EthereumRelayHeaderParcel { - header, - mmr_root: mmr_root.mmr_root, - }) - } - - /// Get Receipt - pub async fn receipt(&self, tx: &str, last: u64) -> Result { - let resp = self - .http - .get(&format!("{}/ethereum/receipt/{}/{}", &self.api, tx, last)) - .send() - .await?; - if resp.status() == StatusCode::INTERNAL_SERVER_ERROR { - Err(Error::ShadowInternalServerError(resp.text().await?).into()) - } else { - let result: Value = resp.json().await?; - if let Some(err) = result.get("error") { - Err(BizError::Bridger(err.as_str().unwrap().to_owned()).into()) - } else { - let json: EthereumReceiptProofThingJson = serde_json::from_value(result)?; - Ok(json.into()) - } - } - } - - /// Get Proposal - pub async fn proof( - &self, - member: u64, - target: u64, - last_leaf: u64, - ) -> Result { - info!( - "Requesting proposal - member: {}, target: {}, last_leaf: {}", - member, target, last_leaf - ); - let map: Value = serde_json::to_value(Proposal { - member, - target, - last_leaf, - })?; - - let resp = self - .http - .post(&format!("{}/ethereum/proof", self.api)) - .json(&map) - .send() - .await?; - - if resp.status() == StatusCode::INTERNAL_SERVER_ERROR { - Err(Error::ShadowInternalServerError(resp.text().await?).into()) - } else { - let result: ProofResult = resp.json().await?; - match result { - ProofResult::Result(json) => Ok(json.into()), - ProofResult::Error { error } => Err(BizError::Bridger(error).into()), - } - } - } -} diff --git a/provider/darwinia-bridger/src/bin/bridger.rs b/provider/darwinia-bridger/src/bin/bridger.rs deleted file mode 100644 index e623a6c39..000000000 --- a/provider/darwinia-bridger/src/bin/bridger.rs +++ /dev/null @@ -1,11 +0,0 @@ -use actix::System; -use darwinia_bridger::cmd; - -#[actix_rt::main] -async fn main() { - if let Err(err) = cmd::exec().await { - log::error!("{}", err.to_string()); - System::current().stop(); - std::process::exit(1); - } -} diff --git a/provider/darwinia-bridger/src/cmd/affirm.rs b/provider/darwinia-bridger/src/cmd/affirm.rs deleted file mode 100644 index 4b40197e7..000000000 --- a/provider/darwinia-bridger/src/cmd/affirm.rs +++ /dev/null @@ -1,56 +0,0 @@ -use crate::service::ExtrinsicsService; -use crate::{ - api::{darwinia_api, Shadow}, - error::Result, - service::RelayService, - Settings, -}; -use actix::Actor; -use rpassword::prompt_password_stdout; -use std::sync::Arc; - -/// Affirm -pub async fn exec(block: u64) -> Result<()> { - std::env::set_var("RUST_LOG", "info,darwinia_bridger"); - env_logger::init(); - - // apis - let mut config = Settings::new(&Settings::default_data_dir()?)?; // TODO: add --data-dir - if config.encrypted { - let passwd = prompt_password_stdout("Please enter password:")?; - config.decrypt(&passwd)?; - } - let shadow = Arc::new(Shadow::new(&config)); - let darwinia = darwinia_api::get_darwinia_instance(&config).await?; - let ethereum2darwinia = darwinia_api::get_e2d_instance(darwinia); - - let darwinia_account = darwinia_api::get_darwinia_account(&config); - let e2d_account = darwinia_api::get_e2d_account(darwinia_account); - - // extrinsic sender - let extrinsics_service = ExtrinsicsService::new( - Some(ethereum2darwinia.clone()), - None, - Some(e2d_account), - None, - "".to_string(), - dirs::home_dir().unwrap(), - ) - .start(); - - info!("Init API succeed!"); - - // affirm - if let Err(err) = RelayService::affirm( - ethereum2darwinia, - shadow, - block, - extrinsics_service.recipient(), - ) - .await - { - error!("{:?}", err); - } - - Ok(()) -} diff --git a/provider/darwinia-bridger/src/cmd/affirm_force.rs b/provider/darwinia-bridger/src/cmd/affirm_force.rs deleted file mode 100644 index 08b815273..000000000 --- a/provider/darwinia-bridger/src/cmd/affirm_force.rs +++ /dev/null @@ -1,40 +0,0 @@ -use crate::{ - api::{darwinia_api, Shadow}, - error::{BizError, Result}, - Settings, -}; -use primitives::chain::ethereum::EthereumHeader; -use rpassword::prompt_password_stdout; - -/// Affirm Force -pub async fn exec(block: u64) -> Result<()> { - std::env::set_var("RUST_LOG", "info,darwinia_bridger"); - env_logger::init(); - - // apis - let mut config = Settings::new(&Settings::default_data_dir()?)?; // TODO: add --data-dir - if config.encrypted { - let passwd = prompt_password_stdout("Please enter password:")?; - config.decrypt(&passwd)?; - } - let shadow = Shadow::new(&config); - let darwinia = darwinia_api::get_darwinia_instance(&config).await?; - let ethereum2darwinia = darwinia_api::get_e2d_instance(darwinia.clone()); - let darwinia_account = darwinia_api::get_darwinia_account(&config); - let from_ethereum_account = darwinia_api::get_e2d_account(darwinia_account); - - let parcel = shadow.parcel(block as usize + 1).await?; - let block_number = parcel.header.number; - if parcel.header == EthereumHeader::default() || parcel.mmr_root == [0u8; 32] { - return Err(BizError::ParcelFromShadowIsEmpty(block).into()); - } - let ex_hash = ethereum2darwinia - .affirm(&from_ethereum_account, parcel) - .await?; - info!( - "Affirmed ethereum block {} in extrinsic {:?}", - block_number, ex_hash - ); - - Ok(()) -} diff --git a/provider/darwinia-bridger/src/cmd/affirm_raw.rs b/provider/darwinia-bridger/src/cmd/affirm_raw.rs deleted file mode 100644 index 2b1dec494..000000000 --- a/provider/darwinia-bridger/src/cmd/affirm_raw.rs +++ /dev/null @@ -1,32 +0,0 @@ -use crate::{api::darwinia_api, error::Result, Settings}; -use rpassword::prompt_password_stdout; - -/// Affirm -pub async fn exec(json: String) -> Result<()> { - std::env::set_var("RUST_LOG", "info,darwinia_bridger"); - env_logger::init(); - - // apis - let mut config = Settings::new(&Settings::default_data_dir()?)?; // TODO: add --data-dir - if config.encrypted { - let passwd = prompt_password_stdout("Please enter password:")?; - config.decrypt(&passwd)?; - } - let darwinia = darwinia_api::get_darwinia_instance(&config).await?; - let ethereum2darwinia = darwinia_api::get_e2d_instance(darwinia); - let darwinia_account = darwinia_api::get_darwinia_account(&config); - let e2d_account = darwinia_api::get_e2d_account(darwinia_account); - - // build from json string - let parcel: primitives::chain::ethereum::EthereumRelayHeaderParcel = - serde_json::from_str(&json).unwrap(); - - // affirm - let hash = ethereum2darwinia - .affirm(&e2d_account, parcel) - .await - .unwrap(); - println!("Extrinsic hash: {:?}", hash); - - Ok(()) -} diff --git a/provider/darwinia-bridger/src/cmd/affirmations.rs b/provider/darwinia-bridger/src/cmd/affirmations.rs deleted file mode 100644 index 895a14837..000000000 --- a/provider/darwinia-bridger/src/cmd/affirmations.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::{api::darwinia_api, error::Result, Settings}; - -/// get all affirmations -pub async fn exec() -> Result<()> { - std::env::set_var("RUST_LOG", "info,darwinia_bridger"); - env_logger::init(); - - // apis - let config = Settings::new(&Settings::default_data_dir()?)?; // TODO: add --data-dir - let darwinia = darwinia_api::get_darwinia_instance(&config).await?; - let ethereum2darwinia = darwinia_api::get_e2d_instance(darwinia); - - info!("Init API succeed!"); - - for (game_id, game) in ethereum2darwinia.affirmations().await?.iter() { - println!("--- GAME {} ---", game_id); - for (round_id, affirmations) in game.iter() { - println!("ROUND {}", round_id); - for affirmation in affirmations { - println!("affirmation: {}", affirmation); - } - } - } - - Ok(()) -} diff --git a/provider/darwinia-bridger/src/cmd/confirm.rs b/provider/darwinia-bridger/src/cmd/confirm.rs deleted file mode 100644 index 0f16a8480..000000000 --- a/provider/darwinia-bridger/src/cmd/confirm.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::{ - api::{darwinia_api, Shadow}, - error::Result, - Settings, -}; -use rpassword::prompt_password_stdout; - -/// Run the bridger -pub async fn exec(block: u64) -> Result<()> { - std::env::set_var("RUST_LOG", "info,darwinia_bridger"); - env_logger::init(); - - let mut config = Settings::new(&Settings::default_data_dir()?)?; // TODO: add --data-dir - if config.encrypted { - let passwd = prompt_password_stdout("Please enter password:")?; - config.decrypt(&passwd)?; - } - let shadow = Shadow::new(&config); - let darwinia = darwinia_api::get_darwinia_instance(&config).await?; - let ethereum2darwinia = darwinia_api::get_e2d_instance(darwinia); - let darwinia_account = darwinia_api::get_darwinia_account(&config); - let e2d_account = darwinia_api::get_e2d_account(darwinia_account); - info!("Init darwinia API succeed!"); - let parcel = shadow.parcel(block as usize).await?; - info!("Init shadow API succeed!"); - ethereum2darwinia - .set_confirmed_parcel(&e2d_account, parcel) - .await?; - info!("Set confirmed block {} succeed!", block); - Ok(()) -} diff --git a/provider/darwinia-bridger/src/cmd/ecdsa.rs b/provider/darwinia-bridger/src/cmd/ecdsa.rs deleted file mode 100644 index 3d562d688..000000000 --- a/provider/darwinia-bridger/src/cmd/ecdsa.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::{api::darwinia_api, error::Error, error::Result, Settings}; -use rpassword::prompt_password_stdout; - -/// Ecdsa -pub async fn exec(message: String) -> Result<()> { - std::env::set_var("RUST_LOG", "info,darwinia_bridger"); - env_logger::init(); - - // apis - let mut config = Settings::new(&Settings::default_data_dir()?)?; // TODO: add --data-dir - if config.encrypted { - let passwd = prompt_password_stdout("Please enter password:")?; - config.decrypt(&passwd)?; - } - let darwinia = darwinia_api::get_darwinia_instance(&config).await?; - let darwinia2ethereum = darwinia_api::get_d2e_instance(darwinia.clone()); - let darwinia_account = darwinia_api::get_darwinia_account(&config); - let to_ethereum_account = darwinia_api::get_d2e_account(darwinia_account, &config); - - info!("Init API succeed!"); - - let message = array_bytes::hex2bytes(&message[2..]) - .map_err(|_| Error::Hex2Bytes("message[2..]".into()))?; - let mut buffer = [0u8; 32]; - buffer.copy_from_slice(&message); - darwinia2ethereum - .ecdsa_sign_and_submit_signed_authorities(&to_ethereum_account, buffer) - .await?; - - Ok(()) -} diff --git a/provider/darwinia-bridger/src/cmd/encrypt_conf.rs b/provider/darwinia-bridger/src/cmd/encrypt_conf.rs deleted file mode 100644 index 15b0b8c67..000000000 --- a/provider/darwinia-bridger/src/cmd/encrypt_conf.rs +++ /dev/null @@ -1,29 +0,0 @@ -use crate::error::BizError; -use crate::error::Result; -use crate::Settings; -use rpassword::prompt_password_stdout; -use std::fs; -use std::path::PathBuf; - -/// Encrypt Key or Decrypt Key -pub async fn exec(from_path: String, to_path: String) -> Result<()> { - std::env::set_var("RUST_LOG", "info,darwinia_bridger"); - env_logger::init(); - - // apis - let from_path = PathBuf::from(from_path); - let mut config = Settings::new(&from_path)?; - let passwd = prompt_password_stdout("Please enter password:")?; - if config.encrypted { - config.decrypt(&passwd)?; - } else { - let confirmed = prompt_password_stdout("Please enter password again:")?; - if passwd != confirmed { - return Err(BizError::Bridger("Two passwords are inconsistent".to_string()).into()); - } - config.encrypt(&passwd)?; - } - let new_config = serde_yaml::to_string(&config)?; - fs::write(to_path + "/config.yml", new_config)?; - Ok(()) -} diff --git a/provider/darwinia-bridger/src/cmd/encrypt_key.rs b/provider/darwinia-bridger/src/cmd/encrypt_key.rs deleted file mode 100644 index 0553863bd..000000000 --- a/provider/darwinia-bridger/src/cmd/encrypt_key.rs +++ /dev/null @@ -1,27 +0,0 @@ -use crate::error::BizError; -use crate::error::Result; -use crate::Crypto; -use rpassword::prompt_password_stdout; - -/// Encrypt Key or Decrypt Key -pub async fn exec(key: String, is_decrypt: bool) -> Result<()> { - std::env::set_var("RUST_LOG", "info,darwinia_bridger"); - env_logger::init(); - - let passwd = prompt_password_stdout("Please enter password:")?; - - let crypto = Crypto { salt: [0; 16] }; - if is_decrypt { - let decrypted = crypto.decrypt(&passwd, &key)?; - println!("{}", decrypted); - } else { - let confirmed = prompt_password_stdout("Please enter password again:")?; - if passwd != confirmed { - return Err(BizError::Bridger("Two passwords are inconsistent".to_string()).into()); - } - let encrypted = crypto.encrypt(&passwd, &key)?; - println!("{}", encrypted); - } - - Ok(()) -} diff --git a/provider/darwinia-bridger/src/cmd/guard.rs b/provider/darwinia-bridger/src/cmd/guard.rs deleted file mode 100644 index b585d5bb9..000000000 --- a/provider/darwinia-bridger/src/cmd/guard.rs +++ /dev/null @@ -1,59 +0,0 @@ -use crate::service::ExtrinsicsService; -use crate::{ - api::{darwinia_api, Shadow}, - error::Result, - service::GuardService, - Settings, -}; -use actix::Actor; -use rpassword::prompt_password_stdout; -use std::sync::Arc; - -/// Run guard -pub async fn exec() -> Result<()> { - std::env::set_var("RUST_LOG", "info,darwinia_bridger"); - env_logger::init(); - - // apis - let mut config = Settings::new(&Settings::default_data_dir()?)?; // TODO: add --data-dir - if config.encrypted { - let passwd = prompt_password_stdout("Please enter password:")?; - config.decrypt(&passwd)?; - } - let shadow = Arc::new(Shadow::new(&config)); - let darwinia = darwinia_api::get_darwinia_instance(&config).await?; - let ethereum2darwinia = darwinia_api::get_e2d_instance(darwinia); - let from_ethereum_account = - darwinia_api::get_e2d_account(darwinia_api::get_darwinia_account(&config)); - // extrinsic sender - let extrinsics_service = ExtrinsicsService::new( - Some(ethereum2darwinia.clone()), - None, - Some(from_ethereum_account.clone()), - None, - "".to_string(), - dirs::home_dir().unwrap(), - ) - .start(); - - info!("Init API succeed!"); - - // guard service - let is_tech_comm_member = ethereum2darwinia - .is_tech_comm_member(None, &from_ethereum_account) - .await?; - let _guard_service = GuardService::new( - shadow.clone(), - ethereum2darwinia.clone(), - from_ethereum_account.clone(), - config.services.guard.step, - is_tech_comm_member, - extrinsics_service.recipient(), - ) - .map(|g| g.start()); - - log::info!("Ctrl-C to shut down"); - tokio::signal::ctrl_c().await.unwrap(); - log::info!("Ctrl-C received, shutting down"); - Ok(()) -} diff --git a/provider/darwinia-bridger/src/cmd/info_d2e.rs b/provider/darwinia-bridger/src/cmd/info_d2e.rs deleted file mode 100644 index e10ea60f4..000000000 --- a/provider/darwinia-bridger/src/cmd/info_d2e.rs +++ /dev/null @@ -1,135 +0,0 @@ -use crate::{api::darwinia_api, error::Result, Settings}; -use parity_scale_codec::Encode; - -use darwinia::{Darwinia2Ethereum, EventInfo, FormatedMMR}; - -use colored::*; -use rpassword::prompt_password_stdout; -use std::fmt; - -#[derive(Default, Debug)] -struct TxProofWithMMRProof { - message: String, - signatures: Vec, - root: String, - mmrindex: u64, - block_header: String, - peaks: Vec, - siblings: Vec, - events_proof_str: String, - signers: Vec, -} - -impl fmt::Display for TxProofWithMMRProof { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!( - f, - r#"{{ - message: {}, - signatures: [{}], - root: {}, - MMRIndex: {}, - blockNumber: {}, - peaks: [{}], - siblings: [{}], - eventsProofStr: {}, - signers: {} -}}"#, - self.message.green(), - self.signatures.join(",").green(), - self.root.green(), - self.mmrindex.to_string().red(), - self.block_header.green(), - self.peaks.join(",").green(), - self.siblings.join(",").green(), - self.events_proof_str.green(), - self.signers.join(","), - ) - } -} - -/// Get Darwinia to Ethereum Info -pub async fn exec( - network: String, - txblock: u64, - mmrblock: u64, - signblock: u64, - istoken: bool, -) -> Result<()> { - std::env::set_var("RUST_LOG", "info,darwinia_bridger"); - env_logger::init(); - - // apis - let mut config = Settings::new(&Settings::default_data_dir()?)?; - if config.encrypted { - let passwd = prompt_password_stdout("Please enter password:")?; - config.decrypt(&passwd)?; - } - let darwinia = darwinia_api::get_darwinia_instance(&config).await?; - let darwinia2ethereum = darwinia_api::get_d2e_instance(darwinia.clone()); - // mmr root block - let mmr_root = darwinia.get_mmr_root(mmrblock as u32).await?; - let message = Darwinia2Ethereum::construct_mmr_root_message(network, mmrblock as u32, mmr_root); - //let message = web3::signing::keccak256(&encoded); - - let header = darwinia.get_block_by_number(txblock as u32).await?; - let proof = darwinia2ethereum - .get_headermmr_genproof(txblock, mmrblock, header.hash()) - .await?; - let event_proof = darwinia - .get_event_proof( - array_bytes::hex2bytes(if istoken { - "e66f3de22eed97c730152f373193b5a0485b407d88f37d5fd6a2c59e5a696691" - } else { - "f8860dda3d08046cf2706b92bf7202eaae7a79191c90e76297e0895605b8b457" - }) - .unwrap(), - header.hash(), - ) - .await?; - - //let mut result = HashMap::new(); - let mut result: TxProofWithMMRProof = TxProofWithMMRProof { - message: array_bytes::bytes2hex("0x", &message), - block_header: array_bytes::bytes2hex("0x", header.encode()), - events_proof_str: array_bytes::bytes2hex( - "0x", - event_proof - .iter() - .map(|x| &x.0) - .collect::>>() - .encode(), - ), - root: array_bytes::bytes2hex("0x", mmr_root), - mmrindex: mmrblock, - ..Default::default() - }; - - if let Some(header_proof) = proof { - let proof: Option = header_proof.into(); - if let Some(formated_proof) = proof { - result.peaks = formated_proof.peaks; - result.siblings = formated_proof.siblings; - } - } - - // confirmed block - let events = darwinia - .get_events_from_block_number(signblock as u32) - .await?; - for event in events { - if let EventInfo::MMRRootSignedEvent(signed_info) = event { - let mut sign_accounts = vec![]; - let mut signatures = vec![]; - for signature in signed_info.signatures { - sign_accounts.push(signature.0.to_string()); - signatures.push(array_bytes::bytes2hex("0x", signature.1.encode())); - } - //result.insert("sign-account".to_string(), sign_accounts.join(",")); - result.signatures = signatures; - result.signers = sign_accounts; - } - } - println!("{}", result); - Ok(()) -} diff --git a/provider/darwinia-bridger/src/cmd/keys.rs b/provider/darwinia-bridger/src/cmd/keys.rs deleted file mode 100644 index 2d18c5025..000000000 --- a/provider/darwinia-bridger/src/cmd/keys.rs +++ /dev/null @@ -1,28 +0,0 @@ -use crate::{error::Result, Settings}; -use primitives::frame::{sudo::KeyStoreExt, technical_committee::MembersStoreExt}; -use primitives::runtime::DarwiniaRuntime; -use substrate_subxt::ClientBuilder; - -/// technical committee members -pub async fn exec() -> Result<()> { - std::env::set_var("RUST_LOG", "info,darwinia_bridger"); - env_logger::init(); - - let config = Settings::new(&Settings::default_data_dir()?)?; // TODO: add --data-dir - - let client = ClientBuilder::::new() - .set_url(&config.darwinia.rpc) - .build() - .await?; - let sudo = client.key(None).await?; - // let sudo_ss58 = sudo.to_string(); - let technical_committee_members = client.members(None).await?; - - println!("sudo key: {:?}", sudo); - println!( - "technical committee members: {:?}", - technical_committee_members - ); - - Ok(()) -} diff --git a/provider/darwinia-bridger/src/cmd/mod.rs b/provider/darwinia-bridger/src/cmd/mod.rs deleted file mode 100644 index 3608a01f3..000000000 --- a/provider/darwinia-bridger/src/cmd/mod.rs +++ /dev/null @@ -1,177 +0,0 @@ -//! Sup Commands -use crate::error::Result; -use std::path::PathBuf; -use structopt::{clap::AppSettings, StructOpt}; - -mod affirm; -mod affirm_force; -mod affirm_raw; -mod affirmations; -mod confirm; -mod ecdsa; -mod encrypt_conf; -mod encrypt_key; -mod guard; -mod info_d2e; -mod keys; -mod run; -mod set_darwinia_start; -mod set_start; -mod show_parcel; -mod sign_mmr_root; - -#[derive(StructOpt, Debug)] -#[structopt(setting = AppSettings::InferSubcommands)] -enum Opt { - /// Run the bridger, this will start `ethereum`, `relay`, `redeem` and `guard` services - Run { - /// Data dir of bridger - #[structopt(short, long)] - data_dir: Option, - /// Run bridger in verbose mode - #[structopt(short, long)] - verbose: bool, - }, - /// Set Confirmed block with sudo privilege - Confirm { - /// The confirmed block number - #[structopt(short, long)] - block: u64, - }, - /// Affirm one target block - Affirm { - /// The block number to affirm - #[structopt(short, long)] - block: u64, - }, - /// Affirm a raw parcel from json str - AffirmRaw { - /// The block number to affirm - #[structopt(short, long)] - json: String, - }, - /// Show sudo and technical committee members' public key - Keys, - /// List affirmations from chain - Affirmations, - /// Run `guard` service standalone - Guard, - /// Show a parcel from ethereum - ShowParcel { - /// The block number to affirm - #[structopt(short, long)] - block: u64, - /// json format - #[structopt(short, long)] - json: bool, - }, - /// Set where to start the ethereum scan - SetStart { - /// Data dir of bridger - #[structopt(short, long)] - data_dir: Option, - /// The new ethereum start - #[structopt(short, long)] - block: u64, - }, - /// Ecdsa sign and send - Ecdsa { - /// The new ethereum start - #[structopt(short, long)] - message: String, - }, - /// Set where to start the darwinia scan - SetDarwiniaStart { - /// Data dir of bridger - #[structopt(short, long)] - data_dir: Option, - /// The new ethereum start - #[structopt(short, long)] - block: u64, - }, - /// Get Darwinia to Ethereum proof info - InfoD2E { - /// network name - #[structopt(short, long)] - network: String, - /// tx block number - #[structopt(short, long)] - txblock: u64, - /// mmr block number - #[structopt(short, long)] - mmrblock: u64, - /// sign block number - #[structopt(short, long)] - signblock: u64, - /// is token or ring/kton - #[structopt(short, long)] - istoken: bool, - }, - /// Sign MMR root - SignMMRRoot { - /// network name - #[structopt(short, long)] - network: String, - /// mmr block - #[structopt(short, long)] - mmrblock: u64, - }, - /// Affirm a targe block without any check - AffirmForce { - /// block number - #[structopt(short, long)] - block: u64, - }, - /// encrypt or decrypt key - EncryptKey { - #[structopt(short, long)] - private_key: String, - #[structopt(short, long)] - decrypt: bool, - }, - /// encrypt or decrypt private_key in config.yml - EncryptConf { - #[structopt(short, long)] - from_path: String, - #[structopt(short, long)] - to_path: String, - }, -} - -/// Exec commands -pub async fn exec() -> Result<()> { - let opt = Opt::from_args(); - match opt { - Opt::Run { data_dir, verbose } => run::exec(data_dir, verbose).await?, - Opt::Confirm { block } => confirm::exec(block).await?, - Opt::Affirm { block } => affirm::exec(block).await?, - Opt::AffirmRaw { json } => affirm_raw::exec(json).await?, - Opt::ShowParcel { block, json } => show_parcel::exec(block, json).await?, - Opt::Keys => keys::exec().await?, - Opt::Affirmations => affirmations::exec().await?, - Opt::Guard => guard::exec().await?, - Opt::SetStart { data_dir, block } => set_start::exec(data_dir, block).await?, - Opt::Ecdsa { message } => ecdsa::exec(message).await?, - Opt::SetDarwiniaStart { data_dir, block } => { - set_darwinia_start::exec(data_dir, block).await? - } - Opt::InfoD2E { - network, - txblock, - mmrblock, - signblock, - istoken, - } => info_d2e::exec(network, txblock, mmrblock, signblock, istoken).await?, - Opt::SignMMRRoot { network, mmrblock } => sign_mmr_root::exec(network, mmrblock).await?, - Opt::AffirmForce { block } => { - affirm_force::exec(block).await?; - } - Opt::EncryptKey { - private_key, - decrypt, - } => encrypt_key::exec(private_key, decrypt).await?, - Opt::EncryptConf { from_path, to_path } => encrypt_conf::exec(from_path, to_path).await?, - } - - Ok(()) -} diff --git a/provider/darwinia-bridger/src/cmd/run.rs b/provider/darwinia-bridger/src/cmd/run.rs deleted file mode 100644 index 1a09abaed..000000000 --- a/provider/darwinia-bridger/src/cmd/run.rs +++ /dev/null @@ -1,280 +0,0 @@ -use crate::api::{darwinia_api, Shadow}; -use crate::{ - // listener::Listener, - error::{Error, Result}, - Settings, -}; -use actix::Actor; -use rpassword::prompt_password_stdout; -use std::path::PathBuf; -use std::sync::Arc; -use std::time::Duration; -use tokio::time; -use web3::{transports::http::Http, Web3}; - -use crate::api::Ethereum; -use crate::error::BizError; -use crate::service::EthereumService; -use crate::service::ExtrinsicsService; -use crate::service::GuardService; -use crate::service::MsgStop; -use crate::service::RedeemService; -use crate::service::RelayService; -use crate::service::SubscribeService; -use crate::tools; - -use darwinia::{ - Darwinia, Darwinia2Ethereum, Ethereum2Darwinia, FromEthereumAccount, ToEthereumAccount, -}; - -/// Run the bridger -pub async fn exec(data_dir: Option, verbose: bool) -> Result<()> { - if std::env::var("RUST_LOG").is_err() { - if verbose { - std::env::set_var("RUST_LOG", "info,darwinia_bridger"); - } else { - std::env::set_var("RUST_LOG", "info"); - } - } - env_logger::init(); - - // --- Data dir --- - let data_dir = data_dir.unwrap_or_else(|| Settings::default_data_dir().unwrap()); - // --- Load config --- - let mut config = Settings::new(&data_dir)?; - - if config.encrypted { - let passwd = prompt_password_stdout("Please enter password:").unwrap(); - config.decrypt(&passwd)?; - } - loop { - if let Err(e) = run(data_dir.clone(), &config).await { - error!("{:?}", e); - match e.downcast_ref() { - // break - Some(Error::NoDarwiniaStart) | Some(Error::NoEthereumStart) => { - return Err(e); - } - // retry - _ => { - info!("Bridger will restart in 30 seconds..."); - time::delay_for(Duration::from_secs(30)).await; - } - } - } - } -} - -async fn run(data_dir: PathBuf, config: &Settings) -> Result<()> { - info!( - "✌️ {} v{}", - env!("CARGO_PKG_NAME"), - env!("CARGO_PKG_VERSION") - ); - - info!("💾 Data dir: {}", data_dir.to_str().unwrap()); - if config.ethereum.rpc.starts_with("ws") { - return Err(BizError::Bridger( - "Bridger currently doesn't support ethereum websocket transport".to_string(), - ) - .into()); - } - - // --- Load cached start - let last_redeemed = tools::get_cache( - data_dir.clone(), - tools::LAST_REDEEMED_CACHE_FILE_NAME, - Error::NoEthereumStart, - ) - .await?; - info!("🌱 Scan ethereum block from: {}", last_redeemed + 1); - - let last_tracked_darwinia_block = tools::get_cache( - data_dir.clone(), - tools::LAST_TRACKED_DARWINIA_BLOCK_FILE_NAME, - Error::NoDarwiniaStart, - ) - .await? as u32; - info!( - "🌱 Scan darwinia block from: {}", - last_tracked_darwinia_block + 1 - ); - - // --- Init APIs --- - let shadow = Arc::new(Shadow::new(&config)); - let darwinia = darwinia_api::get_darwinia_instance(&config).await?; - let ethereum2darwinia = darwinia_api::get_e2d_instance(darwinia.clone()); - let darwinia2ethereum = darwinia_api::get_d2e_instance(darwinia.clone()); - let darwinia_account = darwinia_api::get_darwinia_account(&config); - let from_ethereum_account = darwinia_api::get_e2d_account(darwinia_account.clone()); - let to_ethereum_account = darwinia_api::get_d2e_account(darwinia_account.clone(), &config); - - let web3 = Web3::new( - Http::new(&config.ethereum.rpc) - .map_err(|e| Error::NewHttpError(config.ethereum.rpc.clone(), e.to_string()))?, - ); - - // Stop if darwinia sender is authority but without a signer seed - if darwinia2ethereum - .is_authority(Some(last_tracked_darwinia_block + 1), &to_ethereum_account) - .await? && !to_ethereum_account.has_ethereum_seed() - { - return Err(Error::NoAuthoritySignerSeed.into()); - } - - // --- Network --- - let spec_name = darwinia.runtime_version().await?; - - // --- Print startup info --- - info!("🔗 Connect to"); - info!(" Darwinia {}: {}", &spec_name, config.darwinia.rpc); - info!(" Shadow: {}", config.shadow.endpoint); - info!(" Ethereum: {}", config.ethereum.rpc); - darwinia2ethereum - .account_detail(Some(last_tracked_darwinia_block + 1), &to_ethereum_account) - .await?; - ethereum2darwinia - .account_detail( - Some(last_tracked_darwinia_block + 1), - &from_ethereum_account, - ) - .await?; - - // --- Start services --- - start_services( - &config, - &shadow, - &darwinia, - Some(ethereum2darwinia), - Some(darwinia2ethereum), - Some(from_ethereum_account), - Some(to_ethereum_account), - &web3, - ( - data_dir, - spec_name, - last_redeemed, - last_tracked_darwinia_block, - ), - ) - .await -} - -#[allow(clippy::too_many_arguments)] -async fn start_services( - config: &Settings, - shadow: &Arc, - darwinia: &Darwinia, - ethereum2darwinia: Option, - darwinia2ethereum: Option, - ethereum2darwinia_relayer: Option, - darwinia2ethereum_relayer: Option, - web3: &Web3, - (data_dir, spec_name, last_redeemed, last_tracked_darwinia_block): (PathBuf, String, u64, u32), -) -> Result<()> { - // extrinsic sender - let extrinsics_service = ExtrinsicsService::new( - ethereum2darwinia.clone(), - darwinia2ethereum.clone(), - ethereum2darwinia_relayer.clone(), - darwinia2ethereum_relayer.clone(), - spec_name.clone(), - data_dir.clone(), - ) - .start(); - - let (relay_service, redeem_service, ethereum_service, guard_service) = { - if let Some(ethereum2darwinia) = ðereum2darwinia { - // relay service - let last_confirmed = ethereum2darwinia.last_confirmed().await.unwrap(); - let relay_service = RelayService::new( - shadow.clone(), - ethereum2darwinia.clone(), - last_confirmed, - config.services.relay.step, - extrinsics_service.clone().recipient(), - ) - .start(); - - // redeem service - let redeem_service = RedeemService::new( - shadow.clone(), - ethereum2darwinia.clone(), - config.services.redeem.step, - extrinsics_service.clone().recipient(), - ) - .start(); - - // ethereum service - let ethereum_service = EthereumService::new( - config.clone(), - web3.clone(), - darwinia.clone(), - last_redeemed + 1, - relay_service.clone().recipient(), - redeem_service.clone().recipient(), - data_dir.clone(), - ) - .start(); - - // guard service - let guard_service = if let Some(relayer) = ðereum2darwinia_relayer { - let is_tech_comm_member = ethereum2darwinia - .is_tech_comm_member(Some(last_tracked_darwinia_block + 1), &relayer) - .await?; - GuardService::new( - shadow.clone(), - ethereum2darwinia.clone(), - relayer.clone(), - config.services.guard.step, - is_tech_comm_member, - extrinsics_service.clone().recipient(), - ) - .map(|g| g.start()) - } else { - None - }; - ( - Some(relay_service), - Some(redeem_service), - Some(ethereum_service), - guard_service, - ) - } else { - (None, None, None, None) - } - }; - - if let Some(darwinia2ethereum) = &darwinia2ethereum { - // darwinia subscribe service - let ethereum = Ethereum::new(web3.clone(), &config.clone())?; - let mut subscribe = SubscribeService::new( - darwinia2ethereum.clone(), - darwinia2ethereum_relayer.unwrap(), - ethereum, - extrinsics_service.clone().recipient(), - spec_name, - last_tracked_darwinia_block + 1, - data_dir.clone(), - ); - - if let Err(_e) = subscribe.start().await { - subscribe.stop(); - if let Some(ethereum_service) = ðereum_service { - ethereum_service.do_send(MsgStop {}); - } - if let Some(relay_service) = &relay_service { - relay_service.do_send(MsgStop {}); - } - if let Some(redeem_service) = &redeem_service { - redeem_service.do_send(MsgStop {}); - } - if let Some(guard_service) = &guard_service { - guard_service.do_send(MsgStop {}); - } - extrinsics_service.do_send(MsgStop {}); - anyhow::bail!("DarwiniaTracker broken!"); - } - } - Ok(()) -} diff --git a/provider/darwinia-bridger/src/cmd/set_darwinia_start.rs b/provider/darwinia-bridger/src/cmd/set_darwinia_start.rs deleted file mode 100644 index 6f99bccc0..000000000 --- a/provider/darwinia-bridger/src/cmd/set_darwinia_start.rs +++ /dev/null @@ -1,22 +0,0 @@ -use crate::error::Result; -use crate::tools; -use crate::Settings; -use std::path::PathBuf; - -/// set ethereum start -pub async fn exec(data_dir: Option, start: u64) -> Result<()> { - std::env::set_var("RUST_LOG", "info,darwinia_bridger"); - env_logger::init(); - - let data_dir = data_dir.unwrap_or(Settings::default_data_dir()?); - - tools::set_cache( - data_dir, - tools::LAST_TRACKED_DARWINIA_BLOCK_FILE_NAME, - start, - ) - .await?; - println!("OK"); - - Ok(()) -} diff --git a/provider/darwinia-bridger/src/cmd/set_start.rs b/provider/darwinia-bridger/src/cmd/set_start.rs deleted file mode 100644 index a9d3da957..000000000 --- a/provider/darwinia-bridger/src/cmd/set_start.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::error::Result; -use crate::{tools, Settings}; -use std::path::PathBuf; - -/// set ethereum start -pub async fn exec(data_dir: Option, start: u64) -> Result<()> { - std::env::set_var("RUST_LOG", "info,darwinia_bridger"); - env_logger::init(); - - let data_dir = data_dir.unwrap_or(Settings::default_data_dir()?); - tools::set_cache(data_dir, tools::LAST_REDEEMED_CACHE_FILE_NAME, start).await?; - println!("OK"); - - Ok(()) -} diff --git a/provider/darwinia-bridger/src/cmd/show_parcel.rs b/provider/darwinia-bridger/src/cmd/show_parcel.rs deleted file mode 100644 index cc8f864b8..000000000 --- a/provider/darwinia-bridger/src/cmd/show_parcel.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::{api::Shadow, error::Result, Settings}; -use std::sync::Arc; - -/// Affirm a faked affirmation -pub async fn exec(block: u64, json: bool) -> Result<()> { - std::env::set_var("RUST_LOG", "info,darwinia_bridger"); - env_logger::init(); - - // apis - let config = Settings::new(&Settings::default_data_dir()?)?; // TODO: add --data-dir - let shadow = Arc::new(Shadow::new(&config)); - - // Get parcel - let parcel = shadow.parcel(block as usize).await?; - - // print - if json { - println!("{}", serde_json::to_string(&parcel)?); - } else { - println!("{}", parcel); - } - - Ok(()) -} diff --git a/provider/darwinia-bridger/src/cmd/sign_mmr_root.rs b/provider/darwinia-bridger/src/cmd/sign_mmr_root.rs deleted file mode 100644 index ce80a2881..000000000 --- a/provider/darwinia-bridger/src/cmd/sign_mmr_root.rs +++ /dev/null @@ -1,27 +0,0 @@ -use crate::{api::darwinia_api, error::Result, Settings}; - -use rpassword::prompt_password_stdout; - -/// Sign darwinia mmr root, the current block must be larger then mmrblock -pub async fn exec(network: String, mmrblock: u64) -> Result<()> { - std::env::set_var("RUST_LOG", "info,darwinia_bridger"); - env_logger::init(); - - // apis - let mut config = Settings::new(&Settings::default_data_dir()?)?; - if config.encrypted { - let passwd = prompt_password_stdout("Please enter password:")?; - config.decrypt(&passwd)?; - } - let darwinia = darwinia_api::get_darwinia_instance(&config).await?; - let darwinia_account = darwinia_api::get_darwinia_account(&config); - let to_ethereum_account = darwinia_api::get_d2e_account(darwinia_account, &config); - let darwinia2ethereum = darwinia_api::get_d2e_instance(darwinia); - - let tx = darwinia2ethereum - .ecdsa_sign_and_submit_signed_mmr_root(&to_ethereum_account, network, mmrblock as u32) - .await?; - - println!("{}", tx); - Ok(()) -} diff --git a/provider/darwinia-bridger/src/config.rs b/provider/darwinia-bridger/src/config.rs deleted file mode 100644 index d7c9eae57..000000000 --- a/provider/darwinia-bridger/src/config.rs +++ /dev/null @@ -1,228 +0,0 @@ -//! Bridger Settings -use crate::encrypt_key; - -use super::crypto::{Crypto, EncryptPrivateKey}; -use crate::error::{BizError, Result}; -use config::{Config, File}; -use serde::{Deserialize, Serialize}; -use std::path::{Path, PathBuf}; - -// - Ethereum -------------------------------- -/// Ethereum Settings -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct EthereumSettings { - /// Ethereum rpc url - pub rpc: String, - /// Ethereum contracts - pub contract: EthereumContract, - /// Ethereum Relayer - pub relayer: Option, - /// Ethereum Authority - pub authority: Option, -} - -/// Ethereum Contract Tuple -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct EthereumContractTuple { - /// Contract Address - pub address: String, - /// Contract Topic - pub topics: Option>, -} - -/// Ethereum Contracts -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct EthereumContract { - /// Ring Contract - pub ring: EthereumContractTuple, - /// Kton Contract - pub kton: EthereumContractTuple, - /// Bank Contract - pub bank: EthereumContractTuple, - /// Issuing Contract - pub issuing: EthereumContractTuple, - /// Relay Contract - pub relay: EthereumContractTuple, - /// Backing Contract - pub backing: EthereumContractTuple, -} - -/// Ethereum Relayer -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct EthereumRelayer { - /// Private key - pub private_key: String, - /// ethereum.relayer's beneficiary account public key - pub beneficiary_darwinia_account: String, -} -encrypt_key!(EthereumRelayer); - -/// Ethereum Authority -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct EthereumAuthority { - /// Private key to sign ecdsa signature - pub private_key: String, -} -encrypt_key!(EthereumAuthority); - -// - Darwinia -------------------------------- -/// Darwinia Settings -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct DarwiniaSettings { - /// Darwinia rpc url - pub rpc: String, - /// Darwinia Relayer - pub relayer: DarwiniaRelayer, -} - -/// Darwinia Relayer -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct DarwiniaRelayer { - /// Private key - pub private_key: String, - /// Real Account public key - pub real_account: Option, -} -encrypt_key!(DarwiniaRelayer); - -// - Shadow -------------------------------- -/// Shadow Settings -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct ShadowSettings { - /// Shadow endpoint - pub endpoint: String, -} - -// - Services -------------------------------- -/// Services Settings -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct ServicesSettings { - /// Ethereum - pub ethereum: ServicesEthereum, - /// Relay - pub relay: ServicesRelay, - /// Redeem - pub redeem: ServicesRedeem, - /// Guard - pub guard: ServicesGuard, -} - -/// Services ethereum settings -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct ServicesEthereum { - /// step - pub step: u64, -} - -/// Services relay settings -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct ServicesRelay { - /// step - pub step: u64, -} - -/// Services redeem settings -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct ServicesRedeem { - /// step - pub step: u64, -} - -/// Services guard settings -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct ServicesGuard { - /// step - pub step: u64, -} - -/// Bridger Settings -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct Settings { - /// Encrypted - pub encrypted: bool, - - /// Ethereum Settings - pub ethereum: EthereumSettings, - - /// Darwinia Settings - pub darwinia: DarwiniaSettings, - - /// Shadow Settings - pub shadow: ShadowSettings, - - /// services - pub services: ServicesSettings, -} - -impl Settings { - /// New settings from pathbuf - pub fn new(data_dir: &Path) -> Result { - let mut config_file = data_dir.to_path_buf(); - config_file.push("config.yml"); - - let mut settings = Config::default(); - settings.merge(File::from(config_file))?; - Ok(settings.try_into()?) - } - - /// default_data_dir - pub fn default_data_dir() -> Result { - let mut dir = dirs::home_dir() - .ok_or_else(|| BizError::Bridger("Could not open home dir".to_string()))?; - dir.push(".bridger"); - - Ok(dir) - } - - /// encrypt configure file - pub fn encrypt(&mut self, passwd: &str) -> Result<()> { - if !self.encrypted { - let crypto = Crypto { salt: [0; 16] }; - if let Some(relayer) = &mut self.ethereum.relayer { - relayer.encrypt(&crypto, &passwd)?; - } - if let Some(authority) = &mut self.ethereum.authority { - authority.encrypt(&crypto, &passwd)?; - } - self.darwinia.relayer.encrypt(&crypto, &passwd)?; - self.encrypted = true; - } - Ok(()) - } - - /// decrypt configure file - pub fn decrypt(&mut self, passwd: &str) -> Result<()> { - if self.encrypted { - let crypto = Crypto { salt: [0; 16] }; - if let Some(relayer) = &mut self.ethereum.relayer { - relayer.decrypt(&crypto, &passwd)?; - } - if let Some(authority) = &mut self.ethereum.authority { - authority.decrypt(&crypto, &passwd)?; - } - self.darwinia.relayer.decrypt(&crypto, &passwd)?; - self.encrypted = false; - } - Ok(()) - } -} - -impl Default for Settings { - fn default() -> Self { - let config_file = PathBuf::from("../../.maintain/config/ropsten_pangolin.sample.yml"); - let mut settings = Config::default(); - settings.merge(File::from(config_file)).unwrap(); - settings.try_into().unwrap() - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - pub fn test_yaml_config() { - let settings = Settings::default(); - println!("{:?}", settings.ethereum); - } -} diff --git a/provider/darwinia-bridger/src/crypto.rs b/provider/darwinia-bridger/src/crypto.rs deleted file mode 100644 index cd86b088b..000000000 --- a/provider/darwinia-bridger/src/crypto.rs +++ /dev/null @@ -1,137 +0,0 @@ -use crate::error::{BizError, Result}; -use crypto::buffer::{BufferResult, ReadBuffer, WriteBuffer}; -use crypto::scrypt::scrypt; -use crypto::scrypt::ScryptParams; -use crypto::{aes, blockmodes, buffer}; - -pub trait EncryptPrivateKey { - fn encrypt(&mut self, crypto: &Crypto, passwd: &str) -> Result<()>; - fn decrypt(&mut self, crypto: &Crypto, passwd: &str) -> Result<()>; -} - -/// crypto for private key -pub struct Crypto { - /// salt - pub salt: [u8; 16], -} - -impl Crypto { - fn aes256_cbc_encrypt(&self, input: &[u8], key: &[u8], iv: &[u8]) -> Result> { - let mut encryptor = - aes::cbc_encryptor(aes::KeySize::KeySize256, key, iv, blockmodes::PkcsPadding); - - let mut encrypted = Vec::::new(); - let mut read_buffer = buffer::RefReadBuffer::new(input); - let mut buffer = [0; 4096]; - let mut write_buffer = buffer::RefWriteBuffer::new(&mut buffer); - - loop { - let result = encryptor.encrypt(&mut read_buffer, &mut write_buffer, true); - encrypted.extend( - write_buffer - .take_read_buffer() - .take_remaining() - .iter() - .copied(), - ); - - match result { - Err(_) => return Err(BizError::Bridger("Encryption failed".to_string()).into()), - Ok(BufferResult::BufferUnderflow) => break, - Ok(BufferResult::BufferOverflow) => {} - } - } - Ok(encrypted) - } - - fn aes256_cbc_decrypt(&self, input: &[u8], key: &[u8], iv: &[u8]) -> Result> { - let mut decryptor = - aes::cbc_decryptor(aes::KeySize::KeySize256, key, iv, blockmodes::PkcsPadding); - - let mut decrypted = Vec::::new(); - let mut read_buffer = buffer::RefReadBuffer::new(input); - let mut buffer = [0; 4096]; - let mut write_buffer = buffer::RefWriteBuffer::new(&mut buffer); - - loop { - let result = decryptor.decrypt(&mut read_buffer, &mut write_buffer, true); - decrypted.extend( - write_buffer - .take_read_buffer() - .take_remaining() - .iter() - .copied(), - ); - match result { - Err(e) => { - error!("[{:?}] please check your password", e); - return Err(BizError::Bridger("Decryption failed".to_string()).into()); - } - Ok(BufferResult::BufferUnderflow) => break, - Ok(BufferResult::BufferOverflow) => {} - } - } - - Ok(decrypted) - } - - fn generate_key(&self, passwd: &str) -> [u8; 48] { - //let salt = [0; 16]; - let mut output = [0; 48]; - scrypt( - &passwd.as_bytes(), - &self.salt, - &ScryptParams::new(10, 2, 3), - &mut output, - ); - output - } - - /// encrypt - pub fn encrypt(&self, passwd: &str, plain: &str) -> Result { - let private_key = self.generate_key(&passwd); - let key = &private_key[..32]; - let iv = &private_key[32..48]; - let encrypted = self.aes256_cbc_encrypt(plain.as_bytes(), &key, &iv)?; - Ok(base64::encode(encrypted.as_slice())) - } - - /// decrypt - pub fn decrypt(&self, passwd: &str, encrypted: &str) -> Result { - let private_key = self.generate_key(&passwd); - let key = &private_key[..32]; - let iv = &private_key[32..48]; - let encrypted_data = base64::decode(&encrypted)?; - let decrypted_data = self.aes256_cbc_decrypt(&encrypted_data[..], &key, &iv)?; - Ok(String::from_utf8(decrypted_data)?) - } -} - -/// impl Encrypt PrivateKey method encrypt and decrypt -#[macro_export] -macro_rules! encrypt_key { - ($name: ident) => { - impl EncryptPrivateKey for $name { - fn encrypt(&mut self, crypto: &Crypto, passwd: &str) -> Result<()> { - self.private_key = crypto.encrypt(&passwd, &self.private_key)?; - Ok(()) - } - fn decrypt(&mut self, crypto: &Crypto, passwd: &str) -> Result<()> { - self.private_key = crypto.decrypt(&passwd, &self.private_key)?; - Ok(()) - } - } - }; -} - -#[test] -fn test_encrypt() { - let crypto = Crypto { salt: [1; 16] }; - let plain = "Hello World!"; - let passwd = "123456"; - let encrypted = crypto.encrypt(&passwd, plain).unwrap(); - println!("{}", encrypted); - let decrypted = crypto.decrypt(&passwd, &encrypted).unwrap(); - println!("{}", decrypted); - assert_eq!(decrypted, plain); -} diff --git a/provider/darwinia-bridger/src/error.rs b/provider/darwinia-bridger/src/error.rs deleted file mode 100644 index 96c6efa99..000000000 --- a/provider/darwinia-bridger/src/error.rs +++ /dev/null @@ -1,69 +0,0 @@ -#![allow(missing_docs)] -//! Bridger Result -use crate::service::redeem::EthereumTransactionHash; -use thiserror::Error as ThisError; - -#[derive(ThisError, Debug)] -pub enum Error { - #[error("The last redeemed block number is not set")] - LastRedeemedFileNotExists, - - #[error("No ethereum start, run 'bridger set-start --block [--data-dir ]' to set one")] - NoEthereumStart, - - #[error("No darwinia scan start, run 'bridger set-darwinia-start --block [--data-dir ]' to set one")] - NoDarwiniaStart, - - #[error("No signer seed set for authority, please check your config.toml")] - NoAuthoritySignerSeed, - - #[error("RuntimeUpdated")] - RuntimeUpdated, - - #[error("ShadowInternalServerError: {0}")] - ShadowInternalServerError(String), - - #[error("`bytes2hex` - FAILED: {0}")] - Bytes2Hex(String), - - #[error("`hex2bytes` - FAILED: {0}")] - Hex2Bytes(String), - - #[error("New http with URI {0} error: {1}")] - NewHttpError(String, String), - - #[error("Restart from jsonrpsee")] - RestartFromJsonrpsee, -} - -#[derive(ThisError, Debug)] -pub enum BizError { - #[error("{0}")] - Bridger(String), - - #[error("Heartbeat>>> Scanning ethereum too fast from {0}, the latest block number is {1}")] - ScanningEthereumTooFast(u64, u64), - - #[error("The affirming target block {0} is less than the last_confirmed {1}")] - AffirmingBlockLessThanLastConfirmed(u64, u64), - - #[error("The affirming target block {0} is in pending")] - AffirmingBlockInPending(u64), - - #[error("The affirming target block {0} is in the relayer game")] - AffirmingBlockInGame(u64), - - #[error("Shadow service failed to provide parcel for block {0}")] - ParcelFromShadowIsEmpty(u64), - - #[error("{0:?}'s block {1} is large than last confirmed block {2}")] - RedeemingBlockLargeThanLastConfirmed(EthereumTransactionHash, u64, u64), - - #[error("{0:?} has already been redeemed")] - TxRedeemed(EthereumTransactionHash), - - #[error("Mmr root for ethereum block {0} may be not filled yet, the error from shadow: {1}")] - BlankEthereumMmrRoot(usize, String), -} - -pub type Result = anyhow::Result; diff --git a/provider/darwinia-bridger/src/lib.rs b/provider/darwinia-bridger/src/lib.rs deleted file mode 100644 index 210085a2c..000000000 --- a/provider/darwinia-bridger/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! Darwinia bridger -#![warn(missing_docs)] - -#[macro_use] -extern crate log; - -mod config; -mod crypto; - -pub mod api; -pub mod cmd; -pub mod error; -pub mod service; -pub mod tools; - -pub use self::config::Settings; -pub use self::crypto::Crypto; diff --git a/provider/darwinia-bridger/src/service/ethereum.rs b/provider/darwinia-bridger/src/service/ethereum.rs deleted file mode 100644 index ed9203f37..000000000 --- a/provider/darwinia-bridger/src/service/ethereum.rs +++ /dev/null @@ -1,371 +0,0 @@ -//! Ethereum transaction service -use crate::{ - error::{BizError, Result as BridgerResult}, - service::{ - redeem::{EthereumTransaction, EthereumTransactionHash, MsgEthereumTransaction}, - relay::MsgBlockNumber, - MsgStop, - }, - tools, Settings, -}; -use primitives::bytes; - -use actix::prelude::*; -use std::path::PathBuf; -use std::time::Duration; -use web3::{ - transports::http::Http, - types::{BlockNumber, FilterBuilder, SyncState, H160, H256, U64}, - Web3, -}; - -use darwinia::Darwinia; - -#[derive(Clone, Debug)] -struct MsgScan; - -impl Message for MsgScan { - type Result = (); -} - -/// Darwinia contract addresses -#[derive(Clone, Debug)] -pub struct ContractAddress { - /// r - pub ring: H256, - /// k - pub kton: H256, - /// b - #[allow(dead_code)] - pub bank: H256, - /// relay - pub relay: H256, - /// register - pub register: H256, - /// lock token on ethereum and redeem from darwinia - pub lock: H256, -} - -/// Ethereum transaction service -/// -/// This service can check and scan darwinia txs in Ethereum -pub struct EthereumService { - contracts: ContractAddress, - filters: [FilterBuilder; 4], - web3: Web3, - darwinia: Darwinia, - scan_from: u64, - step: u64, - - relay_service: Recipient, - redeem_service: Recipient, - data_dir: PathBuf, -} - -impl Actor for EthereumService { - type Context = Context; - - fn started(&mut self, ctx: &mut Self::Context) { - info!(" ✨ SERVICE STARTED: ETHEREUM"); - ctx.run_interval(Duration::from_millis(self.step * 1_000), |_this, ctx| { - ctx.notify(MsgScan {}); - }); - } - - fn stopped(&mut self, _: &mut Self::Context) { - info!(" 💤 SERVICE STOPPED: ETHEREUM") - } -} - -impl Handler for EthereumService { - type Result = AtomicResponse; - - fn handle(&mut self, _msg: MsgScan, _: &mut Context) -> Self::Result { - AtomicResponse::new(Box::pin( - async {} - .into_actor(self) - .then(move |_, this, _| { - let f = EthereumService::scan( - this.darwinia.clone(), - this.web3.clone(), - this.contracts.clone(), - this.filters.clone(), - this.scan_from, - this.relay_service.clone(), - this.redeem_service.clone(), - this.data_dir.clone(), - ); - f.into_actor(this) - }) - .map(|r, this, _| match r { - Ok(latest_block_number) => this.scan_from = latest_block_number, - Err(err) => { - if let Some(e) = err.downcast_ref::() { - trace!("{}", e); - } else { - error!("{:?}", err); - } - } - }), - )) - } -} - -impl Handler for EthereumService { - type Result = (); - - fn handle(&mut self, _: MsgStop, ctx: &mut Context) -> Self::Result { - ctx.stop(); - } -} - -impl EthereumService { - /// New Ethereum Service with http - pub fn new( - config: Settings, - web3: Web3, - darwinia: Darwinia, - scan_from: u64, - relay_service: Recipient, - redeem_service: Recipient, - data_dir: PathBuf, - ) -> EthereumService { - let step = config.services.ethereum.step; - let contracts = EthereumService::parse_contract(&config); - let filters = EthereumService::parse_filter(&config); - EthereumService { - contracts, - filters, - web3, - darwinia, - scan_from, - step, - relay_service, - redeem_service, - data_dir, - } - } - - /// Scan ethereum transactions - async fn do_scan( - web3: Web3, - contracts: ContractAddress, - filters: [FilterBuilder; 4], - from: u64, - to: u64, - ) -> BridgerResult> { - let mut txs = vec![]; - let eth = web3.eth(); - for f in filters.iter() { - let logs = match eth - .logs( - f.clone() - .from_block(BlockNumber::Number(U64::from(from))) - .to_block(BlockNumber::Number(U64::from(to))) - .build(), - ) - .await - { - Ok(logs) => logs, - Err(e) => { - error!("Failed to get logs, due to `{}`", e); - - continue; - } - }; - - txs.append( - &mut logs - .iter() - .map(|l| { - let block = l.block_number.unwrap_or_default().low_u64(); - let index = l.transaction_index.unwrap_or_default().low_u64(); - if l.topics.contains(&contracts.ring) || l.topics.contains(&contracts.kton) - { - EthereumTransaction { - tx_hash: EthereumTransactionHash::Token( - l.transaction_hash.unwrap_or_default(), - ), - block_hash: l.block_hash.unwrap_or_default(), - block, - index, - } - } else if l.topics.contains(&contracts.relay) { - EthereumTransaction { - tx_hash: EthereumTransactionHash::SetAuthorities( - l.transaction_hash.unwrap_or_default(), - ), - block_hash: l.block_hash.unwrap_or_default(), - block, - index, - } - } else if l.topics.contains(&contracts.register) { - EthereumTransaction { - tx_hash: EthereumTransactionHash::RegisterErc20Token( - l.transaction_hash.unwrap_or_default(), - ), - block_hash: l.block_hash.unwrap_or_default(), - block, - index, - } - } else if l.topics.contains(&contracts.lock) { - EthereumTransaction { - tx_hash: EthereumTransactionHash::RedeemErc20Token( - l.transaction_hash.unwrap_or_default(), - ), - block_hash: l.block_hash.unwrap_or_default(), - block, - index, - } - } else { - EthereumTransaction { - tx_hash: EthereumTransactionHash::Deposit( - l.transaction_hash.unwrap_or_default(), - ), - block_hash: l.block_hash.unwrap_or_default(), - block, - index, - } - } - }) - .collect::>(), - ); - } - Ok(txs) - } - - #[allow(clippy::too_many_arguments)] - async fn scan( - darwinia: Darwinia, - web3: Web3, - contracts: ContractAddress, - filters: [FilterBuilder; 4], - scan_from: u64, - relay_service: Recipient, - redeem_service: Recipient, - data_dir: PathBuf, - ) -> BridgerResult { - let latest_block_number = EthereumService::get_latest_block_number(&web3).await?; - - // 1. Checking start from a right block number - if scan_from >= latest_block_number { - return Err(BizError::ScanningEthereumTooFast(scan_from, latest_block_number).into()); - } - - trace!( - "Heartbeat>>> Scanning on ethereum for new cross-chain transactions from {} to {} ...", - scan_from, - latest_block_number - ); - - // 2. Scan tx from ethereum - let txs = - EthereumService::do_scan(web3, contracts, filters, scan_from, latest_block_number) - .await?; - if !txs.is_empty() { - info!( - "Found {} txs from {} to {}", - txs.len(), - scan_from, - latest_block_number - ); - for tx in &txs { - trace!(" {:?}", &tx.tx_hash); - - if let Err(e) = relay_service.send(MsgBlockNumber(tx.block)).await { - error!("Send block number to relay service fail: {:?}", e); - } - } - - for tx in &txs { - if darwinia.verified(tx.block_hash, tx.index).await? - || darwinia.verified_issuing(tx.block_hash, tx.index).await? - { - trace!( - " This ethereum tx {:?} has already been redeemed.", - tx.enclosed_hash() - ); - tools::set_cache( - data_dir.clone(), - tools::LAST_REDEEMED_CACHE_FILE_NAME, - tx.block, - ) - .await?; - } else { - // delay to wait for possible previous extrinsics - tokio::time::delay_for(Duration::from_secs(12)).await; - if let Err(e) = redeem_service - .send(MsgEthereumTransaction { tx: tx.clone() }) - .await - { - error!("Send tx to redeem service fail: {:?}", e); - } - } - } - } - - Ok(latest_block_number) - } - - /// Parse contract addresses - pub fn parse_contract(config: &Settings) -> ContractAddress { - let contract = &config.ethereum.contract; - let bank_topics = contract.bank.topics.clone().unwrap(); - let ring_topics = contract.ring.topics.clone().unwrap(); - let kton_topics = contract.kton.topics.clone().unwrap(); - let relay_topics = contract.relay.topics.clone().unwrap(); - let backing_topics = contract.backing.topics.clone().unwrap(); - ContractAddress { - bank: H256::from_slice(&bytes!(bank_topics[0].as_str())), - kton: H256::from_slice(&bytes!(kton_topics[0].as_str())), - ring: H256::from_slice(&bytes!(ring_topics[0].as_str())), - relay: H256::from_slice(&bytes!(relay_topics[0].as_str())), - register: H256::from_slice(&bytes!(backing_topics[0].as_str())), - lock: H256::from_slice(&bytes!(backing_topics[1].as_str())), - } - } - - /// Parse log filter from config - pub fn parse_filter(config: &Settings) -> [FilterBuilder; 4] { - let filters = [ - &config.ethereum.contract.bank, - &config.ethereum.contract.issuing, - &config.ethereum.contract.backing, - &config.ethereum.contract.relay, - ] - .iter() - .map(|c| { - let topics = if let Some(topics) = c.topics.clone() { - topics - .iter() - .map(|t| H256::from_slice(&bytes!(t.as_str()))) - .collect() - } else { - vec![] - }; - FilterBuilder::default() - .address(vec![H160::from_slice(&bytes!(c.address.as_str()))]) - .topics(Some(topics), None, None, None) - }) - .collect::>(); - [ - filters[0].clone(), - filters[1].clone(), - filters[2].clone(), - filters[3].clone(), - ] - } - - /// get_latest_block_number - pub async fn get_latest_block_number(web3: &Web3) -> BridgerResult { - let eth = web3.eth(); - let sync_state = eth.syncing().await?; - - let latest_block_number = match sync_state { - // TOOD: what the difference between eth_blockNumber and eth_getBlockByNumber("latest", false) - SyncState::NotSyncing => eth.block_number().await?.as_u64(), - SyncState::Syncing(info) => info.current_block.as_u64(), - }; - Ok(latest_block_number) - } -} diff --git a/provider/darwinia-bridger/src/service/extrinsics.rs b/provider/darwinia-bridger/src/service/extrinsics.rs deleted file mode 100644 index 618960100..000000000 --- a/provider/darwinia-bridger/src/service/extrinsics.rs +++ /dev/null @@ -1,355 +0,0 @@ -//! Extrinsics Service -#![allow(missing_docs)] -use std::time::Duration; - -use actix::prelude::*; - -use crate::error::Result; -use crate::service::redeem::EthereumTransaction; -use crate::service::MsgStop; -use crate::tools; -use primitives::chain::ethereum::{ - EthereumReceiptProofThing, EthereumRelayHeaderParcel, RedeemFor, -}; -use primitives::runtime::EcdsaMessage; -use std::path::PathBuf; - -use darwinia::{Darwinia2Ethereum, Ethereum2Darwinia, FromEthereumAccount, ToEthereumAccount}; - -#[derive(Clone, Debug)] -pub enum Extrinsic { - Affirm(EthereumRelayHeaderParcel), - Redeem(RedeemFor, EthereumReceiptProofThing, EthereumTransaction), - GuardVote(u64, bool), - SignAndSendMmrRoot(u32), - SignAndSendAuthorities(EcdsaMessage), -} - -/// MsgSign -#[derive(Clone, Debug)] -pub struct MsgExtrinsic(pub Extrinsic); - -impl Message for MsgExtrinsic { - type Result = Result<()>; -} - -/// Extrinsics Service -pub struct ExtrinsicsService { - /// Ethereum to Darwinia Client - pub ethereum2darwinia: Option, - /// Dawrinia to Ethereum Client - pub darwinia2ethereum: Option, - /// ethereum2darwinia relayer - pub ethereum2darwinia_relayer: Option, - /// darwinia2ethereum relayer - pub darwinia2ethereum_relayer: Option, - - spec_name: String, - data_dir: PathBuf, -} - -impl Actor for ExtrinsicsService { - type Context = Context; - - fn started(&mut self, _: &mut Self::Context) { - info!("✨ SERVICE STARTED: EX SENDER QUEUE"); - } - - fn stopped(&mut self, _: &mut Self::Context) { - info!("💤 SERVICE STOPPED: EX SENDER QUEUE") - } -} - -impl Handler for ExtrinsicsService { - type Result = AtomicResponse>; - - fn handle(&mut self, msg: MsgExtrinsic, _: &mut Context) -> Self::Result { - let f = ExtrinsicsService::send_extrinsic( - self.ethereum2darwinia.clone(), - self.darwinia2ethereum.clone(), - self.ethereum2darwinia_relayer.clone(), - self.darwinia2ethereum_relayer.clone(), - msg.0, - self.spec_name.clone(), - self.data_dir.clone(), - ) - .into_actor(self); - - AtomicResponse::new(Box::pin(f)) - } -} - -impl Handler for ExtrinsicsService { - type Result = (); - - fn handle(&mut self, _: MsgStop, ctx: &mut Context) -> Self::Result { - ctx.stop(); - } -} - -impl ExtrinsicsService { - /// New sign service - pub fn new( - ethereum2darwinia: Option, - darwinia2ethereum: Option, - ethereum2darwinia_relayer: Option, - darwinia2ethereum_relayer: Option, - spec_name: String, - data_dir: PathBuf, - ) -> ExtrinsicsService { - ExtrinsicsService { - ethereum2darwinia, - darwinia2ethereum, - ethereum2darwinia_relayer, - darwinia2ethereum_relayer, - spec_name, - data_dir, - } - } - - #[allow(clippy::too_many_arguments)] - async fn send_extrinsic( - ethereum2darwinia: Option, - darwinia2ethereum: Option, - ethereum2darwinia_relayer: Option, - darwinia2ethereum_relayer: Option, - extrinsic: Extrinsic, - spec_name: String, - data_dir: PathBuf, - ) -> Result<()> { - match extrinsic { - Extrinsic::Affirm(parcel) => { - let block_number = parcel.header.number; - if let Some(ethereum2darwinia) = ðereum2darwinia { - if let Some(relayer) = ðereum2darwinia_relayer { - let ex_hash = ethereum2darwinia.affirm(&relayer, parcel).await?; - info!( - "Affirmed ethereum block {} in extrinsic {:?}", - block_number, ex_hash - ); - } else { - info!("cannot affirm without relayer account"); - } - } - } - - Extrinsic::Redeem(redeem_for, proof, ethereum_tx) => { - match redeem_for { - RedeemFor::SetAuthorities => { - if let Some(darwinia2ethereum) = &darwinia2ethereum { - if let Some(relayer) = &darwinia2ethereum_relayer { - let ex_hash = darwinia2ethereum - .sync_authorities_change(&relayer, proof) - .await?; - info!( - "Sent ethereum tx {:?} with extrinsic {:?}", - ethereum_tx.tx_hash, ex_hash - ); - } else { - info!("cannot sync authorities changed without relayer account"); - } - } - } - RedeemFor::RegisterErc20Token => { - if let Some(ethereum2darwinia) = ðereum2darwinia { - if let Some(relayer) = ðereum2darwinia_relayer { - let ex_hash = - ethereum2darwinia.register_erc20(&relayer, proof).await?; - info!( - "register erc20 token tx {:?} with extrinsic {:?}", - ethereum_tx.tx_hash, ex_hash - ); - } - } - } - RedeemFor::RedeemErc20Token => { - if let Some(ethereum2darwinia) = ðereum2darwinia { - if let Some(relayer) = ðereum2darwinia_relayer { - let ex_hash = - ethereum2darwinia.redeem_erc20(&relayer, proof).await?; - info!( - "redeem erc20 token tx {:?} with extrinsic {:?}", - ethereum_tx.tx_hash, ex_hash - ); - } - } - } - _ => { - if let Some(ethereum2darwinia) = ðereum2darwinia { - if let Some(relayer) = ðereum2darwinia_relayer { - let ex_hash = ethereum2darwinia - .redeem(&relayer, redeem_for, proof) - .await?; - info!( - "Redeemed ethereum tx {:?} with extrinsic {:?}", - ethereum_tx.tx_hash, ex_hash - ); - } - } - } - } - - // Update cache - tools::set_cache( - data_dir, - tools::LAST_REDEEMED_CACHE_FILE_NAME, - ethereum_tx.block, - ) - .await?; - } - - Extrinsic::GuardVote(pending_block_number, aye) => { - if let Some(ethereum2darwinia) = ðereum2darwinia { - if let Some(guard) = ðereum2darwinia_relayer { - let ex_hash = ethereum2darwinia - .vote_pending_relay_header_parcel(&guard, pending_block_number, aye) - .await?; - if aye { - info!( - "Voted to approve: {}, ex hash: {:?}", - pending_block_number, ex_hash - ); - } else { - info!( - "Voted to reject: {}, ex hash: {:?}", - pending_block_number, ex_hash - ); - } - } - } - } - - Extrinsic::SignAndSendMmrRoot(block_number) => { - if let Some(darwinia2ethereum) = &darwinia2ethereum { - trace!("Start sign and send mmr_root..."); - if let Some(relayer) = &darwinia2ethereum_relayer { - let ex_hash = darwinia2ethereum - .ecdsa_sign_and_submit_signed_mmr_root( - &relayer, - spec_name, - block_number, - ) - .await?; - info!( - "Sign and send mmr root of block {} in extrinsic {:?}", - block_number, ex_hash - ); - } - } - } - - Extrinsic::SignAndSendAuthorities(message) => { - trace!("Start sign and send authorities..."); - if let Some(darwinia2ethereum) = &darwinia2ethereum { - if let Some(relayer) = &darwinia2ethereum_relayer { - let ex_hash = darwinia2ethereum - .ecdsa_sign_and_submit_signed_authorities(&relayer, message) - .await?; - info!("Sign and send authorities in extrinsic {:?}", ex_hash); - } - } - } - } - - // Delay for waiting to fininsh - tokio::time::delay_for(Duration::from_secs(12)).await; - - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use crate::error::Result; - use actix::prelude::*; - use std::time::Duration; - - #[derive(Clone, Copy)] - struct MyMsg(usize); - impl Message for MyMsg { - type Result = Result; - } - - struct MyActor; - - impl Actor for MyActor { - type Context = Context; - } - - impl Handler for MyActor { - type Result = AtomicResponse>; - - fn handle(&mut self, msg: MyMsg, _: &mut Self::Context) -> Self::Result { - AtomicResponse::new(Box::pin( - async {} - .into_actor(self) - .then(move |_, this, _| { - println!("msg {} processing", msg.0); - if msg.0 == 888 { - println!("sleep 5 seconds for {}", msg.0); - tokio::time::delay_for(Duration::from_secs(5)).into_actor(this) - } else { - println!("passing {}", msg.0); - tokio::time::delay_for(Duration::from_millis(1)).into_actor(this) - } - }) - .map(move |_, _, _| { - println!("at the end of processing {} -----------", msg.0); - if msg.0 == 666 { - Err(anyhow::anyhow!("error")) - } else { - Ok(msg.0) - } - }), - )) - } - } - - #[actix_rt::test] - async fn test_work() { - let my_actor = MyActor.start(); - if let Ok(r) = my_actor.send(MyMsg(12)).await { - if let Ok(r2) = r { - assert_eq!(r2, 12); - } - } - } - - #[actix_rt::test] - async fn test_error() { - let my_actor = MyActor.start(); - if let Ok(r) = my_actor.send(MyMsg(666)).await { - if let Err(e) = r { - assert_eq!(e.to_string(), "error".to_string()); - } - } - } - - #[actix_rt::test] - async fn test_sending_msgs_in_two_different_coroutines() { - let my_actor = MyActor.start(); - let my_actor_clone = my_actor.clone(); - tokio::spawn(async move { - let msg_id = 888; - if let Ok(r) = my_actor_clone.send(MyMsg(msg_id)).await { - println!("msg {} sent", msg_id); - if let Ok(r2) = r { - assert_eq!(r2, msg_id); - println!("msg {} processed", msg_id); - } - } - }); - tokio::spawn(async move { - let msg_id = 12; - if let Ok(r) = my_actor.send(MyMsg(msg_id)).await { - println!("msg {} sent", msg_id); - if let Ok(r2) = r { - assert_eq!(r2, msg_id); - println!("msg {} processed", msg_id); - } - } - }); - tokio::time::delay_for(Duration::from_secs(10)).await; - println!("finished") - } -} diff --git a/provider/darwinia-bridger/src/service/guard.rs b/provider/darwinia-bridger/src/service/guard.rs deleted file mode 100644 index ea37ccd57..000000000 --- a/provider/darwinia-bridger/src/service/guard.rs +++ /dev/null @@ -1,154 +0,0 @@ -//! Guard Service -use actix::prelude::*; -use std::{sync::Arc, time::Duration}; - -use crate::service::extrinsics::{Extrinsic, MsgExtrinsic}; -use crate::service::MsgStop; -use crate::{ - api::Shadow, - error::{BizError, Result}, -}; - -use crate::tools; -use darwinia::{Ethereum2Darwinia, FromEthereumAccount}; - -#[derive(Clone, Debug)] -struct MsgGuard; - -impl Message for MsgGuard { - type Result = (); -} - -/// Redeem Service -pub struct GuardService { - step: u64, - /// Shadow API - pub shadow: Arc, - /// Ethereum to Dawrinia API - pub ethereum2darwinia: Ethereum2Darwinia, - /// Darwinia guard account - pub guard_account: FromEthereumAccount, - extrinsics_service: Recipient, -} - -impl Actor for GuardService { - type Context = Context; - - fn started(&mut self, ctx: &mut Self::Context) { - info!(" ✨ SERVICE STARTED: GUARD"); - ctx.run_interval(Duration::from_millis(self.step * 1_000), |_this, ctx| { - ctx.notify(MsgGuard {}); - }); - } - - fn stopped(&mut self, _: &mut Self::Context) { - info!(" 💤 SERVICE STOPPED: GUARD") - } -} - -impl Handler for GuardService { - type Result = AtomicResponse; - - fn handle(&mut self, _msg: MsgGuard, _: &mut Context) -> Self::Result { - AtomicResponse::new(Box::pin( - async {} - .into_actor(self) - .then(|_, this, _| { - let f = GuardService::guard( - this.ethereum2darwinia.clone(), - this.guard_account.clone(), - this.shadow.clone(), - this.extrinsics_service.clone(), - ); - f.into_actor(this) - }) - .map(|r, _this, _| { - if let Err(err) = r { - if err.downcast_ref::().is_some() { - trace!("{}", err); - } else { - error!("{:?}", err); - } - } - }), - )) - } -} - -impl Handler for GuardService { - type Result = (); - - fn handle(&mut self, _: MsgStop, ctx: &mut Context) -> Self::Result { - ctx.stop(); - } -} - -impl GuardService { - /// New redeem service - pub fn new( - shadow: Arc, - ethereum2darwinia: Ethereum2Darwinia, - guard_account: FromEthereumAccount, - step: u64, - is_tech_comm_member: bool, - extrinsics_service: Recipient, - ) -> Option { - if is_tech_comm_member { - Some(GuardService { - step, - shadow, - ethereum2darwinia, - guard_account, - extrinsics_service, - }) - } else { - warn!(" 🔒 GUARD SERVICE NOT STARTED, YOU ARE NOT TECH COMM MEMBER"); - None - } - } - - async fn guard( - ethereum2darwinia: Ethereum2Darwinia, - guard_account: FromEthereumAccount, - shadow: Arc, - extrinsics_service: Recipient, - ) -> Result<()> { - trace!("Checking pending headers..."); - - let last_confirmed = ethereum2darwinia.last_confirmed().await.unwrap(); - let pending_headers = ethereum2darwinia.pending_headers().await?; - if !pending_headers.is_empty() { - trace!( - "pending headers: {:?}", - pending_headers - .clone() - .iter() - .map(|p| p.1.header.number.to_string()) - .collect::>() - .join(", ") - ); - } - for pending in pending_headers { - let pending_parcel = pending.1; - let voting_state = pending.2; - let pending_block_number: u64 = pending_parcel.header.number; - - // high than last_confirmed(https://github.com/darwinia-network/bridger/issues/33), - // and, - // have not voted - if pending_block_number > last_confirmed - && !ethereum2darwinia.has_voted(&guard_account, voting_state) - { - let parcel_from_shadow = shadow.parcel(pending_block_number as usize).await?; - let ex = if pending_parcel.is_same_as(&parcel_from_shadow) { - Extrinsic::GuardVote(pending_block_number, true) - } else { - Extrinsic::GuardVote(pending_block_number, false) - }; - tools::send_extrinsic(&extrinsics_service, ex).await; - } - } - - Ok(()) - } -} diff --git a/provider/darwinia-bridger/src/service/mod.rs b/provider/darwinia-bridger/src/service/mod.rs deleted file mode 100644 index 2160a0aa8..000000000 --- a/provider/darwinia-bridger/src/service/mod.rs +++ /dev/null @@ -1,23 +0,0 @@ -//! Bridger Services -pub use crate::error::Result; - -pub mod ethereum; -pub mod extrinsics; -pub mod guard; -pub mod redeem; -pub mod relay; -pub mod subscribe; - -pub use self::{ - ethereum::EthereumService, extrinsics::ExtrinsicsService, guard::GuardService, - redeem::RedeemService, relay::RelayService, subscribe::SubscribeService, -}; -use actix::Message; - -/// Msg to stop service -#[derive(Clone, Debug)] -pub struct MsgStop; - -impl Message for MsgStop { - type Result = (); -} diff --git a/provider/darwinia-bridger/src/service/redeem.rs b/provider/darwinia-bridger/src/service/redeem.rs deleted file mode 100644 index 0760a7b46..000000000 --- a/provider/darwinia-bridger/src/service/redeem.rs +++ /dev/null @@ -1,207 +0,0 @@ -//! Redeem Service -use crate::{api::Shadow, error::Result}; -use actix::prelude::*; -use primitives::chain::ethereum::RedeemFor; -use std::{sync::Arc, time::Duration}; - -use crate::error::BizError; -use crate::service::extrinsics::{Extrinsic, MsgExtrinsic}; -use crate::service::MsgStop; -use std::cmp::{Ord, Ordering, PartialOrd}; -use web3::types::H256; - -use crate::tools; -use darwinia::Ethereum2Darwinia; - -/// Ethereum transaction event with hash -#[derive(PartialEq, Eq, Debug, Clone)] -pub enum EthereumTransactionHash { - /// Deposit event - Deposit(H256), - /// Token event - Token(H256), - /// SetAuthoritiesEvent - SetAuthorities(H256), - /// RegisterErc20Token - RegisterErc20Token(H256), - /// RedeemErc20Token - RedeemErc20Token(H256), -} - -/// Reedeemable Ethereum transaction -#[derive(PartialEq, Eq, Clone, Debug)] -pub struct EthereumTransaction { - /// Transaction hash for the event - pub tx_hash: EthereumTransactionHash, - /// Block Hash for the event - pub block_hash: H256, - /// Transaction block - pub block: u64, - /// Transaction index - pub index: u64, -} - -impl EthereumTransaction { - /// Get the hash - pub fn enclosed_hash(&self) -> H256 { - match self.tx_hash { - EthereumTransactionHash::Token(h) => h, - EthereumTransactionHash::Deposit(h) => h, - EthereumTransactionHash::SetAuthorities(h) => h, - EthereumTransactionHash::RegisterErc20Token(h) => h, - EthereumTransactionHash::RedeemErc20Token(h) => h, - } - } -} - -impl PartialOrd for EthereumTransaction { - fn partial_cmp(&self, o: &Self) -> Option { - self.block.partial_cmp(&o.block) - } -} - -impl Ord for EthereumTransaction { - fn cmp(&self, o: &Self) -> Ordering { - self.block.cmp(&o.block) - } -} - -/// message 'EthereumTransaction' -#[derive(Clone, Debug)] -pub struct MsgEthereumTransaction { - /// Transaction hash for the event - pub tx: EthereumTransaction, -} - -impl Message for MsgEthereumTransaction { - type Result = (); -} - -/// Redeem Service -pub struct RedeemService { - step: u64, - /// Shadow API - pub shadow: Arc, - /// Dawrinia API - pub ethereum2darwinia: Ethereum2Darwinia, - - extrinsics_service: Recipient, -} - -impl Actor for RedeemService { - type Context = Context; - - fn started(&mut self, _ctx: &mut Self::Context) { - info!(" ✨ SERVICE STARTED: REDEEM"); - } - - fn stopped(&mut self, _: &mut Self::Context) { - info!(" 💤 SERVICE STOPPED: REDEEM") - } -} - -impl Handler for RedeemService { - type Result = AtomicResponse; - - fn handle(&mut self, msg: MsgEthereumTransaction, _: &mut Context) -> Self::Result { - let msg_clone = msg.clone(); - AtomicResponse::new(Box::pin( - async {} - .into_actor(self) - .then(move |_, this, _| { - let f = RedeemService::redeem( - this.ethereum2darwinia.clone(), - this.shadow.clone(), - msg_clone.tx, - this.extrinsics_service.clone(), - ); - f.into_actor(this) - }) - .map(|r, this, ctx| { - if let Err(err) = r { - if let Some(e) = err.downcast_ref::() { - match e { - BizError::RedeemingBlockLargeThanLastConfirmed(..) => { - trace!("{}, please wait!", err); - ctx.notify_later(msg, Duration::from_millis(this.step * 1000)); - } - _ => trace!("{}", err), - } - } else { - error!("{:?}", err); - } - } - }), - )) - } -} - -impl Handler for RedeemService { - type Result = (); - - fn handle(&mut self, _: MsgStop, ctx: &mut Context) -> Self::Result { - ctx.stop(); - } -} - -impl RedeemService { - /// New redeem service - pub fn new( - shadow: Arc, - ethereum2darwinia: Ethereum2Darwinia, - step: u64, - extrinsics_service: Recipient, - ) -> RedeemService { - RedeemService { - step, - shadow, - ethereum2darwinia, - extrinsics_service, - } - } - - async fn redeem( - ethereum2darwinia: Ethereum2Darwinia, - shadow: Arc, - tx: EthereumTransaction, - extrinsics_service: Recipient, - ) -> Result<()> { - trace!("Try to redeem ethereum tx {:?}...", tx.tx_hash); - - // 1. Checking before redeem - if ethereum2darwinia - .darwinia - .verified(tx.block_hash, tx.index) - .await? - { - return Err(BizError::TxRedeemed(tx.tx_hash).into()); - } - - let last_confirmed = ethereum2darwinia.last_confirmed().await?; - if tx.block >= last_confirmed { - return Err(BizError::RedeemingBlockLargeThanLastConfirmed( - tx.tx_hash, - tx.block, - last_confirmed, - ) - .into()); - } - - // 2. Do redeem - let proof = shadow - .receipt(&format!("{:?}", tx.enclosed_hash()), last_confirmed) - .await?; - let redeem_for = match tx.tx_hash { - EthereumTransactionHash::Deposit(_) => RedeemFor::Deposit, - EthereumTransactionHash::Token(_) => RedeemFor::Token, - EthereumTransactionHash::SetAuthorities(_) => RedeemFor::SetAuthorities, - EthereumTransactionHash::RegisterErc20Token(_) => RedeemFor::RegisterErc20Token, - EthereumTransactionHash::RedeemErc20Token(_) => RedeemFor::RedeemErc20Token, - }; - - let ex = Extrinsic::Redeem(redeem_for, proof, tx); - tools::send_extrinsic(&extrinsics_service, ex).await; - - Ok(()) - } -} diff --git a/provider/darwinia-bridger/src/service/relay.rs b/provider/darwinia-bridger/src/service/relay.rs deleted file mode 100644 index 36acff3a2..000000000 --- a/provider/darwinia-bridger/src/service/relay.rs +++ /dev/null @@ -1,197 +0,0 @@ -//! Relay Service -use crate::{api::Shadow, error::Result}; -use primitives::chain::ethereum::EthereumHeader; -use std::sync::Arc; - -use crate::error::BizError; -use crate::service::extrinsics::{Extrinsic, MsgExtrinsic}; -use crate::service::MsgStop; -use actix::fut::Either; -use actix::prelude::*; -use anyhow::Context as AnyhowContext; -use std::time::Duration; - -use crate::tools; -use darwinia::Ethereum2Darwinia; - -/// message 'block_number' -#[derive(Clone, Debug)] -pub struct MsgBlockNumber(pub u64); - -impl Message for MsgBlockNumber { - type Result = (); -} - -/// message 'execute' -#[derive(Clone, Debug)] -struct MsgExecute; - -impl Message for MsgExecute { - type Result = (); -} - -/// Relay Service -pub struct RelayService { - /// Shadow API - pub shadow: Arc, - /// Dawrinia API - pub ethereum2darwinia: Ethereum2Darwinia, - - target: u64, - relayed: u64, - step: u64, - - extrinsics_service: Recipient, -} - -impl Actor for RelayService { - type Context = Context; - - fn started(&mut self, ctx: &mut Self::Context) { - info!(" ✨ SERVICE STARTED: RELAY"); - ctx.run_interval(Duration::from_millis(self.step * 1_000), |_this, ctx| { - ctx.notify(MsgExecute {}); - }); - } - - fn stopped(&mut self, _: &mut Self::Context) { - info!(" 💤 SERVICE STOPPED: RELAY") - } -} - -impl Handler for RelayService { - type Result = (); - - fn handle(&mut self, msg: MsgBlockNumber, _: &mut Context) -> Self::Result { - if msg.0 > self.relayed && msg.0 > self.target { - self.target = msg.0; - } - } -} - -impl Handler for RelayService { - type Result = AtomicResponse; - - fn handle(&mut self, _: MsgExecute, _: &mut Context) -> Self::Result { - AtomicResponse::new(Box::pin( - async {} - .into_actor(self) - .then(|_, this, _| { - if this.target > this.relayed { - let f = RelayService::affirm( - this.ethereum2darwinia.clone(), - this.shadow.clone(), - this.target, - this.extrinsics_service.clone(), - ); - Either::Left(f.into_actor(this)) - } else { - let f = async { Ok(()) }; - Either::Right(f.into_actor(this)) - } - }) - .map(|r, this, _| { - match r { - Ok(_) => this.relayed = this.target, - Err(err) => { - if let Some(e) = err.downcast_ref::() { - match e { - BizError::AffirmingBlockLessThanLastConfirmed(..) => { - this.relayed = this.target; // not try again - trace!("{}", err); - } - _ => trace!("{}", err), - } - } else { - error!("{:#?}", err); - } - } - } - }), - )) - } -} - -impl Handler for RelayService { - type Result = (); - - fn handle(&mut self, _: MsgStop, ctx: &mut Context) -> Self::Result { - ctx.stop(); - } -} - -impl RelayService { - /// create new relay service actor - pub fn new( - shadow: Arc, - ethereum2darwinia: Ethereum2Darwinia, - last_confirmed: u64, - step: u64, - extrinsics_service: Recipient, - ) -> Self { - RelayService { - ethereum2darwinia, - shadow, - target: last_confirmed, - relayed: last_confirmed, - step, - extrinsics_service, - } - } - - /// affirm target block - pub async fn affirm( - ethereum2darwinia: Ethereum2Darwinia, - shadow: Arc, - target: u64, - extrinsics_service: Recipient, - ) -> Result<()> { - // ///////////////////////// - // checking before affirm - // ///////////////////////// - // 1. last confirmed check - let last_confirmed = ethereum2darwinia.last_confirmed().await?; - if target <= last_confirmed { - return Err( - BizError::AffirmingBlockLessThanLastConfirmed(target, last_confirmed).into(), - ); - } - - // 2. pendings check - let pending_headers = ethereum2darwinia.pending_headers().await?; - for pending_header in pending_headers { - let pending_block_number = pending_header.1.header.number; - if pending_block_number >= target { - return Err(BizError::AffirmingBlockInPending(target).into()); - } - } - - // 3. affirmations check - for (_game_id, game) in ethereum2darwinia.affirmations().await?.iter() { - for (_round_id, affirmations) in game.iter() { - if Ethereum2Darwinia::contains(&affirmations, target) { - return Err(BizError::AffirmingBlockInGame(target).into()); - } - } - } - - trace!("Prepare to affirm ethereum block: {}", target); - let parcel = shadow.parcel(target as usize + 1).await.with_context(|| { - format!( - "Fail to get parcel from shadow when affirming ethereum block {}", - target - ) - })?; - if parcel.header == EthereumHeader::default() || parcel.mmr_root == [0u8; 32] { - return Err(BizError::ParcelFromShadowIsEmpty(target).into()); - } - - // ///////////////////////// - // do affirm - // ///////////////////////// - let ex = Extrinsic::Affirm(parcel); - tools::send_extrinsic(&extrinsics_service, ex).await; - - Ok(()) - } -} diff --git a/provider/darwinia-bridger/src/service/subscribe/darwinia_tracker.rs b/provider/darwinia-bridger/src/service/subscribe/darwinia_tracker.rs deleted file mode 100644 index f4d0cca25..000000000 --- a/provider/darwinia-bridger/src/service/subscribe/darwinia_tracker.rs +++ /dev/null @@ -1,66 +0,0 @@ -use crate::error::Result; -use darwinia::Darwinia; -use std::time::Duration; -use substrate_subxt::sp_runtime::generic::Header; -use substrate_subxt::sp_runtime::traits::BlakeTwo256; -use tokio::time::delay_for; - -/// DarwiniaTracker -pub struct DarwiniaBlockTracker { - darwinia: Darwinia, - next_block: u32, -} - -impl DarwiniaBlockTracker { - /// new - pub fn new(darwinia: Darwinia, scan_from: u32) -> Self { - Self { - darwinia, - next_block: scan_from, - } - } - - /// get next block - pub async fn next_block(&mut self) -> Result> { - loop { - match self.get_next_block().await { - Ok(result) => { - if let Some(header) = result { - return Ok(header); - } else { - delay_for(Duration::from_secs(6)).await; - } - } - Err(err) => { - error!("An error occurred while tracking next darwinia block: {:#?}", err); - let err_msg = format!("{:?}", err); - if err_msg.contains("restart") { - return Err(crate::error::Error::RestartFromJsonrpsee.into()); - } else { - delay_for(Duration::from_secs(30)).await; - } - } - } - } - } - - async fn get_next_block(&mut self) -> Result>> { - let finalized_block_hash = self.darwinia.finalized_head().await?; - match self - .darwinia - .get_block_number_by_hash(finalized_block_hash) - .await? - { - Some(finalized_block_number) => { - if self.next_block > finalized_block_number { - Ok(None) - } else { - let header = self.darwinia.get_block_by_number(self.next_block).await?; - self.next_block += 1; - Ok(Some(header)) - } - } - None => Ok(None), - } - } -} diff --git a/provider/darwinia-bridger/src/service/subscribe/mod.rs b/provider/darwinia-bridger/src/service/subscribe/mod.rs deleted file mode 100644 index 493170950..000000000 --- a/provider/darwinia-bridger/src/service/subscribe/mod.rs +++ /dev/null @@ -1,220 +0,0 @@ -//! Darwinia Subscribe -mod darwinia_tracker; - -use crate::api::Ethereum; -use crate::error::{BizError, Error}; -use crate::service::subscribe::darwinia_tracker::DarwiniaBlockTracker; -use crate::tools; -use crate::{ - error::Result, - service::extrinsics::{Extrinsic, MsgExtrinsic}, -}; -use actix::Recipient; -use primitives::runtime::DarwiniaRuntime; -use std::collections::HashMap; -use std::path::PathBuf; -use substrate_subxt::system::System; -use tokio::time::{delay_for, Duration}; - -use darwinia::{Darwinia2Ethereum, EventInfo, ToEthereumAccount}; - -/// Dawrinia Subscribe -pub struct SubscribeService { - darwinia2ethereum: Darwinia2Ethereum, - account: ToEthereumAccount, - ethereum: Ethereum, - stop: bool, - extrinsics_service: Recipient, - delayed_extrinsics: HashMap, - spec_name: String, - scan_from: u32, - data_dir: PathBuf, -} - -impl SubscribeService { - /// New subscribe service - pub fn new( - darwinia2ethereum: Darwinia2Ethereum, - account: ToEthereumAccount, - ethereum: Ethereum, - extrinsics_service: Recipient, - spec_name: String, - scan_from: u32, - data_dir: PathBuf, - ) -> SubscribeService { - SubscribeService { - darwinia2ethereum, - account, - ethereum, - stop: false, - extrinsics_service, - delayed_extrinsics: HashMap::new(), - spec_name, - scan_from, - data_dir, - } - } - - /// start - pub async fn start(&mut self) -> Result<()> { - let mut tracker = - DarwiniaBlockTracker::new(self.darwinia2ethereum.darwinia.clone(), self.scan_from); - info!("✨ SERVICE STARTED: SUBSCRIBE"); - loop { - let header = tracker.next_block().await?; - - // debug - trace!("Darwinia block {}", header.number); - - // handle the 'mmr root sign and send extrinsics' only block height reached - if let Err(err) = self.handle_delayed_extrinsics(&header).await { - error!( - "An error occurred while processing the delayed extrinsics: {:?}", - err - ); - // Prevent too fast refresh errors - delay_for(Duration::from_secs(30)).await; - } - - // handle events of the block - let hash = header.hash(); - let events = self - .darwinia2ethereum - .darwinia - .get_events_from_block_hash(hash) - .await - .map_err(|err| err.into()); - if let Err(err) = self.handle_events(&header, events).await { - if let Some(Error::RuntimeUpdated) = err.downcast_ref() { - tools::set_cache( - self.data_dir.clone(), - tools::LAST_TRACKED_DARWINIA_BLOCK_FILE_NAME, - header.number as u64, - ) - .await?; - return Err(err); - } else { - error!( - "An error occurred while processing the events of block {}: {:?}", - header.number, err - ); - delay_for(Duration::from_secs(30)).await; - } - } else { - tools::set_cache( - self.data_dir.clone(), - tools::LAST_TRACKED_DARWINIA_BLOCK_FILE_NAME, - header.number as u64, - ) - .await?; - } - - if self.stop { - return Err(BizError::Bridger("Force stop".to_string()).into()); - } - } - } - - /// stop - pub fn stop(&mut self) { - info!("💤 SERVICE STOPPED: SUBSCRIBE"); - self.stop = true; - } - - async fn handle_delayed_extrinsics( - &mut self, - header: &::Header, - ) -> Result<()> { - let cloned = self.delayed_extrinsics.clone(); - for (delayed_to, delayed_ex) in cloned.iter() { - if header.number >= *delayed_to - && self - .darwinia2ethereum - .need_to_sign_mmr_root_of(&self.account, *delayed_to, Some(header.number)) - .await? - { - tools::send_extrinsic(&self.extrinsics_service, delayed_ex.clone()).await; - self.delayed_extrinsics.remove(&delayed_to); - } - } - Ok(()) - } - - async fn handle_events( - &mut self, - header: &::Header, - events: Result>>, - ) -> Result<()> { - for event in events? { - self.handle_event(header, event).await?; - } - Ok(()) - } - - async fn handle_event( - &mut self, - header: &::Header, - event: EventInfo, - ) -> Result<()> { - //todo - //if module != "System" { - //trace!(">> Event - {}::{}", module, variant); - //} - let block = Some(header.number); - match event { - EventInfo::RuntimeUpdatedEvent(_) => { - return Err(Error::RuntimeUpdated.into()); - } - // call ethereum_relay_authorities.request_authority and then sudo call - // EthereumRelayAuthorities.add_authority will emit the event - EventInfo::ScheduleAuthoritiesChangeEvent(event) => { - if self - .darwinia2ethereum - .is_authority(block, &self.account) - .await? && self - .darwinia2ethereum - .need_to_sign_authorities(block, &self.account, event.message) - .await? - { - let ex = Extrinsic::SignAndSendAuthorities(event.message); - tools::send_extrinsic(&self.extrinsics_service, ex).await; - } - } - // authority set changed will emit this event - EventInfo::AuthoritiesChangeSignedEvent(event) => { - let current_term = self.darwinia2ethereum.get_current_authority_term().await?; - if event.term == current_term { - let message = Darwinia2Ethereum::construct_authorities_message( - self.spec_name.clone(), - event.term, - event.new_authorities, - ); - let signatures = event - .signatures - .iter() - .map(|s| s.1.clone()) - .collect::>(); - let tx_hash = self - .ethereum - .submit_authorities_set(message, signatures) - .await?; - info!("Submit authorities to ethereum with tx: {}", tx_hash); - } - } - // call ethereum_backing.lock will emit the event - EventInfo::ScheduleMMRRootEvent(event) => { - if self - .darwinia2ethereum - .is_authority(block, &self.account) - .await? - { - info!("{}", event); - let ex = Extrinsic::SignAndSendMmrRoot(event.block_number); - self.delayed_extrinsics.insert(event.block_number, ex); - } - } - _ => {} - } - Ok(()) - } -} diff --git a/provider/darwinia-bridger/src/tools.rs b/provider/darwinia-bridger/src/tools.rs deleted file mode 100644 index 57d607731..000000000 --- a/provider/darwinia-bridger/src/tools.rs +++ /dev/null @@ -1,63 +0,0 @@ -//! tools -use crate::error::Error; -use crate::error::Result; -use std::path::PathBuf; -use tokio::fs::File; -use tokio::io::{AsyncReadExt, AsyncWriteExt}; - -/// Last redeemed ethereum block file name -pub const LAST_REDEEMED_CACHE_FILE_NAME: &str = "last-redeemed"; - -/// Last tracked darwinia block file name -pub const LAST_TRACKED_DARWINIA_BLOCK_FILE_NAME: &str = "last-tracked-darwinia-block"; - -/// Get cache -pub async fn get_cache(data_dir: PathBuf, filename: &str, err: Error) -> Result { - let mut filepath = data_dir; - filepath.push(filename); - - // read from cache file - match File::open(filepath).await { - Ok(mut file) => { - let mut buffer = String::new(); - file.read_to_string(&mut buffer).await?; - let cache = buffer.trim().parse()?; - Ok(cache) - } - Err(_err) => Err(err.into()), - } -} - -/// Set cache -pub async fn set_cache(data_dir: PathBuf, filename: &str, value: u64) -> Result<()> { - let mut filepath = data_dir; - filepath.push(filename); - let mut file = File::create(filepath).await?; - file.write_all(value.to_string().as_bytes()).await?; - Ok(()) -} - -use crate::service::extrinsics::{Extrinsic, MsgExtrinsic}; -use actix::Recipient; -use tokio::time::{delay_for, Duration}; - -/// send extrinsic to extrinsics_service -pub async fn send_extrinsic(extrinsics_service: &Recipient, ex: Extrinsic) { - let msg = MsgExtrinsic(ex); - loop { - match extrinsics_service.send(msg.clone()).await { - Ok(send_result) => { - if let Err(process_err) = send_result { - error!("{:?}", process_err); - delay_for(Duration::from_secs(30)).await; - } else { - break; - } - } - Err(send_err) => { - error!("{:?}", send_err); - delay_for(Duration::from_secs(30)).await; - } - } - } -} diff --git a/bridger/supports/evm-log-tracker/Cargo.toml b/supports/evm-log-tracker/Cargo.toml similarity index 100% rename from bridger/supports/evm-log-tracker/Cargo.toml rename to supports/evm-log-tracker/Cargo.toml diff --git a/bridger/supports/evm-log-tracker/src/chains/bsc.rs b/supports/evm-log-tracker/src/chains/bsc.rs similarity index 100% rename from bridger/supports/evm-log-tracker/src/chains/bsc.rs rename to supports/evm-log-tracker/src/chains/bsc.rs diff --git a/bridger/supports/evm-log-tracker/src/chains/ethereum.rs b/supports/evm-log-tracker/src/chains/ethereum.rs similarity index 100% rename from bridger/supports/evm-log-tracker/src/chains/ethereum.rs rename to supports/evm-log-tracker/src/chains/ethereum.rs diff --git a/bridger/supports/evm-log-tracker/src/chains/heco.rs b/supports/evm-log-tracker/src/chains/heco.rs similarity index 100% rename from bridger/supports/evm-log-tracker/src/chains/heco.rs rename to supports/evm-log-tracker/src/chains/heco.rs diff --git a/bridger/supports/evm-log-tracker/src/chains/mod.rs b/supports/evm-log-tracker/src/chains/mod.rs similarity index 100% rename from bridger/supports/evm-log-tracker/src/chains/mod.rs rename to supports/evm-log-tracker/src/chains/mod.rs diff --git a/bridger/supports/evm-log-tracker/src/default_logs_handler.rs b/supports/evm-log-tracker/src/default_logs_handler.rs similarity index 100% rename from bridger/supports/evm-log-tracker/src/default_logs_handler.rs rename to supports/evm-log-tracker/src/default_logs_handler.rs diff --git a/bridger/supports/evm-log-tracker/src/error.rs b/supports/evm-log-tracker/src/error.rs similarity index 100% rename from bridger/supports/evm-log-tracker/src/error.rs rename to supports/evm-log-tracker/src/error.rs diff --git a/bridger/supports/evm-log-tracker/src/evm_client.rs b/supports/evm-log-tracker/src/evm_client.rs similarity index 100% rename from bridger/supports/evm-log-tracker/src/evm_client.rs rename to supports/evm-log-tracker/src/evm_client.rs diff --git a/bridger/supports/evm-log-tracker/src/evm_log_tracker.rs b/supports/evm-log-tracker/src/evm_log_tracker.rs similarity index 100% rename from bridger/supports/evm-log-tracker/src/evm_log_tracker.rs rename to supports/evm-log-tracker/src/evm_log_tracker.rs diff --git a/bridger/supports/evm-log-tracker/src/lib.rs b/supports/evm-log-tracker/src/lib.rs similarity index 100% rename from bridger/supports/evm-log-tracker/src/lib.rs rename to supports/evm-log-tracker/src/lib.rs diff --git a/bridger/supports/evm-log-tracker/src/traits.rs b/supports/evm-log-tracker/src/traits.rs similarity index 100% rename from bridger/supports/evm-log-tracker/src/traits.rs rename to supports/evm-log-tracker/src/traits.rs diff --git a/bridger/supports/support-ethereum/Cargo.toml b/supports/support-ethereum/Cargo.toml similarity index 100% rename from bridger/supports/support-ethereum/Cargo.toml rename to supports/support-ethereum/Cargo.toml diff --git a/bridger/supports/support-ethereum/src/affirmation.rs b/supports/support-ethereum/src/affirmation.rs similarity index 100% rename from bridger/supports/support-ethereum/src/affirmation.rs rename to supports/support-ethereum/src/affirmation.rs diff --git a/bridger/supports/support-ethereum/src/block.rs b/supports/support-ethereum/src/block.rs similarity index 100% rename from bridger/supports/support-ethereum/src/block.rs rename to supports/support-ethereum/src/block.rs diff --git a/bridger/supports/support-ethereum/src/ethash.rs b/supports/support-ethereum/src/ethash.rs similarity index 100% rename from bridger/supports/support-ethereum/src/ethash.rs rename to supports/support-ethereum/src/ethash.rs diff --git a/bridger/supports/support-ethereum/src/lib.rs b/supports/support-ethereum/src/lib.rs similarity index 100% rename from bridger/supports/support-ethereum/src/lib.rs rename to supports/support-ethereum/src/lib.rs diff --git a/bridger/supports/support-ethereum/src/mmr.rs b/supports/support-ethereum/src/mmr.rs similarity index 100% rename from bridger/supports/support-ethereum/src/mmr.rs rename to supports/support-ethereum/src/mmr.rs diff --git a/bridger/supports/support-ethereum/src/parcel.rs b/supports/support-ethereum/src/parcel.rs similarity index 100% rename from bridger/supports/support-ethereum/src/parcel.rs rename to supports/support-ethereum/src/parcel.rs diff --git a/bridger/supports/support-ethereum/src/proof.rs b/supports/support-ethereum/src/proof.rs similarity index 100% rename from bridger/supports/support-ethereum/src/proof.rs rename to supports/support-ethereum/src/proof.rs diff --git a/bridger/supports/support-ethereum/src/proxy_type.rs b/supports/support-ethereum/src/proxy_type.rs similarity index 100% rename from bridger/supports/support-ethereum/src/proxy_type.rs rename to supports/support-ethereum/src/proxy_type.rs diff --git a/bridger/supports/support-ethereum/src/receipt.rs b/supports/support-ethereum/src/receipt.rs similarity index 100% rename from bridger/supports/support-ethereum/src/receipt.rs rename to supports/support-ethereum/src/receipt.rs diff --git a/bridger/supports/support-keep/Cargo.toml b/supports/support-keep/Cargo.toml similarity index 100% rename from bridger/supports/support-keep/Cargo.toml rename to supports/support-keep/Cargo.toml diff --git a/bridger/supports/support-keep/src/lib.rs b/supports/support-keep/src/lib.rs similarity index 100% rename from bridger/supports/support-keep/src/lib.rs rename to supports/support-keep/src/lib.rs diff --git a/bridger/supports/support-keep/src/state.rs b/supports/support-keep/src/state.rs similarity index 100% rename from bridger/supports/support-keep/src/state.rs rename to supports/support-keep/src/state.rs diff --git a/bridger/supports/support-keep/src/task.rs b/supports/support-keep/src/task.rs similarity index 100% rename from bridger/supports/support-keep/src/task.rs rename to supports/support-keep/src/task.rs diff --git a/bridger/supports/support-keep/src/types.rs b/supports/support-keep/src/types.rs similarity index 100% rename from bridger/supports/support-keep/src/types.rs rename to supports/support-keep/src/types.rs diff --git a/bridger/supports/support-s2s/Cargo.toml b/supports/support-s2s/Cargo.toml similarity index 100% rename from bridger/supports/support-s2s/Cargo.toml rename to supports/support-s2s/Cargo.toml diff --git a/bridger/supports/support-s2s/src/declaration/millau.rs b/supports/support-s2s/src/declaration/millau.rs similarity index 100% rename from bridger/supports/support-s2s/src/declaration/millau.rs rename to supports/support-s2s/src/declaration/millau.rs diff --git a/bridger/supports/support-s2s/src/declaration/mod.rs b/supports/support-s2s/src/declaration/mod.rs similarity index 100% rename from bridger/supports/support-s2s/src/declaration/mod.rs rename to supports/support-s2s/src/declaration/mod.rs diff --git a/bridger/supports/support-s2s/src/declaration/pangolin.rs b/supports/support-s2s/src/declaration/pangolin.rs similarity index 100% rename from bridger/supports/support-s2s/src/declaration/pangolin.rs rename to supports/support-s2s/src/declaration/pangolin.rs diff --git a/bridger/supports/support-s2s/src/lib.rs b/supports/support-s2s/src/lib.rs similarity index 100% rename from bridger/supports/support-s2s/src/lib.rs rename to supports/support-s2s/src/lib.rs diff --git a/bridger/supports/support-s2s/src/macros/declare_relay_headers.rs b/supports/support-s2s/src/macros/declare_relay_headers.rs similarity index 100% rename from bridger/supports/support-s2s/src/macros/declare_relay_headers.rs rename to supports/support-s2s/src/macros/declare_relay_headers.rs diff --git a/bridger/supports/support-s2s/src/macros/declare_relay_messages.rs b/supports/support-s2s/src/macros/declare_relay_messages.rs similarity index 100% rename from bridger/supports/support-s2s/src/macros/declare_relay_messages.rs rename to supports/support-s2s/src/macros/declare_relay_messages.rs diff --git a/bridger/supports/support-s2s/src/macros/mod.rs b/supports/support-s2s/src/macros/mod.rs similarity index 100% rename from bridger/supports/support-s2s/src/macros/mod.rs rename to supports/support-s2s/src/macros/mod.rs diff --git a/bridger/supports/support-s2s/src/relay/finality_pipeline.rs b/supports/support-s2s/src/relay/finality_pipeline.rs similarity index 100% rename from bridger/supports/support-s2s/src/relay/finality_pipeline.rs rename to supports/support-s2s/src/relay/finality_pipeline.rs diff --git a/bridger/supports/support-s2s/src/relay/finality_target.rs b/supports/support-s2s/src/relay/finality_target.rs similarity index 100% rename from bridger/supports/support-s2s/src/relay/finality_target.rs rename to supports/support-s2s/src/relay/finality_target.rs diff --git a/bridger/supports/support-s2s/src/relay/headers_initialize.rs b/supports/support-s2s/src/relay/headers_initialize.rs similarity index 100% rename from bridger/supports/support-s2s/src/relay/headers_initialize.rs rename to supports/support-s2s/src/relay/headers_initialize.rs diff --git a/bridger/supports/support-s2s/src/relay/messages_lane.rs b/supports/support-s2s/src/relay/messages_lane.rs similarity index 100% rename from bridger/supports/support-s2s/src/relay/messages_lane.rs rename to supports/support-s2s/src/relay/messages_lane.rs diff --git a/bridger/supports/support-s2s/src/relay/messages_source.rs b/supports/support-s2s/src/relay/messages_source.rs similarity index 100% rename from bridger/supports/support-s2s/src/relay/messages_source.rs rename to supports/support-s2s/src/relay/messages_source.rs diff --git a/bridger/supports/support-s2s/src/relay/messages_target.rs b/supports/support-s2s/src/relay/messages_target.rs similarity index 100% rename from bridger/supports/support-s2s/src/relay/messages_target.rs rename to supports/support-s2s/src/relay/messages_target.rs diff --git a/bridger/supports/support-s2s/src/relay/mod.rs b/supports/support-s2s/src/relay/mod.rs similarity index 100% rename from bridger/supports/support-s2s/src/relay/mod.rs rename to supports/support-s2s/src/relay/mod.rs diff --git a/bridger/supports/support-s2s/src/relay/on_demand_headers.rs b/supports/support-s2s/src/relay/on_demand_headers.rs similarity index 100% rename from bridger/supports/support-s2s/src/relay/on_demand_headers.rs rename to supports/support-s2s/src/relay/on_demand_headers.rs diff --git a/bridger/supports/support-s2s/src/runner/mod.rs b/supports/support-s2s/src/runner/mod.rs similarity index 100% rename from bridger/supports/support-s2s/src/runner/mod.rs rename to supports/support-s2s/src/runner/mod.rs diff --git a/bridger/supports/support-s2s/src/runner/pangolin_millau/init.rs b/supports/support-s2s/src/runner/pangolin_millau/init.rs similarity index 100% rename from bridger/supports/support-s2s/src/runner/pangolin_millau/init.rs rename to supports/support-s2s/src/runner/pangolin_millau/init.rs diff --git a/bridger/supports/support-s2s/src/runner/pangolin_millau/mod.rs b/supports/support-s2s/src/runner/pangolin_millau/mod.rs similarity index 100% rename from bridger/supports/support-s2s/src/runner/pangolin_millau/mod.rs rename to supports/support-s2s/src/runner/pangolin_millau/mod.rs diff --git a/bridger/supports/support-s2s/src/runner/pangolin_millau/relay.rs b/supports/support-s2s/src/runner/pangolin_millau/relay.rs similarity index 100% rename from bridger/supports/support-s2s/src/runner/pangolin_millau/relay.rs rename to supports/support-s2s/src/runner/pangolin_millau/relay.rs diff --git a/bridger/supports/support-s2s/src/traits.rs b/supports/support-s2s/src/traits.rs similarity index 100% rename from bridger/supports/support-s2s/src/traits.rs rename to supports/support-s2s/src/traits.rs diff --git a/bridger/supports/support-s2s/src/types.rs b/supports/support-s2s/src/types.rs similarity index 100% rename from bridger/supports/support-s2s/src/types.rs rename to supports/support-s2s/src/types.rs diff --git a/bridger/task/linked-darwinia/Cargo.toml b/task/linked-darwinia/Cargo.toml similarity index 100% rename from bridger/task/linked-darwinia/Cargo.toml rename to task/linked-darwinia/Cargo.toml diff --git a/bridger/task/linked-darwinia/src/bus.rs b/task/linked-darwinia/src/bus.rs similarity index 100% rename from bridger/task/linked-darwinia/src/bus.rs rename to task/linked-darwinia/src/bus.rs diff --git a/bridger/task/linked-darwinia/src/config.rs b/task/linked-darwinia/src/config.rs similarity index 100% rename from bridger/task/linked-darwinia/src/config.rs rename to task/linked-darwinia/src/config.rs diff --git a/bridger/task/linked-darwinia/src/lib.rs b/task/linked-darwinia/src/lib.rs similarity index 100% rename from bridger/task/linked-darwinia/src/lib.rs rename to task/linked-darwinia/src/lib.rs diff --git a/bridger/task/linked-darwinia/src/message.rs b/task/linked-darwinia/src/message.rs similarity index 100% rename from bridger/task/linked-darwinia/src/message.rs rename to task/linked-darwinia/src/message.rs diff --git a/bridger/task/linked-darwinia/src/route.rs b/task/linked-darwinia/src/route.rs similarity index 100% rename from bridger/task/linked-darwinia/src/route.rs rename to task/linked-darwinia/src/route.rs diff --git a/bridger/task/linked-darwinia/src/service/extrinsic.rs b/task/linked-darwinia/src/service/extrinsic.rs similarity index 100% rename from bridger/task/linked-darwinia/src/service/extrinsic.rs rename to task/linked-darwinia/src/service/extrinsic.rs diff --git a/bridger/task/linked-darwinia/src/service/mod.rs b/task/linked-darwinia/src/service/mod.rs similarity index 100% rename from bridger/task/linked-darwinia/src/service/mod.rs rename to task/linked-darwinia/src/service/mod.rs diff --git a/bridger/task/linked-darwinia/src/task.rs b/task/linked-darwinia/src/task.rs similarity index 100% rename from bridger/task/linked-darwinia/src/task.rs rename to task/linked-darwinia/src/task.rs diff --git a/bridger/task/linked-template/Cargo.toml b/task/linked-template/Cargo.toml similarity index 100% rename from bridger/task/linked-template/Cargo.toml rename to task/linked-template/Cargo.toml diff --git a/bridger/task/linked-template/src/bus.rs b/task/linked-template/src/bus.rs similarity index 100% rename from bridger/task/linked-template/src/bus.rs rename to task/linked-template/src/bus.rs diff --git a/bridger/task/linked-template/src/config.rs b/task/linked-template/src/config.rs similarity index 100% rename from bridger/task/linked-template/src/config.rs rename to task/linked-template/src/config.rs diff --git a/bridger/task/linked-template/src/lib.rs b/task/linked-template/src/lib.rs similarity index 100% rename from bridger/task/linked-template/src/lib.rs rename to task/linked-template/src/lib.rs diff --git a/bridger/task/linked-template/src/message.rs b/task/linked-template/src/message.rs similarity index 100% rename from bridger/task/linked-template/src/message.rs rename to task/linked-template/src/message.rs diff --git a/bridger/task/linked-template/src/route.rs b/task/linked-template/src/route.rs similarity index 100% rename from bridger/task/linked-template/src/route.rs rename to task/linked-template/src/route.rs diff --git a/bridger/task/linked-template/src/service/mod.rs b/task/linked-template/src/service/mod.rs similarity index 100% rename from bridger/task/linked-template/src/service/mod.rs rename to task/linked-template/src/service/mod.rs diff --git a/bridger/task/linked-template/src/service/some.rs b/task/linked-template/src/service/some.rs similarity index 100% rename from bridger/task/linked-template/src/service/some.rs rename to task/linked-template/src/service/some.rs diff --git a/bridger/task/linked-template/src/task.rs b/task/linked-template/src/task.rs similarity index 100% rename from bridger/task/linked-template/src/task.rs rename to task/linked-template/src/task.rs diff --git a/bridger/task/linked-template/tests/test_template.rs b/task/linked-template/tests/test_template.rs similarity index 100% rename from bridger/task/linked-template/tests/test_template.rs rename to task/linked-template/tests/test_template.rs diff --git a/bridger/task/task-darwinia-ethereum/Cargo.toml b/task/task-darwinia-ethereum/Cargo.toml similarity index 100% rename from bridger/task/task-darwinia-ethereum/Cargo.toml rename to task/task-darwinia-ethereum/Cargo.toml diff --git a/bridger/task/task-darwinia-ethereum/README.md b/task/task-darwinia-ethereum/README.md similarity index 100% rename from bridger/task/task-darwinia-ethereum/README.md rename to task/task-darwinia-ethereum/README.md diff --git a/bridger/task/task-darwinia-ethereum/docs/Guide.md b/task/task-darwinia-ethereum/docs/Guide.md similarity index 100% rename from bridger/task/task-darwinia-ethereum/docs/Guide.md rename to task/task-darwinia-ethereum/docs/Guide.md diff --git a/bridger/task/task-darwinia-ethereum/src/Relay.json b/task/task-darwinia-ethereum/src/Relay.json similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/Relay.json rename to task/task-darwinia-ethereum/src/Relay.json diff --git a/bridger/task/task-darwinia-ethereum/src/bus.rs b/task/task-darwinia-ethereum/src/bus.rs similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/bus.rs rename to task/task-darwinia-ethereum/src/bus.rs diff --git a/bridger/task/task-darwinia-ethereum/src/config.rs b/task/task-darwinia-ethereum/src/config.rs similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/config.rs rename to task/task-darwinia-ethereum/src/config.rs diff --git a/bridger/task/task-darwinia-ethereum/src/error.rs b/task/task-darwinia-ethereum/src/error.rs similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/error.rs rename to task/task-darwinia-ethereum/src/error.rs diff --git a/bridger/task/task-darwinia-ethereum/src/ethereum.rs b/task/task-darwinia-ethereum/src/ethereum.rs similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/ethereum.rs rename to task/task-darwinia-ethereum/src/ethereum.rs diff --git a/bridger/task/task-darwinia-ethereum/src/lib.rs b/task/task-darwinia-ethereum/src/lib.rs similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/lib.rs rename to task/task-darwinia-ethereum/src/lib.rs diff --git a/bridger/task/task-darwinia-ethereum/src/message.rs b/task/task-darwinia-ethereum/src/message.rs similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/message.rs rename to task/task-darwinia-ethereum/src/message.rs diff --git a/bridger/task/task-darwinia-ethereum/src/route.rs b/task/task-darwinia-ethereum/src/route.rs similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/route.rs rename to task/task-darwinia-ethereum/src/route.rs diff --git a/bridger/task/task-darwinia-ethereum/src/service/darwinia/darwinia_tracker.rs b/task/task-darwinia-ethereum/src/service/darwinia/darwinia_tracker.rs similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/service/darwinia/darwinia_tracker.rs rename to task/task-darwinia-ethereum/src/service/darwinia/darwinia_tracker.rs diff --git a/bridger/task/task-darwinia-ethereum/src/service/darwinia/mod.rs b/task/task-darwinia-ethereum/src/service/darwinia/mod.rs similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/service/darwinia/mod.rs rename to task/task-darwinia-ethereum/src/service/darwinia/mod.rs diff --git a/bridger/task/task-darwinia-ethereum/src/service/ethereum/ethereum_logs_handler.rs b/task/task-darwinia-ethereum/src/service/ethereum/ethereum_logs_handler.rs similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/service/ethereum/ethereum_logs_handler.rs rename to task/task-darwinia-ethereum/src/service/ethereum/ethereum_logs_handler.rs diff --git a/bridger/task/task-darwinia-ethereum/src/service/ethereum/mod.rs b/task/task-darwinia-ethereum/src/service/ethereum/mod.rs similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/service/ethereum/mod.rs rename to task/task-darwinia-ethereum/src/service/ethereum/mod.rs diff --git a/bridger/task/task-darwinia-ethereum/src/service/extrinsics.rs b/task/task-darwinia-ethereum/src/service/extrinsics.rs similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/service/extrinsics.rs rename to task/task-darwinia-ethereum/src/service/extrinsics.rs diff --git a/bridger/task/task-darwinia-ethereum/src/service/guard.rs b/task/task-darwinia-ethereum/src/service/guard.rs similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/service/guard.rs rename to task/task-darwinia-ethereum/src/service/guard.rs diff --git a/bridger/task/task-darwinia-ethereum/src/service/mod.rs b/task/task-darwinia-ethereum/src/service/mod.rs similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/service/mod.rs rename to task/task-darwinia-ethereum/src/service/mod.rs diff --git a/bridger/task/task-darwinia-ethereum/src/service/redeem.rs b/task/task-darwinia-ethereum/src/service/redeem.rs similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/service/redeem.rs rename to task/task-darwinia-ethereum/src/service/redeem.rs diff --git a/bridger/task/task-darwinia-ethereum/src/service/relay.rs b/task/task-darwinia-ethereum/src/service/relay.rs similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/service/relay.rs rename to task/task-darwinia-ethereum/src/service/relay.rs diff --git a/bridger/task/task-darwinia-ethereum/src/task.rs b/task/task-darwinia-ethereum/src/task.rs similarity index 100% rename from bridger/task/task-darwinia-ethereum/src/task.rs rename to task/task-darwinia-ethereum/src/task.rs diff --git a/bridger/task/task-pangolin-millau/Cargo.toml b/task/task-pangolin-millau/Cargo.toml similarity index 100% rename from bridger/task/task-pangolin-millau/Cargo.toml rename to task/task-pangolin-millau/Cargo.toml diff --git a/bridger/task/task-pangolin-millau/docs/Guide.md b/task/task-pangolin-millau/docs/Guide.md similarity index 100% rename from bridger/task/task-pangolin-millau/docs/Guide.md rename to task/task-pangolin-millau/docs/Guide.md diff --git a/bridger/task/task-pangolin-millau/docs/Guide_zh_CN.md b/task/task-pangolin-millau/docs/Guide_zh_CN.md similarity index 100% rename from bridger/task/task-pangolin-millau/docs/Guide_zh_CN.md rename to task/task-pangolin-millau/docs/Guide_zh_CN.md diff --git a/bridger/task/task-pangolin-millau/src/bus.rs b/task/task-pangolin-millau/src/bus.rs similarity index 100% rename from bridger/task/task-pangolin-millau/src/bus.rs rename to task/task-pangolin-millau/src/bus.rs diff --git a/bridger/task/task-pangolin-millau/src/config.rs b/task/task-pangolin-millau/src/config.rs similarity index 100% rename from bridger/task/task-pangolin-millau/src/config.rs rename to task/task-pangolin-millau/src/config.rs diff --git a/bridger/task/task-pangolin-millau/src/lib.rs b/task/task-pangolin-millau/src/lib.rs similarity index 100% rename from bridger/task/task-pangolin-millau/src/lib.rs rename to task/task-pangolin-millau/src/lib.rs diff --git a/bridger/task/task-pangolin-millau/src/message.rs b/task/task-pangolin-millau/src/message.rs similarity index 100% rename from bridger/task/task-pangolin-millau/src/message.rs rename to task/task-pangolin-millau/src/message.rs diff --git a/bridger/task/task-pangolin-millau/src/route.rs b/task/task-pangolin-millau/src/route.rs similarity index 100% rename from bridger/task/task-pangolin-millau/src/route.rs rename to task/task-pangolin-millau/src/route.rs diff --git a/bridger/task/task-pangolin-millau/src/service/init.rs b/task/task-pangolin-millau/src/service/init.rs similarity index 100% rename from bridger/task/task-pangolin-millau/src/service/init.rs rename to task/task-pangolin-millau/src/service/init.rs diff --git a/bridger/task/task-pangolin-millau/src/service/mod.rs b/task/task-pangolin-millau/src/service/mod.rs similarity index 100% rename from bridger/task/task-pangolin-millau/src/service/mod.rs rename to task/task-pangolin-millau/src/service/mod.rs diff --git a/bridger/task/task-pangolin-millau/src/service/relay.rs b/task/task-pangolin-millau/src/service/relay.rs similarity index 100% rename from bridger/task/task-pangolin-millau/src/service/relay.rs rename to task/task-pangolin-millau/src/service/relay.rs diff --git a/bridger/task/task-pangolin-millau/src/task.rs b/task/task-pangolin-millau/src/task.rs similarity index 100% rename from bridger/task/task-pangolin-millau/src/task.rs rename to task/task-pangolin-millau/src/task.rs diff --git a/bridger/task/task-template/Cargo.toml b/task/task-template/Cargo.toml similarity index 100% rename from bridger/task/task-template/Cargo.toml rename to task/task-template/Cargo.toml diff --git a/bridger/task/task-template/src/bus.rs b/task/task-template/src/bus.rs similarity index 100% rename from bridger/task/task-template/src/bus.rs rename to task/task-template/src/bus.rs diff --git a/bridger/task/task-template/src/config.rs b/task/task-template/src/config.rs similarity index 100% rename from bridger/task/task-template/src/config.rs rename to task/task-template/src/config.rs diff --git a/bridger/task/task-template/src/lib.rs b/task/task-template/src/lib.rs similarity index 100% rename from bridger/task/task-template/src/lib.rs rename to task/task-template/src/lib.rs diff --git a/bridger/task/task-template/src/message.rs b/task/task-template/src/message.rs similarity index 100% rename from bridger/task/task-template/src/message.rs rename to task/task-template/src/message.rs diff --git a/bridger/task/task-template/src/route.rs b/task/task-template/src/route.rs similarity index 100% rename from bridger/task/task-template/src/route.rs rename to task/task-template/src/route.rs diff --git a/bridger/task/task-template/src/service/mod.rs b/task/task-template/src/service/mod.rs similarity index 100% rename from bridger/task/task-template/src/service/mod.rs rename to task/task-template/src/service/mod.rs diff --git a/bridger/task/task-template/src/service/some.rs b/task/task-template/src/service/some.rs similarity index 100% rename from bridger/task/task-template/src/service/some.rs rename to task/task-template/src/service/some.rs diff --git a/bridger/task/task-template/src/task.rs b/task/task-template/src/task.rs similarity index 100% rename from bridger/task/task-template/src/task.rs rename to task/task-template/src/task.rs diff --git a/bridger/task/task-template/tests/test_template.rs b/task/task-template/tests/test_template.rs similarity index 100% rename from bridger/task/task-template/tests/test_template.rs rename to task/task-template/tests/test_template.rs diff --git a/bridger/traits/Cargo.toml b/traits/Cargo.toml similarity index 100% rename from bridger/traits/Cargo.toml rename to traits/Cargo.toml diff --git a/bridger/traits/src/bridge/chain.rs b/traits/src/bridge/chain.rs similarity index 100% rename from bridger/traits/src/bridge/chain.rs rename to traits/src/bridge/chain.rs diff --git a/bridger/traits/src/bridge/component.rs b/traits/src/bridge/component.rs similarity index 100% rename from bridger/traits/src/bridge/component.rs rename to traits/src/bridge/component.rs diff --git a/bridger/traits/src/bridge/config.rs b/traits/src/bridge/config.rs similarity index 100% rename from bridger/traits/src/bridge/config.rs rename to traits/src/bridge/config.rs diff --git a/bridger/traits/src/bridge/mod.rs b/traits/src/bridge/mod.rs similarity index 100% rename from bridger/traits/src/bridge/mod.rs rename to traits/src/bridge/mod.rs diff --git a/bridger/traits/src/bridge/service.rs b/traits/src/bridge/service.rs similarity index 100% rename from bridger/traits/src/bridge/service.rs rename to traits/src/bridge/service.rs diff --git a/bridger/traits/src/bridge/task.rs b/traits/src/bridge/task.rs similarity index 100% rename from bridger/traits/src/bridge/task.rs rename to traits/src/bridge/task.rs diff --git a/bridger/traits/src/error.rs b/traits/src/error.rs similarity index 100% rename from bridger/traits/src/error.rs rename to traits/src/error.rs diff --git a/bridger/traits/src/lib.rs b/traits/src/lib.rs similarity index 100% rename from bridger/traits/src/lib.rs rename to traits/src/lib.rs