From f9c24ef0db390c355241445af37a5c7999a7dc66 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Tue, 4 May 2021 15:27:09 -0400 Subject: [PATCH] Squashed 'bridges/' changes from 89a76998..b2099c5c b2099c5c Bump Substrate to `b094edaf` (#958) 3f037094 Bump endowment amounts on Rialto and Millau (#957) b21fd07c Bump Substrate WASM builder (#947) 30ccd07c Bump Substrate to `ec180313` (#955) a7422ab1 Upgrade to GitHub-native Dependabot (#945) ed20ef34 Move pallet-bridge-dispatch types to primitives (#948) 2070c4d6 Endow accounts and add `bridgeIds` to chainspec. (#951) f43c9243 Fix account derivation in CLI (#952) 9ac07e73 Add backbone configuration of cargo-spellcheck (#924) 2761c3fe Message dispatch support multiple instances (#942) 801c99f3 Add Wococo<>Rococo Header Relayer (#925) 21f49051 Remove Westend<>Rococo header sync (#940) 06235f16 do not panic if pallet is not yet initialized (#937) a13ee0bc Bump Substrate (#939) f8680cbf jsonrpsee alpha6 (#938) 6163bcbf reonnect to failed client in on-demand relay background task (#936) 14e82bea Do not spawn additional task for on-demand relays (#933) b1557b88 Relay at least one header for every source chain session (#923) 9420649c Remove deprecated Runtime Header APIs (#932) 9627011e Update README.md (#931) 7b736b9c Truncate output in logs. (#930) faad06e3 Make sure that relayers have dates in logs. (#927) 07734535 Update dump-logs script. (#928) c2d56b2e Add pruning to bechmarks & update weights. (#918) a30c51dc Add properties to Chain Spec (#917) d691c73e Fix issue with on-demand headers relay not starting (#921) 8ee55c1e Fix image publishing. (#922) f51fb59d Prefix in relay loops logs (#920) git-subtree-dir: bridges git-subtree-split: b2099c5c0baf569e2ec7228507b6e4f3972143cc --- polkadot/.config/lingua.dic | 176 ++++++ polkadot/.config/spellcheck.toml | 11 + polkadot/.dependabot/config.yml | 22 - polkadot/.github/dependabot.yml | 42 ++ polkadot/.github/workflows/lint.yml | 30 +- polkadot/.github/workflows/rust.yml | 4 +- polkadot/Cargo.lock | 500 +++++++++++------- polkadot/README.md | 4 +- polkadot/bin/millau/node/Cargo.toml | 2 + polkadot/bin/millau/node/src/chain_spec.rs | 31 +- polkadot/bin/millau/node/src/cli.rs | 2 +- polkadot/bin/millau/node/src/service.rs | 57 +- polkadot/bin/millau/runtime/Cargo.toml | 2 +- polkadot/bin/millau/runtime/build.rs | 5 +- polkadot/bin/millau/runtime/src/lib.rs | 7 +- .../bin/millau/runtime/src/rialto_messages.rs | 11 +- polkadot/bin/rialto/node/Cargo.toml | 2 + polkadot/bin/rialto/node/src/chain_spec.rs | 30 +- polkadot/bin/rialto/node/src/cli.rs | 2 +- polkadot/bin/rialto/node/src/service.rs | 55 +- polkadot/bin/rialto/runtime/Cargo.toml | 2 +- polkadot/bin/rialto/runtime/build.rs | 5 +- polkadot/bin/rialto/runtime/src/lib.rs | 43 +- .../bin/rialto/runtime/src/millau_messages.rs | 11 +- polkadot/bin/runtime-common/README.md | 8 +- polkadot/bin/runtime-common/src/messages.rs | 46 +- .../relay-headers-rococo-to-westend.sh | 24 - .../relay-headers-westend-to-rococo.sh | 24 - polkadot/docs/high-level-overview.md | 2 +- polkadot/modules/currency-exchange/src/lib.rs | 2 +- polkadot/modules/dispatch/README.md | 4 +- polkadot/modules/dispatch/src/lib.rs | 80 +-- polkadot/modules/grandpa/src/benchmarking.rs | 29 +- polkadot/modules/grandpa/src/lib.rs | 87 ++- polkadot/modules/grandpa/src/weights.rs | 50 +- polkadot/modules/messages/src/weights.rs | 94 ++-- polkadot/primitives/chain-millau/src/lib.rs | 25 - polkadot/primitives/chain-rialto/src/lib.rs | 25 - polkadot/primitives/chain-rococo/src/lib.rs | 17 +- polkadot/primitives/chain-wococo/Cargo.toml | 36 ++ polkadot/primitives/chain-wococo/src/lib.rs | 172 ++++++ .../primitives/message-dispatch/Cargo.toml | 7 + .../primitives/message-dispatch/src/lib.rs | 75 ++- polkadot/primitives/runtime/src/lib.rs | 4 +- polkadot/relays/bin-substrate/Cargo.toml | 4 +- .../relays/bin-substrate/src/chains/millau.rs | 2 +- .../relays/bin-substrate/src/chains/mod.rs | 19 +- .../relays/bin-substrate/src/chains/rialto.rs | 2 +- ...westend.rs => rococo_headers_to_wococo.rs} | 20 +- .../src/chains/westend_headers_to_rococo.rs | 2 +- .../relays/bin-substrate/src/chains/wococo.rs | 39 ++ .../src/chains/wococo_headers_to_rococo.rs | 60 +++ .../relays/bin-substrate/src/cli/bridge.rs | 4 +- .../bin-substrate/src/cli/derive_account.rs | 4 +- .../bin-substrate/src/cli/init_bridge.rs | 34 +- polkadot/relays/bin-substrate/src/cli/mod.rs | 15 + .../bin-substrate/src/cli/relay_headers.rs | 21 +- .../src/cli/relay_headers_and_messages.rs | 5 + .../bin-substrate/src/cli/send_message.rs | 2 +- .../bin-substrate/src/finality_pipeline.rs | 4 +- polkadot/relays/bin-substrate/src/main.rs | 3 - .../relays/bin-substrate/src/messages_lane.rs | 2 +- .../bin-substrate/src/messages_source.rs | 2 +- .../bin-substrate/src/messages_target.rs | 2 +- .../bin-substrate/src/on_demand_headers.rs | 258 +++++++-- polkadot/relays/client-ethereum/Cargo.toml | 4 +- polkadot/relays/client-substrate/Cargo.toml | 4 +- polkadot/relays/client-wococo/Cargo.toml | 23 + polkadot/relays/client-wococo/src/lib.rs | 97 ++++ polkadot/relays/exchange/src/exchange.rs | 15 +- polkadot/relays/exchange/src/exchange_loop.rs | 12 +- polkadot/relays/finality/src/finality_loop.rs | 9 +- .../finality/src/finality_loop_tests.rs | 3 +- polkadot/relays/finality/src/lib.rs | 2 +- polkadot/relays/headers/src/sync_loop.rs | 8 +- polkadot/relays/headers/src/sync_types.rs | 2 +- polkadot/relays/messages/src/message_lane.rs | 2 +- .../relays/messages/src/message_lane_loop.rs | 67 +-- .../messages/src/message_race_delivery.rs | 53 +- polkadot/relays/utils/src/initialize.rs | 46 +- polkadot/relays/utils/src/relay_loop.rs | 146 +++-- polkadot/scripts/dump-logs.sh | 8 +- 82 files changed, 2056 insertions(+), 816 deletions(-) create mode 100644 polkadot/.config/lingua.dic create mode 100644 polkadot/.config/spellcheck.toml delete mode 100644 polkadot/.dependabot/config.yml create mode 100644 polkadot/.github/dependabot.yml delete mode 100755 polkadot/deployments/local-scripts/relay-headers-rococo-to-westend.sh delete mode 100755 polkadot/deployments/local-scripts/relay-headers-westend-to-rococo.sh create mode 100644 polkadot/primitives/chain-wococo/Cargo.toml create mode 100644 polkadot/primitives/chain-wococo/src/lib.rs rename polkadot/relays/bin-substrate/src/chains/{rococo_headers_to_westend.rs => rococo_headers_to_wococo.rs} (71%) create mode 100644 polkadot/relays/bin-substrate/src/chains/wococo.rs create mode 100644 polkadot/relays/bin-substrate/src/chains/wococo_headers_to_rococo.rs create mode 100644 polkadot/relays/client-wococo/Cargo.toml create mode 100644 polkadot/relays/client-wococo/src/lib.rs diff --git a/polkadot/.config/lingua.dic b/polkadot/.config/lingua.dic new file mode 100644 index 0000000000..a31ecf2c7b --- /dev/null +++ b/polkadot/.config/lingua.dic @@ -0,0 +1,176 @@ +90 +annualised/MS +Apache-2.0/M +AccountId/MS +api/SM +auth +auths/SM +API/SM +APIs +arg +args +aren +async +Best/MS +BlockId +BFT/M +bitfield/MS +blake2/MS +blockchain/MS +borked +BridgeStorage +BlockNumber +BTC/S +CLI/MS +Chain1 +Chain2 +ChainSpec +ChainTime +chain_getBlock +choosen +config/MS +crypto/MS +customizable/B +debian/M +decodable/MS +DOT/S +doesn +dispatchables +ed25519 +enum/MS +ERC-20 +ethereum/MS +externality/MS +extrinsic/MS +extrinsics +fedora/M +FN +FinalizationError +GiB/S +GPL/M +GPLv3/M +Handler/MS +HeaderA +HeaderId +https +implementers +inherent/MS +initialize/RG +instantiate/B +intrinsic/MS +intrinsics +InitiateChange +isn +io +js +keccak256/M +KSM/S +Lane1 +Lane2 +Lane3 +LaneId +kusama/S +KYC/M +keccak +Kovan +merkle/MS +MessageNonce +MessageNonces +Merklized +MaybeOrphan +MaybeExtra +MetricsParams +MessagePayload +misbehavior/SM +misbehaviors +MIN_SIZE +MIT/M +max_value +multivalidator/SM +natively +OldHeader +nonces +number +no_std +ok +oneshot/MS +others' +OutboundMessages +parablock/MS +parachain/MS +parameterize/D +pallet_message_lane +polkadot/MS +pov-block/MS +PoA +PoV/MS +precommit +promethius +promethius' +prune_end +prune_depth +provisioner/MS +redhat/M +repo/MS +receival +RPC/MS +RLP +runtime/MS +Runtime1 +Runtime2 +rustc/MS +ServiceFactory/MS +SignedExtension +SIZE_FACTOR +sr25519 +SS58 +SS58Prefix +src +S|N +SURI +source +struct/MS +Submitter1 +submitters/MS +subsystem/MS +subsystems' +shouldn +synchronizer +taskmanager/MS +teleport/RG +teleportation/SM +teleporter/SM +teleporters +testnet/MS +trie/MS +trustless/Y +ThisChain +TCP +ubuntu/M +union/MSG +undeliverable +unfinalized +unpruned +unservable/B +unsynced +ve +vec +Vec +validator/SM +verifier +w3f/MS +wasm/M +WND/S +XCM/S +XCMP/M +include/BG +isolate/BG +Instance1 +Instance2 +Instance42 +Pre +Rialto +stringified +Stringified +millau +Millau diff --git a/polkadot/.config/spellcheck.toml b/polkadot/.config/spellcheck.toml new file mode 100644 index 0000000000..015f9b97c7 --- /dev/null +++ b/polkadot/.config/spellcheck.toml @@ -0,0 +1,11 @@ +[hunspell] +lang = "en_US" +search_dirs = ["."] +extra_dictionaries = ["lingua.dic"] + +[hunspell.quirks] +# `Type`'s +# 5x +transform_regex = ["^'([^\\s])'$", "^[0-9]+(?:\\.[0-9]*)?x$", "^'s$", "^\\+$", "[><+-]"] +allow_concatenation = true +allow_dashes = true diff --git a/polkadot/.dependabot/config.yml b/polkadot/.dependabot/config.yml deleted file mode 100644 index 61599ccba9..0000000000 --- a/polkadot/.dependabot/config.yml +++ /dev/null @@ -1,22 +0,0 @@ -version: 1 -update_configs: - - package_manager: "rust:cargo" - directory: "/" - update_schedule: "weekly" - ignored_updates: - - match: - dependency_name: "sp-*" - - match: - dependency_name: "sc-*" - - match: - dependency_name: "substrate-*" - - match: - dependency_name: "frame-*" - - match: - dependency_name: "pallet-*" - - match: - dependency_name: "node-inspect" - automerged_updates: - - match: - update_type: "all" - version_requirement_updates: "auto" diff --git a/polkadot/.github/dependabot.yml b/polkadot/.github/dependabot.yml new file mode 100644 index 0000000000..a06d573703 --- /dev/null +++ b/polkadot/.github/dependabot.yml @@ -0,0 +1,42 @@ +version: 2 +updates: +- package-ecosystem: cargo + directory: "/" + schedule: + interval: weekly + time: "03:00" + timezone: Europe/Berlin + open-pull-requests-limit: 20 + ignore: + - dependency-name: frame-* + versions: + - ">= 0" + - dependency-name: node-inspect + versions: + - ">= 0" + - dependency-name: pallet-* + versions: + - ">= 0" + - dependency-name: sc-* + versions: + - ">= 0" + - dependency-name: sp-* + versions: + - ">= 0" + - dependency-name: substrate-* + versions: + - ">= 0" + - dependency-name: vergen + versions: + - 4.0.1 + - 4.0.2 + - 4.1.0 + - 4.2.0 + - dependency-name: jsonrpc-core + versions: + - 17.0.0 + - dependency-name: finality-grandpa + versions: + - 0.13.0 + - 0.14.0 + rebase-strategy: disabled diff --git a/polkadot/.github/workflows/lint.yml b/polkadot/.github/workflows/lint.yml index 4ebd12e0d6..e01f2cf065 100644 --- a/polkadot/.github/workflows/lint.yml +++ b/polkadot/.github/workflows/lint.yml @@ -21,23 +21,45 @@ jobs: env: RUST_BACKTRACE: full steps: - + - name: Cancel Previous Runs uses: styfle/cancel-workflow-action@0.4.1 with: access_token: ${{ github.token }} - + - name: Checkout sources & submodules uses: actions/checkout@master with: fetch-depth: 5 submodules: recursive - + - name: Add rustfmt run: rustup component add rustfmt - + - name: rust-fmt check uses: actions-rs/cargo@master with: command: fmt args: --all -- --check + check-spellcheck: + name: Check For Spelling and/or Grammar Mistakes + runs-on: ubuntu-latest + env: + RUST_BACKTRACE: full + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.4.1 + with: + access_token: ${{ github.token }} + + - name: Checkout sources & submodules + uses: actions/checkout@master + with: + fetch-depth: 5 + submodules: recursive + + - name: Add cargo-spellcheck + run: cargo install cargo-spellcheck + + - name: Run spellcheck + run: cargo spellcheck check -m 1 -vv $(find modules/currency-exchange/src -name "*.rs") diff --git a/polkadot/.github/workflows/rust.yml b/polkadot/.github/workflows/rust.yml index e6f7939efb..14e72ddad0 100644 --- a/polkadot/.github/workflows/rust.yml +++ b/polkadot/.github/workflows/rust.yml @@ -85,8 +85,8 @@ jobs: matrix: toolchain: - stable - #- beta - - nightly + #- beta + - nightly-2021-04-10 runs-on: ubuntu-latest env: RUST_BACKTRACE: full diff --git a/polkadot/Cargo.lock b/polkadot/Cargo.lock index 5811d7ad3b..abe77d2a3c 100644 --- a/polkadot/Cargo.lock +++ b/polkadot/Cargo.lock @@ -164,22 +164,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "asn1_der" -version = "0.6.3" +version = "0.7.4" 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", -] +checksum = "9d6e24d2cce90c53b948c46271bfb053e4bdc2db9b5d3f65e20f8cf28a1b7fc3" [[package]] name = "async-channel" @@ -339,9 +326,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.42" +version = "0.1.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d" +checksum = "0b98e84bbb4cbcdd97da190ba0c58a1bb0de2c1fdf67d159e192ed766aeca722" dependencies = [ "proc-macro2", "quote", @@ -706,7 +693,9 @@ name = "bp-message-dispatch" version = "0.1.0" dependencies = [ "bp-runtime", + "frame-support", "parity-scale-codec 2.0.1", + "sp-std", ] [[package]] @@ -844,6 +833,21 @@ dependencies = [ "sp-version", ] +[[package]] +name = "bp-wococo" +version = "0.1.0" +dependencies = [ + "bp-header-chain", + "bp-messages", + "bp-polkadot-core", + "bp-runtime", + "parity-scale-codec 2.0.1", + "sp-api", + "sp-runtime", + "sp-std", + "sp-version", +] + [[package]] name = "bridge-runtime-common" version = "0.1.0" @@ -880,6 +884,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "build-helper" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdce191bf3fa4995ce948c8c83b4640a1745457a149e73c6db75b4ffe36aad5f" +dependencies = [ + "semver 0.6.0", +] + [[package]] name = "bumpalo" version = "3.6.1" @@ -939,6 +952,28 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" +[[package]] +name = "cargo-platform" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0226944a63d1bf35a3b5f948dd7c59e263db83695c9e8bffc4037de02e30f1d7" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714a157da7991e23d90686b9524b9e12e0407a108647f52e9328f4b3d51ac7f" +dependencies = [ + "cargo-platform", + "semver 0.11.0", + "semver-parser 0.10.2", + "serde", + "serde_json", +] + [[package]] name = "cc" version = "1.0.67" @@ -2012,7 +2047,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "parity-scale-codec 2.0.1", ] @@ -2030,7 +2065,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "3.1.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "frame-support", "frame-system", @@ -2049,7 +2084,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "Inflector", "chrono", @@ -2072,7 +2107,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "frame-support", "frame-system", @@ -2087,7 +2122,7 @@ dependencies = [ [[package]] name = "frame-metadata" version = "13.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "parity-scale-codec 2.0.1", "serde", @@ -2098,7 +2133,7 @@ dependencies = [ [[package]] name = "frame-support" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "bitflags", "frame-metadata", @@ -2124,7 +2159,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "Inflector", "frame-support-procedural-tools", @@ -2136,7 +2171,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 1.0.0", @@ -2148,7 +2183,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "proc-macro2", "quote", @@ -2158,7 +2193,7 @@ dependencies = [ [[package]] name = "frame-system" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "frame-support", "impl-trait-for-tuples", @@ -2175,7 +2210,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "parity-scale-codec 2.0.1", "sp-api", @@ -3232,9 +3267,9 @@ dependencies = [ [[package]] name = "jsonrpsee-proc-macros" -version = "0.2.0-alpha.5" +version = "0.2.0-alpha.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0cbaee9ca6440e191545a68c7bf28db0ff918359a904e37a6e7cf7edd132f5a" +checksum = "5784ee8bb31988fa2c7a755fe31b0e21aa51894a67e5c99b6d4470f0253bf31a" dependencies = [ "Inflector", "proc-macro-crate 1.0.0", @@ -3245,9 +3280,9 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.2.0-alpha.5" +version = "0.2.0-alpha.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ce2de6884fb4abee16eca02329a1eec1eb8df8aed751a8e929083820c78ce7" +checksum = "bab3dabceeeeb865897661d532d47202eaae71cd2c606f53cb69f1fbc0555a51" dependencies = [ "async-trait", "beef", @@ -3261,9 +3296,9 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" -version = "0.2.0-alpha.5" +version = "0.2.0-alpha.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03ece6acc5ef1e7877fd53887e8937b273466713dc8c017a32223c2b9b678d63" +checksum = "d6fdb4390bd25358c62e8b778652a564a1723ba07dca0feb3da439c2253fe59f" dependencies = [ "async-std", "async-tls", @@ -3397,9 +3432,9 @@ dependencies = [ [[package]] name = "libp2p" -version = "0.36.0" +version = "0.37.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe5759b526f75102829c15e4d8566603b4bf502ed19b5f35920d98113873470d" +checksum = "08053fbef67cd777049ef7a95ebaca2ece370b4ed7712c3fa404d69a88cb741b" dependencies = [ "atomic", "bytes 1.0.1", @@ -3436,9 +3471,9 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.28.1" +version = "0.28.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e1797734bbd4c453664fefb029628f77c356ffc5bce98f06b18a7db3ebb0f7" +checksum = "554d3e7e9e65f939d66b75fd6a4c67f258fe250da61b91f46c545fc4a89b51d9" dependencies = [ "asn1_der", "bs58", @@ -3495,9 +3530,9 @@ dependencies = [ [[package]] name = "libp2p-floodsub" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897645f99e9b396df256a6aa8ba8c4bc019ac6b7c62556f624b5feea9acc82bb" +checksum = "48a9b570f6766301d9c4aa00fce3554cad1598e2f466debbc4dde909028417cf" dependencies = [ "cuckoofilter", "fnv", @@ -3513,9 +3548,9 @@ dependencies = [ [[package]] name = "libp2p-gossipsub" -version = "0.29.0" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "794b0c85f5df1acbc1fc38414d37272594811193b6325c76d3931c3e3f5df8c0" +checksum = "e7b0c8506a6ec3344b9e706d7c7a6dba826f8ede735cfe13dde12a8c263c4af9" dependencies = [ "asynchronous-codec 0.6.0", "base64 0.13.0", @@ -3539,9 +3574,9 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f88ebc841d744979176ab4b8b294a3e655a7ba4ef26a905d073a52b49ed4dff5" +checksum = "5f668f00efd9883e8b7bcc582eaf0164615792608f886f6577da18bcbeea0a46" dependencies = [ "futures 0.3.13", "libp2p-core", @@ -3555,9 +3590,9 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb5b90b6bda749023a85f60b49ea74b387c25f17d8df541ae72a3c75dd52e63" +checksum = "b07312ebe5ee4fd2404447a0609814574df55c65d4e20838b957bbd34907d820" dependencies = [ "arrayvec 0.5.2", "asynchronous-codec 0.6.0", @@ -3581,9 +3616,9 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.29.0" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be28ca13bb648d249a9baebd750ebc64ce7040ddd5f0ce1035ff1f4549fb596d" +checksum = "41e282f974c4bea56db8acca50387f05189406e346318cb30190b0bde662961e" dependencies = [ "async-io", "data-encoding", @@ -3642,9 +3677,9 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea10fc5209260915ea65b78f612d7ff78a29ab288e7aa3250796866af861c45" +checksum = "bf4bfaffac63bf3c7ec11ed9d8879d455966ddea7e78ee14737f0b6dce0d1cd1" dependencies = [ "futures 0.3.13", "libp2p-core", @@ -3688,9 +3723,9 @@ dependencies = [ [[package]] name = "libp2p-relay" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ff268be6a9d6f3c6cca3b81bbab597b15217f9ad8787c6c40fc548c1af7cd24" +checksum = "0b8786aca3f18671d8776289706a5521f6c9124a820f69e358de214b9939440d" dependencies = [ "asynchronous-codec 0.6.0", "bytes 1.0.1", @@ -3711,9 +3746,9 @@ dependencies = [ [[package]] name = "libp2p-request-response" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "725367dd2318c54c5ab1a6418592e5b01c63b0dedfbbfb8389220b2bcf691899" +checksum = "1cdbe172f08e6d0f95fa8634e273d4c4268c4063de2e33e7435194b0130c62e3" dependencies = [ "async-trait", "bytes 1.0.1", @@ -3731,9 +3766,9 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75c26980cadd7c25d89071cb23e1f7f5df4863128cc91d83c6ddc72338cecafa" +checksum = "1e04d8e1eef675029ec728ba14e8d0da7975d84b6679b699b4ae91a1de9c3a92" dependencies = [ "either", "futures 0.3.13", @@ -3747,9 +3782,9 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c564ebaa36a64839f51eaddb0243aaaa29ce64affb56129193cc3248b72af273" +checksum = "365b0a699fea5168676840567582a012ea297b1ca02eee467e58301b9c9c5eed" dependencies = [ "quote", "syn", @@ -3818,9 +3853,9 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.31.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d6144cc94143fb0a8dd1e7c2fbcc32a2808168bcd1d69920635424d5993b7b" +checksum = "f35da42cfc6d5cb0dcf3ad6881bc68d146cdf38f98655e09e33fbba4d13eabc4" dependencies = [ "futures 0.3.13", "libp2p-core", @@ -4104,12 +4139,14 @@ dependencies = [ "sc-service", "sc-telemetry", "sc-transaction-pool", + "serde_json", "sp-consensus", "sp-consensus-aura", "sp-core", "sp-finality-grandpa", "sp-inherents", "sp-runtime", + "sp-timestamp", "structopt", "substrate-build-script-utils", "substrate-frame-rpc-system", @@ -4159,7 +4196,7 @@ dependencies = [ "sp-transaction-pool", "sp-trie", "sp-version", - "substrate-wasm-builder-runner", + "substrate-wasm-builder", ] [[package]] @@ -4393,7 +4430,7 @@ dependencies = [ [[package]] name = "node-inspect" version = "0.8.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "derive_more", "log", @@ -4573,7 +4610,7 @@ dependencies = [ [[package]] name = "pallet-aura" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "frame-support", "frame-system", @@ -4589,14 +4626,13 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "frame-support", "frame-system", "impl-trait-for-tuples", "parity-scale-codec 2.0.1", "sp-authorship", - "sp-inherents", "sp-runtime", "sp-std", ] @@ -4604,7 +4640,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "frame-benchmarking", "frame-support", @@ -4716,7 +4752,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "frame-benchmarking", "frame-support", @@ -4737,7 +4773,7 @@ dependencies = [ [[package]] name = "pallet-randomness-collective-flip" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "frame-support", "frame-system", @@ -4750,7 +4786,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "frame-support", "frame-system", @@ -4784,7 +4820,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "frame-support", "frame-system", @@ -4797,7 +4833,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "frame-benchmarking", "frame-support", @@ -4814,7 +4850,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "frame-support", "frame-system", @@ -4830,7 +4866,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "jsonrpc-core 15.1.0", "jsonrpc-core-client", @@ -4847,7 +4883,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "pallet-transaction-payment", "parity-scale-codec 2.0.1", @@ -4998,6 +5034,15 @@ dependencies = [ "synstructure", ] +[[package]] +name = "parity-wasm" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16ad52817c4d343339b3bc2e26861bd21478eda0b7509acf83505727000512ac" +dependencies = [ + "byteorder", +] + [[package]] name = "parity-wasm" version = "0.41.0" @@ -5502,7 +5547,7 @@ checksum = "0f53bc2558e8376358ebdc28301546471d67336584f6438ed4b7c7457a055fd7" dependencies = [ "byteorder", "log", - "parity-wasm", + "parity-wasm 0.41.0", ] [[package]] @@ -6005,6 +6050,23 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "relay-wococo-client" +version = "0.1.0" +dependencies = [ + "bp-wococo", + "frame-support", + "frame-system", + "headers-relay", + "pallet-transaction-payment", + "parity-scale-codec 2.0.1", + "relay-substrate-client", + "relay-utils", + "sp-core", + "sp-keyring", + "sp-runtime", +] + [[package]] name = "remove_dir_all" version = "0.5.3" @@ -6057,12 +6119,14 @@ dependencies = [ "sc-service", "sc-telemetry", "sc-transaction-pool", + "serde_json", "sp-consensus", "sp-consensus-aura", "sp-core", "sp-finality-grandpa", "sp-inherents", "sp-runtime", + "sp-timestamp", "structopt", "substrate-build-script-utils", "substrate-frame-rpc-system", @@ -6120,7 +6184,7 @@ dependencies = [ "sp-transaction-pool", "sp-trie", "sp-version", - "substrate-wasm-builder-runner", + "substrate-wasm-builder", ] [[package]] @@ -6204,7 +6268,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" dependencies = [ - "semver", + "semver 0.9.0", ] [[package]] @@ -6290,10 +6354,19 @@ dependencies = [ "cipher", ] +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "sc-basic-authorship" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "futures 0.3.13", "futures-timer 3.0.2", @@ -6316,7 +6389,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "parity-scale-codec 2.0.1", "sc-client-api", @@ -6332,7 +6405,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec 2.0.1", @@ -6353,7 +6426,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "proc-macro-crate 1.0.0", "proc-macro2", @@ -6364,7 +6437,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "chrono", "fdlimit", @@ -6402,7 +6475,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "derive_more", "fnv", @@ -6436,7 +6509,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "blake2-rfc", "hash-db", @@ -6466,7 +6539,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "parking_lot 0.11.1", "sc-client-api", @@ -6478,7 +6551,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "async-trait", "derive_more", @@ -6502,7 +6575,6 @@ dependencies = [ "sp-io", "sp-keystore", "sp-runtime", - "sp-timestamp", "sp-version", "substrate-prometheus-endpoint", ] @@ -6510,7 +6582,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "async-trait", "derive_more", @@ -6548,7 +6620,6 @@ dependencies = [ "sp-io", "sp-keystore", "sp-runtime", - "sp-timestamp", "sp-utils", "sp-version", "substrate-prometheus-endpoint", @@ -6557,7 +6628,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "fork-tree", "parity-scale-codec 2.0.1", @@ -6570,11 +6641,12 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "async-trait", "futures 0.3.13", "futures-timer 3.0.2", + "impl-trait-for-tuples", "log", "parity-scale-codec 2.0.1", "sc-client-api", @@ -6597,28 +6669,25 @@ dependencies = [ [[package]] name = "sc-consensus-uncles" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ - "log", "sc-client-api", "sp-authorship", - "sp-consensus", - "sp-core", - "sp-inherents", "sp-runtime", + "thiserror", ] [[package]] name = "sc-executor" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "derive_more", "lazy_static", "libsecp256k1", "log", "parity-scale-codec 2.0.1", - "parity-wasm", + "parity-wasm 0.41.0", "parking_lot 0.11.1", "sc-executor-common", "sc-executor-wasmi", @@ -6641,11 +6710,11 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "derive_more", "parity-scale-codec 2.0.1", - "parity-wasm", + "parity-wasm 0.41.0", "pwasm-utils", "sp-allocator", "sp-core", @@ -6658,7 +6727,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "log", "parity-scale-codec 2.0.1", @@ -6673,11 +6742,11 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "log", "parity-scale-codec 2.0.1", - "parity-wasm", + "parity-wasm 0.41.0", "pwasm-utils", "sc-executor-common", "scoped-tls", @@ -6691,7 +6760,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "async-trait", "derive_more", @@ -6731,7 +6800,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "derive_more", "finality-grandpa 0.14.0", @@ -6755,7 +6824,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "ansi_term 0.12.1", "futures 0.3.13", @@ -6773,7 +6842,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "async-trait", "derive_more", @@ -6793,7 +6862,7 @@ dependencies = [ [[package]] name = "sc-light" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "hash-db", "lazy_static", @@ -6812,7 +6881,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "async-std", "async-trait", @@ -6865,7 +6934,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "futures 0.3.13", "futures-timer 3.0.2", @@ -6882,7 +6951,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "bytes 0.5.6", "fnv", @@ -6910,7 +6979,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "futures 0.3.13", "libp2p", @@ -6923,7 +6992,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -6932,7 +7001,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "futures 0.3.13", "hash-db", @@ -6966,7 +7035,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "derive_more", "futures 0.3.13", @@ -6990,7 +7059,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "futures 0.1.31", "jsonrpc-core 15.1.0", @@ -7008,7 +7077,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "async-trait", "directories", @@ -7072,7 +7141,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "log", "parity-scale-codec 2.0.1", @@ -7087,7 +7156,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "chrono", "futures 0.3.13", @@ -7107,7 +7176,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "ansi_term 0.12.1", "atty", @@ -7134,7 +7203,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "proc-macro-crate 1.0.0", "proc-macro2", @@ -7145,7 +7214,7 @@ dependencies = [ [[package]] name = "sc-transaction-graph" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "derive_more", "futures 0.3.13", @@ -7167,7 +7236,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "futures 0.3.13", "futures-diagnose", @@ -7293,13 +7362,32 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537" +dependencies = [ + "semver-parser 0.7.0", +] + [[package]] name = "semver" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" dependencies = [ - "semver-parser", + "semver-parser 0.7.0", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser 0.10.2", + "serde", ] [[package]] @@ -7308,6 +7396,15 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + [[package]] name = "serde" version = "1.0.124" @@ -7560,7 +7657,7 @@ dependencies = [ [[package]] name = "sp-allocator" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "log", "sp-core", @@ -7572,7 +7669,7 @@ dependencies = [ [[package]] name = "sp-api" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "hash-db", "log", @@ -7589,7 +7686,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "blake2-rfc", "proc-macro-crate 1.0.0", @@ -7601,7 +7698,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "parity-scale-codec 2.0.1", "serde", @@ -7613,7 +7710,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "integer-sqrt", "num-traits", @@ -7627,8 +7724,9 @@ dependencies = [ [[package]] name = "sp-authorship" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ + "async-trait", "parity-scale-codec 2.0.1", "sp-inherents", "sp-runtime", @@ -7638,7 +7736,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "parity-scale-codec 2.0.1", "sp-api", @@ -7650,7 +7748,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "futures 0.3.13", "log", @@ -7668,7 +7766,7 @@ dependencies = [ [[package]] name = "sp-chain-spec" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "serde", "serde_json", @@ -7677,7 +7775,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "async-trait", "futures 0.3.13", @@ -7704,8 +7802,9 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ + "async-trait", "parity-scale-codec 2.0.1", "sp-api", "sp-application-crypto", @@ -7720,8 +7819,9 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ + "async-trait", "merlin", "parity-scale-codec 2.0.1", "serde", @@ -7741,7 +7841,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "parity-scale-codec 2.0.1", "sp-arithmetic", @@ -7751,7 +7851,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "parity-scale-codec 2.0.1", "schnorrkel", @@ -7763,7 +7863,7 @@ dependencies = [ [[package]] name = "sp-core" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "base58", "blake2-rfc", @@ -7807,7 +7907,7 @@ dependencies = [ [[package]] name = "sp-database" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "kvdb", "parking_lot 0.11.1", @@ -7816,7 +7916,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "proc-macro2", "quote", @@ -7826,7 +7926,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "environmental", "parity-scale-codec 2.0.1", @@ -7837,7 +7937,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "finality-grandpa 0.14.0", "log", @@ -7854,11 +7954,13 @@ dependencies = [ [[package]] name = "sp-inherents" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ + "async-trait", + "impl-trait-for-tuples", "parity-scale-codec 2.0.1", - "parking_lot 0.11.1", "sp-core", + "sp-runtime", "sp-std", "thiserror", ] @@ -7866,7 +7968,7 @@ dependencies = [ [[package]] name = "sp-io" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "futures 0.3.13", "hash-db", @@ -7890,7 +7992,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "lazy_static", "sp-core", @@ -7901,7 +8003,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "async-trait", "derive_more", @@ -7918,7 +8020,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "ruzstd", "zstd", @@ -7927,7 +8029,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "sp-api", "sp-core", @@ -7937,7 +8039,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "backtrace", ] @@ -7945,7 +8047,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "serde", "sp-core", @@ -7954,7 +8056,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "either", "hash256-std-hasher", @@ -7975,7 +8077,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec 2.0.1", @@ -7992,7 +8094,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "Inflector", "proc-macro-crate 1.0.0", @@ -8004,7 +8106,7 @@ dependencies = [ [[package]] name = "sp-serializer" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "serde", "serde_json", @@ -8013,7 +8115,7 @@ dependencies = [ [[package]] name = "sp-session" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "parity-scale-codec 2.0.1", "sp-api", @@ -8026,7 +8128,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "parity-scale-codec 2.0.1", "sp-runtime", @@ -8036,7 +8138,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "hash-db", "log", @@ -8058,12 +8160,12 @@ dependencies = [ [[package]] name = "sp-std" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" [[package]] name = "sp-storage" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "impl-serde", "parity-scale-codec 2.0.1", @@ -8076,7 +8178,7 @@ dependencies = [ [[package]] name = "sp-tasks" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "log", "sp-core", @@ -8089,20 +8191,24 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ + "async-trait", + "futures-timer 3.0.2", + "log", "parity-scale-codec 2.0.1", "sp-api", "sp-inherents", "sp-runtime", "sp-std", + "thiserror", "wasm-timer", ] [[package]] name = "sp-tracing" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "log", "parity-scale-codec 2.0.1", @@ -8115,7 +8221,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "derive_more", "futures 0.3.13", @@ -8131,7 +8237,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "hash-db", "memory-db", @@ -8145,7 +8251,7 @@ dependencies = [ [[package]] name = "sp-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "futures 0.3.13", "futures-core", @@ -8157,7 +8263,7 @@ dependencies = [ [[package]] name = "sp-version" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "impl-serde", "parity-scale-codec 2.0.1", @@ -8169,7 +8275,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec 2.0.1", @@ -8390,7 +8496,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "frame-system-rpc-runtime-api", "futures 0.3.13", @@ -8413,7 +8519,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.9.0" -source = "git+https://github.com/paritytech/substrate?branch=master#46a64ac817ec909c66203a7e0715ee111762d3f7" +source = "git+https://github.com/paritytech/substrate?branch=master#b094edafd1cd5d26e49ecbf92b0ce7553cfad717" dependencies = [ "async-std", "derive_more", @@ -8433,6 +8539,7 @@ dependencies = [ "async-trait", "bp-header-chain", "bp-kusama", + "bp-message-dispatch", "bp-messages", "bp-millau", "bp-polkadot", @@ -8440,6 +8547,7 @@ dependencies = [ "bp-rococo", "bp-runtime", "bp-westend", + "bp-wococo", "bridge-runtime-common", "finality-grandpa 0.14.0", "finality-relay", @@ -8453,7 +8561,6 @@ dependencies = [ "millau-runtime", "num-format", "num-traits", - "pallet-bridge-dispatch", "pallet-bridge-messages", "parity-scale-codec 2.0.1", "paste 1.0.4", @@ -8465,6 +8572,7 @@ dependencies = [ "relay-substrate-client", "relay-utils", "relay-westend-client", + "relay-wococo-client", "rialto-runtime", "sp-core", "sp-finality-grandpa", @@ -8476,10 +8584,20 @@ dependencies = [ ] [[package]] -name = "substrate-wasm-builder-runner" -version = "2.0.0" +name = "substrate-wasm-builder" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54cab12167e32b38a62c5ea5825aa0874cde315f907a46aad2b05aa8ef3d862f" +checksum = "79091baab813855ddf65b191de9fe53e656b6b67c1e9bd23fdcbff8788164684" +dependencies = [ + "ansi_term 0.12.1", + "atty", + "build-helper", + "cargo_metadata", + "tempfile", + "toml", + "walkdir", + "wasm-gc-api", +] [[package]] name = "subtle" @@ -9351,6 +9469,17 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi 0.3.9", + "winapi-util", +] + [[package]] name = "want" version = "0.2.0" @@ -9450,6 +9579,17 @@ version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9a543ae66aa233d14bb765ed9af4a33e81b8b58d1584cf1b47ff8cd0b9e4489" +[[package]] +name = "wasm-gc-api" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0c32691b6c7e6c14e7f8fd55361a9088b507aa49620fcd06c09b3a1082186b9" +dependencies = [ + "log", + "parity-wasm 0.32.0", + "rustc-demangle", +] + [[package]] name = "wasm-timer" version = "0.2.5" @@ -9475,7 +9615,7 @@ dependencies = [ "memory_units", "num-rational", "num-traits", - "parity-wasm", + "parity-wasm 0.41.0", "wasmi-validation", ] @@ -9485,7 +9625,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea78c597064ba73596099281e2f4cfc019075122a65cdda3205af94f0b264d93" dependencies = [ - "parity-wasm", + "parity-wasm 0.41.0", ] [[package]] @@ -9895,15 +10035,15 @@ checksum = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" [[package]] name = "yamux" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cc7bd8c983209ed5d527f44b01c41b7dc146fd960c61cf9e1d25399841dc271" +checksum = "e7d9028f208dd5e63c614be69f115c1b53cacc1111437d4c765185856666c107" dependencies = [ "futures 0.3.13", "log", "nohash-hasher", "parking_lot 0.11.1", - "rand 0.7.3", + "rand 0.8.3", "static_assertions", ] diff --git a/polkadot/README.md b/polkadot/README.md index 8f6446c887..84d776c4f8 100644 --- a/polkadot/README.md +++ b/polkadot/README.md @@ -126,8 +126,8 @@ both Substrate chains it must be run last. ```bash # In `parity-bridges-common` folder -./deployments/local-scripts/run-rialto-bridge-node.sh -./deployments/local-scripts/run-millau-bridge-node.sh +./deployments/local-scripts/run-rialto-node.sh +./deployments/local-scripts/run-millau-node.sh ./deployments/local-scripts/relay-millau-to-rialto.sh ``` diff --git a/polkadot/bin/millau/node/Cargo.toml b/polkadot/bin/millau/node/Cargo.toml index e31e2c871a..4c5f081e15 100644 --- a/polkadot/bin/millau/node/Cargo.toml +++ b/polkadot/bin/millau/node/Cargo.toml @@ -12,6 +12,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] jsonrpc-core = "15.1.0" structopt = "0.3.21" +serde_json = "1.0.59" # Bridge dependencies @@ -46,6 +47,7 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "master" } [build-dependencies] diff --git a/polkadot/bin/millau/node/src/chain_spec.rs b/polkadot/bin/millau/node/src/chain_spec.rs index f9e9502da7..374c0f739c 100644 --- a/polkadot/bin/millau/node/src/chain_spec.rs +++ b/polkadot/bin/millau/node/src/chain_spec.rs @@ -67,6 +67,18 @@ pub fn get_authority_keys_from_seed(s: &str) -> (AccountId, AuraId, GrandpaId) { impl Alternative { /// Get an actual chain config from one of the alternatives. pub(crate) fn load(self) -> ChainSpec { + let properties = Some( + serde_json::json!({ + "tokenDecimals": 9, + "tokenSymbol": "MLAU", + "bridgeIds": { + "Rialto": bp_runtime::RIALTO_BRIDGE_INSTANCE, + } + }) + .as_object() + .expect("Map given; qed") + .clone(), + ); match self { Alternative::Development => ChainSpec::from_genesis( "Development", @@ -81,6 +93,9 @@ impl Alternative { get_account_id_from_seed::("Bob"), get_account_id_from_seed::("Alice//stash"), get_account_id_from_seed::("Bob//stash"), + derive_account_from_rialto_id(bp_runtime::SourceAccount::Account( + get_account_id_from_seed::("Alice"), + )), ], true, ) @@ -88,7 +103,7 @@ impl Alternative { vec![], None, None, - None, + properties, None, ), Alternative::LocalTestnet => ChainSpec::from_genesis( @@ -127,7 +142,13 @@ impl Alternative { pallet_bridge_messages::DefaultInstance, >::relayer_fund_account_id(), derive_account_from_rialto_id(bp_runtime::SourceAccount::Account( - get_account_id_from_seed::("Dave"), + get_account_id_from_seed::("Alice"), + )), + derive_account_from_rialto_id(bp_runtime::SourceAccount::Account( + get_account_id_from_seed::("Charlie"), + )), + derive_account_from_rialto_id(bp_runtime::SourceAccount::Account( + get_account_id_from_seed::("Eve"), )), ], true, @@ -136,7 +157,7 @@ impl Alternative { vec![], None, None, - None, + properties, None, ), } @@ -155,11 +176,11 @@ fn testnet_genesis( ) -> GenesisConfig { GenesisConfig { frame_system: SystemConfig { - code: WASM_BINARY.to_vec(), + code: WASM_BINARY.expect("Millau development WASM not available").to_vec(), changes_trie_config: Default::default(), }, pallet_balances: BalancesConfig { - balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 50)).collect(), + balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 40)).collect(), }, pallet_aura: AuraConfig { authorities: Vec::new(), diff --git a/polkadot/bin/millau/node/src/cli.rs b/polkadot/bin/millau/node/src/cli.rs index 46323ed25c..12f99b6b95 100644 --- a/polkadot/bin/millau/node/src/cli.rs +++ b/polkadot/bin/millau/node/src/cli.rs @@ -63,7 +63,7 @@ pub enum Subcommand { Revert(sc_cli::RevertCmd), /// Inspect blocks or extrinsics. - Inspect(node_inspect::cli::InspectCmd), + Inspect(node_inspect::cli::InspectKeyCmd), /// Benchmark runtime pallets. Benchmark(frame_benchmarking_cli::BenchmarkCmd), diff --git a/polkadot/bin/millau/node/src/service.rs b/polkadot/bin/millau/node/src/service.rs index 8677ec2e70..a3cb4fa245 100644 --- a/polkadot/bin/millau/node/src/service.rs +++ b/polkadot/bin/millau/node/src/service.rs @@ -37,8 +37,8 @@ use sc_finality_grandpa::SharedVoterState; use sc_keystore::LocalKeystore; use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; use sc_telemetry::{Telemetry, TelemetryWorker}; +use sp_consensus::SlotData; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; -use sp_inherents::InherentDataProviders; use std::sync::Arc; use std::time::Duration; @@ -80,8 +80,6 @@ pub fn new_partial( if config.keystore_remote.is_some() { return Err(ServiceError::Other("Remote Keystores are not supported.".to_string())); } - let inherent_data_providers = InherentDataProviders::new(); - let telemetry = config .telemetry_endpoints .clone() @@ -124,14 +122,24 @@ pub fn new_partial( let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone()); - let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { + let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); + + let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { block_import: aura_block_import.clone(), justification_import: Some(Box::new(grandpa_block_import)), client: client.clone(), - inherent_data_providers: inherent_data_providers.clone(), + create_inherent_data_providers: move |_, ()| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( + *timestamp, + slot_duration, + ); + + Ok((timestamp, slot)) + }, spawner: &task_manager.spawn_essential_handle(), can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), - slot_duration: sc_consensus_aura::slot_duration(&*client)?, registry: config.prometheus_registry(), check_for_equivocation: Default::default(), telemetry: telemetry.as_ref().map(|x| x.handle()), @@ -145,7 +153,6 @@ pub fn new_partial( keystore_container, select_chain, transaction_pool, - inherent_data_providers, other: (aura_block_import, grandpa_link, telemetry), }) } @@ -167,7 +174,6 @@ pub fn new_full(mut config: Configuration) -> Result mut keystore_container, select_chain, transaction_pool, - inherent_data_providers, other: (block_import, grandpa_link, mut telemetry), } = new_partial(&config)?; @@ -277,13 +283,25 @@ pub fn new_full(mut config: Configuration) -> Result let can_author_with = sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); - let aura = sc_consensus_aura::start_aura::(StartAuraParams { - slot_duration: sc_consensus_aura::slot_duration(&*client)?, - client: client.clone(), + let slot_duration = sc_consensus_aura::slot_duration(&*client)?; + let raw_slot_duration = slot_duration.slot_duration(); + + let aura = sc_consensus_aura::start_aura::(StartAuraParams { + slot_duration, + client, select_chain, block_import, proposer_factory, - inherent_data_providers, + create_inherent_data_providers: move |_, ()| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( + *timestamp, + raw_slot_duration, + ); + + Ok((timestamp, slot)) + }, force_authoring, backoff_authoring_blocks, keystore: keystore_container.sync_keystore(), @@ -394,14 +412,23 @@ pub fn new_light(mut config: Configuration) -> Result let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone()); - let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { + let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); + let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { block_import: aura_block_import, justification_import: Some(Box::new(grandpa_block_import)), client: client.clone(), - inherent_data_providers: InherentDataProviders::new(), + create_inherent_data_providers: move |_, ()| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( + *timestamp, + slot_duration, + ); + + Ok((timestamp, slot)) + }, spawner: &task_manager.spawn_essential_handle(), can_author_with: sp_consensus::NeverCanAuthor, - slot_duration: sc_consensus_aura::slot_duration(&*client)?, registry: config.prometheus_registry(), check_for_equivocation: Default::default(), telemetry: telemetry.as_ref().map(|x| x.handle()), diff --git a/polkadot/bin/millau/runtime/Cargo.toml b/polkadot/bin/millau/runtime/Cargo.toml index e1f7ed10c6..240b079d11 100644 --- a/polkadot/bin/millau/runtime/Cargo.toml +++ b/polkadot/bin/millau/runtime/Cargo.toml @@ -56,7 +56,7 @@ sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" , sp-version = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } [build-dependencies] -wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "2.0.0" } +substrate-wasm-builder = "3.0.0" [features] default = ["std"] diff --git a/polkadot/bin/millau/runtime/build.rs b/polkadot/bin/millau/runtime/build.rs index dcb5cb0621..cc86570432 100644 --- a/polkadot/bin/millau/runtime/build.rs +++ b/polkadot/bin/millau/runtime/build.rs @@ -14,13 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -use wasm_builder_runner::WasmBuilder; +use substrate_wasm_builder::WasmBuilder; fn main() { WasmBuilder::new() .with_current_project() - .with_wasm_builder_from_crates("1.0.11") - .export_heap_base() .import_memory() + .export_heap_base() .build() } diff --git a/polkadot/bin/millau/runtime/src/lib.rs b/polkadot/bin/millau/runtime/src/lib.rs index 30cf1bd87c..4f5e083632 100644 --- a/polkadot/bin/millau/runtime/src/lib.rs +++ b/polkadot/bin/millau/runtime/src/lib.rs @@ -55,7 +55,7 @@ use sp_version::RuntimeVersion; // A few exports that help ease life for downstream crates. pub use frame_support::{ construct_runtime, parameter_types, - traits::{Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem, Randomness}, + traits::{Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem}, weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, RuntimeDbWeight, Weight}, StorageValue, }; @@ -308,7 +308,6 @@ parameter_types! { // Note that once this is hit the pallet will essentially throttle incoming requests down to one // call per block. pub const MaxRequests: u32 = 50; - pub const WestendValidatorCount: u32 = 255; // Number of headers to keep. // @@ -478,10 +477,6 @@ impl_runtime_apis! { ) -> sp_inherents::CheckInherentsResult { data.check_extrinsics(&block) } - - fn random_seed() -> ::Hash { - RandomnessCollectiveFlip::random_seed().0 - } } impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { diff --git a/polkadot/bin/millau/runtime/src/rialto_messages.rs b/polkadot/bin/millau/runtime/src/rialto_messages.rs index a800117dc5..a61d7cce29 100644 --- a/polkadot/bin/millau/runtime/src/rialto_messages.rs +++ b/polkadot/bin/millau/runtime/src/rialto_messages.rs @@ -31,7 +31,7 @@ use frame_support::{ weights::{DispatchClass, Weight}, RuntimeDebug, }; -use sp_runtime::{FixedPointNumber, FixedU128}; +use sp_runtime::{traits::Zero, FixedPointNumber, FixedU128}; use sp_std::{convert::TryFrom, ops::RangeInclusive}; /// Initial value of `RialtoToMillauConversionRate` parameter. @@ -214,7 +214,9 @@ impl TargetHeaderChain for Rialto fn verify_messages_delivery_proof( proof: Self::MessagesDeliveryProof, ) -> Result<(LaneId, InboundLaneData), Self::Error> { - messages::source::verify_messages_delivery_proof::(proof) + messages::source::verify_messages_delivery_proof::( + proof, + ) } } @@ -231,7 +233,10 @@ impl SourceHeaderChain for Rialto { proof: Self::MessagesProof, messages_count: u32, ) -> Result>, Self::Error> { - messages::target::verify_messages_proof::(proof, messages_count) + messages::target::verify_messages_proof::( + proof, + messages_count, + ) } } diff --git a/polkadot/bin/rialto/node/Cargo.toml b/polkadot/bin/rialto/node/Cargo.toml index a51ee7a5ab..38272cd8c7 100644 --- a/polkadot/bin/rialto/node/Cargo.toml +++ b/polkadot/bin/rialto/node/Cargo.toml @@ -12,6 +12,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] jsonrpc-core = "15.1.0" structopt = "0.3.21" +serde_json = "1.0.59" # Bridge dependencies @@ -47,6 +48,7 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "master" } [build-dependencies] diff --git a/polkadot/bin/rialto/node/src/chain_spec.rs b/polkadot/bin/rialto/node/src/chain_spec.rs index 732cf1a4b1..cf14845df1 100644 --- a/polkadot/bin/rialto/node/src/chain_spec.rs +++ b/polkadot/bin/rialto/node/src/chain_spec.rs @@ -19,6 +19,7 @@ use rialto_runtime::{ AccountId, AuraConfig, BalancesConfig, BridgeKovanConfig, BridgeRialtoPoAConfig, GenesisConfig, GrandpaConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, WASM_BINARY, }; +use serde_json::json; use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_core::{sr25519, Pair, Public}; use sp_finality_grandpa::AuthorityId as GrandpaId; @@ -67,6 +68,18 @@ pub fn get_authority_keys_from_seed(s: &str) -> (AccountId, AuraId, GrandpaId) { impl Alternative { /// Get an actual chain config from one of the alternatives. pub(crate) fn load(self) -> ChainSpec { + let properties = Some( + json!({ + "tokenDecimals": 9, + "tokenSymbol": "RLT", + "bridgeIds": { + "Millau": bp_runtime::MILLAU_BRIDGE_INSTANCE, + } + }) + .as_object() + .expect("Map given; qed") + .clone(), + ); match self { Alternative::Development => ChainSpec::from_genesis( "Development", @@ -81,6 +94,9 @@ impl Alternative { get_account_id_from_seed::("Bob"), get_account_id_from_seed::("Alice//stash"), get_account_id_from_seed::("Bob//stash"), + derive_account_from_millau_id(bp_runtime::SourceAccount::Account( + get_account_id_from_seed::("Bob"), + )), ], true, ) @@ -88,7 +104,7 @@ impl Alternative { vec![], None, None, - None, + properties, None, ), Alternative::LocalTestnet => ChainSpec::from_genesis( @@ -126,9 +142,15 @@ impl Alternative { rialto_runtime::Runtime, pallet_bridge_messages::DefaultInstance, >::relayer_fund_account_id(), + derive_account_from_millau_id(bp_runtime::SourceAccount::Account( + get_account_id_from_seed::("Bob"), + )), derive_account_from_millau_id(bp_runtime::SourceAccount::Account( get_account_id_from_seed::("Dave"), )), + derive_account_from_millau_id(bp_runtime::SourceAccount::Account( + get_account_id_from_seed::("Ferdie"), + )), ], true, ) @@ -136,7 +158,7 @@ impl Alternative { vec![], None, None, - None, + properties, None, ), } @@ -155,11 +177,11 @@ fn testnet_genesis( ) -> GenesisConfig { GenesisConfig { frame_system: SystemConfig { - code: WASM_BINARY.to_vec(), + code: WASM_BINARY.expect("Rialto development WASM not available").to_vec(), changes_trie_config: Default::default(), }, pallet_balances: BalancesConfig { - balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 50)).collect(), + balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 40)).collect(), }, pallet_aura: AuraConfig { authorities: Vec::new(), diff --git a/polkadot/bin/rialto/node/src/cli.rs b/polkadot/bin/rialto/node/src/cli.rs index 46323ed25c..12f99b6b95 100644 --- a/polkadot/bin/rialto/node/src/cli.rs +++ b/polkadot/bin/rialto/node/src/cli.rs @@ -63,7 +63,7 @@ pub enum Subcommand { Revert(sc_cli::RevertCmd), /// Inspect blocks or extrinsics. - Inspect(node_inspect::cli::InspectCmd), + Inspect(node_inspect::cli::InspectKeyCmd), /// Benchmark runtime pallets. Benchmark(frame_benchmarking_cli::BenchmarkCmd), diff --git a/polkadot/bin/rialto/node/src/service.rs b/polkadot/bin/rialto/node/src/service.rs index 841202ac7b..a0d3d311a0 100644 --- a/polkadot/bin/rialto/node/src/service.rs +++ b/polkadot/bin/rialto/node/src/service.rs @@ -37,8 +37,8 @@ use sc_finality_grandpa::SharedVoterState; use sc_keystore::LocalKeystore; use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; use sc_telemetry::{Telemetry, TelemetryWorker}; +use sp_consensus::SlotData; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; -use sp_inherents::InherentDataProviders; use std::sync::Arc; use std::time::Duration; @@ -80,7 +80,6 @@ pub fn new_partial( if config.keystore_remote.is_some() { return Err(ServiceError::Other("Remote Keystores are not supported.".to_string())); } - let inherent_data_providers = InherentDataProviders::new(); let telemetry = config .telemetry_endpoints @@ -124,14 +123,24 @@ pub fn new_partial( let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone()); - let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { + let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); + + let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { block_import: aura_block_import.clone(), justification_import: Some(Box::new(grandpa_block_import)), client: client.clone(), - inherent_data_providers: inherent_data_providers.clone(), + create_inherent_data_providers: move |_, ()| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( + *timestamp, + slot_duration, + ); + + Ok((timestamp, slot)) + }, spawner: &task_manager.spawn_essential_handle(), can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), - slot_duration: sc_consensus_aura::slot_duration(&*client)?, registry: config.prometheus_registry(), check_for_equivocation: Default::default(), telemetry: telemetry.as_ref().map(|x| x.handle()), @@ -145,7 +154,6 @@ pub fn new_partial( keystore_container, select_chain, transaction_pool, - inherent_data_providers, other: (aura_block_import, grandpa_link, telemetry), }) } @@ -167,7 +175,6 @@ pub fn new_full(mut config: Configuration) -> Result mut keystore_container, select_chain, transaction_pool, - inherent_data_providers, other: (block_import, grandpa_link, mut telemetry), } = new_partial(&config)?; @@ -278,13 +285,24 @@ pub fn new_full(mut config: Configuration) -> Result let can_author_with = sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); - let aura = sc_consensus_aura::start_aura::(StartAuraParams { - slot_duration: sc_consensus_aura::slot_duration(&*client)?, - client: client.clone(), + let slot_duration = sc_consensus_aura::slot_duration(&*client)?; + let raw_slot_duration = slot_duration.slot_duration(); + let aura = sc_consensus_aura::start_aura::(StartAuraParams { + slot_duration, + client, select_chain, block_import, proposer_factory, - inherent_data_providers, + create_inherent_data_providers: move |_, ()| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( + *timestamp, + raw_slot_duration, + ); + + Ok((timestamp, slot)) + }, force_authoring, backoff_authoring_blocks, keystore: keystore_container.sync_keystore(), @@ -395,14 +413,23 @@ pub fn new_light(mut config: Configuration) -> Result let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone()); - let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { + let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); + let import_queue = sc_consensus_aura::import_queue::(ImportQueueParams { block_import: aura_block_import, justification_import: Some(Box::new(grandpa_block_import)), client: client.clone(), - inherent_data_providers: InherentDataProviders::new(), + create_inherent_data_providers: move |_, ()| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration( + *timestamp, + slot_duration, + ); + + Ok((timestamp, slot)) + }, spawner: &task_manager.spawn_essential_handle(), can_author_with: sp_consensus::NeverCanAuthor, - slot_duration: sc_consensus_aura::slot_duration(&*client)?, registry: config.prometheus_registry(), check_for_equivocation: Default::default(), telemetry: telemetry.as_ref().map(|x| x.handle()), diff --git a/polkadot/bin/rialto/runtime/Cargo.toml b/polkadot/bin/rialto/runtime/Cargo.toml index ea8c51d0e8..63a48a255b 100644 --- a/polkadot/bin/rialto/runtime/Cargo.toml +++ b/polkadot/bin/rialto/runtime/Cargo.toml @@ -68,7 +68,7 @@ sp-version = { git = "https://github.com/paritytech/substrate", branch = "master libsecp256k1 = { version = "0.3.4", features = ["hmac"] } [build-dependencies] -wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "2.0.0" } +substrate-wasm-builder = "3.0.0" [features] default = ["std"] diff --git a/polkadot/bin/rialto/runtime/build.rs b/polkadot/bin/rialto/runtime/build.rs index dcb5cb0621..cc86570432 100644 --- a/polkadot/bin/rialto/runtime/build.rs +++ b/polkadot/bin/rialto/runtime/build.rs @@ -14,13 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -use wasm_builder_runner::WasmBuilder; +use substrate_wasm_builder::WasmBuilder; fn main() { WasmBuilder::new() .with_current_project() - .with_wasm_builder_from_crates("1.0.11") - .export_heap_base() .import_memory() + .export_heap_base() .build() } diff --git a/polkadot/bin/rialto/runtime/src/lib.rs b/polkadot/bin/rialto/runtime/src/lib.rs index 4e81d3efb1..5259a10493 100644 --- a/polkadot/bin/rialto/runtime/src/lib.rs +++ b/polkadot/bin/rialto/runtime/src/lib.rs @@ -61,7 +61,7 @@ use sp_version::RuntimeVersion; // A few exports that help ease life for downstream crates. pub use frame_support::{ construct_runtime, parameter_types, - traits::{Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem, Randomness}, + traits::{Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem}, weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, RuntimeDbWeight, Weight}, StorageValue, }; @@ -409,19 +409,34 @@ impl pallet_session::Config for Runtime { } parameter_types! { - // This is a pretty unscientific cap. - // - // Note that once this is hit the pallet will essentially throttle incoming requests down to one - // call per block. + /// This is a pretty unscientific cap. + /// + /// Note that once this is hit the pallet will essentially throttle incoming requests down to one + /// call per block. pub const MaxRequests: u32 = 50; +} - // Number of headers to keep. - // - // Assuming the worst case of every header being finalized, we will keep headers at least for a - // week. +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + /// Number of headers to keep in benchmarks. + /// + /// In benchmarks we always populate with full number of `HeadersToKeep` to make sure that + /// pruning is taken into account. + /// + /// Note: This is lower than regular value, to speed up benchmarking setup. + pub const HeadersToKeep: u32 = 1024; +} + +#[cfg(not(feature = "runtime-benchmarks"))] +parameter_types! { + /// Number of headers to keep. + /// + /// Assuming the worst case of every header being finalized, we will keep headers at least for a + /// week. pub const HeadersToKeep: u32 = 7 * bp_rialto::DAYS as u32; } +pub type MillauGrandpaInstance = (); impl pallet_bridge_grandpa::Config for Runtime { type BridgedChain = bp_millau::Millau; type MaxRequests = MaxRequests; @@ -572,10 +587,6 @@ impl_runtime_apis! { ) -> sp_inherents::CheckInherentsResult { data.check_extrinsics(&block) } - - fn random_seed() -> ::Hash { - RandomnessCollectiveFlip::random_seed().0 - } } impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { @@ -874,7 +885,7 @@ impl_runtime_apis! { params: MessageParams, ) -> (millau_messages::ToMillauMessagePayload, Balance) { let message_payload = vec![0; params.size as usize]; - let dispatch_origin = pallet_bridge_dispatch::CallOrigin::SourceAccount( + let dispatch_origin = bp_message_dispatch::CallOrigin::SourceAccount( params.sender_account, ); @@ -944,10 +955,10 @@ impl_runtime_apis! { make_millau_outbound_lane_data_key, make_millau_header, call_weight, - pallet_bridge_dispatch::MessagePayload { + bp_message_dispatch::MessagePayload { spec_version: VERSION.spec_version, weight: call_weight, - origin: pallet_bridge_dispatch::CallOrigin::< + origin: bp_message_dispatch::CallOrigin::< bp_millau::AccountId, MultiSigner, Signature, diff --git a/polkadot/bin/rialto/runtime/src/millau_messages.rs b/polkadot/bin/rialto/runtime/src/millau_messages.rs index 8ee2094660..30a34b9276 100644 --- a/polkadot/bin/rialto/runtime/src/millau_messages.rs +++ b/polkadot/bin/rialto/runtime/src/millau_messages.rs @@ -31,7 +31,7 @@ use frame_support::{ weights::{DispatchClass, Weight}, RuntimeDebug, }; -use sp_runtime::{FixedPointNumber, FixedU128}; +use sp_runtime::{traits::Zero, FixedPointNumber, FixedU128}; use sp_std::{convert::TryFrom, ops::RangeInclusive}; /// Initial value of `MillauToRialtoConversionRate` parameter. @@ -214,7 +214,9 @@ impl TargetHeaderChain for Millau fn verify_messages_delivery_proof( proof: Self::MessagesDeliveryProof, ) -> Result<(LaneId, InboundLaneData), Self::Error> { - messages::source::verify_messages_delivery_proof::(proof) + messages::source::verify_messages_delivery_proof::( + proof, + ) } } @@ -231,7 +233,10 @@ impl SourceHeaderChain for Millau { proof: Self::MessagesProof, messages_count: u32, ) -> Result>, Self::Error> { - messages::target::verify_messages_proof::(proof, messages_count) + messages::target::verify_messages_proof::( + proof, + messages_count, + ) } } diff --git a/polkadot/bin/runtime-common/README.md b/polkadot/bin/runtime-common/README.md index b375f48309..a7322af973 100644 --- a/polkadot/bin/runtime-common/README.md +++ b/polkadot/bin/runtime-common/README.md @@ -8,7 +8,7 @@ messages module into your runtime. Basic prerequisites of these helpers are: - all message lanes are identical and may be used to transfer the same messages; - the messages sent over the bridge are dispatched using [call dispatch module](../../modules/dispatch/README.md); -- the messages are `pallet_bridge_dispatch::MessagePayload` structures, where `call` field is +- the messages are `bp_message_dispatch::MessagePayload` structures, where `call` field is encoded `Call` of the target chain. This means that the `Call` is opaque to the [messages module](../../modules/messages/README.md) instance at the source chain. It is pre-encoded by the message submitter; @@ -118,7 +118,7 @@ are: `maximal_message_size`, `verify_chain_message`, `verify_messages_delivery_p `estimate_message_dispatch_and_delivery_fee`. `FromThisChainMessagePayload` is a message that the sender sends through our bridge. It is the -`pallet_bridge_dispatch::MessagePayload`, where `call` field is encoded target chain call. So +`bp_message_dispatch::MessagePayload`, where `call` field is encoded target chain call. So at this chain we don't see internals of this call - we just know its size. `FromThisChainMessageVerifier` is an implementation of `bp_messages::LaneMessageVerifier`. It @@ -131,8 +131,8 @@ has following checks in its `verify_message` method: 1. it'll reject a message if it has the wrong dispatch origin declared. Like if the submitter is not the root of this chain, but it tries to dispatch the message at the target chain using - `pallet_bridge_dispatch::CallOrigin::SourceRoot` origin. Or he has provided wrong signature - in the `pallet_bridge_dispatch::CallOrigin::TargetAccount` origin; + `bp_message_dispatch::CallOrigin::SourceRoot` origin. Or he has provided wrong signature + in the `bp_message_dispatch::CallOrigin::TargetAccount` origin; 1. it'll reject a message if the delivery and dispatch fee that the submitter wants to pay is lesser than the fee that is computed using the `estimate_message_dispatch_and_delivery_fee` function. diff --git a/polkadot/bin/runtime-common/src/messages.rs b/polkadot/bin/runtime-common/src/messages.rs index 8e83c0f94a..e879aa17bf 100644 --- a/polkadot/bin/runtime-common/src/messages.rs +++ b/polkadot/bin/runtime-common/src/messages.rs @@ -180,7 +180,7 @@ pub mod source { pub type BridgedChainOpaqueCall = Vec; /// Message payload for This -> Bridged chain messages. - pub type FromThisChainMessagePayload = pallet_bridge_dispatch::MessagePayload< + pub type FromThisChainMessagePayload = bp_message_dispatch::MessagePayload< AccountIdOf>, SignerOf>, SignatureOf>, @@ -352,20 +352,21 @@ pub mod source { } /// Verify proof of This -> Bridged chain messages delivery. - pub fn verify_messages_delivery_proof( + pub fn verify_messages_delivery_proof( proof: FromBridgedChainMessagesDeliveryProof>>, ) -> Result, &'static str> where - ThisRuntime: pallet_bridge_grandpa::Config, + ThisRuntime: pallet_bridge_grandpa::Config, ThisRuntime: pallet_bridge_messages::Config>>, - HashOf>: Into::BridgedChain>>, + HashOf>: + Into>::BridgedChain>>, { let FromBridgedChainMessagesDeliveryProof { bridged_header_hash, storage_proof, lane, } = proof; - pallet_bridge_grandpa::Pallet::::parse_finalized_storage_proof( + pallet_bridge_grandpa::Pallet::::parse_finalized_storage_proof( bridged_header_hash.into(), StorageProof::new(storage_proof), |storage| { @@ -394,14 +395,14 @@ pub mod target { use super::*; /// Call origin for Bridged -> This chain messages. - pub type FromBridgedChainMessageCallOrigin = pallet_bridge_dispatch::CallOrigin< + pub type FromBridgedChainMessageCallOrigin = bp_message_dispatch::CallOrigin< AccountIdOf>, SignerOf>, SignatureOf>, >; /// Decoded Bridged -> This message payload. - pub type FromBridgedChainMessagePayload = pallet_bridge_dispatch::MessagePayload< + pub type FromBridgedChainMessagePayload = bp_message_dispatch::MessagePayload< AccountIdOf>, SignerOf>, SignatureOf>, @@ -504,20 +505,21 @@ pub mod target { /// The `messages_count` argument verification (sane limits) is supposed to be made /// outside of this function. This function only verifies that the proof declares exactly /// `messages_count` messages. - pub fn verify_messages_proof( + pub fn verify_messages_proof( proof: FromBridgedChainMessagesProof>>, messages_count: u32, ) -> Result>>>, &'static str> where - ThisRuntime: pallet_bridge_grandpa::Config, + ThisRuntime: pallet_bridge_grandpa::Config, ThisRuntime: pallet_bridge_messages::Config>>, - HashOf>: Into::BridgedChain>>, + HashOf>: + Into>::BridgedChain>>, { verify_messages_proof_with_parser::( proof, messages_count, |bridged_header_hash, bridged_storage_proof| { - pallet_bridge_grandpa::Pallet::::parse_finalized_storage_proof( + pallet_bridge_grandpa::Pallet::::parse_finalized_storage_proof( bridged_header_hash.into(), StorageProof::new(bridged_storage_proof), |storage_adapter| storage_adapter, @@ -929,7 +931,7 @@ mod tests { let message_on_bridged_chain = source::FromThisChainMessagePayload:: { spec_version: 1, weight: 100, - origin: pallet_bridge_dispatch::CallOrigin::SourceRoot, + origin: bp_message_dispatch::CallOrigin::SourceRoot, call: ThisChainCall::Transfer.encode(), } .encode(); @@ -943,7 +945,7 @@ mod tests { target::FromBridgedChainMessagePayload:: { spec_version: 1, weight: 100, - origin: pallet_bridge_dispatch::CallOrigin::SourceRoot, + origin: bp_message_dispatch::CallOrigin::SourceRoot, call: target::FromBridgedChainEncodedMessageCall:: { encoded_call: ThisChainCall::Transfer.encode(), _marker: PhantomData::default(), @@ -960,7 +962,7 @@ mod tests { source::FromThisChainMessagePayload:: { spec_version: 1, weight: 100, - origin: pallet_bridge_dispatch::CallOrigin::SourceRoot, + origin: bp_message_dispatch::CallOrigin::SourceRoot, call: vec![42], } } @@ -1010,7 +1012,7 @@ mod tests { let payload = source::FromThisChainMessagePayload:: { spec_version: 1, weight: 100, - origin: pallet_bridge_dispatch::CallOrigin::SourceRoot, + origin: bp_message_dispatch::CallOrigin::SourceRoot, call: vec![42], }; @@ -1053,7 +1055,7 @@ mod tests { let payload = source::FromThisChainMessagePayload:: { spec_version: 1, weight: 100, - origin: pallet_bridge_dispatch::CallOrigin::SourceAccount(ThisChainAccountId(1)), + origin: bp_message_dispatch::CallOrigin::SourceAccount(ThisChainAccountId(1)), call: vec![42], }; @@ -1120,7 +1122,7 @@ mod tests { > { spec_version: 1, weight: 5, - origin: pallet_bridge_dispatch::CallOrigin::SourceRoot, + origin: bp_message_dispatch::CallOrigin::SourceRoot, call: vec![1, 2, 3, 4, 5, 6], },) .is_err() @@ -1135,7 +1137,7 @@ mod tests { > { spec_version: 1, weight: BRIDGED_CHAIN_MAX_EXTRINSIC_WEIGHT + 1, - origin: pallet_bridge_dispatch::CallOrigin::SourceRoot, + origin: bp_message_dispatch::CallOrigin::SourceRoot, call: vec![1, 2, 3, 4, 5, 6], },) .is_err() @@ -1150,7 +1152,7 @@ mod tests { > { spec_version: 1, weight: BRIDGED_CHAIN_MAX_EXTRINSIC_WEIGHT, - origin: pallet_bridge_dispatch::CallOrigin::SourceRoot, + origin: bp_message_dispatch::CallOrigin::SourceRoot, call: vec![0; source::maximal_message_size::() as usize + 1], },) .is_err() @@ -1165,7 +1167,7 @@ mod tests { > { spec_version: 1, weight: BRIDGED_CHAIN_MAX_EXTRINSIC_WEIGHT, - origin: pallet_bridge_dispatch::CallOrigin::SourceRoot, + origin: bp_message_dispatch::CallOrigin::SourceRoot, call: vec![0; source::maximal_message_size::() as _], },), Ok(()), @@ -1407,6 +1409,8 @@ mod tests { #[test] fn transaction_payment_works_with_zero_multiplier() { + use sp_runtime::traits::Zero; + assert_eq!( transaction_payment( 100, @@ -1424,6 +1428,8 @@ mod tests { #[test] fn transaction_payment_works_with_non_zero_multiplier() { + use sp_runtime::traits::One; + assert_eq!( transaction_payment( 100, diff --git a/polkadot/deployments/local-scripts/relay-headers-rococo-to-westend.sh b/polkadot/deployments/local-scripts/relay-headers-rococo-to-westend.sh deleted file mode 100755 index d54d16f7e3..0000000000 --- a/polkadot/deployments/local-scripts/relay-headers-rococo-to-westend.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# -# Run an instance of the Rococo -> Westend header sync. -# -# Right now this relies on local Westend and Rococo networks -# running (which include `pallet-bridge-grandpa` in their -# runtimes), but in the future it could use use public RPC nodes. - -set -xeu - -RUST_LOG=rpc=trace,bridge=trace ./target/debug/substrate-relay init-bridge RococoToWestend \ - --source-host 127.0.0.1 \ - --source-port 9955 \ - --target-host 127.0.0.1 \ - --target-port 9944 \ - --target-signer //Eve - -RUST_LOG=rpc=trace,bridge=trace ./target/debug/substrate-relay relay-headers RococoToWestend \ - --source-host 127.0.0.1 \ - --source-port 9955 \ - --target-host 127.0.0.1 \ - --target-port 9944 \ - --target-signer //Bob \ - --prometheus-host=0.0.0.0 \ diff --git a/polkadot/deployments/local-scripts/relay-headers-westend-to-rococo.sh b/polkadot/deployments/local-scripts/relay-headers-westend-to-rococo.sh deleted file mode 100755 index e718656a9d..0000000000 --- a/polkadot/deployments/local-scripts/relay-headers-westend-to-rococo.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# -# Run an instance of the Westend -> Rococo header sync. -# -# Right now this relies on local Westend and Rococo networks -# running (which include `pallet-bridge-grandpa` in their -# runtimes), but in the future it could use use public RPC nodes. - -set -xeu - -RUST_LOG=rpc=trace,bridge=trace ./target/debug/substrate-relay init-bridge WestendToRococo \ - --source-host 127.0.0.1 \ - --source-port 9944 \ - --target-host 127.0.0.1 \ - --target-port 9955 \ - --target-signer //Dave - -RUST_LOG=rpc=trace,bridge=trace ./target/debug/substrate-relay relay-headers WestendToRococo \ - --source-host 127.0.0.1 \ - --source-port 9944 \ - --target-host 127.0.0.1 \ - --target-port 9955 \ - --target-signer //Charlie \ - --prometheus-host=0.0.0.0 \ diff --git a/polkadot/docs/high-level-overview.md b/polkadot/docs/high-level-overview.md index 14b1eee6d4..9ca3ca42ff 100644 --- a/polkadot/docs/high-level-overview.md +++ b/polkadot/docs/high-level-overview.md @@ -172,6 +172,6 @@ source chain needs to prove ownership of this account by using their target chai sign: `(Call, SourceChainAccountId).encode()`. This will be included in the message payload and verified by the target chain before dispatch. -See [`CallOrigin` documentation](../modules/dispatch/src/lib.rs) for more details. +See [`CallOrigin` documentation](../primitives/message-dispatch/src/lib.rs) for more details. #### Message Relayers Strategy diff --git a/polkadot/modules/currency-exchange/src/lib.rs b/polkadot/modules/currency-exchange/src/lib.rs index 542082f85a..9a8af5ba50 100644 --- a/polkadot/modules/currency-exchange/src/lib.rs +++ b/polkadot/modules/currency-exchange/src/lib.rs @@ -70,7 +70,7 @@ decl_error! { InvalidRecipient, /// Cannot map from peer recipient to this blockchain recipient. FailedToMapRecipients, - /// Failed to convert from peer blockchain currency to this blockhain currency. + /// Failed to convert from peer blockchain currency to this blockchain currency. FailedToConvertCurrency, /// Deposit has failed. DepositFailed, diff --git a/polkadot/modules/dispatch/README.md b/polkadot/modules/dispatch/README.md index f2ee04beaf..c4e703c402 100644 --- a/polkadot/modules/dispatch/README.md +++ b/polkadot/modules/dispatch/README.md @@ -13,7 +13,7 @@ Every message that is being dispatched has three main characteristics: - `id` is the unique id of the message within the given bridge. For messages coming from the [messages module](../messages/README.md), it may worth to use a tuple `(LaneId, MessageNonce)` to identify a message; -- `message` is the `pallet_bridge_dispatch::MessagePayload` structure. The `call` field is set +- `message` is the `bp_message_dispatch::MessagePayload` structure. The `call` field is set to the (potentially) encoded `Call` of this chain. The easiest way to understand what is happening when a `Call` is being dispatched, is to look at the @@ -33,7 +33,7 @@ module events set: chain storage has been corrupted. The `Call` is decoded after `spec_version` check, so we'll never try to decode `Call` from other runtime version; - `MessageSignatureMismatch` event is emitted if submitter has chose to dispatch message using - specified this chain account (`pallet_bridge_dispatch::CallOrigin::TargetAccount` origin), + specified this chain account (`bp_message_dispatch::CallOrigin::TargetAccount` origin), but he has failed to prove that he owns the private key for this account; - `MessageCallRejected` event is emitted if the module has been deployed with some call filter and this filter has rejected the `Call`. In your bridge you may choose to reject all messages except diff --git a/polkadot/modules/dispatch/src/lib.rs b/polkadot/modules/dispatch/src/lib.rs index 416d080b0c..0b0074c20b 100644 --- a/polkadot/modules/dispatch/src/lib.rs +++ b/polkadot/modules/dispatch/src/lib.rs @@ -24,8 +24,8 @@ #![cfg_attr(not(feature = "std"), no_std)] #![warn(missing_docs)] -use bp_message_dispatch::{MessageDispatch, Weight}; -use bp_runtime::{derive_account_id, InstanceId, Size, SourceAccount}; +use bp_message_dispatch::{CallOrigin, MessageDispatch, MessagePayload, SpecVersion, Weight}; +use bp_runtime::{derive_account_id, InstanceId, SourceAccount}; use codec::{Decode, Encode}; use frame_support::{ decl_event, decl_module, decl_storage, @@ -33,7 +33,6 @@ use frame_support::{ ensure, traits::{Filter, Get}, weights::{extract_actual_weight, GetDispatchInfo}, - RuntimeDebug, }; use frame_system::RawOrigin; use sp_runtime::{ @@ -42,78 +41,6 @@ use sp_runtime::{ }; use sp_std::{fmt::Debug, marker::PhantomData, prelude::*}; -/// Spec version type. -pub type SpecVersion = u32; - -// TODO [#895] move to primitives -/// Origin of a Call when it is dispatched on the target chain. -/// -/// The source chain can (and should) verify that the message can be dispatched on the target chain -/// with a particular origin given the source chain's origin. This can be done with the -/// `verify_message_origin()` function. -#[derive(RuntimeDebug, Encode, Decode, Clone, PartialEq, Eq)] -pub enum CallOrigin { - /// Call is sent by the Root origin on the source chain. On the target chain it is dispatched - /// from a derived account. - /// - /// The derived account represents the source Root account on the target chain. This is useful - /// if the target chain needs some way of knowing that a call came from a priviledged origin on - /// the source chain (maybe to allow a configuration change for example). - SourceRoot, - - /// Call is sent by `SourceChainAccountId` on the source chain. On the target chain it is - /// dispatched from an account controlled by a private key on the target chain. - /// - /// The account can be identified by `TargetChainAccountPublic`. The proof that the - /// `SourceChainAccountId` controls `TargetChainAccountPublic` is the `TargetChainSignature` - /// over `(Call, SourceChainAccountId, TargetChainSpecVersion, SourceChainBridgeId).encode()`. - /// - /// NOTE sending messages using this origin (or any other) does not have replay protection! - /// The assumption is that both the source account and the target account is controlled by - /// the same entity, so source-chain replay protection is sufficient. - /// As a consequence, it's extremely important for the target chain user to never produce - /// a signature with their target-private key on something that could be sent over the bridge, - /// i.e. if the target user signs `(, Call::Transfer(X, 5))` - /// The owner of `some-source-account-id` can send that message multiple times, which would - /// result with multiple transfer calls being dispatched on the target chain. - /// So please, NEVER USE YOUR PRIVATE KEY TO SIGN SOMETHING YOU DON'T FULLY UNDERSTAND! - TargetAccount(SourceChainAccountId, TargetChainAccountPublic, TargetChainSignature), - - /// Call is sent by the `SourceChainAccountId` on the source chain. On the target chain it is - /// dispatched from a derived account ID. - /// - /// The account ID on the target chain is derived from the source account ID This is useful if - /// you need a way to represent foreign accounts on this chain for call dispatch purposes. - /// - /// Note that the derived account does not need to have a private key on the target chain. This - /// origin can therefore represent proxies, pallets, etc. as well as "regular" accounts. - SourceAccount(SourceChainAccountId), -} - -// TODO [#895] move to primitives -/// Message payload type used by dispatch module. -#[derive(RuntimeDebug, Encode, Decode, Clone, PartialEq, Eq)] -pub struct MessagePayload { - /// Runtime specification version. We only dispatch messages that have the same - /// runtime version. Otherwise we risk to misinterpret encoded calls. - pub spec_version: SpecVersion, - /// Weight of the call, declared by the message sender. If it is less than actual - /// static weight, the call is not dispatched. - pub weight: Weight, - /// Call origin to be used during dispatch. - pub origin: CallOrigin, - /// The call itself. - pub call: Call, -} - -impl Size - for MessagePayload> -{ - fn size_hint(&self) -> u32 { - self.call.len() as _ - } -} - /// The module configuration trait. pub trait Config: frame_system::Config { /// The overarching event type. @@ -314,8 +241,7 @@ impl, I: Instance> MessageDispatch for Pallet { // finally dispatch message let origin = RawOrigin::Signed(origin_account).into(); - - log::trace!(target: "runtime::bridge-dispatch", "Message being dispatched is: {:?}", &call); + log::trace!(target: "runtime::bridge-dispatch", "Message being dispatched is: {:.4096?}", &call); let dispatch_result = call.dispatch(origin); let actual_call_weight = extract_actual_weight(&dispatch_result, &dispatch_info); diff --git a/polkadot/modules/grandpa/src/benchmarking.rs b/polkadot/modules/grandpa/src/benchmarking.rs index cb170fdc8b..b7294e9180 100644 --- a/polkadot/modules/grandpa/src/benchmarking.rs +++ b/polkadot/modules/grandpa/src/benchmarking.rs @@ -51,9 +51,10 @@ use bp_test_utils::{ TEST_GRANDPA_ROUND, TEST_GRANDPA_SET_ID, }; use frame_benchmarking::{benchmarks_instance_pallet, whitelisted_caller}; +use frame_support::traits::Get; use frame_system::RawOrigin; use sp_finality_grandpa::AuthorityId; -use sp_runtime::traits::{One, Zero}; +use sp_runtime::traits::Zero; use sp_std::{vec, vec::Vec}; // The maximum number of vote ancestries to include in a justification. @@ -66,6 +67,14 @@ const MAX_VOTE_ANCESTRIES: u32 = 1000; // number of validators. const MAX_VALIDATOR_SET_SIZE: u32 = 1024; +/// Returns number of first header to be imported. +/// +/// Since we boostrap the pallet with `HeadersToKeep` already imported headers, +/// this function computes the next expected header number to import. +fn header_number, I: 'static, N: From>() -> N { + (T::HeadersToKeep::get() + 1).into() +} + benchmarks_instance_pallet! { // This is the "gold standard" benchmark for this extrinsic, and it's what should be used to // annotate the weight in the pallet. @@ -90,9 +99,9 @@ benchmarks_instance_pallet! { is_halted: false, }; - initialize_bridge::(init_data); - let header: BridgedHeader = bp_test_utils::test_header(One::one()); + bootstrap_bridge::(init_data); + let header: BridgedHeader = bp_test_utils::test_header(header_number::()); let params = JustificationGeneratorParams { header: header.clone(), round: TEST_GRANDPA_ROUND, @@ -106,7 +115,7 @@ benchmarks_instance_pallet! { }: _(RawOrigin::Signed(caller), header, justification) verify { - let header: BridgedHeader = bp_test_utils::test_header(One::one()); + let header: BridgedHeader = bp_test_utils::test_header(header_number::()); let expected_hash = header.hash(); assert_eq!(>::get(), expected_hash); @@ -127,8 +136,8 @@ benchmarks_instance_pallet! { is_halted: false, }; - initialize_bridge::(init_data); - let header: BridgedHeader = bp_test_utils::test_header(One::one()); + bootstrap_bridge::(init_data); + let header: BridgedHeader = bp_test_utils::test_header(header_number::()); let params = JustificationGeneratorParams { header: header.clone(), @@ -143,7 +152,7 @@ benchmarks_instance_pallet! { }: submit_finality_proof(RawOrigin::Signed(caller), header, justification) verify { - let header: BridgedHeader = bp_test_utils::test_header(One::one()); + let header: BridgedHeader = bp_test_utils::test_header(header_number::()); let expected_hash = header.hash(); assert_eq!(>::get(), expected_hash); @@ -170,8 +179,8 @@ benchmarks_instance_pallet! { is_halted: false, }; - initialize_bridge::(init_data); - let header: BridgedHeader = bp_test_utils::test_header(One::one()); + bootstrap_bridge::(init_data); + let header: BridgedHeader = bp_test_utils::test_header(header_number::()); let params = JustificationGeneratorParams { header: header.clone(), @@ -186,7 +195,7 @@ benchmarks_instance_pallet! { }: submit_finality_proof(RawOrigin::Signed(caller), header, justification) verify { - let header: BridgedHeader = bp_test_utils::test_header(One::one()); + let header: BridgedHeader = bp_test_utils::test_header(header_number::()); let expected_hash = header.hash(); assert_eq!(>::get(), expected_hash); diff --git a/polkadot/modules/grandpa/src/lib.rs b/polkadot/modules/grandpa/src/lib.rs index 9fb7372b02..d38f61826f 100644 --- a/polkadot/modules/grandpa/src/lib.rs +++ b/polkadot/modules/grandpa/src/lib.rs @@ -42,7 +42,7 @@ use bp_header_chain::justification::GrandpaJustification; use bp_header_chain::InitializationData; use bp_runtime::{BlockNumberOf, Chain, HashOf, HasherOf, HeaderOf}; use finality_grandpa::voter_set::VoterSet; -use frame_support::ensure; +use frame_support::{ensure, fail}; use frame_system::{ensure_signed, RawOrigin}; use sp_finality_grandpa::{ConsensusLog, GRANDPA_ENGINE_ID}; use sp_runtime::traits::{BadOrigin, Header as HeaderT, Zero}; @@ -143,11 +143,17 @@ pub mod pallet { let (hash, number) = (finality_target.hash(), finality_target.number()); log::trace!(target: "runtime::bridge-grandpa", "Going to try and finalize header {:?}", finality_target); - let best_finalized = >::get(>::get()).expect( - "In order to reach this point the bridge must have been initialized. Afterwards, - every time `BestFinalized` is updated `ImportedHeaders` is also updated. Therefore - `ImportedHeaders` must contain an entry for `BestFinalized`.", - ); + let best_finalized = match >::get(>::get()) { + Some(best_finalized) => best_finalized, + None => { + log::error!( + target: "runtime::bridge-grandpa", + "Cannot finalize header {:?} because pallet is not yet initialized", + finality_target, + ); + fail!(>::NotInitialized); + } + }; // We do a quick check here to ensure that our header chain is making progress and isn't // "travelling back in time" (which could be indicative of something bad, e.g a hard-fork). @@ -158,20 +164,8 @@ pub mod pallet { verify_justification::(&justification, hash, *number, authority_set)?; let _enacted = try_enact_authority_change::(&finality_target, set_id)?; - let index = >::get(); - let pruning = >::try_get(index); - >::put(hash); - >::insert(hash, finality_target); - >::insert(index, hash); >::mutate(|count| *count += 1); - - // Update ring buffer pointer and remove old header. - >::put((index + 1) % T::HeadersToKeep::get()); - if let Ok(hash) = pruning { - log::debug!(target: "runtime::bridge-grandpa", "Pruning old header: {:?}.", hash); - >::remove(hash); - } - + insert_header::(finality_target, hash); log::info!(target: "runtime::bridge-grandpa", "Succesfully imported finalized header with hash {:?}!", hash); Ok(().into()) @@ -346,6 +340,8 @@ pub mod pallet { /// /// This is the case for non-standard (e.g forced) authority set changes. UnsupportedScheduledChange, + /// The pallet is not yet initialized. + NotInitialized, /// The pallet has already been initialized. AlreadyInitialized, /// All pallet operations are halted. @@ -427,6 +423,25 @@ pub mod pallet { ) } + /// Import a previously verified header to the storage. + /// + /// Note this function solely takes care of updating the storage and pruning old entries, + /// but does not verify the validaty of such import. + pub(crate) fn insert_header, I: 'static>(header: BridgedHeader, hash: BridgedBlockHash) { + let index = >::get(); + let pruning = >::try_get(index); + >::put(hash); + >::insert(hash, header); + >::insert(index, hash); + + // Update ring buffer pointer and remove old header. + >::put((index + 1) % T::HeadersToKeep::get()); + if let Ok(hash) = pruning { + log::debug!(target: "runtime::bridge-grandpa", "Pruning old header: {:?}.", hash); + >::remove(hash); + } + } + /// Since this writes to storage with no real checks this should only be used in functions that /// were called by a trusted origin. pub(crate) fn initialize_bridge, I: 'static>( @@ -441,8 +456,8 @@ pub mod pallet { let initial_hash = header.hash(); >::put(initial_hash); - >::put(initial_hash); - >::insert(initial_hash, header); + >::put(0); + insert_header::(header, initial_hash); let authority_set = bp_header_chain::AuthoritySet::new(authority_list, set_id); >::put(authority_set); @@ -450,6 +465,29 @@ pub mod pallet { >::put(is_halted); } + #[cfg(feature = "runtime-benchmarks")] + pub(crate) fn bootstrap_bridge, I: 'static>( + init_params: super::InitializationData>, + ) { + let start_number = *init_params.header.number(); + let end_number = start_number + T::HeadersToKeep::get().into(); + initialize_bridge::(init_params); + + let mut number = start_number; + while number < end_number { + number = number + sp_runtime::traits::One::one(); + let header = >::new( + number, + Default::default(), + Default::default(), + Default::default(), + Default::default(), + ); + let hash = header.hash(); + insert_header::(header, hash); + } + } + /// Ensure that the origin is either root, or `PalletOwner`. fn ensure_owner_or_root, I: 'static>(origin: T::Origin) -> Result<(), BadOrigin> { match origin.into() { @@ -737,6 +775,13 @@ mod tests { }) } + #[test] + fn pallet_rejects_header_if_not_initialized_yet() { + run_test(|| { + assert_noop!(submit_finality_proof(1), Error::::NotInitialized); + }); + } + #[test] fn succesfully_imports_header_with_valid_finality() { run_test(|| { diff --git a/polkadot/modules/grandpa/src/weights.rs b/polkadot/modules/grandpa/src/weights.rs index a548534a20..9e7c2ebc08 100644 --- a/polkadot/modules/grandpa/src/weights.rs +++ b/polkadot/modules/grandpa/src/weights.rs @@ -17,7 +17,7 @@ //! Autogenerated weights for pallet_bridge_grandpa //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-04-14, STEPS: [50, ], REPEAT: 20 +//! DATE: 2021-04-21, STEPS: [50, ], REPEAT: 20 //! LOW RANGE: [], HIGH RANGE: [] //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled //! CHAIN: Some("dev"), DB CACHE: 128 @@ -60,29 +60,29 @@ pub struct RialtoWeight(PhantomData); impl WeightInfo for RialtoWeight { fn submit_finality_proof(v: u32, p: u32) -> Weight { (0 as Weight) - .saturating_add((837_084_000 as Weight).saturating_mul(v as Weight)) - .saturating_add((874_929_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((756_462_000 as Weight).saturating_mul(v as Weight)) + .saturating_add((791_236_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(6 as Weight)) } fn submit_finality_proof_on_single_fork(v: u32) -> Weight { - (276_463_000 as Weight) - .saturating_add((14_149_000 as Weight).saturating_mul(v as Weight)) + (280_121_000 as Weight) + .saturating_add((14_098_000 as Weight).saturating_mul(v as Weight)) .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(6 as Weight)) } fn submit_finality_proof_on_many_forks(p: u32) -> Weight { - (10_676_019_000 as Weight) - .saturating_add((97_598_000 as Weight).saturating_mul(p as Weight)) + (10_370_940_000 as Weight) + .saturating_add((96_902_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(6 as Weight)) } fn find_scheduled_change(n: u32) -> Weight { - (618_000 as Weight).saturating_add((8_000 as Weight).saturating_mul(n as Weight)) + (479_000 as Weight).saturating_add((11_000 as Weight).saturating_mul(n as Weight)) } fn read_write_authority_sets(n: u32) -> Weight { - (8_582_000 as Weight) - .saturating_add((234_000 as Weight).saturating_mul(n as Weight)) + (8_030_000 as Weight) + .saturating_add((232_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -92,29 +92,29 @@ impl WeightInfo for RialtoWeight { impl WeightInfo for () { fn submit_finality_proof(v: u32, p: u32) -> Weight { (0 as Weight) - .saturating_add((837_084_000 as Weight).saturating_mul(v as Weight)) - .saturating_add((874_929_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((756_462_000 as Weight).saturating_mul(v as Weight)) + .saturating_add((791_236_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + .saturating_add(RocksDbWeight::get().writes(6 as Weight)) } fn submit_finality_proof_on_single_fork(v: u32) -> Weight { - (276_463_000 as Weight) - .saturating_add((14_149_000 as Weight).saturating_mul(v as Weight)) + (280_121_000 as Weight) + .saturating_add((14_098_000 as Weight).saturating_mul(v as Weight)) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + .saturating_add(RocksDbWeight::get().writes(6 as Weight)) } fn submit_finality_proof_on_many_forks(p: u32) -> Weight { - (10_676_019_000 as Weight) - .saturating_add((97_598_000 as Weight).saturating_mul(p as Weight)) + (10_370_940_000 as Weight) + .saturating_add((96_902_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + .saturating_add(RocksDbWeight::get().writes(6 as Weight)) } fn find_scheduled_change(n: u32) -> Weight { - (618_000 as Weight).saturating_add((8_000 as Weight).saturating_mul(n as Weight)) + (479_000 as Weight).saturating_add((11_000 as Weight).saturating_mul(n as Weight)) } fn read_write_authority_sets(n: u32) -> Weight { - (8_582_000 as Weight) - .saturating_add((234_000 as Weight).saturating_mul(n as Weight)) + (8_030_000 as Weight) + .saturating_add((232_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } diff --git a/polkadot/modules/messages/src/weights.rs b/polkadot/modules/messages/src/weights.rs index 0eecd0d846..f86a21e3ed 100644 --- a/polkadot/modules/messages/src/weights.rs +++ b/polkadot/modules/messages/src/weights.rs @@ -17,7 +17,7 @@ //! Autogenerated weights for pallet_bridge_messages //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-04-14, STEPS: [50, ], REPEAT: 20 +//! DATE: 2021-04-21, STEPS: [50, ], REPEAT: 20 //! LOW RANGE: [], HIGH RANGE: [] //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled //! CHAIN: Some("dev"), DB CACHE: 128 @@ -73,105 +73,105 @@ pub trait WeightInfo { pub struct RialtoWeight(PhantomData); impl WeightInfo for RialtoWeight { fn send_minimal_message_worst_case() -> Weight { - (149_497_000 as Weight) + (149_643_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(12 as Weight)) } fn send_1_kb_message_worst_case() -> Weight { - (154_339_000 as Weight) + (153_329_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(12 as Weight)) } fn send_16_kb_message_worst_case() -> Weight { - (200_066_000 as Weight) + (200_113_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(12 as Weight)) } fn increase_message_fee() -> Weight { - (6_432_637_000 as Weight) + (6_407_252_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn receive_single_message_proof() -> Weight { - (141_671_000 as Weight) + (141_256_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn receive_two_messages_proof() -> Weight { - (247_393_000 as Weight) + (247_723_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn receive_single_message_proof_with_outbound_lane_state() -> Weight { - (159_312_000 as Weight) + (159_731_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn receive_single_message_proof_1_kb() -> Weight { - (167_935_000 as Weight) + (168_546_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn receive_single_message_proof_16_kb() -> Weight { - (449_846_000 as Weight) + (450_087_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn receive_delivery_proof_for_single_message() -> Weight { - (127_322_000 as Weight) + (164_519_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight { - (134_120_000 as Weight) + (173_300_000 as Weight) .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight { - (191_193_000 as Weight) + (246_205_000 as Weight) .saturating_add(T::DbWeight::get().reads(8 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } fn send_messages_of_various_lengths(i: u32) -> Weight { - (115_699_000 as Weight) + (149_551_000 as Weight) .saturating_add((3_000 as Weight).saturating_mul(i as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(12 as Weight)) } fn receive_multiple_messages_proof(i: u32) -> Weight { (0 as Weight) - .saturating_add((113_551_000 as Weight).saturating_mul(i as Weight)) + .saturating_add((114_817_000 as Weight).saturating_mul(i as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn receive_message_proofs_with_extra_nodes(i: u32) -> Weight { - (458_731_000 as Weight) - .saturating_add((9_000 as Weight).saturating_mul(i as Weight)) + (437_797_000 as Weight) + .saturating_add((10_000 as Weight).saturating_mul(i as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn receive_message_proofs_with_large_leaf(i: u32) -> Weight { - (82_314_000 as Weight) + (137_633_000 as Weight) .saturating_add((7_000 as Weight).saturating_mul(i as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn receive_multiple_messages_proof_with_outbound_lane_state(i: u32) -> Weight { - (16_766_000 as Weight) - .saturating_add((115_533_000 as Weight).saturating_mul(i as Weight)) + (0 as Weight) + .saturating_add((118_482_000 as Weight).saturating_mul(i as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn receive_delivery_proof_for_multiple_messages_by_single_relayer(i: u32) -> Weight { - (122_146_000 as Weight) - .saturating_add((6_789_000 as Weight).saturating_mul(i as Weight)) + (116_036_000 as Weight) + .saturating_add((7_118_000 as Weight).saturating_mul(i as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(i as Weight))) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn receive_delivery_proof_for_multiple_messages_by_multiple_relayers(i: u32) -> Weight { - (155_671_000 as Weight) - .saturating_add((63_020_000 as Weight).saturating_mul(i as Weight)) + (172_780_000 as Weight) + .saturating_add((63_718_000 as Weight).saturating_mul(i as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(i as Weight))) .saturating_add(T::DbWeight::get().writes(3 as Weight)) @@ -182,105 +182,105 @@ impl WeightInfo for RialtoWeight { // For backwards compatibility and tests impl WeightInfo for () { fn send_minimal_message_worst_case() -> Weight { - (149_497_000 as Weight) + (149_643_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(12 as Weight)) } fn send_1_kb_message_worst_case() -> Weight { - (154_339_000 as Weight) + (153_329_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(12 as Weight)) } fn send_16_kb_message_worst_case() -> Weight { - (200_066_000 as Weight) + (200_113_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(12 as Weight)) } fn increase_message_fee() -> Weight { - (6_432_637_000 as Weight) + (6_407_252_000 as Weight) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn receive_single_message_proof() -> Weight { - (141_671_000 as Weight) + (141_256_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn receive_two_messages_proof() -> Weight { - (247_393_000 as Weight) + (247_723_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn receive_single_message_proof_with_outbound_lane_state() -> Weight { - (159_312_000 as Weight) + (159_731_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn receive_single_message_proof_1_kb() -> Weight { - (167_935_000 as Weight) + (168_546_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn receive_single_message_proof_16_kb() -> Weight { - (449_846_000 as Weight) + (450_087_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn receive_delivery_proof_for_single_message() -> Weight { - (127_322_000 as Weight) + (164_519_000 as Weight) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight { - (134_120_000 as Weight) + (173_300_000 as Weight) .saturating_add(RocksDbWeight::get().reads(7 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight { - (191_193_000 as Weight) + (246_205_000 as Weight) .saturating_add(RocksDbWeight::get().reads(8 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } fn send_messages_of_various_lengths(i: u32) -> Weight { - (115_699_000 as Weight) + (149_551_000 as Weight) .saturating_add((3_000 as Weight).saturating_mul(i as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(12 as Weight)) } fn receive_multiple_messages_proof(i: u32) -> Weight { (0 as Weight) - .saturating_add((113_551_000 as Weight).saturating_mul(i as Weight)) + .saturating_add((114_817_000 as Weight).saturating_mul(i as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn receive_message_proofs_with_extra_nodes(i: u32) -> Weight { - (458_731_000 as Weight) - .saturating_add((9_000 as Weight).saturating_mul(i as Weight)) + (437_797_000 as Weight) + .saturating_add((10_000 as Weight).saturating_mul(i as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn receive_message_proofs_with_large_leaf(i: u32) -> Weight { - (82_314_000 as Weight) + (137_633_000 as Weight) .saturating_add((7_000 as Weight).saturating_mul(i as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn receive_multiple_messages_proof_with_outbound_lane_state(i: u32) -> Weight { - (16_766_000 as Weight) - .saturating_add((115_533_000 as Weight).saturating_mul(i as Weight)) + (0 as Weight) + .saturating_add((118_482_000 as Weight).saturating_mul(i as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn receive_delivery_proof_for_multiple_messages_by_single_relayer(i: u32) -> Weight { - (122_146_000 as Weight) - .saturating_add((6_789_000 as Weight).saturating_mul(i as Weight)) + (116_036_000 as Weight) + .saturating_add((7_118_000 as Weight).saturating_mul(i as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(i as Weight))) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn receive_delivery_proof_for_multiple_messages_by_multiple_relayers(i: u32) -> Weight { - (155_671_000 as Weight) - .saturating_add((63_020_000 as Weight).saturating_mul(i as Weight)) + (172_780_000 as Weight) + .saturating_add((63_718_000 as Weight).saturating_mul(i as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(i as Weight))) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) diff --git a/polkadot/primitives/chain-millau/src/lib.rs b/polkadot/primitives/chain-millau/src/lib.rs index 22f09cb5b0..a5f3a888f9 100644 --- a/polkadot/primitives/chain-millau/src/lib.rs +++ b/polkadot/primitives/chain-millau/src/lib.rs @@ -259,31 +259,6 @@ pub const FROM_MILLAU_LATEST_CONFIRMED_NONCE_METHOD: &str = "FromMillauInboundLa pub const FROM_MILLAU_UNREWARDED_RELAYERS_STATE: &str = "FromMillauInboundLaneApi_unrewarded_relayers_state"; sp_api::decl_runtime_apis! { - /// API for querying information about Millau headers from the Bridge Pallet instance. - /// - /// This API is implemented by runtimes that are bridging with the Millau chain, not the - /// Millau runtime itself. - pub trait MillauHeaderApi { - /// Returns number and hash of the best blocks known to the bridge module. - /// - /// Will return multiple headers if there are many headers at the same "best" height. - /// - /// The caller should only submit an `import_header` transaction that makes - /// (or leads to making) other header the best one. - fn best_blocks() -> Vec<(BlockNumber, Hash)>; - /// Returns number and hash of the best finalized block known to the bridge module. - fn finalized_block() -> (BlockNumber, Hash); - /// Returns numbers and hashes of headers that require finality proofs. - /// - /// An empty response means that there are no headers which currently require a - /// finality proof. - fn incomplete_headers() -> Vec<(BlockNumber, Hash)>; - /// Returns true if the header is known to the runtime. - fn is_known_block(hash: Hash) -> bool; - /// Returns true if the header is considered finalized by the runtime. - fn is_finalized_block(hash: Hash) -> bool; - } - /// API for querying information about the finalized Millau headers. /// /// This API is implemented by runtimes that are bridging with the Millau chain, not the diff --git a/polkadot/primitives/chain-rialto/src/lib.rs b/polkadot/primitives/chain-rialto/src/lib.rs index c10f31bae3..c063dc72a7 100644 --- a/polkadot/primitives/chain-rialto/src/lib.rs +++ b/polkadot/primitives/chain-rialto/src/lib.rs @@ -220,31 +220,6 @@ pub const FROM_RIALTO_LATEST_CONFIRMED_NONCE_METHOD: &str = "FromRialtoInboundLa pub const FROM_RIALTO_UNREWARDED_RELAYERS_STATE: &str = "FromRialtoInboundLaneApi_unrewarded_relayers_state"; sp_api::decl_runtime_apis! { - /// API for querying information about Rialto headers from the Bridge Pallet instance. - /// - /// This API is implemented by runtimes that are bridging with the Rialto chain, not the - /// Rialto runtime itself. - pub trait RialtoHeaderApi { - /// Returns number and hash of the best blocks known to the bridge module. - /// - /// Will return multiple headers if there are many headers at the same "best" height. - /// - /// The caller should only submit an `import_header` transaction that makes - /// (or leads to making) other header the best one. - fn best_blocks() -> Vec<(BlockNumber, Hash)>; - /// Returns number and hash of the best finalized block known to the bridge module. - fn finalized_block() -> (BlockNumber, Hash); - /// Returns numbers and hashes of headers that require finality proofs. - /// - /// An empty response means that there are no headers which currently require a - /// finality proof. - fn incomplete_headers() -> Vec<(BlockNumber, Hash)>; - /// Returns true if the header is known to the runtime. - fn is_known_block(hash: Hash) -> bool; - /// Returns true if the header is considered finalized by the runtime. - fn is_finalized_block(hash: Hash) -> bool; - } - /// API for querying information about the finalized Rialto headers. /// /// This API is implemented by runtimes that are bridging with the Rialto chain, not the diff --git a/polkadot/primitives/chain-rococo/src/lib.rs b/polkadot/primitives/chain-rococo/src/lib.rs index b79fdf6cfc..66cbb475bd 100644 --- a/polkadot/primitives/chain-rococo/src/lib.rs +++ b/polkadot/primitives/chain-rococo/src/lib.rs @@ -37,7 +37,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: sp_version::create_runtime_str!("rococo"), impl_name: sp_version::create_runtime_str!("parity-rococo-v1.5"), authoring_version: 0, - spec_version: 231, + spec_version: 232, impl_version: 0, apis: sp_version::create_apis_vec![[]], transaction_version: 0, @@ -55,14 +55,14 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { /// See: https://github.com/paritytech/polkadot/blob/master/runtime/rococo/src/lib.rs #[derive(parity_scale_codec::Encode, parity_scale_codec::Decode, Debug, PartialEq, Eq, Clone)] pub enum Call { - /// Westend bridge pallet. - #[codec(index = 40)] - BridgeGrandpaWestend(BridgeGrandpaWestendCall), + /// Wococo bridge pallet. + #[codec(index = 41)] + BridgeGrandpaWococo(BridgeGrandpaWococoCall), } #[derive(parity_scale_codec::Encode, parity_scale_codec::Decode, Debug, PartialEq, Eq, Clone)] #[allow(non_camel_case_types)] -pub enum BridgeGrandpaWestendCall { +pub enum BridgeGrandpaWococoCall { #[codec(index = 0)] submit_finality_proof( ::Header, @@ -83,13 +83,6 @@ impl sp_runtime::traits::Dispatchable for Call { } } -// We use this to get the account on Rococo (target) which is derived from Westend's (source) -// account. -pub fn derive_account_from_westend_id(id: bp_runtime::SourceAccount) -> AccountId { - let encoded_id = bp_runtime::derive_account_id(bp_runtime::WESTEND_BRIDGE_INSTANCE, id); - AccountIdConverter::convert(encoded_id) -} - /// Name of the `RococoFinalityApi::best_finalized` runtime method. pub const BEST_FINALIZED_ROCOCO_HEADER_METHOD: &str = "RococoFinalityApi_best_finalized"; /// Name of the `RococoFinalityApi::is_known_header` runtime method. diff --git a/polkadot/primitives/chain-wococo/Cargo.toml b/polkadot/primitives/chain-wococo/Cargo.toml new file mode 100644 index 0000000000..ecf783a51e --- /dev/null +++ b/polkadot/primitives/chain-wococo/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "bp-wococo" +description = "Primitives of Wococo runtime." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +parity-scale-codec = { version = "2.0.0", default-features = false, features = ["derive"] } + +# Bridge Dependencies +bp-header-chain = { path = "../header-chain", default-features = false } +bp-messages = { path = "../messages", default-features = false } +bp-polkadot-core = { path = "../polkadot-core", default-features = false } +bp-runtime = { path = "../runtime", default-features = false } + +# Substrate Based Dependencies +sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[features] +default = ["std"] +std = [ + "bp-header-chain/std", + "bp-messages/std", + "bp-polkadot-core/std", + "bp-runtime/std", + "parity-scale-codec/std", + "sp-api/std", + "sp-runtime/std", + "sp-std/std", + "sp-version/std", +] diff --git a/polkadot/primitives/chain-wococo/src/lib.rs b/polkadot/primitives/chain-wococo/src/lib.rs new file mode 100644 index 0000000000..f7a472ddf3 --- /dev/null +++ b/polkadot/primitives/chain-wococo/src/lib.rs @@ -0,0 +1,172 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +#![cfg_attr(not(feature = "std"), no_std)] +// RuntimeApi generated functions +#![allow(clippy::too_many_arguments)] +// Runtime-generated DecodeLimit::decode_all_with_depth_limit +#![allow(clippy::unnecessary_mut_passed)] + +use bp_messages::{LaneId, MessageNonce, UnrewardedRelayersState, Weight}; +use bp_runtime::Chain; +use sp_std::prelude::*; +use sp_version::RuntimeVersion; + +pub use bp_polkadot_core::*; + +/// Wococo Chain +pub type Wococo = PolkadotLike; + +pub type UncheckedExtrinsic = bp_polkadot_core::UncheckedExtrinsic; + +// NOTE: This needs to be kept up to date with the Rococo runtime found in the Polkadot repo. +pub const VERSION: RuntimeVersion = RuntimeVersion { + spec_name: sp_version::create_runtime_str!("rococo"), + impl_name: sp_version::create_runtime_str!("parity-rococo-v1.5"), + authoring_version: 0, + spec_version: 232, + impl_version: 0, + apis: sp_version::create_apis_vec![[]], + transaction_version: 0, +}; + +/// Wococo Runtime `Call` enum. +/// +/// The enum represents a subset of possible `Call`s we can send to Rococo chain. +/// Ideally this code would be auto-generated from Metadata, because we want to +/// avoid depending directly on the ENTIRE runtime just to get the encoding of `Dispatchable`s. +/// +/// All entries here (like pretty much in the entire file) must be kept in sync with Rococo +/// `construct_runtime`, so that we maintain SCALE-compatibility. +/// +/// See: https://github.com/paritytech/polkadot/blob/master/runtime/rococo/src/lib.rs +#[derive(parity_scale_codec::Encode, parity_scale_codec::Decode, Debug, PartialEq, Eq, Clone)] +pub enum Call { + /// Rococo bridge pallet. + #[codec(index = 40)] + BridgeGrandpaRococo(BridgeGrandpaRococoCall), +} + +#[derive(parity_scale_codec::Encode, parity_scale_codec::Decode, Debug, PartialEq, Eq, Clone)] +#[allow(non_camel_case_types)] +pub enum BridgeGrandpaRococoCall { + #[codec(index = 0)] + submit_finality_proof( + ::Header, + bp_header_chain::justification::GrandpaJustification<::Header>, + ), + #[codec(index = 1)] + initialize(bp_header_chain::InitializationData<::Header>), +} + +impl sp_runtime::traits::Dispatchable for Call { + type Origin = (); + type Config = (); + type Info = (); + type PostInfo = (); + + fn dispatch(self, _origin: Self::Origin) -> sp_runtime::DispatchResultWithInfo { + unimplemented!("The Call is not expected to be dispatched.") + } +} + +// We use this to get the account on Wococo (target) which is derived from Rococo's (source) +// account. +pub fn derive_account_from_rococo_id(id: bp_runtime::SourceAccount) -> AccountId { + let encoded_id = bp_runtime::derive_account_id(bp_runtime::ROCOCO_BRIDGE_INSTANCE, id); + AccountIdConverter::convert(encoded_id) +} + +/// Name of the `WococoFinalityApi::best_finalized` runtime method. +pub const BEST_FINALIZED_WOCOCO_HEADER_METHOD: &str = "WococoFinalityApi_best_finalized"; +/// Name of the `WococoFinalityApi::is_known_header` runtime method. +pub const IS_KNOWN_WOCOCO_HEADER_METHOD: &str = "WococoFinalityApi_is_known_header"; + +/// Name of the `ToWococoOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime method. +pub const TO_WOCOCO_ESTIMATE_MESSAGE_FEE_METHOD: &str = + "ToWococoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee"; +/// Name of the `ToWococoOutboundLaneApi::messages_dispatch_weight` runtime method. +pub const TO_WOCOCO_MESSAGES_DISPATCH_WEIGHT_METHOD: &str = "ToWococoOutboundLaneApi_messages_dispatch_weight"; +/// Name of the `ToWococoOutboundLaneApi::latest_generated_nonce` runtime method. +pub const TO_WOCOCO_LATEST_GENERATED_NONCE_METHOD: &str = "ToWococoOutboundLaneApi_latest_generated_nonce"; +/// Name of the `ToWococoOutboundLaneApi::latest_received_nonce` runtime method. +pub const TO_WOCOCO_LATEST_RECEIVED_NONCE_METHOD: &str = "ToWococoOutboundLaneApi_latest_received_nonce"; + +/// Name of the `FromWococoInboundLaneApi::latest_received_nonce` runtime method. +pub const FROM_WOCOCO_LATEST_RECEIVED_NONCE_METHOD: &str = "FromWococoInboundLaneApi_latest_received_nonce"; +/// Name of the `FromWococoInboundLaneApi::latest_onfirmed_nonce` runtime method. +pub const FROM_WOCOCO_LATEST_CONFIRMED_NONCE_METHOD: &str = "FromWococoInboundLaneApi_latest_confirmed_nonce"; +/// Name of the `FromWococoInboundLaneApi::unrewarded_relayers_state` runtime method. +pub const FROM_WOCOCO_UNREWARDED_RELAYERS_STATE: &str = "FromWococoInboundLaneApi_unrewarded_relayers_state"; + +sp_api::decl_runtime_apis! { + /// API for querying information about the finalized Wococo headers. + /// + /// This API is implemented by runtimes that are bridging with the Wococo chain, not the + /// Wococo runtime itself. + pub trait WococoFinalityApi { + /// Returns number and hash of the best finalized header known to the bridge module. + fn best_finalized() -> (BlockNumber, Hash); + /// Returns true if the header is known to the runtime. + fn is_known_header(hash: Hash) -> bool; + } + + /// Outbound message lane API for messages that are sent to Wococo chain. + /// + /// This API is implemented by runtimes that are sending messages to Wococo chain, not the + /// Wococo runtime itself. + pub trait ToWococoOutboundLaneApi { + /// Estimate message delivery and dispatch fee that needs to be paid by the sender on + /// this chain. + /// + /// Returns `None` if message is too expensive to be sent to Wococo from this chain. + /// + /// Please keep in mind that this method returns lowest message fee required for message + /// to be accepted to the lane. It may be good idea to pay a bit over this price to account + /// future exchange rate changes and guarantee that relayer would deliver your message + /// to the target chain. + fn estimate_message_delivery_and_dispatch_fee( + lane_id: LaneId, + payload: OutboundPayload, + ) -> Option; + /// Returns total dispatch weight and encoded payload size of all messages in given inclusive range. + /// + /// If some (or all) messages are missing from the storage, they'll also will + /// be missing from the resulting vector. The vector is ordered by the nonce. + fn messages_dispatch_weight( + lane: LaneId, + begin: MessageNonce, + end: MessageNonce, + ) -> Vec<(MessageNonce, Weight, u32)>; + /// Returns nonce of the latest message, received by bridged chain. + fn latest_received_nonce(lane: LaneId) -> MessageNonce; + /// Returns nonce of the latest message, generated by given lane. + fn latest_generated_nonce(lane: LaneId) -> MessageNonce; + } + + /// Inbound message lane API for messages sent by Wococo chain. + /// + /// This API is implemented by runtimes that are receiving messages from Wococo chain, not the + /// Wococo runtime itself. + pub trait FromWococoInboundLaneApi { + /// Returns nonce of the latest message, received by given lane. + fn latest_received_nonce(lane: LaneId) -> MessageNonce; + /// Nonce of latest message that has been confirmed to the bridged chain. + fn latest_confirmed_nonce(lane: LaneId) -> MessageNonce; + /// State of the unrewarded relayers set at given lane. + fn unrewarded_relayers_state(lane: LaneId) -> UnrewardedRelayersState; + } +} diff --git a/polkadot/primitives/message-dispatch/Cargo.toml b/polkadot/primitives/message-dispatch/Cargo.toml index 293c637e8d..84fa48553a 100644 --- a/polkadot/primitives/message-dispatch/Cargo.toml +++ b/polkadot/primitives/message-dispatch/Cargo.toml @@ -10,9 +10,16 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" bp-runtime = { path = "../runtime", default-features = false } codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false } +# Substrate Dependencies + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } + [features] default = ["std"] std = [ "bp-runtime/std", "codec/std", + "frame-support/std", + "sp-std/std", ] diff --git a/polkadot/primitives/message-dispatch/src/lib.rs b/polkadot/primitives/message-dispatch/src/lib.rs index 3b83e38517..1244371239 100644 --- a/polkadot/primitives/message-dispatch/src/lib.rs +++ b/polkadot/primitives/message-dispatch/src/lib.rs @@ -19,11 +19,17 @@ #![cfg_attr(not(feature = "std"), no_std)] #![warn(missing_docs)] -use bp_runtime::InstanceId; +use bp_runtime::{InstanceId, Size}; +use codec::{Decode, Encode}; +use frame_support::RuntimeDebug; +use sp_std::prelude::*; /// Message dispatch weight. pub type Weight = u64; +/// Spec version type. +pub type SpecVersion = u32; + /// A generic trait to dispatch arbitrary messages delivered over the bridge. pub trait MessageDispatch { /// A type of the message to be dispatched. @@ -47,3 +53,70 @@ pub trait MessageDispatch { /// the whole message). fn dispatch(bridge: InstanceId, id: MessageId, message: Result); } + +/// Origin of a Call when it is dispatched on the target chain. +/// +/// The source chain can (and should) verify that the message can be dispatched on the target chain +/// with a particular origin given the source chain's origin. This can be done with the +/// `verify_message_origin()` function. +#[derive(RuntimeDebug, Encode, Decode, Clone, PartialEq, Eq)] +pub enum CallOrigin { + /// Call is sent by the Root origin on the source chain. On the target chain it is dispatched + /// from a derived account. + /// + /// The derived account represents the source Root account on the target chain. This is useful + /// if the target chain needs some way of knowing that a call came from a priviledged origin on + /// the source chain (maybe to allow a configuration change for example). + SourceRoot, + + /// Call is sent by `SourceChainAccountId` on the source chain. On the target chain it is + /// dispatched from an account controlled by a private key on the target chain. + /// + /// The account can be identified by `TargetChainAccountPublic`. The proof that the + /// `SourceChainAccountId` controls `TargetChainAccountPublic` is the `TargetChainSignature` + /// over `(Call, SourceChainAccountId, TargetChainSpecVersion, SourceChainBridgeId).encode()`. + /// + /// NOTE sending messages using this origin (or any other) does not have replay protection! + /// The assumption is that both the source account and the target account is controlled by + /// the same entity, so source-chain replay protection is sufficient. + /// As a consequence, it's extremely important for the target chain user to never produce + /// a signature with their target-private key on something that could be sent over the bridge, + /// i.e. if the target user signs `(, Call::Transfer(X, 5))` + /// The owner of `some-source-account-id` can send that message multiple times, which would + /// result with multiple transfer calls being dispatched on the target chain. + /// So please, NEVER USE YOUR PRIVATE KEY TO SIGN SOMETHING YOU DON'T FULLY UNDERSTAND! + TargetAccount(SourceChainAccountId, TargetChainAccountPublic, TargetChainSignature), + + /// Call is sent by the `SourceChainAccountId` on the source chain. On the target chain it is + /// dispatched from a derived account ID. + /// + /// The account ID on the target chain is derived from the source account ID This is useful if + /// you need a way to represent foreign accounts on this chain for call dispatch purposes. + /// + /// Note that the derived account does not need to have a private key on the target chain. This + /// origin can therefore represent proxies, pallets, etc. as well as "regular" accounts. + SourceAccount(SourceChainAccountId), +} + +/// Message payload type used by dispatch module. +#[derive(RuntimeDebug, Encode, Decode, Clone, PartialEq, Eq)] +pub struct MessagePayload { + /// Runtime specification version. We only dispatch messages that have the same + /// runtime version. Otherwise we risk to misinterpret encoded calls. + pub spec_version: SpecVersion, + /// Weight of the call, declared by the message sender. If it is less than actual + /// static weight, the call is not dispatched. + pub weight: Weight, + /// Call origin to be used during dispatch. + pub origin: CallOrigin, + /// The call itself. + pub call: Call, +} + +impl Size + for MessagePayload> +{ + fn size_hint(&self) -> u32 { + self.call.len() as _ + } +} diff --git a/polkadot/primitives/runtime/src/lib.rs b/polkadot/primitives/runtime/src/lib.rs index e7f990d283..aa457f1d0b 100644 --- a/polkadot/primitives/runtime/src/lib.rs +++ b/polkadot/primitives/runtime/src/lib.rs @@ -50,8 +50,8 @@ pub const KUSAMA_BRIDGE_INSTANCE: InstanceId = *b"ksma"; /// Bridge-with-Rococo instance id. pub const ROCOCO_BRIDGE_INSTANCE: InstanceId = *b"roco"; -/// Bridge-with-Westend instance id. -pub const WESTEND_BRIDGE_INSTANCE: InstanceId = *b"wend"; +/// Bridge-with-Wococo instance id. +pub const WOCOCO_BRIDGE_INSTANCE: InstanceId = *b"woco"; /// Call-dispatch module prefix. pub const CALL_DISPATCH_MODULE_PREFIX: &[u8] = b"pallet-bridge/dispatch"; diff --git a/polkadot/relays/bin-substrate/Cargo.toml b/polkadot/relays/bin-substrate/Cargo.toml index d203201e60..fc61d138fd 100644 --- a/polkadot/relays/bin-substrate/Cargo.toml +++ b/polkadot/relays/bin-substrate/Cargo.toml @@ -23,10 +23,12 @@ structopt = "0.3" bp-header-chain = { path = "../../primitives/header-chain" } bp-kusama = { path = "../../primitives/chain-kusama" } bp-messages = { path = "../../primitives/messages" } +bp-message-dispatch = { path = "../../primitives/message-dispatch" } bp-millau = { path = "../../primitives/chain-millau" } bp-polkadot = { path = "../../primitives/chain-polkadot" } bp-rialto = { path = "../../primitives/chain-rialto" } bp-rococo = { path = "../../primitives/chain-rococo" } +bp-wococo = { path = "../../primitives/chain-wococo" } bp-runtime = { path = "../../primitives/runtime" } bp-westend = { path = "../../primitives/chain-westend" } bridge-runtime-common = { path = "../../bin/runtime-common" } @@ -35,13 +37,13 @@ finality-relay = { path = "../finality" } headers-relay = { path = "../headers" } messages-relay = { path = "../messages" } millau-runtime = { path = "../../bin/millau/runtime" } -pallet-bridge-dispatch = { path = "../../modules/dispatch" } pallet-bridge-messages = { path = "../../modules/messages" } relay-kusama-client = { path = "../client-kusama" } relay-millau-client = { path = "../client-millau" } relay-polkadot-client = { path = "../client-polkadot" } relay-rialto-client = { path = "../client-rialto" } relay-rococo-client = { path = "../client-rococo" } +relay-wococo-client = { path = "../client-wococo" } relay-substrate-client = { path = "../client-substrate" } relay-utils = { path = "../utils" } relay-westend-client = { path = "../client-westend" } diff --git a/polkadot/relays/bin-substrate/src/chains/millau.rs b/polkadot/relays/bin-substrate/src/chains/millau.rs index ac5e611fdb..41ac760828 100644 --- a/polkadot/relays/bin-substrate/src/chains/millau.rs +++ b/polkadot/relays/bin-substrate/src/chains/millau.rs @@ -21,9 +21,9 @@ use crate::cli::{ encode_call::{self, Call, CliEncodeCall}, encode_message, send_message, CliChain, }; +use bp_message_dispatch::{CallOrigin, MessagePayload}; use codec::Decode; use frame_support::weights::{GetDispatchInfo, Weight}; -use pallet_bridge_dispatch::{CallOrigin, MessagePayload}; use relay_millau_client::Millau; use sp_version::RuntimeVersion; diff --git a/polkadot/relays/bin-substrate/src/chains/mod.rs b/polkadot/relays/bin-substrate/src/chains/mod.rs index 9e6a7361d5..b4061ced37 100644 --- a/polkadot/relays/bin-substrate/src/chains/mod.rs +++ b/polkadot/relays/bin-substrate/src/chains/mod.rs @@ -20,14 +20,15 @@ pub mod millau_headers_to_rialto; pub mod millau_messages_to_rialto; pub mod rialto_headers_to_millau; pub mod rialto_messages_to_millau; -pub mod rococo_headers_to_westend; +pub mod rococo_headers_to_wococo; pub mod westend_headers_to_millau; -pub mod westend_headers_to_rococo; +pub mod wococo_headers_to_rococo; mod millau; mod rialto; mod rococo; mod westend; +mod wococo; use relay_utils::metrics::{FloatJsonValueMetric, MetricsParams}; @@ -131,7 +132,7 @@ mod tests { let payload = send_message::message_payload( Default::default(), call.get_dispatch_info().weight, - pallet_bridge_dispatch::CallOrigin::SourceRoot, + bp_message_dispatch::CallOrigin::SourceRoot, &call, ); assert_eq!(Millau::verify_message(&payload), Ok(())); @@ -141,7 +142,7 @@ mod tests { let payload = send_message::message_payload( Default::default(), call.get_dispatch_info().weight, - pallet_bridge_dispatch::CallOrigin::SourceRoot, + bp_message_dispatch::CallOrigin::SourceRoot, &call, ); assert!(Millau::verify_message(&payload).is_err()); @@ -168,7 +169,7 @@ mod tests { let payload = send_message::message_payload( Default::default(), maximal_dispatch_weight, - pallet_bridge_dispatch::CallOrigin::SourceRoot, + bp_message_dispatch::CallOrigin::SourceRoot, &call, ); assert_eq!(Millau::verify_message(&payload), Ok(())); @@ -176,7 +177,7 @@ mod tests { let payload = send_message::message_payload( Default::default(), maximal_dispatch_weight + 1, - pallet_bridge_dispatch::CallOrigin::SourceRoot, + bp_message_dispatch::CallOrigin::SourceRoot, &call, ); assert!(Millau::verify_message(&payload).is_err()); @@ -193,7 +194,7 @@ mod tests { let payload = send_message::message_payload( Default::default(), maximal_dispatch_weight, - pallet_bridge_dispatch::CallOrigin::SourceRoot, + bp_message_dispatch::CallOrigin::SourceRoot, &call, ); assert_eq!(Rialto::verify_message(&payload), Ok(())); @@ -201,7 +202,7 @@ mod tests { let payload = send_message::message_payload( Default::default(), maximal_dispatch_weight + 1, - pallet_bridge_dispatch::CallOrigin::SourceRoot, + bp_message_dispatch::CallOrigin::SourceRoot, &call, ); assert!(Rialto::verify_message(&payload).is_err()); @@ -270,7 +271,7 @@ mod rococo_tests { votes_ancestries: vec![], }; - let actual = bp_rococo::BridgeGrandpaWestendCall::submit_finality_proof(header.clone(), justification.clone()); + let actual = bp_rococo::BridgeGrandpaWococoCall::submit_finality_proof(header.clone(), justification.clone()); let expected = millau_runtime::BridgeGrandpaRialtoCall::::submit_finality_proof( header, justification, diff --git a/polkadot/relays/bin-substrate/src/chains/rialto.rs b/polkadot/relays/bin-substrate/src/chains/rialto.rs index 25c1ab04c9..77eeb06da0 100644 --- a/polkadot/relays/bin-substrate/src/chains/rialto.rs +++ b/polkadot/relays/bin-substrate/src/chains/rialto.rs @@ -21,9 +21,9 @@ use crate::cli::{ encode_call::{self, Call, CliEncodeCall}, encode_message, send_message, CliChain, }; +use bp_message_dispatch::{CallOrigin, MessagePayload}; use codec::Decode; use frame_support::weights::{GetDispatchInfo, Weight}; -use pallet_bridge_dispatch::{CallOrigin, MessagePayload}; use relay_rialto_client::Rialto; use sp_version::RuntimeVersion; diff --git a/polkadot/relays/bin-substrate/src/chains/rococo_headers_to_westend.rs b/polkadot/relays/bin-substrate/src/chains/rococo_headers_to_wococo.rs similarity index 71% rename from polkadot/relays/bin-substrate/src/chains/rococo_headers_to_westend.rs rename to polkadot/relays/bin-substrate/src/chains/rococo_headers_to_wococo.rs index dca91adb3d..5247c6068b 100644 --- a/polkadot/relays/bin-substrate/src/chains/rococo_headers_to_westend.rs +++ b/polkadot/relays/bin-substrate/src/chains/rococo_headers_to_wococo.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! Rococo-to-Westend headers sync entrypoint. +//! Rococo-to-Wococo headers sync entrypoint. use crate::finality_pipeline::{SubstrateFinalitySyncPipeline, SubstrateFinalityToSubstrate}; @@ -23,37 +23,37 @@ use codec::Encode; use relay_rococo_client::{Rococo, SyncHeader as RococoSyncHeader}; use relay_substrate_client::{Chain, TransactionSignScheme}; use relay_utils::metrics::MetricsParams; -use relay_westend_client::{SigningParams as WestendSigningParams, Westend}; +use relay_wococo_client::{SigningParams as WococoSigningParams, Wococo}; use sp_core::{Bytes, Pair}; -/// Rococo-to-Westend finality sync pipeline. -pub(crate) type RococoFinalityToWestend = SubstrateFinalityToSubstrate; +/// Rococo-to-Wococo finality sync pipeline. +pub(crate) type RococoFinalityToWococo = SubstrateFinalityToSubstrate; -impl SubstrateFinalitySyncPipeline for RococoFinalityToWestend { +impl SubstrateFinalitySyncPipeline for RococoFinalityToWococo { const BEST_FINALIZED_SOURCE_HEADER_ID_AT_TARGET: &'static str = bp_rococo::BEST_FINALIZED_ROCOCO_HEADER_METHOD; - type TargetChain = Westend; + type TargetChain = Wococo; fn customize_metrics(params: MetricsParams) -> anyhow::Result { crate::chains::add_polkadot_kusama_price_metrics::(params) } - fn transactions_author(&self) -> bp_westend::AccountId { + fn transactions_author(&self) -> bp_wococo::AccountId { (*self.target_sign.public().as_array_ref()).into() } fn make_submit_finality_proof_transaction( &self, - transaction_nonce: ::Index, + transaction_nonce: ::Index, header: RococoSyncHeader, proof: GrandpaJustification, ) -> Bytes { - let call = bp_westend::Call::BridgeGrandpaRococo(bp_westend::BridgeGrandpaRococoCall::submit_finality_proof( + let call = bp_wococo::Call::BridgeGrandpaRococo(bp_wococo::BridgeGrandpaRococoCall::submit_finality_proof( header.into_inner(), proof, )); let genesis_hash = *self.target_client.genesis_hash(); - let transaction = Westend::sign_transaction(genesis_hash, &self.target_sign, transaction_nonce, call); + let transaction = Wococo::sign_transaction(genesis_hash, &self.target_sign, transaction_nonce, call); Bytes(transaction.encode()) } diff --git a/polkadot/relays/bin-substrate/src/chains/westend_headers_to_rococo.rs b/polkadot/relays/bin-substrate/src/chains/westend_headers_to_rococo.rs index 577a858d92..f1b3902157 100644 --- a/polkadot/relays/bin-substrate/src/chains/westend_headers_to_rococo.rs +++ b/polkadot/relays/bin-substrate/src/chains/westend_headers_to_rococo.rs @@ -48,7 +48,7 @@ impl SubstrateFinalitySyncPipeline for WestendFinalityToRococo { header: WestendSyncHeader, proof: GrandpaJustification, ) -> Bytes { - let call = bp_rococo::Call::BridgeGrandpaWestend(bp_rococo::BridgeGrandpaWestendCall::submit_finality_proof( + let call = bp_rococo::Call::BridgeGrandpaWestend(bp_rococo::BridgeGrandpaCall::submit_finality_proof( header.into_inner(), proof, )); diff --git a/polkadot/relays/bin-substrate/src/chains/wococo.rs b/polkadot/relays/bin-substrate/src/chains/wococo.rs new file mode 100644 index 0000000000..549aa8a882 --- /dev/null +++ b/polkadot/relays/bin-substrate/src/chains/wococo.rs @@ -0,0 +1,39 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +use crate::cli::{encode_message, CliChain}; +use frame_support::weights::Weight; +use relay_wococo_client::Wococo; +use sp_version::RuntimeVersion; + +impl CliChain for Wococo { + const RUNTIME_VERSION: RuntimeVersion = bp_wococo::VERSION; + + type KeyPair = sp_core::sr25519::Pair; + type MessagePayload = (); + + fn ss58_format() -> u16 { + 42 + } + + fn max_extrinsic_weight() -> Weight { + 0 + } + + fn encode_message(_message: encode_message::MessagePayload) -> Result { + Err("Sending messages from Wococo is not yet supported.".into()) + } +} diff --git a/polkadot/relays/bin-substrate/src/chains/wococo_headers_to_rococo.rs b/polkadot/relays/bin-substrate/src/chains/wococo_headers_to_rococo.rs new file mode 100644 index 0000000000..9dfae5294e --- /dev/null +++ b/polkadot/relays/bin-substrate/src/chains/wococo_headers_to_rococo.rs @@ -0,0 +1,60 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Wococo-to-Rococo headers sync entrypoint. + +use crate::finality_pipeline::{SubstrateFinalitySyncPipeline, SubstrateFinalityToSubstrate}; + +use bp_header_chain::justification::GrandpaJustification; +use codec::Encode; +use relay_rococo_client::{Rococo, SigningParams as RococoSigningParams}; +use relay_substrate_client::{Chain, TransactionSignScheme}; +use relay_utils::metrics::MetricsParams; +use relay_wococo_client::{SyncHeader as WococoSyncHeader, Wococo}; +use sp_core::{Bytes, Pair}; + +/// Wococo-to-Rococo finality sync pipeline. +pub(crate) type WococoFinalityToRococo = SubstrateFinalityToSubstrate; + +impl SubstrateFinalitySyncPipeline for WococoFinalityToRococo { + const BEST_FINALIZED_SOURCE_HEADER_ID_AT_TARGET: &'static str = bp_wococo::BEST_FINALIZED_WOCOCO_HEADER_METHOD; + + type TargetChain = Rococo; + + fn customize_metrics(params: MetricsParams) -> anyhow::Result { + crate::chains::add_polkadot_kusama_price_metrics::(params) + } + + fn transactions_author(&self) -> bp_rococo::AccountId { + (*self.target_sign.public().as_array_ref()).into() + } + + fn make_submit_finality_proof_transaction( + &self, + transaction_nonce: ::Index, + header: WococoSyncHeader, + proof: GrandpaJustification, + ) -> Bytes { + let call = bp_rococo::Call::BridgeGrandpaWococo(bp_rococo::BridgeGrandpaWococoCall::submit_finality_proof( + header.into_inner(), + proof, + )); + let genesis_hash = *self.target_client.genesis_hash(); + let transaction = Rococo::sign_transaction(genesis_hash, &self.target_sign, transaction_nonce, call); + + Bytes(transaction.encode()) + } +} diff --git a/polkadot/relays/bin-substrate/src/cli/bridge.rs b/polkadot/relays/bin-substrate/src/cli/bridge.rs index faf4417d1e..996edb4994 100644 --- a/polkadot/relays/bin-substrate/src/cli/bridge.rs +++ b/polkadot/relays/bin-substrate/src/cli/bridge.rs @@ -53,7 +53,7 @@ macro_rules! select_full_bridge { // Derive-account #[allow(unused_imports)] - use bp_millau::derive_account_from_rialto_id as derive_account; + use bp_rialto::derive_account_from_millau_id as derive_account; // Relay-messages #[allow(unused_imports)] @@ -75,7 +75,7 @@ macro_rules! select_full_bridge { // Derive-account #[allow(unused_imports)] - use bp_rialto::derive_account_from_millau_id as derive_account; + use bp_millau::derive_account_from_rialto_id as derive_account; // Relay-messages #[allow(unused_imports)] diff --git a/polkadot/relays/bin-substrate/src/cli/derive_account.rs b/polkadot/relays/bin-substrate/src/cli/derive_account.rs index 92b32b0d47..dff62c21f6 100644 --- a/polkadot/relays/bin-substrate/src/cli/derive_account.rs +++ b/polkadot/relays/bin-substrate/src/cli/derive_account.rs @@ -91,11 +91,11 @@ mod tests { assert_eq!( format!("{}", rialto_derived), - "73gLnUwrAdH4vMjbXCiNEpgyz1PLk9JxCaY4cKzvfSZT73KE" + "74GNQjmkcfstRftSQPJgMREchqHM56EvAUXRc266cZ1NYVW5" ); assert_eq!( format!("{}", millau_derived), - "5rpTJqGv1BPAYy2sXzkPpc3Wx1ZpQtgfuBsrDpNV4HsXAmbi" + "5rERgaT1Z8nM3et2epA5i1VtEBfp5wkhwHtVE8HK7BRbjAH2" ); assert_eq!(millau_derived, millau2_derived); } diff --git a/polkadot/relays/bin-substrate/src/cli/init_bridge.rs b/polkadot/relays/bin-substrate/src/cli/init_bridge.rs index cdd8ec3691..b5590b9e5a 100644 --- a/polkadot/relays/bin-substrate/src/cli/init_bridge.rs +++ b/polkadot/relays/bin-substrate/src/cli/init_bridge.rs @@ -44,8 +44,8 @@ arg_enum! { MillauToRialto, RialtoToMillau, WestendToMillau, - WestendToRococo, - RococoToWestend, + RococoToWococo, + WococoToRococo, } } @@ -102,26 +102,26 @@ macro_rules! select_bridge { $generic } - InitBridgeName::WestendToRococo => { - type Source = relay_westend_client::Westend; + InitBridgeName::RococoToWococo => { + type Source = relay_rococo_client::Rococo; + type Target = relay_wococo_client::Wococo; + + fn encode_init_bridge( + init_data: InitializationData<::Header>, + ) -> ::Call { + bp_wococo::Call::BridgeGrandpaRococo(bp_wococo::BridgeGrandpaRococoCall::initialize(init_data)) + } + + $generic + } + InitBridgeName::WococoToRococo => { + type Source = relay_wococo_client::Wococo; type Target = relay_rococo_client::Rococo; fn encode_init_bridge( init_data: InitializationData<::Header>, ) -> ::Call { - bp_rococo::Call::BridgeGrandpaWestend(bp_rococo::BridgeGrandpaWestendCall::initialize(init_data)) - } - - $generic - } - InitBridgeName::RococoToWestend => { - type Source = relay_rococo_client::Rococo; - type Target = relay_westend_client::Westend; - - fn encode_init_bridge( - init_data: InitializationData<::Header>, - ) -> ::Call { - bp_westend::Call::BridgeGrandpaRococo(bp_westend::BridgeGrandpaRococoCall::initialize(init_data)) + bp_rococo::Call::BridgeGrandpaWococo(bp_rococo::BridgeGrandpaWococoCall::initialize(init_data)) } $generic diff --git a/polkadot/relays/bin-substrate/src/cli/mod.rs b/polkadot/relays/bin-substrate/src/cli/mod.rs index 505ef11ee2..341051de5c 100644 --- a/polkadot/relays/bin-substrate/src/cli/mod.rs +++ b/polkadot/relays/bin-substrate/src/cli/mod.rs @@ -89,8 +89,23 @@ pub enum Command { } impl Command { + // Initialize logger depending on the command. + fn init_logger(&self) { + use relay_utils::initialize::{initialize_logger, initialize_relay}; + + match self { + Self::RelayHeaders(_) | Self::RelayMessages(_) | Self::RelayHeadersAndMessages(_) | Self::InitBridge(_) => { + initialize_relay(); + } + _ => { + initialize_logger(false); + } + } + } + /// Run the command. pub async fn run(self) -> anyhow::Result<()> { + self.init_logger(); match self { Self::RelayHeaders(arg) => arg.run().await?, Self::RelayMessages(arg) => arg.run().await?, diff --git a/polkadot/relays/bin-substrate/src/cli/relay_headers.rs b/polkadot/relays/bin-substrate/src/cli/relay_headers.rs index 346790f2ae..e8459b58bf 100644 --- a/polkadot/relays/bin-substrate/src/cli/relay_headers.rs +++ b/polkadot/relays/bin-substrate/src/cli/relay_headers.rs @@ -42,8 +42,8 @@ arg_enum! { MillauToRialto, RialtoToMillau, WestendToMillau, - WestendToRococo, - RococoToWestend, + RococoToWococo, + WococoToRococo, } } @@ -71,17 +71,17 @@ macro_rules! select_bridge { $generic } - RelayHeadersBridge::WestendToRococo => { - type Source = relay_westend_client::Westend; - type Target = relay_rococo_client::Rococo; - type Finality = crate::chains::westend_headers_to_rococo::WestendFinalityToRococo; + RelayHeadersBridge::RococoToWococo => { + type Source = relay_rococo_client::Rococo; + type Target = relay_wococo_client::Wococo; + type Finality = crate::chains::rococo_headers_to_wococo::RococoFinalityToWococo; $generic } - RelayHeadersBridge::RococoToWestend => { - type Source = relay_rococo_client::Rococo; - type Target = relay_westend_client::Westend; - type Finality = crate::chains::rococo_headers_to_westend::RococoFinalityToWestend; + RelayHeadersBridge::WococoToRococo => { + type Source = relay_wococo_client::Wococo; + type Target = relay_rococo_client::Rococo; + type Finality = crate::chains::wococo_headers_to_rococo::WococoFinalityToRococo; $generic } @@ -102,6 +102,7 @@ impl RelayHeaders { Finality::new(target_client.clone(), target_sign), source_client, target_client, + false, metrics_params, ) .await diff --git a/polkadot/relays/bin-substrate/src/cli/relay_headers_and_messages.rs b/polkadot/relays/bin-substrate/src/cli/relay_headers_and_messages.rs index 98ff1268fa..f2238ba576 100644 --- a/polkadot/relays/bin-substrate/src/cli/relay_headers_and_messages.rs +++ b/polkadot/relays/bin-substrate/src/cli/relay_headers_and_messages.rs @@ -96,6 +96,9 @@ macro_rules! select_bridge { type LeftToRightMessages = crate::chains::millau_messages_to_rialto::MillauMessagesToRialto; type RightToLeftMessages = crate::chains::rialto_messages_to_millau::RialtoMessagesToMillau; + const MAX_MISSING_LEFT_HEADERS_AT_RIGHT: bp_millau::BlockNumber = bp_millau::SESSION_LENGTH; + const MAX_MISSING_RIGHT_HEADERS_AT_LEFT: bp_rialto::BlockNumber = bp_rialto::SESSION_LENGTH; + use crate::chains::millau_messages_to_rialto::run as left_to_right_messages; use crate::chains::rialto_messages_to_millau::run as right_to_left_messages; @@ -131,11 +134,13 @@ impl RelayHeadersAndMessages { left_client.clone(), right_client.clone(), LeftToRightFinality::new(right_client.clone(), right_sign.clone()), + MAX_MISSING_LEFT_HEADERS_AT_RIGHT, ); let right_to_left_on_demand_headers = OnDemandHeadersRelay::new( right_client.clone(), left_client.clone(), RightToLeftFinality::new(left_client.clone(), left_sign.clone()), + MAX_MISSING_RIGHT_HEADERS_AT_LEFT, ); let left_to_right_messages = left_to_right_messages(MessagesRelayParams { diff --git a/polkadot/relays/bin-substrate/src/cli/send_message.rs b/polkadot/relays/bin-substrate/src/cli/send_message.rs index 64448f0f1d..6fa82a8cdb 100644 --- a/polkadot/relays/bin-substrate/src/cli/send_message.rs +++ b/polkadot/relays/bin-substrate/src/cli/send_message.rs @@ -21,9 +21,9 @@ use crate::cli::{ Balance, CliChain, ExplicitOrMaximal, HexBytes, HexLaneId, Origins, SourceConnectionParams, SourceSigningParams, TargetSigningParams, }; +use bp_message_dispatch::{CallOrigin, MessagePayload}; use codec::Encode; use frame_support::{dispatch::GetDispatchInfo, weights::Weight}; -use pallet_bridge_dispatch::{CallOrigin, MessagePayload}; use relay_substrate_client::{Chain, TransactionSignScheme}; use sp_core::{Bytes, Pair}; use sp_runtime::{traits::IdentifyAccount, AccountId32, MultiSignature, MultiSigner}; diff --git a/polkadot/relays/bin-substrate/src/finality_pipeline.rs b/polkadot/relays/bin-substrate/src/finality_pipeline.rs index bc8461f6a8..dad69b1576 100644 --- a/polkadot/relays/bin-substrate/src/finality_pipeline.rs +++ b/polkadot/relays/bin-substrate/src/finality_pipeline.rs @@ -96,7 +96,7 @@ where SourceChain: Clone + Chain + Debug, BlockNumberOf: BlockNumberBase, TargetChain: Clone + Chain + Debug, - TargetSign: Clone + Send + Sync, + TargetSign: 'static + Clone + Send + Sync, { const SOURCE_NAME: &'static str = SourceChain::NAME; const TARGET_NAME: &'static str = TargetChain::NAME; @@ -112,6 +112,7 @@ pub async fn run( pipeline: P, source_client: Client, target_client: Client, + is_on_demand_task: bool, metrics_params: MetricsParams, ) -> anyhow::Result<()> where @@ -137,6 +138,7 @@ where FinalitySource::new(source_client), SubstrateFinalityTarget::new(target_client, pipeline), FinalitySyncParams { + is_on_demand_task, tick: std::cmp::max(SourceChain::AVERAGE_BLOCK_INTERVAL, TargetChain::AVERAGE_BLOCK_INTERVAL), recent_finality_proofs_limit: RECENT_FINALITY_PROOFS_LIMIT, stall_timeout: STALL_TIMEOUT, diff --git a/polkadot/relays/bin-substrate/src/main.rs b/polkadot/relays/bin-substrate/src/main.rs index 6bf7561fcd..d119042b0d 100644 --- a/polkadot/relays/bin-substrate/src/main.rs +++ b/polkadot/relays/bin-substrate/src/main.rs @@ -18,8 +18,6 @@ #![warn(missing_docs)] -use relay_utils::initialize::initialize_logger; - mod chains; mod cli; mod finality_pipeline; @@ -31,7 +29,6 @@ mod messages_target; mod on_demand_headers; fn main() { - initialize_logger(false); let command = cli::parse_args(); let run = command.run(); let result = async_std::task::block_on(run); diff --git a/polkadot/relays/bin-substrate/src/messages_lane.rs b/polkadot/relays/bin-substrate/src/messages_lane.rs index 9948b6ec08..616e2253a6 100644 --- a/polkadot/relays/bin-substrate/src/messages_lane.rs +++ b/polkadot/relays/bin-substrate/src/messages_lane.rs @@ -203,7 +203,7 @@ mod tests { // reserved for messages dispatch allows dispatch of non-trivial messages. // // Any significant change in this values should attract additional attention. - (1020, 216_583_333_334), + (1013, 216_583_333_334), ); } } diff --git a/polkadot/relays/bin-substrate/src/messages_source.rs b/polkadot/relays/bin-substrate/src/messages_source.rs index cf98f3276b..0ccf8bbde8 100644 --- a/polkadot/relays/bin-substrate/src/messages_source.rs +++ b/polkadot/relays/bin-substrate/src/messages_source.rs @@ -93,7 +93,7 @@ impl RelayClient for SubstrateMessagesSource where C: Chain, P: SubstrateMessageLane, - R: Send + Sync, + R: 'static + Send + Sync, I: Send + Sync + Instance, { type Error = SubstrateError; diff --git a/polkadot/relays/bin-substrate/src/messages_target.rs b/polkadot/relays/bin-substrate/src/messages_target.rs index 1760832730..39f638d7e9 100644 --- a/polkadot/relays/bin-substrate/src/messages_target.rs +++ b/polkadot/relays/bin-substrate/src/messages_target.rs @@ -93,7 +93,7 @@ impl RelayClient for SubstrateMessagesTarget where C: Chain, P: SubstrateMessageLane, - R: Send + Sync, + R: 'static + Send + Sync, I: Send + Sync + Instance, { type Error = SubstrateError; diff --git a/polkadot/relays/bin-substrate/src/on_demand_headers.rs b/polkadot/relays/bin-substrate/src/on_demand_headers.rs index 4c86b6a170..77d2b37054 100644 --- a/polkadot/relays/bin-substrate/src/on_demand_headers.rs +++ b/polkadot/relays/bin-substrate/src/on_demand_headers.rs @@ -20,14 +20,22 @@ use crate::finality_pipeline::{SubstrateFinalitySyncPipeline, SubstrateFinalityT use crate::finality_target::SubstrateFinalityTarget; use bp_header_chain::justification::GrandpaJustification; -use finality_relay::TargetClient as FinalityTargetClient; +use finality_relay::{ + FinalitySyncPipeline, SourceClient as FinalitySourceClient, TargetClient as FinalityTargetClient, +}; use futures::{ channel::{mpsc, oneshot}, select, FutureExt, StreamExt, }; -use num_traits::Zero; -use relay_substrate_client::{BlockNumberOf, Chain, Client, HashOf, HeaderIdOf, SyncHeader}; -use relay_utils::{metrics::MetricsParams, BlockNumberBase, HeaderId}; +use num_traits::{CheckedSub, Zero}; +use relay_substrate_client::{ + finality_source::FinalitySource as SubstrateFinalitySource, BlockNumberOf, Chain, Client, HashOf, HeaderIdOf, + SyncHeader, +}; +use relay_utils::{ + metrics::MetricsParams, relay_loop::Client as RelayClient, BlockNumberBase, FailedClient, HeaderId, + MaybeConnectionError, +}; use std::fmt::Debug; /// On-demand Substrate <-> Substrate headers relay. @@ -49,6 +57,7 @@ impl OnDemandHeadersRelay { source_client: Client, target_client: Client, pipeline: SubstrateFinalityToSubstrate, + maximal_headers_difference: SourceChain::BlockNumber, ) -> Self where SourceChain: Chain + Debug, @@ -68,7 +77,14 @@ impl OnDemandHeadersRelay { { let (required_header_tx, required_header_rx) = mpsc::channel(1); async_std::task::spawn(async move { - background_task(source_client, target_client, pipeline, required_header_rx).await; + background_task( + source_client, + target_client, + pipeline, + maximal_headers_difference, + required_header_rx, + ) + .await; }); let background_task_name = format!( @@ -100,6 +116,7 @@ async fn background_task( source_client: Client, target_client: Client, pipeline: SubstrateFinalityToSubstrate, + maximal_headers_difference: SourceChain::BlockNumber, mut required_header_rx: mpsc::Receiver>, ) where SourceChain: Chain + Debug, @@ -118,7 +135,11 @@ async fn background_task( FinalityTargetClient>, { let relay_task_name = on_demand_headers_relay_name::(); - let finality_target = SubstrateFinalityTarget::new(target_client.clone(), pipeline.clone()); + let mut finality_source = SubstrateFinalitySource::< + _, + SubstrateFinalityToSubstrate, + >::new(source_client.clone()); + let mut finality_target = SubstrateFinalityTarget::new(target_client.clone(), pipeline.clone()); let mut active_headers_relay = None; let mut required_header_number = Zero::zero(); @@ -150,30 +171,45 @@ async fn background_task( }, } - // read best finalized source block from target - let available_header_number = match finality_target.best_finalized_source_block_number().await { - Ok(available_header_number) => available_header_number, - Err(error) => { - log::error!( - target: "bridge", - "Failed to read best finalized {} header from {} in {} relay: {:?}", - SourceChain::NAME, - TargetChain::NAME, - relay_task_name, - error, - ); + // read best finalized source header number from source + let best_finalized_source_header_at_source = + best_finalized_source_header_at_source(&finality_source, &relay_task_name).await; + if matches!(best_finalized_source_header_at_source, Err(ref e) if e.is_connection_error()) { + relay_utils::relay_loop::reconnect_failed_client( + FailedClient::Source, + relay_utils::relay_loop::RECONNECT_DELAY, + &mut finality_source, + &mut finality_target, + ) + .await; + continue; + } - // we don't know what's happening with target client, so better to stop on-demand relay than - // submit unneeded transactions - // => assume that required header is known to the target node - required_header_number - } - }; + // read best finalized source header number from target + let best_finalized_source_header_at_target = + best_finalized_source_header_at_target::(&finality_target, &relay_task_name).await; + if matches!(best_finalized_source_header_at_target, Err(ref e) if e.is_connection_error()) { + relay_utils::relay_loop::reconnect_failed_client( + FailedClient::Target, + relay_utils::relay_loop::RECONNECT_DELAY, + &mut finality_source, + &mut finality_target, + ) + .await; + continue; + } // start or stop headers relay if required - let activate = required_header_number > available_header_number; - match (activate, active_headers_relay.is_some()) { - (true, false) => { + let action = select_on_demand_relay_action::( + best_finalized_source_header_at_source.ok(), + best_finalized_source_header_at_target.ok(), + required_header_number, + maximal_headers_difference, + &relay_task_name, + active_headers_relay.is_some(), + ); + match action { + OnDemandRelayAction::Start => { let (relay_exited_tx, new_relay_exited_rx) = oneshot::channel(); active_headers_relay = start_on_demand_headers_relay( relay_task_name.clone(), @@ -186,14 +222,127 @@ async fn background_task( relay_exited_rx = new_relay_exited_rx.right_future(); } } - (false, true) => { + OnDemandRelayAction::Stop => { stop_on_demand_headers_relay(active_headers_relay.take()).await; } - _ => (), + OnDemandRelayAction::None => (), } } } +/// Read best finalized source block number from source client. +/// +/// Returns `None` if we have failed to read the number. +async fn best_finalized_source_header_at_source( + finality_source: &SubstrateFinalitySource, + relay_task_name: &str, +) -> Result as RelayClient>::Error> +where + SubstrateFinalitySource: FinalitySourceClient

, + P: FinalitySyncPipeline, +{ + finality_source.best_finalized_block_number().await.map_err(|error| { + log::error!( + target: "bridge", + "Failed to read best finalized source header from source in {} relay: {:?}", + relay_task_name, + error, + ); + + error + }) +} + +/// Read best finalized source block number from target client. +/// +/// Returns `None` if we have failed to read the number. +async fn best_finalized_source_header_at_target( + finality_target: &SubstrateFinalityTarget, + relay_task_name: &str, +) -> Result as RelayClient>::Error> +where + SubstrateFinalityTarget: FinalityTargetClient

, + P: FinalitySyncPipeline, +{ + finality_target + .best_finalized_source_block_number() + .await + .map_err(|error| { + log::error!( + target: "bridge", + "Failed to read best finalized source header from target in {} relay: {:?}", + relay_task_name, + error, + ); + + error + }) +} + +/// What to do with the on-demand relay task? +#[derive(Debug, PartialEq)] +enum OnDemandRelayAction { + Start, + Stop, + None, +} + +fn select_on_demand_relay_action( + best_finalized_source_header_at_source: Option, + best_finalized_source_header_at_target: Option, + mut required_source_header_at_target: C::BlockNumber, + maximal_headers_difference: C::BlockNumber, + relay_task_name: &str, + is_active: bool, +) -> OnDemandRelayAction { + // if we have been unable to read header number from the target, then let's assume + // that it is the same as required header number. Otherwise we risk submitting + // unneeded transactions + let best_finalized_source_header_at_target = + best_finalized_source_header_at_target.unwrap_or(required_source_header_at_target); + + // if we have been unable to read header number from the source, then let's assume + // that it is the same as at the target + let best_finalized_source_header_at_source = + best_finalized_source_header_at_source.unwrap_or(best_finalized_source_header_at_target); + + // if there are too many source headers missing from the target node, require some + // new headers at target + // + // why do we need that? When complex headers+messages relay is used, it'll normally only relay + // headers when there are undelivered messages/confirmations. But security model of the + // `pallet-bridge-grandpa` module relies on the fact that headers are synced in real-time and + // that it'll see authorities-change header before unbonding period will end for previous + // authorities set. + let current_headers_difference = best_finalized_source_header_at_source + .checked_sub(&best_finalized_source_header_at_target) + .unwrap_or_else(Zero::zero); + if current_headers_difference > maximal_headers_difference { + required_source_header_at_target = best_finalized_source_header_at_source; + + // don't log if relay is already running + if !is_active { + log::trace!( + target: "bridge", + "Too many {} headers missing at target in {} relay ({} vs {}). Going to sync up to the {}", + C::NAME, + relay_task_name, + best_finalized_source_header_at_source, + best_finalized_source_header_at_target, + best_finalized_source_header_at_source, + ); + } + } + + // now let's select what to do with relay + let needs_to_be_active = required_source_header_at_target > best_finalized_source_header_at_target; + match (needs_to_be_active, is_active) { + (true, false) => OnDemandRelayAction::Start, + (false, true) => OnDemandRelayAction::Stop, + _ => OnDemandRelayAction::None, + } +} + /// On-demand headers relay task name. fn on_demand_headers_relay_name() -> String { format!("on-demand-{}-to-{}", SourceChain::NAME, TargetChain::NAME) @@ -219,7 +368,7 @@ where TargetSign: 'static, { let headers_relay_future = - crate::finality_pipeline::run(pipeline, source_client, target_client, MetricsParams::disabled()); + crate::finality_pipeline::run(pipeline, source_client, target_client, true, MetricsParams::disabled()); let closure_task_name = task_name.clone(); async_std::task::Builder::new() .name(task_name.clone()) @@ -253,3 +402,52 @@ async fn stop_on_demand_headers_relay(task: Option = Some(10); + const AT_TARGET: Option = Some(1); + + #[test] + fn starts_relay_when_headers_are_required() { + assert_eq!( + select_on_demand_relay_action::(AT_SOURCE, AT_TARGET, 5, 100, "test", false), + OnDemandRelayAction::Start, + ); + + assert_eq!( + select_on_demand_relay_action::(AT_SOURCE, AT_TARGET, 5, 100, "test", true), + OnDemandRelayAction::None, + ); + } + + #[test] + fn starts_relay_when_too_many_headers_missing() { + assert_eq!( + select_on_demand_relay_action::(AT_SOURCE, AT_TARGET, 0, 5, "test", false), + OnDemandRelayAction::Start, + ); + + assert_eq!( + select_on_demand_relay_action::(AT_SOURCE, AT_TARGET, 0, 5, "test", true), + OnDemandRelayAction::None, + ); + } + + #[test] + fn stops_relay_if_required_header_is_synced() { + assert_eq!( + select_on_demand_relay_action::(AT_SOURCE, AT_TARGET, AT_TARGET.unwrap(), 100, "test", true), + OnDemandRelayAction::Stop, + ); + + assert_eq!( + select_on_demand_relay_action::(AT_SOURCE, AT_TARGET, AT_TARGET.unwrap(), 100, "test", false), + OnDemandRelayAction::None, + ); + } +} diff --git a/polkadot/relays/client-ethereum/Cargo.toml b/polkadot/relays/client-ethereum/Cargo.toml index ebae252ed5..da4e7ef59e 100644 --- a/polkadot/relays/client-ethereum/Cargo.toml +++ b/polkadot/relays/client-ethereum/Cargo.toml @@ -10,8 +10,8 @@ bp-eth-poa = { path = "../../primitives/ethereum-poa" } codec = { package = "parity-scale-codec", version = "2.0.0" } headers-relay = { path = "../headers" } hex-literal = "0.3" -jsonrpsee-proc-macros = "=0.2.0-alpha.5" -jsonrpsee-ws-client = "=0.2.0-alpha.5" +jsonrpsee-proc-macros = "=0.2.0-alpha.6" +jsonrpsee-ws-client = "=0.2.0-alpha.6" libsecp256k1 = { version = "0.3.4", default-features = false, features = ["hmac"] } log = "0.4.11" relay-utils = { path = "../utils" } diff --git a/polkadot/relays/client-substrate/Cargo.toml b/polkadot/relays/client-substrate/Cargo.toml index 7b3f46230f..699c3da400 100644 --- a/polkadot/relays/client-substrate/Cargo.toml +++ b/polkadot/relays/client-substrate/Cargo.toml @@ -9,8 +9,8 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" async-std = "1.6.5" async-trait = "0.1.40" codec = { package = "parity-scale-codec", version = "2.0.0" } -jsonrpsee-proc-macros = "=0.2.0-alpha.5" -jsonrpsee-ws-client = "=0.2.0-alpha.5" +jsonrpsee-proc-macros = "=0.2.0-alpha.6" +jsonrpsee-ws-client = "=0.2.0-alpha.6" log = "0.4.11" num-traits = "0.2" rand = "0.7" diff --git a/polkadot/relays/client-wococo/Cargo.toml b/polkadot/relays/client-wococo/Cargo.toml new file mode 100644 index 0000000000..22d710ca3d --- /dev/null +++ b/polkadot/relays/client-wococo/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "relay-wococo-client" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +codec = { package = "parity-scale-codec", version = "2.0.0" } +headers-relay = { path = "../headers" } +relay-substrate-client = { path = "../client-substrate" } +relay-utils = { path = "../utils" } + +# Bridge dependencies +bp-wococo = { path = "../../primitives/chain-wococo" } + +# Substrate Dependencies +frame-system = { git = "https://github.com/paritytech/substrate", branch = "master" } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/polkadot/relays/client-wococo/src/lib.rs b/polkadot/relays/client-wococo/src/lib.rs new file mode 100644 index 0000000000..be2f872b7d --- /dev/null +++ b/polkadot/relays/client-wococo/src/lib.rs @@ -0,0 +1,97 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Types used to connect to the Wococo-Substrate chain. + +use codec::Encode; +use relay_substrate_client::{Chain, ChainBase, ChainWithBalances, TransactionSignScheme}; +use sp_core::{storage::StorageKey, Pair}; +use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount}; +use std::time::Duration; + +/// Wococo header id. +pub type HeaderId = relay_utils::HeaderId; + +/// Wococo header type used in headers sync. +pub type SyncHeader = relay_substrate_client::SyncHeader; + +/// Wococo chain definition +#[derive(Debug, Clone, Copy)] +pub struct Wococo; + +impl ChainBase for Wococo { + type BlockNumber = bp_wococo::BlockNumber; + type Hash = bp_wococo::Hash; + type Hasher = bp_wococo::Hashing; + type Header = bp_wococo::Header; +} + +impl Chain for Wococo { + const NAME: &'static str = "Wococo"; + const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(6); + + type AccountId = bp_wococo::AccountId; + type Index = bp_wococo::Index; + type SignedBlock = bp_wococo::SignedBlock; + type Call = bp_wococo::Call; +} + +impl ChainWithBalances for Wococo { + type NativeBalance = bp_wococo::Balance; + + fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey { + StorageKey(bp_wococo::account_info_storage_key(account_id)) + } +} + +impl TransactionSignScheme for Wococo { + type Chain = Wococo; + type AccountKeyPair = sp_core::sr25519::Pair; + type SignedTransaction = bp_wococo::UncheckedExtrinsic; + + fn sign_transaction( + genesis_hash: ::Hash, + signer: &Self::AccountKeyPair, + signer_nonce: ::Index, + call: ::Call, + ) -> Self::SignedTransaction { + let raw_payload = SignedPayload::new( + call, + bp_wococo::SignedExtensions::new( + bp_wococo::VERSION, + sp_runtime::generic::Era::Immortal, + genesis_hash, + signer_nonce, + 0, + ), + ) + .expect("SignedExtension never fails."); + + let signature = raw_payload.using_encoded(|payload| signer.sign(payload)); + let signer: sp_runtime::MultiSigner = signer.public().into(); + let (call, extra, _) = raw_payload.deconstruct(); + + bp_wococo::UncheckedExtrinsic::new_signed( + call, + sp_runtime::MultiAddress::Id(signer.into_account()), + signature.into(), + extra, + ) + } +} + +/// Wococo signing params. +pub type SigningParams = sp_core::sr25519::Pair; diff --git a/polkadot/relays/exchange/src/exchange.rs b/polkadot/relays/exchange/src/exchange.rs index cec0d7cba1..4a2f07fa7f 100644 --- a/polkadot/relays/exchange/src/exchange.rs +++ b/polkadot/relays/exchange/src/exchange.rs @@ -26,7 +26,7 @@ use std::{ }; /// Transaction proof pipeline. -pub trait TransactionProofPipeline { +pub trait TransactionProofPipeline: 'static { /// Name of the transaction proof source. const SOURCE_NAME: &'static str; /// Name of the transaction proof target. @@ -35,18 +35,21 @@ pub trait TransactionProofPipeline { /// Block type. type Block: SourceBlock; /// Transaction inclusion proof type. - type TransactionProof; + type TransactionProof: 'static + Send + Sync; } /// Block that is participating in exchange. -pub trait SourceBlock { +pub trait SourceBlock: 'static + Send + Sync { /// Block hash type. - type Hash: Clone + Debug + Display; + type Hash: 'static + Clone + Send + Sync + Debug + Display; /// Block number type. - type Number: Debug + type Number: 'static + + Debug + Display + Clone + Copy + + Send + + Sync + Into + std::cmp::Ord + std::ops::Add @@ -61,7 +64,7 @@ pub trait SourceBlock { } /// Transaction that is participating in exchange. -pub trait SourceTransaction { +pub trait SourceTransaction: 'static + Send { /// Transaction hash type. type Hash: Debug + Display; diff --git a/polkadot/relays/exchange/src/exchange_loop.rs b/polkadot/relays/exchange/src/exchange_loop.rs index b46d34e047..4525c33e36 100644 --- a/polkadot/relays/exchange/src/exchange_loop.rs +++ b/polkadot/relays/exchange/src/exchange_loop.rs @@ -39,9 +39,9 @@ pub struct TransactionProofsRelayState { } /// Transactions proofs relay storage. -pub trait TransactionProofsRelayStorage: Clone { +pub trait TransactionProofsRelayStorage: 'static + Clone + Send + Sync { /// Associated block number. - type BlockNumber; + type BlockNumber: 'static + Send + Sync; /// Get relay state. fn state(&self) -> TransactionProofsRelayState; @@ -64,7 +64,7 @@ impl InMemoryStorage { } } -impl TransactionProofsRelayStorage for InMemoryStorage { +impl TransactionProofsRelayStorage for InMemoryStorage { type BlockNumber = BlockNumber; fn state(&self) -> TransactionProofsRelayState { @@ -89,7 +89,7 @@ pub async fn run( source_client: impl SourceClient

, target_client: impl TargetClient

, metrics_params: MetricsParams, - exit_signal: impl Future, + exit_signal: impl Future + 'static + Send, ) -> Result<(), String> { let exit_signal = exit_signal.shared(); @@ -99,7 +99,7 @@ pub async fn run( .standalone_metric(|registry, prefix| GlobalMetrics::new(registry, prefix))? .expose() .await? - .run(|source_client, target_client, metrics| { + .run(metrics_prefix::

(), move |source_client, target_client, metrics| { run_until_connection_lost( storage.clone(), source_client, @@ -117,7 +117,7 @@ async fn run_until_connection_lost( source_client: impl SourceClient

, target_client: impl TargetClient

, metrics_exch: Option, - exit_signal: impl Future, + exit_signal: impl Future + Send, ) -> Result<(), FailedClient> { let mut retry_backoff = retry_backoff(); let mut state = storage.state(); diff --git a/polkadot/relays/finality/src/finality_loop.rs b/polkadot/relays/finality/src/finality_loop.rs index aff32e46de..3aa55a8ac5 100644 --- a/polkadot/relays/finality/src/finality_loop.rs +++ b/polkadot/relays/finality/src/finality_loop.rs @@ -39,6 +39,8 @@ use std::{ /// Finality proof synchronization loop parameters. #[derive(Debug, Clone)] pub struct FinalitySyncParams { + /// If `true`, then the separate async task for running finality loop is NOT spawned. + pub is_on_demand_task: bool, /// Interval at which we check updates on both clients. Normally should be larger than /// `min(source_block_time, target_block_time)`. /// @@ -65,7 +67,7 @@ pub struct FinalitySyncParams { pub trait SourceClient: RelayClient { /// Stream of new finality proofs. The stream is allowed to miss proofs for some /// headers, even if those headers are mandatory. - type FinalityProofsStream: Stream; + type FinalityProofsStream: Stream + Send; /// Get best finalized block number. async fn best_finalized_block_number(&self) -> Result; @@ -101,16 +103,17 @@ pub async fn run( target_client: impl TargetClient

, sync_params: FinalitySyncParams, metrics_params: MetricsParams, - exit_signal: impl Future, + exit_signal: impl Future + 'static + Send, ) -> Result<(), String> { let exit_signal = exit_signal.shared(); relay_utils::relay_loop(source_client, target_client) + .spawn_loop_task(!sync_params.is_on_demand_task) .with_metrics(Some(metrics_prefix::

()), metrics_params) .loop_metric(|registry, prefix| SyncLoopMetrics::new(registry, prefix))? .standalone_metric(|registry, prefix| GlobalMetrics::new(registry, prefix))? .expose() .await? - .run(|source_client, target_client, metrics| { + .run(metrics_prefix::

(), move |source_client, target_client, metrics| { run_until_connection_lost( source_client, target_client, diff --git a/polkadot/relays/finality/src/finality_loop_tests.rs b/polkadot/relays/finality/src/finality_loop_tests.rs index eedd902003..645aeb1777 100644 --- a/polkadot/relays/finality/src/finality_loop_tests.rs +++ b/polkadot/relays/finality/src/finality_loop_tests.rs @@ -106,7 +106,7 @@ impl RelayClient for TestSourceClient { #[async_trait] impl SourceClient for TestSourceClient { - type FinalityProofsStream = Pin>>; + type FinalityProofsStream = Pin + 'static + Send>>; async fn best_finalized_block_number(&self) -> Result { let mut data = self.data.lock(); @@ -197,6 +197,7 @@ fn run_sync_loop(state_function: impl Fn(&mut ClientsData) -> bool + Send + Sync data: clients_data.clone(), }; let sync_params = FinalitySyncParams { + is_on_demand_task: false, tick: Duration::from_secs(0), recent_finality_proofs_limit: 1024, stall_timeout: Duration::from_secs(1), diff --git a/polkadot/relays/finality/src/lib.rs b/polkadot/relays/finality/src/lib.rs index d5048aa160..64ec5bed05 100644 --- a/polkadot/relays/finality/src/lib.rs +++ b/polkadot/relays/finality/src/lib.rs @@ -28,7 +28,7 @@ mod finality_loop; mod finality_loop_tests; /// Finality proofs synchronization pipeline. -pub trait FinalitySyncPipeline: Clone + Debug + Send + Sync { +pub trait FinalitySyncPipeline: 'static + Clone + Debug + Send + Sync { /// Name of the finality proofs source. const SOURCE_NAME: &'static str; /// Name of the finality proofs target. diff --git a/polkadot/relays/headers/src/sync_loop.rs b/polkadot/relays/headers/src/sync_loop.rs index e4f1b7b045..b204932056 100644 --- a/polkadot/relays/headers/src/sync_loop.rs +++ b/polkadot/relays/headers/src/sync_loop.rs @@ -102,7 +102,7 @@ pub trait TargetClient: RelayClient { /// Synchronization maintain procedure. #[async_trait] -pub trait SyncMaintain: Clone + Send + Sync { +pub trait SyncMaintain: 'static + Clone + Send + Sync { /// Run custom maintain procedures. This is guaranteed to be called when both source and target /// clients are unoccupied. async fn maintain(&self, _sync: &mut HeadersSync

) {} @@ -125,7 +125,7 @@ pub async fn run>( sync_maintain: impl SyncMaintain

, sync_params: HeadersSyncParams, metrics_params: MetricsParams, - exit_signal: impl Future, + exit_signal: impl Future + 'static + Send, ) -> Result<(), String> { let exit_signal = exit_signal.shared(); relay_utils::relay_loop(source_client, target_client) @@ -134,7 +134,7 @@ pub async fn run>( .standalone_metric(|registry, prefix| GlobalMetrics::new(registry, prefix))? .expose() .await? - .run(|source_client, target_client, metrics| { + .run(metrics_prefix::

(), move |source_client, target_client, metrics| { run_until_connection_lost( source_client, source_tick, @@ -159,7 +159,7 @@ async fn run_until_connection_lost>( sync_maintain: impl SyncMaintain

, sync_params: HeadersSyncParams, metrics_sync: Option, - exit_signal: impl Future, + exit_signal: impl Future + Send, ) -> Result<(), FailedClient> { let mut progress_context = (Instant::now(), None, None); diff --git a/polkadot/relays/headers/src/sync_types.rs b/polkadot/relays/headers/src/sync_types.rs index e6500ad5fa..5809ebab59 100644 --- a/polkadot/relays/headers/src/sync_types.rs +++ b/polkadot/relays/headers/src/sync_types.rs @@ -43,7 +43,7 @@ pub enum HeaderStatus { } /// Headers synchronization pipeline. -pub trait HeadersSyncPipeline: Clone + Send + Sync { +pub trait HeadersSyncPipeline: 'static + Clone + Send + Sync { /// Name of the headers source. const SOURCE_NAME: &'static str; /// Name of the headers target. diff --git a/polkadot/relays/messages/src/message_lane.rs b/polkadot/relays/messages/src/message_lane.rs index 5090ef124e..6473ec9875 100644 --- a/polkadot/relays/messages/src/message_lane.rs +++ b/polkadot/relays/messages/src/message_lane.rs @@ -23,7 +23,7 @@ use relay_utils::{BlockNumberBase, HeaderId}; use std::fmt::Debug; /// One-way message lane. -pub trait MessageLane: Clone + Send + Sync { +pub trait MessageLane: 'static + Clone + Send + Sync { /// Name of the messages source. const SOURCE_NAME: &'static str; /// Name of the messages target. diff --git a/polkadot/relays/messages/src/message_lane_loop.rs b/polkadot/relays/messages/src/message_lane_loop.rs index 41eee606d8..af04bf984e 100644 --- a/polkadot/relays/messages/src/message_lane_loop.rs +++ b/polkadot/relays/messages/src/message_lane_loop.rs @@ -227,7 +227,7 @@ pub async fn run( source_client: impl SourceClient

, target_client: impl TargetClient

, metrics_params: MetricsParams, - exit_signal: impl Future, + exit_signal: impl Future + Send + 'static, ) -> Result<(), String> { let exit_signal = exit_signal.shared(); relay_utils::relay_loop(source_client, target_client) @@ -237,15 +237,18 @@ pub async fn run( .standalone_metric(|registry, prefix| GlobalMetrics::new(registry, prefix))? .expose() .await? - .run(|source_client, target_client, metrics| { - run_until_connection_lost( - params.clone(), - source_client, - target_client, - metrics, - exit_signal.clone(), - ) - }) + .run( + metrics_prefix::

(¶ms.lane), + move |source_client, target_client, metrics| { + run_until_connection_lost( + params.clone(), + source_client, + target_client, + metrics, + exit_signal.clone(), + ) + }, + ) .await } @@ -579,6 +582,9 @@ pub(crate) mod tests { ) -> Result<(), TestError> { let mut data = self.data.lock(); (self.tick)(&mut *data); + data.source_state.best_self = + HeaderId(data.source_state.best_self.0 + 1, data.source_state.best_self.1 + 1); + data.source_state.best_finalized_self = data.source_state.best_self; data.submitted_messages_receiving_proofs.push(proof); data.source_latest_confirmed_received_nonce = proof; Ok(()) @@ -681,6 +687,7 @@ pub(crate) mod tests { } data.target_state.best_self = HeaderId(data.target_state.best_self.0 + 1, data.target_state.best_self.1 + 1); + data.target_state.best_finalized_self = data.target_state.best_self; data.target_latest_received_nonce = *proof.0.end(); if let Some(target_latest_confirmed_received_nonce) = proof.1 { data.target_latest_confirmed_received_nonce = target_latest_confirmed_received_nonce; @@ -701,7 +708,7 @@ pub(crate) mod tests { data: TestClientData, source_tick: Arc, target_tick: Arc, - exit_signal: impl Future, + exit_signal: impl Future + 'static + Send, ) -> TestClientData { async_std::task::block_on(async { let data = Arc::new(Mutex::new(data)); @@ -809,37 +816,37 @@ pub(crate) mod tests { ..Default::default() }, Arc::new(|data: &mut TestClientData| { + // blocks are produced on every tick + data.source_state.best_self = + HeaderId(data.source_state.best_self.0 + 1, data.source_state.best_self.1 + 1); + data.source_state.best_finalized_self = data.source_state.best_self; // headers relay must only be started when we need new target headers at source node if data.target_to_source_header_required.is_some() { assert!(data.source_state.best_finalized_peer_at_best_self.0 < data.target_state.best_self.0); data.target_to_source_header_required = None; } + // syncing target headers -> source chain + if let Some(last_requirement) = data.target_to_source_header_requirements.last() { + if *last_requirement != data.source_state.best_finalized_peer_at_best_self { + data.source_state.best_finalized_peer_at_best_self = *last_requirement; + } + } }), Arc::new(move |data: &mut TestClientData| { + // blocks are produced on every tick + data.target_state.best_self = + HeaderId(data.target_state.best_self.0 + 1, data.target_state.best_self.1 + 1); + data.target_state.best_finalized_self = data.target_state.best_self; // headers relay must only be started when we need new source headers at target node if data.source_to_target_header_required.is_some() { assert!(data.target_state.best_finalized_peer_at_best_self.0 < data.source_state.best_self.0); data.source_to_target_header_required = None; } - // syncing source headers -> target chain (all at once) - if data.target_state.best_finalized_peer_at_best_self.0 < data.source_state.best_finalized_self.0 { - data.target_state.best_finalized_peer_at_best_self = data.source_state.best_finalized_self; - } - // syncing source headers -> target chain (all at once) - if data.source_state.best_finalized_peer_at_best_self.0 < data.target_state.best_finalized_self.0 { - data.source_state.best_finalized_peer_at_best_self = data.target_state.best_finalized_self; - } - // if target has received messages batch => increase blocks so that confirmations may be sent - if data.target_latest_received_nonce == 4 - || data.target_latest_received_nonce == 8 - || data.target_latest_received_nonce == 10 - { - data.target_state.best_self = - HeaderId(data.target_state.best_self.0 + 1, data.target_state.best_self.0 + 1); - data.target_state.best_finalized_self = data.target_state.best_self; - data.source_state.best_self = - HeaderId(data.source_state.best_self.0 + 1, data.source_state.best_self.0 + 1); - data.source_state.best_finalized_self = data.source_state.best_self; + // syncing source headers -> target chain + if let Some(last_requirement) = data.source_to_target_header_requirements.last() { + if *last_requirement != data.target_state.best_finalized_peer_at_best_self { + data.target_state.best_finalized_peer_at_best_self = *last_requirement; + } } // if source has received all messages receiving confirmations => stop if data.source_latest_confirmed_received_nonce == 10 { diff --git a/polkadot/relays/messages/src/message_race_delivery.rs b/polkadot/relays/messages/src/message_race_delivery.rs index 225c59f23c..b50b0ffe31 100644 --- a/polkadot/relays/messages/src/message_race_delivery.rs +++ b/polkadot/relays/messages/src/message_race_delivery.rs @@ -292,7 +292,16 @@ impl RaceStrategy, TargetHeaderIdOf

, P::M } fn required_source_header_at_target(&self, current_best: &SourceHeaderIdOf

) -> Option> { - self.strategy.required_source_header_at_target(current_best) + let header_required_for_messages_delivery = self.strategy.required_source_header_at_target(current_best); + let header_required_for_reward_confirmations_delivery = + self.latest_confirmed_nonces_at_source.back().map(|(id, _)| id.clone()); + match ( + header_required_for_messages_delivery, + header_required_for_reward_confirmations_delivery, + ) { + (Some(id1), Some(id2)) => Some(if id1.0 > id2.0 { id1 } else { id2 }), + (a, b) => a.or(b), + } } fn best_at_source(&self) -> Option { @@ -876,4 +885,46 @@ mod tests { Some(((20..=23), proof_parameters(true, 4))) ); } + + #[test] + fn source_header_is_requied_when_confirmations_are_required() { + // let's prepare situation when: + // - all messages [20; 23] have been generated at source block#1; + let (mut state, mut strategy) = prepare_strategy(); + // - messages [20; 21] have been delivered, but messages [11; 20] can't be delivered because of unrewarded + // relayers vector capacity; + strategy.max_unconfirmed_nonces_at_target = 2; + assert_eq!( + strategy.select_nonces_to_deliver(&state), + Some(((20..=21), proof_parameters(false, 2))) + ); + strategy.finalized_target_nonces_updated( + TargetClientNonces { + latest_nonce: 21, + nonces_data: DeliveryRaceTargetNoncesData { + confirmed_nonce: 19, + unrewarded_relayers: UnrewardedRelayersState { + unrewarded_relayer_entries: 2, + messages_in_oldest_entry: 2, + total_messages: 2, + }, + }, + }, + &mut state, + ); + assert_eq!(strategy.select_nonces_to_deliver(&state), None); + // - messages [1; 10] receiving confirmation has been delivered at source block#2; + strategy.source_nonces_updated( + header_id(2), + SourceClientNonces { + new_nonces: BTreeMap::new(), + confirmed_nonce: Some(21), + }, + ); + // - so now we'll need to relay source block#11 to be able to accept messages [11; 20]. + assert_eq!( + strategy.required_source_header_at_target(&header_id(1)), + Some(header_id(2)) + ); + } } diff --git a/polkadot/relays/utils/src/initialize.rs b/polkadot/relays/utils/src/initialize.rs index 7d5f66a538..b87937923b 100644 --- a/polkadot/relays/utils/src/initialize.rs +++ b/polkadot/relays/utils/src/initialize.rs @@ -16,7 +16,11 @@ //! Relayer initialization functions. -use std::{fmt::Display, io::Write}; +use std::{cell::RefCell, fmt::Display, io::Write}; + +async_std::task_local! { + pub(crate) static LOOP_NAME: RefCell = RefCell::new(String::default()); +} /// Initialize relay environment. pub fn initialize_relay() { @@ -43,20 +47,56 @@ pub fn initialize_logger(with_timestamp: bool) { Either::Right(ansi_term::Colour::Fixed(8).bold().paint(timestamp)) }; - writeln!(buf, "{} {} {} {}", timestamp, log_level, log_target, record.args(),) + writeln!( + buf, + "{}{} {} {} {}", + loop_name_prefix(), + timestamp, + log_level, + log_target, + record.args(), + ) }); } else { builder.format(move |buf, record| { let log_level = color_level(record.level()); let log_target = color_target(record.target()); - writeln!(buf, "{} {} {}", log_level, log_target, record.args(),) + writeln!( + buf, + "{}{} {} {}", + loop_name_prefix(), + log_level, + log_target, + record.args(), + ) }); } builder.init(); } +/// Initialize relay loop. Must only be called once per every loop task. +pub(crate) fn initialize_loop(loop_name: String) { + LOOP_NAME.with(|g_loop_name| *g_loop_name.borrow_mut() = loop_name); +} + +/// Returns loop name prefix to use in logs. The prefix is initialized with the `initialize_loop` call. +fn loop_name_prefix() -> String { + // try_with to avoid panic outside of async-std task context + LOOP_NAME + .try_with(|loop_name| { + // using borrow is ok here, because loop is only initialized once (=> borrow_mut will only be called once) + let loop_name = loop_name.borrow(); + if loop_name.is_empty() { + String::new() + } else { + format!("[{}] ", loop_name) + } + }) + .unwrap_or_else(|_| String::new()) +} + enum Either { Left(A), Right(B), diff --git a/polkadot/relays/utils/src/relay_loop.rs b/polkadot/relays/utils/src/relay_loop.rs index 8790b0913e..8fcaabe443 100644 --- a/polkadot/relays/utils/src/relay_loop.rs +++ b/polkadot/relays/utils/src/relay_loop.rs @@ -26,9 +26,9 @@ pub const RECONNECT_DELAY: Duration = Duration::from_secs(10); /// Basic blockchain client from relay perspective. #[async_trait] -pub trait Client: Clone + Send + Sync { +pub trait Client: 'static + Clone + Send + Sync { /// Type of error this clients returns. - type Error: Debug + MaybeConnectionError; + type Error: 'static + Debug + MaybeConnectionError + Send + Sync; /// Try to reconnect to source node. async fn reconnect(&mut self) -> Result<(), Self::Error>; @@ -38,6 +38,7 @@ pub trait Client: Clone + Send + Sync { pub fn relay_loop(source_client: SC, target_client: TC) -> Loop { Loop { reconnect_delay: RECONNECT_DELAY, + spawn_loop_task: true, source_client, target_client, loop_metric: None, @@ -49,6 +50,7 @@ pub fn relay_metrics(prefix: Option, params: MetricsParams) -> LoopMetri LoopMetrics { relay_loop: Loop { reconnect_delay: RECONNECT_DELAY, + spawn_loop_task: true, source_client: (), target_client: (), loop_metric: None, @@ -63,6 +65,7 @@ pub fn relay_metrics(prefix: Option, params: MetricsParams) -> LoopMetri /// Generic relay loop. pub struct Loop { reconnect_delay: Duration, + spawn_loop_task: bool, source_client: SC, target_client: TC, loop_metric: Option, @@ -84,11 +87,23 @@ impl Loop { self } + /// Set spawn-dedicated-loop-task flag. + /// + /// If `true` (default), separate async task is spawned to run relay loop. This is the default + /// behavior for all loops. If `false`, then loop is executed as a part of the current + /// task. The `false` is used for on-demand tasks, which are cancelled from time to time + /// and there's already a dedicated on-demand task for running such loops. + pub fn spawn_loop_task(mut self, spawn_loop_task: bool) -> Self { + self.spawn_loop_task = spawn_loop_task; + self + } + /// Start building loop metrics using given prefix. pub fn with_metrics(self, prefix: Option, params: MetricsParams) -> LoopMetrics { LoopMetrics { relay_loop: Loop { reconnect_delay: self.reconnect_delay, + spawn_loop_task: self.spawn_loop_task, source_client: self.source_client, target_client: self.target_client, loop_metric: None, @@ -105,63 +120,47 @@ impl Loop { /// This function represents an outer loop, which in turn calls provided `run_loop` function to do /// actual job. When `run_loop` returns, this outer loop reconnects to failed client (source, /// target or both) and calls `run_loop` again. - pub async fn run(mut self, run_loop: R) -> Result<(), String> + pub async fn run(mut self, loop_name: String, run_loop: R) -> Result<(), String> where - R: Fn(SC, TC, Option) -> F, - F: Future>, - SC: Client, - TC: Client, - LM: Clone, + R: 'static + Send + Fn(SC, TC, Option) -> F, + F: 'static + Send + Future>, + SC: 'static + Client, + TC: 'static + Client, + LM: 'static + Send + Clone, { - loop { - let result = run_loop( - self.source_client.clone(), - self.target_client.clone(), - self.loop_metric.clone(), - ) - .await; + let spawn_loop_task = self.spawn_loop_task; + let run_loop_task = async move { + crate::initialize::initialize_loop(loop_name); - match result { - Ok(()) => break, - Err(failed_client) => loop { - async_std::task::sleep(self.reconnect_delay).await; - if failed_client == FailedClient::Both || failed_client == FailedClient::Source { - match self.source_client.reconnect().await { - Ok(()) => (), - Err(error) => { - log::warn!( - target: "bridge", - "Failed to reconnect to source client. Going to retry in {}s: {:?}", - self.reconnect_delay.as_secs(), - error, - ); - continue; - } - } - } - if failed_client == FailedClient::Both || failed_client == FailedClient::Target { - match self.target_client.reconnect().await { - Ok(()) => (), - Err(error) => { - log::warn!( - target: "bridge", - "Failed to reconnect to target client. Going to retry in {}s: {:?}", - self.reconnect_delay.as_secs(), - error, - ); - continue; - } - } - } + loop { + let loop_metric = self.loop_metric.clone(); + let future_result = run_loop(self.source_client.clone(), self.target_client.clone(), loop_metric); + let result = future_result.await; - break; - }, + match result { + Ok(()) => break, + Err(failed_client) => { + reconnect_failed_client( + failed_client, + self.reconnect_delay, + &mut self.source_client, + &mut self.target_client, + ) + .await + } + } + + log::debug!(target: "bridge", "Restarting relay loop"); } - log::debug!(target: "bridge", "Restarting relay loop"); - } + Ok(()) + }; - Ok(()) + if spawn_loop_task { + async_std::task::spawn(run_loop_task).await + } else { + run_loop_task.await + } } } @@ -237,6 +236,7 @@ impl LoopMetrics { Ok(Loop { reconnect_delay: self.relay_loop.reconnect_delay, + spawn_loop_task: self.relay_loop.spawn_loop_task, source_client: self.relay_loop.source_client, target_client: self.relay_loop.target_client, loop_metric: self.loop_metric, @@ -244,6 +244,48 @@ impl LoopMetrics { } } +/// Deal with the client who has returned connection error. +pub async fn reconnect_failed_client( + failed_client: FailedClient, + reconnect_delay: Duration, + source_client: &mut impl Client, + target_client: &mut impl Client, +) { + loop { + async_std::task::sleep(reconnect_delay).await; + if failed_client == FailedClient::Both || failed_client == FailedClient::Source { + match source_client.reconnect().await { + Ok(()) => (), + Err(error) => { + log::warn!( + target: "bridge", + "Failed to reconnect to source client. Going to retry in {}s: {:?}", + reconnect_delay.as_secs(), + error, + ); + continue; + } + } + } + if failed_client == FailedClient::Both || failed_client == FailedClient::Target { + match target_client.reconnect().await { + Ok(()) => (), + Err(error) => { + log::warn!( + target: "bridge", + "Failed to reconnect to target client. Going to retry in {}s: {:?}", + reconnect_delay.as_secs(), + error, + ); + continue; + } + } + } + + break; + } +} + /// Create new registry with global metrics. fn create_metrics_registry(prefix: Option) -> Registry { match prefix { diff --git a/polkadot/scripts/dump-logs.sh b/polkadot/scripts/dump-logs.sh index f076cbccbc..02aa4af2f7 100644 --- a/polkadot/scripts/dump-logs.sh +++ b/polkadot/scripts/dump-logs.sh @@ -15,10 +15,10 @@ cd $LOGS_DIR SERVICES=(\ deployments_relay-messages-millau-to-rialto-generator_1 \ deployments_relay-messages-rialto-to-millau-generator_1 \ - deployments_relay-messages-millau-to-rialto_1 \ - deployments_relay-messages-rialto-to-millau_1 \ - deployments_relay-headers-millau-to-rialto_1 \ - deployments_relay-headers-rialto-to-millau_1 \ + deployments_relay-messages-millau-to-rialto-lane-00000001_1 \ + deployments_relay-messages-rialto-to-millau-lane-00000001_1 \ + deployments_relay-millau-rialto_1 \ + deployments_relay-headers-westend-to-millau_1 \ deployments_rialto-node-alice_1 \ deployments_rialto-node-bob_1 \ deployments_millau-node-alice_1 \