diff --git a/polkadot/.config/lingua.dic b/polkadot/.config/lingua.dic new file mode 100644 index 0000000000000000000000000000000000000000..a31ecf2c7bde9bbd099d2301dba708cdc8b5e7e7 --- /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 0000000000000000000000000000000000000000..015f9b97c75fd9c990b679b80d38f7bdd04f5aeb --- /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 61599ccba92e32ebd77f66c9bc51346286598315..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..a06d573703d8a63a6ad42b4c824edc33e49b0802 --- /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 4ebd12e0d6ff32776406212fcbbc9c32ecbd4471..e01f2cf065de48efeb176a748f2e71135dc9b2cf 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 e6f7939efbcf8007c1ef0966b1c57f24f9d9f770..14e72ddad02e9d4ccefc46918706284ccf74d7e4 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 5811d7ad3b12f11f1bb3526d618291faf699765b..abe77d2a3c3c049c0e90e746938082c39cc0432c 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 8f6446c8875aac67bac71a9bf2cff0b91cacebc3..84d776c4f8effd0b66b5f0c5dc4a4889b71ab141 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 e31e2c871a50848e18d728dc27fd68787913c4b7..4c5f081e150693c13165ac3ebe4205df73e1657f 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 f9e9502da72ba205c4ecebd55336a05feb85f7a7..374c0f739c53ac76f69a3999b5affe12072d57ef 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::<sr25519::Public>("Bob"), get_account_id_from_seed::<sr25519::Public>("Alice//stash"), get_account_id_from_seed::<sr25519::Public>("Bob//stash"), + derive_account_from_rialto_id(bp_runtime::SourceAccount::Account( + get_account_id_from_seed::<sr25519::Public>("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::<sr25519::Public>("Dave"), + get_account_id_from_seed::<sr25519::Public>("Alice"), + )), + derive_account_from_rialto_id(bp_runtime::SourceAccount::Account( + get_account_id_from_seed::<sr25519::Public>("Charlie"), + )), + derive_account_from_rialto_id(bp_runtime::SourceAccount::Account( + get_account_id_from_seed::<sr25519::Public>("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 46323ed25c9ed2e39ebc6089b5bfa0e2ad29ddfd..12f99b6b95bab227725a30c3d61b188a28c35df1 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 8677ec2e70df1ccb0a8c96a2dc3cb2197215fed4..a3cb4fa2457d3d4438392d32303eac5f1c8b4542 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::<AuraPair, _, _, _, _, _>(ImportQueueParams { + let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); + + let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _, _>(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<TaskManager, ServiceError> 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<TaskManager, ServiceError> let can_author_with = sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); - let aura = sc_consensus_aura::start_aura::<AuraPair, _, _, _, _, _, _, _, _, _>(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::<AuraPair, _, _, _, _, _, _, _, _, _, _>(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<TaskManager, ServiceError> let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone()); - let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _>(ImportQueueParams { + let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); + let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _, _>(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 e1f7ed10c63e653963136087dcd12ede3c53307e..240b079d110f42fabc3182cadf92fdd4e6d4f196 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 dcb5cb06218e542b110a6ee545280b9fef8b010a..cc865704327dd9b90f87fdbe22f5eb49aca5e82b 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 <http://www.gnu.org/licenses/>. -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 30cf1bd87cd87657dbc3e7f97824895e7c95db45..4f5e0836320028529a1931b1baecb9aa15e55a13 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() -> <Block as BlockT>::Hash { - RandomnessCollectiveFlip::random_seed().0 - } } impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime { diff --git a/polkadot/bin/millau/runtime/src/rialto_messages.rs b/polkadot/bin/millau/runtime/src/rialto_messages.rs index a800117dc551896f23074d798c34f6d132ec8e12..a61d7cce2978d5c20cc967355387e90161f2489a 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<ToRialtoMessagePayload, bp_rialto::AccountId> for Rialto fn verify_messages_delivery_proof( proof: Self::MessagesDeliveryProof, ) -> Result<(LaneId, InboundLaneData<bp_millau::AccountId>), Self::Error> { - messages::source::verify_messages_delivery_proof::<WithRialtoMessageBridge, Runtime>(proof) + messages::source::verify_messages_delivery_proof::<WithRialtoMessageBridge, Runtime, crate::RialtoGrandpaInstance>( + proof, + ) } } @@ -231,7 +233,10 @@ impl SourceHeaderChain<bp_rialto::Balance> for Rialto { proof: Self::MessagesProof, messages_count: u32, ) -> Result<ProvedMessages<Message<bp_rialto::Balance>>, Self::Error> { - messages::target::verify_messages_proof::<WithRialtoMessageBridge, Runtime>(proof, messages_count) + messages::target::verify_messages_proof::<WithRialtoMessageBridge, Runtime, crate::RialtoGrandpaInstance>( + proof, + messages_count, + ) } } diff --git a/polkadot/bin/rialto/node/Cargo.toml b/polkadot/bin/rialto/node/Cargo.toml index a51ee7a5ab5f20feb96d717b15c3140a139f2c73..38272cd8c786feb9a9f492000c9e15303696f00c 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 732cf1a4b13a2f12198d9f73e11594be0f26f4ae..cf14845df1906b279238c5d5164a46980e75577f 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::<sr25519::Public>("Bob"), get_account_id_from_seed::<sr25519::Public>("Alice//stash"), get_account_id_from_seed::<sr25519::Public>("Bob//stash"), + derive_account_from_millau_id(bp_runtime::SourceAccount::Account( + get_account_id_from_seed::<sr25519::Public>("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::<sr25519::Public>("Bob"), + )), derive_account_from_millau_id(bp_runtime::SourceAccount::Account( get_account_id_from_seed::<sr25519::Public>("Dave"), )), + derive_account_from_millau_id(bp_runtime::SourceAccount::Account( + get_account_id_from_seed::<sr25519::Public>("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 46323ed25c9ed2e39ebc6089b5bfa0e2ad29ddfd..12f99b6b95bab227725a30c3d61b188a28c35df1 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 841202ac7bfa5372918214a8df5da970ee7afa74..a0d3d311a018b6b3a71353ff292272628316d02a 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::<AuraPair, _, _, _, _, _>(ImportQueueParams { + let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); + + let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _, _>(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<TaskManager, ServiceError> 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<TaskManager, ServiceError> let can_author_with = sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); - let aura = sc_consensus_aura::start_aura::<AuraPair, _, _, _, _, _, _, _, _, _>(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::<AuraPair, _, _, _, _, _, _, _, _, _, _>(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<TaskManager, ServiceError> let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(grandpa_block_import.clone(), client.clone()); - let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _>(ImportQueueParams { + let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration(); + let import_queue = sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _, _>(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 ea8c51d0e8c00eb2809dde05a0b1f2c51b97480f..63a48a255bd42da94b815f265d6592d5143c7b12 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 dcb5cb06218e542b110a6ee545280b9fef8b010a..cc865704327dd9b90f87fdbe22f5eb49aca5e82b 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 <http://www.gnu.org/licenses/>. -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 4e81d3efb1fb16351433b163c32838c1f3e4ae9d..5259a10493a76a8065db81c7a665a0f46e5db607 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; +} + +#[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; +} - // Number of headers to keep. - // - // Assuming the worst case of every header being finalized, we will keep headers at least for a - // week. +#[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() -> <Block as BlockT>::Hash { - RandomnessCollectiveFlip::random_seed().0 - } } impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime { @@ -874,7 +885,7 @@ impl_runtime_apis! { params: MessageParams<Self::AccountId>, ) -> (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 8ee2094660c104b2bff2b74b39265f69ebdbeece..30a34b9276ce1ddb5cd2c16893f3f19b0e68d9c8 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<ToMillauMessagePayload, bp_millau::AccountId> for Millau fn verify_messages_delivery_proof( proof: Self::MessagesDeliveryProof, ) -> Result<(LaneId, InboundLaneData<bp_rialto::AccountId>), Self::Error> { - messages::source::verify_messages_delivery_proof::<WithMillauMessageBridge, Runtime>(proof) + messages::source::verify_messages_delivery_proof::<WithMillauMessageBridge, Runtime, crate::MillauGrandpaInstance>( + proof, + ) } } @@ -231,7 +233,10 @@ impl SourceHeaderChain<bp_millau::Balance> for Millau { proof: Self::MessagesProof, messages_count: u32, ) -> Result<ProvedMessages<Message<bp_millau::Balance>>, Self::Error> { - messages::target::verify_messages_proof::<WithMillauMessageBridge, Runtime>(proof, messages_count) + messages::target::verify_messages_proof::<WithMillauMessageBridge, Runtime, crate::MillauGrandpaInstance>( + proof, + messages_count, + ) } } diff --git a/polkadot/bin/runtime-common/README.md b/polkadot/bin/runtime-common/README.md index b375f48309c3a6bd33f35bffc7a518cc5257db0c..a7322af9739962242826aaa724a13221aab85204 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 8e83c0f94ada4ee538b9bdf51314a8012997f8fd..e879aa17bfb2bb9b327d52cec45eba3ea30a1ca4 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<u8>; /// Message payload for This -> Bridged chain messages. - pub type FromThisChainMessagePayload<B> = pallet_bridge_dispatch::MessagePayload< + pub type FromThisChainMessagePayload<B> = bp_message_dispatch::MessagePayload< AccountIdOf<ThisChain<B>>, SignerOf<BridgedChain<B>>, SignatureOf<BridgedChain<B>>, @@ -352,20 +352,21 @@ pub mod source { } /// Verify proof of This -> Bridged chain messages delivery. - pub fn verify_messages_delivery_proof<B: MessageBridge, ThisRuntime>( + pub fn verify_messages_delivery_proof<B: MessageBridge, ThisRuntime, GrandpaInstance: 'static>( proof: FromBridgedChainMessagesDeliveryProof<HashOf<BridgedChain<B>>>, ) -> Result<ParsedMessagesDeliveryProofFromBridgedChain<B>, &'static str> where - ThisRuntime: pallet_bridge_grandpa::Config, + ThisRuntime: pallet_bridge_grandpa::Config<GrandpaInstance>, ThisRuntime: pallet_bridge_messages::Config<MessagesInstanceOf<BridgedChain<B>>>, - HashOf<BridgedChain<B>>: Into<bp_runtime::HashOf<<ThisRuntime as pallet_bridge_grandpa::Config>::BridgedChain>>, + HashOf<BridgedChain<B>>: + Into<bp_runtime::HashOf<<ThisRuntime as pallet_bridge_grandpa::Config<GrandpaInstance>>::BridgedChain>>, { let FromBridgedChainMessagesDeliveryProof { bridged_header_hash, storage_proof, lane, } = proof; - pallet_bridge_grandpa::Pallet::<ThisRuntime>::parse_finalized_storage_proof( + pallet_bridge_grandpa::Pallet::<ThisRuntime, GrandpaInstance>::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<B> = pallet_bridge_dispatch::CallOrigin< + pub type FromBridgedChainMessageCallOrigin<B> = bp_message_dispatch::CallOrigin< AccountIdOf<BridgedChain<B>>, SignerOf<ThisChain<B>>, SignatureOf<ThisChain<B>>, >; /// Decoded Bridged -> This message payload. - pub type FromBridgedChainMessagePayload<B> = pallet_bridge_dispatch::MessagePayload< + pub type FromBridgedChainMessagePayload<B> = bp_message_dispatch::MessagePayload< AccountIdOf<BridgedChain<B>>, SignerOf<ThisChain<B>>, SignatureOf<ThisChain<B>>, @@ -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<B: MessageBridge, ThisRuntime>( + pub fn verify_messages_proof<B: MessageBridge, ThisRuntime, GrandpaInstance: 'static>( proof: FromBridgedChainMessagesProof<HashOf<BridgedChain<B>>>, messages_count: u32, ) -> Result<ProvedMessages<Message<BalanceOf<BridgedChain<B>>>>, &'static str> where - ThisRuntime: pallet_bridge_grandpa::Config, + ThisRuntime: pallet_bridge_grandpa::Config<GrandpaInstance>, ThisRuntime: pallet_bridge_messages::Config<MessagesInstanceOf<BridgedChain<B>>>, - HashOf<BridgedChain<B>>: Into<bp_runtime::HashOf<<ThisRuntime as pallet_bridge_grandpa::Config>::BridgedChain>>, + HashOf<BridgedChain<B>>: + Into<bp_runtime::HashOf<<ThisRuntime as pallet_bridge_grandpa::Config<GrandpaInstance>>::BridgedChain>>, { verify_messages_proof_with_parser::<B, _, _>( proof, messages_count, |bridged_header_hash, bridged_storage_proof| { - pallet_bridge_grandpa::Pallet::<ThisRuntime>::parse_finalized_storage_proof( + pallet_bridge_grandpa::Pallet::<ThisRuntime, GrandpaInstance>::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::<OnBridgedChainBridge> { 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::<OnThisChainBridge> { spec_version: 1, weight: 100, - origin: pallet_bridge_dispatch::CallOrigin::SourceRoot, + origin: bp_message_dispatch::CallOrigin::SourceRoot, call: target::FromBridgedChainEncodedMessageCall::<OnThisChainBridge> { encoded_call: ThisChainCall::Transfer.encode(), _marker: PhantomData::default(), @@ -960,7 +962,7 @@ mod tests { source::FromThisChainMessagePayload::<OnThisChainBridge> { 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::<OnThisChainBridge> { 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::<OnThisChainBridge> { 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::<OnThisChainBridge>() 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::<OnThisChainBridge>() 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 d54d16f7e3440a28dea23eb6233bad95e84a9ca4..0000000000000000000000000000000000000000 --- 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 e718656a9d1e77cad3e5cd115266f08f24ef75ca..0000000000000000000000000000000000000000 --- 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 14b1eee6d4505e612736795926e1750cf6d4ec52..9ca3ca42ff5e51eab3c1cbd5ee9181a5384f9ed0 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 542082f85ab167265b8b26cea570178218c5d135..9a8af5ba5016f046816688e91a7b98dd108c83a1 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 f2ee04beaf53eac74763414136ad1ec0aeceb9f7..c4e703c402d5af61c9aa02cd41f56fe29dc0a345 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 416d080b0c17a3c46896c0e28721fcf82fa45878..0b0074c20b76bf7a606075defe91cdeed6864438 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<SourceChainAccountId, TargetChainAccountPublic, TargetChainSignature> { - /// 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 `(<some-source-account-id>, 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<SourceChainAccountId, TargetChainAccountPublic, TargetChainSignature, Call> { - /// 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<SourceChainAccountId, TargetChainAccountPublic, TargetChainSignature>, - /// The call itself. - pub call: Call, -} - -impl<SourceChainAccountId, TargetChainAccountPublic, TargetChainSignature> Size - for MessagePayload<SourceChainAccountId, TargetChainAccountPublic, TargetChainSignature, Vec<u8>> -{ - fn size_hint(&self) -> u32 { - self.call.len() as _ - } -} - /// The module configuration trait. pub trait Config<I = DefaultInstance>: frame_system::Config { /// The overarching event type. @@ -314,8 +241,7 @@ impl<T: Config<I>, I: Instance> MessageDispatch<T::MessageId> for Pallet<T, I> { // 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 cb170fdc8b193fd90ef5792260cb42686c1b7364..b7294e918003ebb2dfa374bdc863984a176139ab 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<T: Config<I>, I: 'static, N: From<u32>>() -> 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::<T, I>(init_data); - let header: BridgedHeader<T, I> = bp_test_utils::test_header(One::one()); + bootstrap_bridge::<T, I>(init_data); + let header: BridgedHeader<T, I> = bp_test_utils::test_header(header_number::<T, I, _>()); 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<T, I> = bp_test_utils::test_header(One::one()); + let header: BridgedHeader<T, I> = bp_test_utils::test_header(header_number::<T, I, _>()); let expected_hash = header.hash(); assert_eq!(<BestFinalized<T, I>>::get(), expected_hash); @@ -127,8 +136,8 @@ benchmarks_instance_pallet! { is_halted: false, }; - initialize_bridge::<T, I>(init_data); - let header: BridgedHeader<T, I> = bp_test_utils::test_header(One::one()); + bootstrap_bridge::<T, I>(init_data); + let header: BridgedHeader<T, I> = bp_test_utils::test_header(header_number::<T, I, _>()); 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<T, I> = bp_test_utils::test_header(One::one()); + let header: BridgedHeader<T, I> = bp_test_utils::test_header(header_number::<T, I, _>()); let expected_hash = header.hash(); assert_eq!(<BestFinalized<T, I>>::get(), expected_hash); @@ -170,8 +179,8 @@ benchmarks_instance_pallet! { is_halted: false, }; - initialize_bridge::<T, I>(init_data); - let header: BridgedHeader<T, I> = bp_test_utils::test_header(One::one()); + bootstrap_bridge::<T, I>(init_data); + let header: BridgedHeader<T, I> = bp_test_utils::test_header(header_number::<T, I, _>()); 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<T, I> = bp_test_utils::test_header(One::one()); + let header: BridgedHeader<T, I> = bp_test_utils::test_header(header_number::<T, I, _>()); let expected_hash = header.hash(); assert_eq!(<BestFinalized<T, I>>::get(), expected_hash); diff --git a/polkadot/modules/grandpa/src/lib.rs b/polkadot/modules/grandpa/src/lib.rs index 9fb7372b0204e221dd7cc94829e3de1df3d2fa13..d38f61826f98c3b9f4920819092e0fad2bd16ee6 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 = <ImportedHeaders<T, I>>::get(<BestFinalized<T, I>>::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 <ImportedHeaders<T, I>>::get(<BestFinalized<T, I>>::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!(<Error<T, I>>::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::<T, I>(&justification, hash, *number, authority_set)?; let _enacted = try_enact_authority_change::<T, I>(&finality_target, set_id)?; - let index = <ImportedHashesPointer<T, I>>::get(); - let pruning = <ImportedHashes<T, I>>::try_get(index); - <BestFinalized<T, I>>::put(hash); - <ImportedHeaders<T, I>>::insert(hash, finality_target); - <ImportedHashes<T, I>>::insert(index, hash); <RequestCount<T, I>>::mutate(|count| *count += 1); - - // Update ring buffer pointer and remove old header. - <ImportedHashesPointer<T, I>>::put((index + 1) % T::HeadersToKeep::get()); - if let Ok(hash) = pruning { - log::debug!(target: "runtime::bridge-grandpa", "Pruning old header: {:?}.", hash); - <ImportedHeaders<T, I>>::remove(hash); - } - + insert_header::<T, I>(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<T: Config<I>, I: 'static>(header: BridgedHeader<T, I>, hash: BridgedBlockHash<T, I>) { + let index = <ImportedHashesPointer<T, I>>::get(); + let pruning = <ImportedHashes<T, I>>::try_get(index); + <BestFinalized<T, I>>::put(hash); + <ImportedHeaders<T, I>>::insert(hash, header); + <ImportedHashes<T, I>>::insert(index, hash); + + // Update ring buffer pointer and remove old header. + <ImportedHashesPointer<T, I>>::put((index + 1) % T::HeadersToKeep::get()); + if let Ok(hash) = pruning { + log::debug!(target: "runtime::bridge-grandpa", "Pruning old header: {:?}.", hash); + <ImportedHeaders<T, I>>::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<T: Config<I>, I: 'static>( @@ -441,8 +456,8 @@ pub mod pallet { let initial_hash = header.hash(); <InitialHash<T, I>>::put(initial_hash); - <BestFinalized<T, I>>::put(initial_hash); - <ImportedHeaders<T, I>>::insert(initial_hash, header); + <ImportedHashesPointer<T, I>>::put(0); + insert_header::<T, I>(header, initial_hash); let authority_set = bp_header_chain::AuthoritySet::new(authority_list, set_id); <CurrentAuthoritySet<T, I>>::put(authority_set); @@ -450,6 +465,29 @@ pub mod pallet { <IsHalted<T, I>>::put(is_halted); } + #[cfg(feature = "runtime-benchmarks")] + pub(crate) fn bootstrap_bridge<T: Config<I>, I: 'static>( + init_params: super::InitializationData<BridgedHeader<T, I>>, + ) { + let start_number = *init_params.header.number(); + let end_number = start_number + T::HeadersToKeep::get().into(); + initialize_bridge::<T, I>(init_params); + + let mut number = start_number; + while number < end_number { + number = number + sp_runtime::traits::One::one(); + let header = <BridgedHeader<T, I>>::new( + number, + Default::default(), + Default::default(), + Default::default(), + Default::default(), + ); + let hash = header.hash(); + insert_header::<T, I>(header, hash); + } + } + /// Ensure that the origin is either root, or `PalletOwner`. fn ensure_owner_or_root<T: Config<I>, 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::<TestRuntime>::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 a548534a20b7eb368e0a363b9663dfee7fa3b0b6..9e7c2ebc087e81d79cdc0dcff6859ddeea433189 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<T>(PhantomData<T>); impl<T: frame_system::Config> WeightInfo for RialtoWeight<T> { 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<T: frame_system::Config> WeightInfo for RialtoWeight<T> { 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 0eecd0d84623724e46f1c9930604367d898715fb..f86a21e3ed9086f75a407e3e3e7bcb9f45e08f21 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<T>(PhantomData<T>); impl<T: frame_system::Config> WeightInfo for RialtoWeight<T> { 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<T: frame_system::Config> WeightInfo for RialtoWeight<T> { // 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 22f09cb5b09300a6e6eec7db0907c5feac75b653..a5f3a888f9ad0f18afb0260141882a5e7e392617 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 c10f31bae33f13d44fa117e9a08b979fb223226c..c063dc72a7f2593cb4a4b86ad4b14cc03d67434e 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 b79fdf6cfcf01f858268ad4a858a47f3fcfe1c4a..66cbb475bda2dae7bed4eecf934ed656325902ae 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( <PolkadotLike as Chain>::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>) -> 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 0000000000000000000000000000000000000000..ecf783a51eeb90e033b1c9705488cb5b245f5f4d --- /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 <admin@parity.io>"] +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 0000000000000000000000000000000000000000..f7a472ddf31dfd78b459a695151cdd3b98a682f5 --- /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 <http://www.gnu.org/licenses/>. + +#![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<Call>; + +// 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( + <PolkadotLike as Chain>::Header, + bp_header_chain::justification::GrandpaJustification<<PolkadotLike as Chain>::Header>, + ), + #[codec(index = 1)] + initialize(bp_header_chain::InitializationData<<PolkadotLike as Chain>::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<Self::PostInfo> { + 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>) -> 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<OutboundMessageFee: Parameter, OutboundPayload: Parameter> { + /// 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<OutboundMessageFee>; + /// 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 293c637e8df25994173fca9ebb9152b2996263f8..84fa48553a21ad018e44be450887fd5e4e3240b9 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 3b83e38517e2d282c13523735331a513b7df04dc..1244371239644463a777ba2ce615ae6046affe12 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<MessageId> { /// A type of the message to be dispatched. @@ -47,3 +53,70 @@ pub trait MessageDispatch<MessageId> { /// the whole message). fn dispatch(bridge: InstanceId, id: MessageId, message: Result<Self::Message, ()>); } + +/// 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<SourceChainAccountId, TargetChainAccountPublic, TargetChainSignature> { + /// 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 `(<some-source-account-id>, 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<SourceChainAccountId, TargetChainAccountPublic, TargetChainSignature, Call> { + /// 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<SourceChainAccountId, TargetChainAccountPublic, TargetChainSignature>, + /// The call itself. + pub call: Call, +} + +impl<SourceChainAccountId, TargetChainAccountPublic, TargetChainSignature> Size + for MessagePayload<SourceChainAccountId, TargetChainAccountPublic, TargetChainSignature, Vec<u8>> +{ + 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 e7f990d2830964edde0353ee9a165701d13ad97f..aa457f1d0b0bc74755f0b15cc6c22cadd93580b5 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 d203201e60a442955a96fc2801e2e4e32c896f1d..fc61d138fde0be61eda25c3b5cd5484c83afba8d 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 ac5e611fdbcb5ef911538cd763f6ef5410d5ce3b..41ac76082807cc3b5b9a59ddca6cdeddb9b7ebbc 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 9e6a7361d5fdf19ff9a5b49d1a8827517b5e3111..b4061ced37f726905164976da6e890a7162226a2 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::<millau_runtime::Runtime>::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 25c1ab04c9fd1b96d230a8b716b9a8dbc8aa3d20..77eeb06da0d70a5fe97290fc9218bcbd08500e67 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 dca91adb3df68dda77e0b06263d44915d7aa17f9..5247c6068b5ecdb9d517b6c382c8573d6e7b600e 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 <http://www.gnu.org/licenses/>. -//! 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, Westend, WestendSigningParams>; +/// Rococo-to-Wococo finality sync pipeline. +pub(crate) type RococoFinalityToWococo = SubstrateFinalityToSubstrate<Rococo, Wococo, WococoSigningParams>; -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<MetricsParams> { crate::chains::add_polkadot_kusama_price_metrics::<Self>(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: <Westend as Chain>::Index, + transaction_nonce: <Wococo as Chain>::Index, header: RococoSyncHeader, proof: GrandpaJustification<bp_rococo::Header>, ) -> 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 577a858d9229091b67c4c153dd6ea5f7ad761234..f1b390215748d7fc8c86e87e1a9da92ea7fe51fb 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<bp_westend::Header>, ) -> 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 0000000000000000000000000000000000000000..549aa8a882c75e65478c81a3b6c4982291006e36 --- /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 <http://www.gnu.org/licenses/>. + +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<Self::MessagePayload, String> { + 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 0000000000000000000000000000000000000000..9dfae5294e29212059b5ba4568451c02c08eaed0 --- /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 <http://www.gnu.org/licenses/>. + +//! 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<Wococo, Rococo, RococoSigningParams>; + +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<MetricsParams> { + crate::chains::add_polkadot_kusama_price_metrics::<Self>(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: <Rococo as Chain>::Index, + header: WococoSyncHeader, + proof: GrandpaJustification<bp_wococo::Header>, + ) -> 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 faf4417d1e9955f4f28889e7fb80bbcbb0032ebc..996edb49942a100352bd5bc7a42dabdeeef9c2d2 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 92b32b0d479ca5be602e907db596d9e697943b09..dff62c21f6fea0154bbb01cadc8b27243c590201 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 cdd8ec369161dfc757a90737a44e97c9d25525ec..b5590b9e5a445c1808163bf5e9a966396314fc1e 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; - type Target = relay_rococo_client::Rococo; + InitBridgeName::RococoToWococo => { + type Source = relay_rococo_client::Rococo; + type Target = relay_wococo_client::Wococo; fn encode_init_bridge( init_data: InitializationData<<Source as ChainBase>::Header>, ) -> <Target as Chain>::Call { - bp_rococo::Call::BridgeGrandpaWestend(bp_rococo::BridgeGrandpaWestendCall::initialize(init_data)) + bp_wococo::Call::BridgeGrandpaRococo(bp_wococo::BridgeGrandpaRococoCall::initialize(init_data)) } $generic } - InitBridgeName::RococoToWestend => { - type Source = relay_rococo_client::Rococo; - type Target = relay_westend_client::Westend; + InitBridgeName::WococoToRococo => { + type Source = relay_wococo_client::Wococo; + type Target = relay_rococo_client::Rococo; fn encode_init_bridge( init_data: InitializationData<<Source as ChainBase>::Header>, ) -> <Target as Chain>::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 505ef11ee2a51d095e4f591a2c40ed25e7ccb091..341051de5c2790e017ebfca1c35474178c095fe5 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 346790f2ae74e4fc39f3b2246f236dc7b6b8fc30..e8459b58bf605dc38eb4124ef3d1dc62943b49b6 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 98ff1268fae9a79a0f1bae125c21bce23129715f..f2238ba5763c1c24bd9b578fb0a5a09dae374517 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 64448f0f1db3ff68f0d2db762c43c8d29dabd159..6fa82a8cdb5e30ea9702b76a2fe50cc1af3ffdd0 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 bc8461f6a8385aa9a8371c8b7c0f5cebb4a50fd7..dad69b1576b0e6a46a6629e1b1054903bf594caa 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<SourceChain>: 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<SourceChain, TargetChain, P>( pipeline: P, source_client: Client<SourceChain>, target_client: Client<TargetChain>, + 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 6bf7561fcdb37fdfcf1d4846dd763f731143544a..d119042b0d8dc01639734696f19e6381a75dc7c8 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 9948b6ec08365fc8ce6b4dbc51ec660f4cc5bf15..616e2253a6b0309a8b67b09a5de083e623241895 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 cf98f3276be6c25d5ddf962ba45898d9ebe5df9a..0ccf8bbde885a7048c0cb680a0ea23d5f74f3891 100644 --- a/polkadot/relays/bin-substrate/src/messages_source.rs +++ b/polkadot/relays/bin-substrate/src/messages_source.rs @@ -93,7 +93,7 @@ impl<C, P, R, I> RelayClient for SubstrateMessagesSource<C, P, R, I> 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 176083273069bd2facf26717c15378fce2811efb..39f638d7e91c12e34e24c30a33ea2e47adcb506c 100644 --- a/polkadot/relays/bin-substrate/src/messages_target.rs +++ b/polkadot/relays/bin-substrate/src/messages_target.rs @@ -93,7 +93,7 @@ impl<C, P, R, I> RelayClient for SubstrateMessagesTarget<C, P, R, I> 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 4c86b6a17018abece2c030edacfa930d8a02a298..77d2b37054104ca13681dcd61855d29b9f3e0209 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<SourceChain: Chain> OnDemandHeadersRelay<SourceChain> { source_client: Client<SourceChain>, target_client: Client<TargetChain>, pipeline: SubstrateFinalityToSubstrate<SourceChain, TargetChain, TargetSign>, + maximal_headers_difference: SourceChain::BlockNumber, ) -> Self where SourceChain: Chain + Debug, @@ -68,7 +77,14 @@ impl<SourceChain: Chain> OnDemandHeadersRelay<SourceChain> { { 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<SourceChain, TargetChain, TargetSign>( source_client: Client<SourceChain>, target_client: Client<TargetChain>, pipeline: SubstrateFinalityToSubstrate<SourceChain, TargetChain, TargetSign>, + maximal_headers_difference: SourceChain::BlockNumber, mut required_header_rx: mpsc::Receiver<HeaderIdOf<SourceChain>>, ) where SourceChain: Chain + Debug, @@ -118,7 +135,11 @@ async fn background_task<SourceChain, TargetChain, TargetSign>( FinalityTargetClient<SubstrateFinalityToSubstrate<SourceChain, TargetChain, TargetSign>>, { let relay_task_name = on_demand_headers_relay_name::<SourceChain, TargetChain>(); - let finality_target = SubstrateFinalityTarget::new(target_client.clone(), pipeline.clone()); + let mut finality_source = SubstrateFinalitySource::< + _, + SubstrateFinalityToSubstrate<SourceChain, TargetChain, TargetSign>, + >::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<SourceChain, TargetChain, TargetSign>( }, } - // 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::<SourceChain, _, _>(&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::<SourceChain>( + 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<SourceChain, TargetChain, TargetSign>( 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<SourceChain: Chain, P>( + finality_source: &SubstrateFinalitySource<SourceChain, P>, + relay_task_name: &str, +) -> Result<SourceChain::BlockNumber, <SubstrateFinalitySource<SourceChain, P> as RelayClient>::Error> +where + SubstrateFinalitySource<SourceChain, P>: FinalitySourceClient<P>, + P: FinalitySyncPipeline<Number = SourceChain::BlockNumber>, +{ + 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<SourceChain: Chain, TargetChain: Chain, P>( + finality_target: &SubstrateFinalityTarget<TargetChain, P>, + relay_task_name: &str, +) -> Result<SourceChain::BlockNumber, <SubstrateFinalityTarget<TargetChain, P> as RelayClient>::Error> +where + SubstrateFinalityTarget<TargetChain, P>: FinalityTargetClient<P>, + P: FinalitySyncPipeline<Number = SourceChain::BlockNumber>, +{ + 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<C: Chain>( + best_finalized_source_header_at_source: Option<C::BlockNumber>, + best_finalized_source_header_at_target: Option<C::BlockNumber>, + 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<SourceChain: Chain, TargetChain: Chain>() -> 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<async_std::task::JoinHandle<( log::info!(target: "bridge", "Cancelled {} headers relay", task_name); } } + +#[cfg(test)] +mod tests { + use super::*; + + type TestChain = relay_millau_client::Millau; + + const AT_SOURCE: Option<bp_millau::BlockNumber> = Some(10); + const AT_TARGET: Option<bp_millau::BlockNumber> = Some(1); + + #[test] + fn starts_relay_when_headers_are_required() { + assert_eq!( + select_on_demand_relay_action::<TestChain>(AT_SOURCE, AT_TARGET, 5, 100, "test", false), + OnDemandRelayAction::Start, + ); + + assert_eq!( + select_on_demand_relay_action::<TestChain>(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::<TestChain>(AT_SOURCE, AT_TARGET, 0, 5, "test", false), + OnDemandRelayAction::Start, + ); + + assert_eq!( + select_on_demand_relay_action::<TestChain>(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::<TestChain>(AT_SOURCE, AT_TARGET, AT_TARGET.unwrap(), 100, "test", true), + OnDemandRelayAction::Stop, + ); + + assert_eq!( + select_on_demand_relay_action::<TestChain>(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 ebae252ed5ab3cb1185a5293a0395743f18823d6..da4e7ef59efee82e376d378501df669278247ef2 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 7b3f46230fce16371a17cfb1cd411807bc0c35fb..699c3da400ffe8a574e06025ae22854d0a8f2744 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 0000000000000000000000000000000000000000..22d710ca3d7b76e09bb60ec58ac5abbb7b1ef947 --- /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 <admin@parity.io>"] +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 0000000000000000000000000000000000000000..be2f872b7d77546ab960f3f502865e917dadcf58 --- /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 <http://www.gnu.org/licenses/>. + +//! 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<bp_wococo::Hash, bp_wococo::BlockNumber>; + +/// Wococo header type used in headers sync. +pub type SyncHeader = relay_substrate_client::SyncHeader<bp_wococo::Header>; + +/// 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: <Self::Chain as ChainBase>::Hash, + signer: &Self::AccountKeyPair, + signer_nonce: <Self::Chain as Chain>::Index, + call: <Self::Chain as Chain>::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 cec0d7cba1fa40e08d4cac51be1b9a9e311c9ae4..4a2f07fa7f979fb0aea5fa5a28f4cca7cc059757 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<u64> + std::cmp::Ord + std::ops::Add<Output = Self::Number> @@ -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 b46d34e047a8bba4f96d6709bb1f66d40b4e0433..4525c33e36a151e34d7ea665b0be9085d7ed4805 100644 --- a/polkadot/relays/exchange/src/exchange_loop.rs +++ b/polkadot/relays/exchange/src/exchange_loop.rs @@ -39,9 +39,9 @@ pub struct TransactionProofsRelayState<BlockNumber> { } /// 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<Self::BlockNumber>; @@ -64,7 +64,7 @@ impl<BlockNumber> InMemoryStorage<BlockNumber> { } } -impl<BlockNumber: Clone + Copy> TransactionProofsRelayStorage for InMemoryStorage<BlockNumber> { +impl<BlockNumber: 'static + Clone + Copy + Send + Sync> TransactionProofsRelayStorage for InMemoryStorage<BlockNumber> { type BlockNumber = BlockNumber; fn state(&self) -> TransactionProofsRelayState<BlockNumber> { @@ -89,7 +89,7 @@ pub async fn run<P: TransactionProofPipeline>( source_client: impl SourceClient<P>, target_client: impl TargetClient<P>, metrics_params: MetricsParams, - exit_signal: impl Future<Output = ()>, + exit_signal: impl Future<Output = ()> + 'static + Send, ) -> Result<(), String> { let exit_signal = exit_signal.shared(); @@ -99,7 +99,7 @@ pub async fn run<P: TransactionProofPipeline>( .standalone_metric(|registry, prefix| GlobalMetrics::new(registry, prefix))? .expose() .await? - .run(|source_client, target_client, metrics| { + .run(metrics_prefix::<P>(), move |source_client, target_client, metrics| { run_until_connection_lost( storage.clone(), source_client, @@ -117,7 +117,7 @@ async fn run_until_connection_lost<P: TransactionProofPipeline>( source_client: impl SourceClient<P>, target_client: impl TargetClient<P>, metrics_exch: Option<ExchangeLoopMetrics>, - exit_signal: impl Future<Output = ()>, + exit_signal: impl Future<Output = ()> + 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 aff32e46de443dbe38834bce2a3655b6a32a211e..3aa55a8ac591598b7cd1d6ef217d0e8271ed94a7 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<P: FinalitySyncPipeline>: 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<Item = P::FinalityProof>; + type FinalityProofsStream: Stream<Item = P::FinalityProof> + Send; /// Get best finalized block number. async fn best_finalized_block_number(&self) -> Result<P::Number, Self::Error>; @@ -101,16 +103,17 @@ pub async fn run<P: FinalitySyncPipeline>( target_client: impl TargetClient<P>, sync_params: FinalitySyncParams, metrics_params: MetricsParams, - exit_signal: impl Future<Output = ()>, + exit_signal: impl Future<Output = ()> + '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::<P>()), 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::<P>(), 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 eedd902003308df662a3362f994e1db2d487c4d7..645aeb1777c60d6135ad4ba4be90600bea1208b6 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<TestFinalitySyncPipeline> for TestSourceClient { - type FinalityProofsStream = Pin<Box<dyn Stream<Item = TestFinalityProof>>>; + type FinalityProofsStream = Pin<Box<dyn Stream<Item = TestFinalityProof> + 'static + Send>>; async fn best_finalized_block_number(&self) -> Result<TestNumber, TestError> { 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 d5048aa1607d59b98dfa2e8f14a735de952472e8..64ec5bed05005ff4664660b27feb094bee157675 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 e4f1b7b04507e06fae5e70081acde44399abbb8e..b204932056509a4891788a1cc284f30ebd3a9b8d 100644 --- a/polkadot/relays/headers/src/sync_loop.rs +++ b/polkadot/relays/headers/src/sync_loop.rs @@ -102,7 +102,7 @@ pub trait TargetClient<P: HeadersSyncPipeline>: RelayClient { /// Synchronization maintain procedure. #[async_trait] -pub trait SyncMaintain<P: HeadersSyncPipeline>: Clone + Send + Sync { +pub trait SyncMaintain<P: HeadersSyncPipeline>: '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<P>) {} @@ -125,7 +125,7 @@ pub async fn run<P: HeadersSyncPipeline, TC: TargetClient<P>>( sync_maintain: impl SyncMaintain<P>, sync_params: HeadersSyncParams, metrics_params: MetricsParams, - exit_signal: impl Future<Output = ()>, + exit_signal: impl Future<Output = ()> + '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<P: HeadersSyncPipeline, TC: TargetClient<P>>( .standalone_metric(|registry, prefix| GlobalMetrics::new(registry, prefix))? .expose() .await? - .run(|source_client, target_client, metrics| { + .run(metrics_prefix::<P>(), move |source_client, target_client, metrics| { run_until_connection_lost( source_client, source_tick, @@ -159,7 +159,7 @@ async fn run_until_connection_lost<P: HeadersSyncPipeline, TC: TargetClient<P>>( sync_maintain: impl SyncMaintain<P>, sync_params: HeadersSyncParams, metrics_sync: Option<SyncLoopMetrics>, - exit_signal: impl Future<Output = ()>, + exit_signal: impl Future<Output = ()> + 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 e6500ad5facb075c617ab5f7d1c9aad66261de01..5809ebab59e1c47b1b9e8a02c690ee3523bc3521 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 5090ef124e7f7202ce1f1e88b657ea14cae5b8bc..6473ec987500b9b030a033c457f32e5fd65b6752 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 41eee606d82befab7d761a5d7e0f87e20ffb82eb..af04bf984e1f95ce70e838e17ea3ff343426053c 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<P: MessageLane>( source_client: impl SourceClient<P>, target_client: impl TargetClient<P>, metrics_params: MetricsParams, - exit_signal: impl Future<Output = ()>, + exit_signal: impl Future<Output = ()> + 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<P: MessageLane>( .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::<P>(¶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<dyn Fn(&mut TestClientData) + Send + Sync>, target_tick: Arc<dyn Fn(&mut TestClientData) + Send + Sync>, - exit_signal: impl Future<Output = ()>, + exit_signal: impl Future<Output = ()> + '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 225c59f23ca33e93fea686cacaa400f883e07b96..b50b0ffe31ba350a3b46de94bfd54d39572eb2f5 100644 --- a/polkadot/relays/messages/src/message_race_delivery.rs +++ b/polkadot/relays/messages/src/message_race_delivery.rs @@ -292,7 +292,16 @@ impl<P: MessageLane> RaceStrategy<SourceHeaderIdOf<P>, TargetHeaderIdOf<P>, P::M } fn required_source_header_at_target(&self, current_best: &SourceHeaderIdOf<P>) -> Option<SourceHeaderIdOf<P>> { - 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<MessageNonce> { @@ -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 7d5f66a53815c0458194e8b432a59f1e9c708d91..b87937923bd4e0b70be329cb09190076fbc4a2e2 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<String> = 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<A, B> { Left(A), Right(B), diff --git a/polkadot/relays/utils/src/relay_loop.rs b/polkadot/relays/utils/src/relay_loop.rs index 8790b0913e17696ea440a2e3c04fd070fe5de2c1..8fcaabe4430cc83d354fe7191e7db5e33afdc7c8 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<SC, TC>(source_client: SC, target_client: TC) -> Loop<SC, TC, ()> { 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<String>, 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<String>, params: MetricsParams) -> LoopMetri /// Generic relay loop. pub struct Loop<SC, TC, LM> { reconnect_delay: Duration, + spawn_loop_task: bool, source_client: SC, target_client: TC, loop_metric: Option<LM>, @@ -84,11 +87,23 @@ impl<SC, TC, LM> Loop<SC, TC, LM> { 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<String>, params: MetricsParams) -> LoopMetrics<SC, TC, ()> { 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<SC, TC, LM> Loop<SC, TC, LM> { /// 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<R, F>(mut self, run_loop: R) -> Result<(), String> + pub async fn run<R, F>(mut self, loop_name: String, run_loop: R) -> Result<(), String> where - R: Fn(SC, TC, Option<LM>) -> F, - F: Future<Output = Result<(), FailedClient>>, - SC: Client, - TC: Client, - LM: Clone, + R: 'static + Send + Fn(SC, TC, Option<LM>) -> F, + F: 'static + Send + Future<Output = Result<(), FailedClient>>, + 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; - - 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; - } - } + let spawn_loop_task = self.spawn_loop_task; + let run_loop_task = async move { + crate::initialize::initialize_loop(loop_name); + + 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; + + match result { + Ok(()) => break, + Err(failed_client) => { + reconnect_failed_client( + failed_client, + self.reconnect_delay, + &mut self.source_client, + &mut self.target_client, + ) + .await } + } - break; - }, + 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<SC, TC, LM> LoopMetrics<SC, TC, LM> { 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<SC, TC, LM> LoopMetrics<SC, TC, LM> { } } +/// 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<String>) -> Registry { match prefix { diff --git a/polkadot/scripts/dump-logs.sh b/polkadot/scripts/dump-logs.sh index f076cbccbca168457593fee74c459552034f0803..02aa4af2f7564b14d82f1c010adb921bc04fc15d 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 \