From b18bfab7064b65bc7865b8d666fb7f06e19e0865 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Tue, 14 Nov 2023 11:50:26 +0300 Subject: [PATCH] Drop Rialto <> Millau bridges (#2663) (#2694) * drop Rialto <> Millau bridges * clippy --- bridges/README.md | 175 +- bridges/bin/millau/node/Cargo.toml | 61 - bridges/bin/millau/node/build.rs | 23 - bridges/bin/millau/node/src/chain_spec.rs | 237 -- bridges/bin/millau/node/src/cli.rs | 73 - bridges/bin/millau/node/src/command.rs | 154 - bridges/bin/millau/node/src/lib.rs | 32 - bridges/bin/millau/node/src/main.rs | 30 - bridges/bin/millau/node/src/service.rs | 479 --- bridges/bin/millau/runtime/Cargo.toml | 155 - bridges/bin/millau/runtime/build.rs | 26 - bridges/bin/millau/runtime/src/lib.rs | 1300 -------- .../bin/millau/runtime/src/rialto_messages.rs | 216 -- .../runtime/src/rialto_parachain_messages.rs | 227 -- bridges/bin/millau/runtime/src/weights/mod.rs | 21 - ...h_runtime_with_rialto_messages_instance.rs | 188 -- ...with_rialto_parachain_messages_instance.rs | 188 -- bridges/bin/millau/runtime/src/xcm_config.rs | 410 --- bridges/bin/rialto-parachain/node/Cargo.toml | 81 - bridges/bin/rialto-parachain/node/build.rs | 22 - .../rialto-parachain/node/src/chain_spec.rs | 202 -- bridges/bin/rialto-parachain/node/src/cli.rs | 109 - .../bin/rialto-parachain/node/src/command.rs | 372 --- bridges/bin/rialto-parachain/node/src/lib.rs | 19 - bridges/bin/rialto-parachain/node/src/main.rs | 30 - .../bin/rialto-parachain/node/src/service.rs | 505 --- .../bin/rialto-parachain/runtime/Cargo.toml | 146 - bridges/bin/rialto-parachain/runtime/build.rs | 26 - .../bin/rialto-parachain/runtime/src/lib.rs | 975 ------ .../runtime/src/millau_messages.rs | 206 -- bridges/bin/rialto/node/Cargo.toml | 61 - bridges/bin/rialto/node/build.rs | 23 - bridges/bin/rialto/node/src/chain_spec.rs | 282 -- bridges/bin/rialto/node/src/cli.rs | 84 - bridges/bin/rialto/node/src/command.rs | 193 -- bridges/bin/rialto/node/src/main.rs | 28 - .../rialto/node/src/workers/execute-worker.rs | 23 - .../rialto/node/src/workers/prepare-worker.rs | 23 - bridges/bin/rialto/runtime/Cargo.toml | 153 - bridges/bin/rialto/runtime/build.rs | 26 - bridges/bin/rialto/runtime/src/lib.rs | 1074 ------ .../bin/rialto/runtime/src/millau_messages.rs | 200 -- bridges/bin/rialto/runtime/src/parachains.rs | 274 -- bridges/bin/rialto/runtime/src/xcm_config.rs | 280 -- bridges/bin/runtime-common/src/lib.rs | 41 +- bridges/bin/runtime-common/src/mock.rs | 7 +- .../runtime-common/src/priority_calculator.rs | 1 + bridges/docs/high-level-overview.md | 2 +- bridges/modules/grandpa/src/weights.rs | 62 +- bridges/modules/messages/src/weights.rs | 226 +- bridges/modules/parachains/src/weights.rs | 122 +- bridges/modules/parachains/src/weights_ext.rs | 2 +- bridges/modules/relayers/src/weights.rs | 2 +- .../modules/shift-session-manager/Cargo.toml | 38 - .../modules/shift-session-manager/README.md | 10 - .../modules/shift-session-manager/src/lib.rs | 259 -- .../xcm-bridge-hub-router/src/weights.rs | 2 +- bridges/primitives/chain-millau/Cargo.toml | 62 - bridges/primitives/chain-millau/src/lib.rs | 244 -- .../chain-millau/src/millau_hash.rs | 56 - .../chain-rialto-parachain/Cargo.toml | 39 - .../chain-rialto-parachain/src/lib.rs | 148 - bridges/primitives/chain-rialto/Cargo.toml | 38 - bridges/primitives/chain-rialto/src/lib.rs | 210 -- bridges/primitives/runtime/src/chain.rs | 6 +- bridges/primitives/runtime/src/lib.rs | 29 - bridges/relays/bin-substrate/Cargo.toml | 19 - .../relays/bin-substrate/src/bridges/mod.rs | 3 - .../rialto_millau/millau_headers_to_rialto.rs | 74 - .../millau_messages_to_rialto.rs | 47 - .../src/bridges/rialto_millau/mod.rs | 22 - .../rialto_millau/rialto_headers_to_millau.rs | 74 - .../rialto_messages_to_millau.rs | 47 - .../millau_headers_to_rialto_parachain.rs | 95 - .../millau_messages_to_rialto_parachain.rs | 51 - .../bridges/rialto_parachain_millau/mod.rs | 22 - .../rialto_parachain_messages_to_millau.rs | 51 - .../rialto_parachains_to_millau.rs | 65 - .../src/bridges/westend_millau/mod.rs | 20 - .../westend_headers_to_millau.rs | 54 - .../westend_parachains_to_millau.rs | 90 - .../relays/bin-substrate/src/chains/millau.rs | 75 - .../relays/bin-substrate/src/chains/mod.rs | 87 - .../relays/bin-substrate/src/chains/rialto.rs | 62 - .../src/chains/rialto_parachain.rs | 65 - .../relays/bin-substrate/src/cli/bridge.rs | 4 - .../bin-substrate/src/cli/chain_schema.rs | 44 +- .../src/cli/detect_equivocations.rs | 15 - .../bin-substrate/src/cli/encode_message.rs | 189 -- .../bin-substrate/src/cli/init_bridge.rs | 81 - bridges/relays/bin-substrate/src/cli/mod.rs | 47 +- .../src/cli/register_parachain.rs | 324 -- .../bin-substrate/src/cli/relay_headers.rs | 19 - .../src/cli/relay_headers_and_messages/mod.rs | 361 +- .../parachain_to_parachain.rs | 64 +- .../relay_to_parachain.rs | 53 +- .../relay_to_relay.rs | 38 +- .../bin-substrate/src/cli/relay_messages.rs | 18 - .../bin-substrate/src/cli/relay_parachains.rs | 10 - .../src/cli/resubmit_transactions.rs | 560 ---- .../bin-substrate/src/cli/send_message.rs | 177 - bridges/relays/client-millau/Cargo.toml | 27 - bridges/relays/client-millau/src/lib.rs | 197 -- .../relays/client-rialto-parachain/Cargo.toml | 30 - .../src/codegen_runtime.rs | 2936 ----------------- .../relays/client-rialto-parachain/src/lib.rs | 138 - bridges/relays/client-rialto/Cargo.toml | 27 - bridges/relays/client-rialto/src/lib.rs | 191 -- bridges/relays/finality/README.md | 14 +- bridges/relays/lib-substrate-relay/Cargo.toml | 7 +- bridges/relays/lib-substrate-relay/src/lib.rs | 23 +- .../lib-substrate-relay/src/messages_lane.rs | 2 - .../src/messages_source.rs | 35 +- bridges/relays/parachains/README.md | 14 +- 114 files changed, 363 insertions(+), 17323 deletions(-) delete mode 100644 bridges/bin/millau/node/Cargo.toml delete mode 100644 bridges/bin/millau/node/build.rs delete mode 100644 bridges/bin/millau/node/src/chain_spec.rs delete mode 100644 bridges/bin/millau/node/src/cli.rs delete mode 100644 bridges/bin/millau/node/src/command.rs delete mode 100644 bridges/bin/millau/node/src/lib.rs delete mode 100644 bridges/bin/millau/node/src/main.rs delete mode 100644 bridges/bin/millau/node/src/service.rs delete mode 100644 bridges/bin/millau/runtime/Cargo.toml delete mode 100644 bridges/bin/millau/runtime/build.rs delete mode 100644 bridges/bin/millau/runtime/src/lib.rs delete mode 100644 bridges/bin/millau/runtime/src/rialto_messages.rs delete mode 100644 bridges/bin/millau/runtime/src/rialto_parachain_messages.rs delete mode 100644 bridges/bin/millau/runtime/src/weights/mod.rs delete mode 100644 bridges/bin/millau/runtime/src/weights/pallet_bridge_messages_messages_bench_runtime_with_rialto_messages_instance.rs delete mode 100644 bridges/bin/millau/runtime/src/weights/pallet_bridge_messages_messages_bench_runtime_with_rialto_parachain_messages_instance.rs delete mode 100644 bridges/bin/millau/runtime/src/xcm_config.rs delete mode 100644 bridges/bin/rialto-parachain/node/Cargo.toml delete mode 100644 bridges/bin/rialto-parachain/node/build.rs delete mode 100644 bridges/bin/rialto-parachain/node/src/chain_spec.rs delete mode 100644 bridges/bin/rialto-parachain/node/src/cli.rs delete mode 100644 bridges/bin/rialto-parachain/node/src/command.rs delete mode 100644 bridges/bin/rialto-parachain/node/src/lib.rs delete mode 100644 bridges/bin/rialto-parachain/node/src/main.rs delete mode 100644 bridges/bin/rialto-parachain/node/src/service.rs delete mode 100644 bridges/bin/rialto-parachain/runtime/Cargo.toml delete mode 100644 bridges/bin/rialto-parachain/runtime/build.rs delete mode 100644 bridges/bin/rialto-parachain/runtime/src/lib.rs delete mode 100644 bridges/bin/rialto-parachain/runtime/src/millau_messages.rs delete mode 100644 bridges/bin/rialto/node/Cargo.toml delete mode 100644 bridges/bin/rialto/node/build.rs delete mode 100644 bridges/bin/rialto/node/src/chain_spec.rs delete mode 100644 bridges/bin/rialto/node/src/cli.rs delete mode 100644 bridges/bin/rialto/node/src/command.rs delete mode 100644 bridges/bin/rialto/node/src/main.rs delete mode 100644 bridges/bin/rialto/node/src/workers/execute-worker.rs delete mode 100644 bridges/bin/rialto/node/src/workers/prepare-worker.rs delete mode 100644 bridges/bin/rialto/runtime/Cargo.toml delete mode 100644 bridges/bin/rialto/runtime/build.rs delete mode 100644 bridges/bin/rialto/runtime/src/lib.rs delete mode 100644 bridges/bin/rialto/runtime/src/millau_messages.rs delete mode 100644 bridges/bin/rialto/runtime/src/parachains.rs delete mode 100644 bridges/bin/rialto/runtime/src/xcm_config.rs delete mode 100644 bridges/modules/shift-session-manager/Cargo.toml delete mode 100644 bridges/modules/shift-session-manager/README.md delete mode 100644 bridges/modules/shift-session-manager/src/lib.rs delete mode 100644 bridges/primitives/chain-millau/Cargo.toml delete mode 100644 bridges/primitives/chain-millau/src/lib.rs delete mode 100644 bridges/primitives/chain-millau/src/millau_hash.rs delete mode 100644 bridges/primitives/chain-rialto-parachain/Cargo.toml delete mode 100644 bridges/primitives/chain-rialto-parachain/src/lib.rs delete mode 100644 bridges/primitives/chain-rialto/Cargo.toml delete mode 100644 bridges/primitives/chain-rialto/src/lib.rs delete mode 100644 bridges/relays/bin-substrate/src/bridges/rialto_millau/millau_headers_to_rialto.rs delete mode 100644 bridges/relays/bin-substrate/src/bridges/rialto_millau/millau_messages_to_rialto.rs delete mode 100644 bridges/relays/bin-substrate/src/bridges/rialto_millau/mod.rs delete mode 100644 bridges/relays/bin-substrate/src/bridges/rialto_millau/rialto_headers_to_millau.rs delete mode 100644 bridges/relays/bin-substrate/src/bridges/rialto_millau/rialto_messages_to_millau.rs delete mode 100644 bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/millau_headers_to_rialto_parachain.rs delete mode 100644 bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/millau_messages_to_rialto_parachain.rs delete mode 100644 bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/mod.rs delete mode 100644 bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/rialto_parachain_messages_to_millau.rs delete mode 100644 bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/rialto_parachains_to_millau.rs delete mode 100644 bridges/relays/bin-substrate/src/bridges/westend_millau/mod.rs delete mode 100644 bridges/relays/bin-substrate/src/bridges/westend_millau/westend_headers_to_millau.rs delete mode 100644 bridges/relays/bin-substrate/src/bridges/westend_millau/westend_parachains_to_millau.rs delete mode 100644 bridges/relays/bin-substrate/src/chains/millau.rs delete mode 100644 bridges/relays/bin-substrate/src/chains/rialto.rs delete mode 100644 bridges/relays/bin-substrate/src/chains/rialto_parachain.rs delete mode 100644 bridges/relays/bin-substrate/src/cli/encode_message.rs delete mode 100644 bridges/relays/bin-substrate/src/cli/register_parachain.rs delete mode 100644 bridges/relays/bin-substrate/src/cli/resubmit_transactions.rs delete mode 100644 bridges/relays/bin-substrate/src/cli/send_message.rs delete mode 100644 bridges/relays/client-millau/Cargo.toml delete mode 100644 bridges/relays/client-millau/src/lib.rs delete mode 100644 bridges/relays/client-rialto-parachain/Cargo.toml delete mode 100644 bridges/relays/client-rialto-parachain/src/codegen_runtime.rs delete mode 100644 bridges/relays/client-rialto-parachain/src/lib.rs delete mode 100644 bridges/relays/client-rialto/Cargo.toml delete mode 100644 bridges/relays/client-rialto/src/lib.rs diff --git a/bridges/README.md b/bridges/README.md index da46fe67d924a..f8191f432adfa 100644 --- a/bridges/README.md +++ b/bridges/README.md @@ -68,7 +68,7 @@ For example, consider the case below where we want to bridge two Substrate based ``` +---------------+ +---------------+ | | | | -| Rialto | | Millau | +| Rococo | | Westend | | | | | +-------+-------+ +-------+-------+ ^ ^ @@ -79,9 +79,9 @@ For example, consider the case below where we want to bridge two Substrate based +---------------+ ``` -The Millau chain must be able to accept Rialto headers and verify their integrity. It does this by using a runtime +The Rococo chain must be able to accept Westend headers and verify their integrity. It does this by using a runtime module designed to track GRANDPA finality. Since two blockchains can't interact directly they need an external service, -called a relayer, to communicate. The relayer will subscribe to new Rialto headers via RPC and submit them to the Millau +called a relayer, to communicate. The relayer will subscribe to new Rococo headers via RPC and submit them to the Westend chain for verification. Take a look at [Bridge High Level Documentation](./docs/high-level-overview.md) for more in-depth description of the @@ -94,164 +94,23 @@ Here's an overview of how the project is laid out. The main bits are the `bin`, messages between chains. ``` -├── bin // Node and Runtime for the various Substrate chains -│ └── ... -├── deployments // Useful tools for deploying test networks +├── modules // Substrate Runtime Modules (a.k.a Pallets) +│ ├── beefy // On-Chain BEEFY Light Client (in progress) +│ ├── grandpa // On-Chain GRANDPA Light Client +│ ├── messages // Cross Chain Message Passing +│ ├── parachains // On-Chain Parachains Light Client +│ ├── relayers // Relayer Rewards Registry +│ ├── xcm-bridge-hub // Multiple Dynamic Bridges Support +│ ├── xcm-bridge-hub-router // XCM Router that may be used to Connect to XCM Bridge Hub +├── primitives // Code shared between modules, runtimes, and relays │ └── ... -├── modules // Substrate Runtime Modules (a.k.a Pallets) -│ ├── beefy // On-Chain BEEFY Light Client (in progress) -│ ├── grandpa // On-Chain GRANDPA Light Client -│ ├── messages // Cross Chain Message Passing -│ ├── parachains // On-Chain Parachains Light Client -│ ├── relayers // Relayer rewards registry +├── relays // Application for sending finality proofs and messages between chains │ └── ... -├── primitives // Code shared between modules, runtimes, and relays -│ └── ... -├── relays // Application for sending finality proofs and messages between chains -│ └── ... -└── scripts // Useful development and maintenance scripts +└── scripts // Useful development and maintenance scripts ``` ## Running the Bridge -To run the Bridge you need to be able to connect the bridge relay node to the RPC interface of nodes on each side of the -bridge (source and target chain). - -There are 2 ways to run the bridge, described below: - -- building & running from source: with this option, you'll be able to run the bridge between two standalone chains that -are running GRANDPA finality gadget to achieve finality; - -- running a Docker Compose setup: this is a recommended option, where you'll see bridges with parachains, complex relays -and more. - -### Using the Source - -First you'll need to build the bridge nodes and relay. This can be done as follows: - -```bash -# In `parity-bridges-common` folder -cargo build -p rialto-bridge-node -cargo build -p millau-bridge-node -cargo build -p substrate-relay -``` - -### Running a Dev network - -We will launch a dev network to demonstrate how to relay a message between two Substrate based chains (named Rialto and -Millau). - -To do this we will need two nodes, two relayers which will relay headers, and two relayers which will relay messages. - -#### Running from local scripts - -To run a simple dev network you can use the scripts located in the [`deployments/local-scripts` -folder](./deployments/local-scripts). - -First, we must run the two Substrate nodes. - -```bash -# In `parity-bridges-common` folder -./deployments/local-scripts/run-rialto-node.sh -./deployments/local-scripts/run-millau-node.sh -``` - -After the nodes are up we can run the header relayers. - -```bash -./deployments/local-scripts/relay-millau-to-rialto.sh -./deployments/local-scripts/relay-rialto-to-millau.sh -``` - -At this point you should see the relayer submitting headers from the Millau Substrate chain to the Rialto Substrate -chain. - -``` -# Header Relayer Logs -[Millau_to_Rialto_Sync] [date] DEBUG bridge Going to submit finality proof of Millau header #147 to Rialto -[...] [date] INFO bridge Synced 147 of 147 headers -[...] [date] DEBUG bridge Going to submit finality proof of Millau header #148 to Rialto -[...] [date] INFO bridge Synced 148 of 149 headers -``` - -Finally, we can run the message relayers. - -```bash -./deployments/local-scripts/relay-messages-millau-to-rialto.sh -./deployments/local-scripts/relay-messages-rialto-to-millau.sh -``` - -You will also see the message lane relayers listening for new messages. - -``` -# Message Relayer Logs -[Millau_to_Rialto_MessageLane_00000000] [date] DEBUG bridge Asking Millau::ReceivingConfirmationsDelivery about best message nonces -[...] [date] INFO bridge Synced Some(2) of Some(3) nonces in Millau::MessagesDelivery -> Rialto::MessagesDelivery race -[...] [date] DEBUG bridge Asking Millau::MessagesDelivery about message nonces -[...] [date] DEBUG bridge Received best nonces from Millau::ReceivingConfirmationsDelivery: TargetClientNonces { - latest_nonce: 0, nonces_data: () } -[...] [date] DEBUG bridge Asking Millau::ReceivingConfirmationsDelivery about finalized message nonces -[...] [date] DEBUG bridge Received finalized nonces from Millau::ReceivingConfirmationsDelivery: TargetClientNonces { - latest_nonce: 0, nonces_data: () } -[...] [date] DEBUG bridge Received nonces from Millau::MessagesDelivery: SourceClientNonces { new_nonces: {}, confirmed_nonce: Some(0) } -[...] [date] DEBUG bridge Asking Millau node about its state -[...] [date] DEBUG bridge Received state from Millau node: ClientState { best_self: HeaderId(1593, 0xacac***), best_finalized_self: - HeaderId(1590, 0x0be81d...), best_finalized_peer_at_best_self: HeaderId(0, 0xdcdd89...) } -``` - -To send a message see the ["How to send a message" section](#how-to-send-a-message). - -### How to send a message - -In this section we'll show you how to quickly send a bridge message. The message is just an encoded XCM `Trap(43)` -message. - -```bash -# In `parity-bridges-common` folder -./scripts/send-message-from-millau-rialto.sh -``` - -After sending a message you will see the following logs showing a message was successfully sent: - -``` -INFO bridge Sending message to Rialto. Size: 11. -TRACE bridge Sent transaction to Millau node: 0x5e68... -``` - -And at the Rialto node logs you'll something like this: - -``` -... runtime::bridge-messages: Received messages: total=1, valid=1. Weight used: Weight(ref_time: 1215065371, proof_size: - 48559)/Weight(ref_time: 1215065371, proof_size: 54703). -``` - -It means that the message has been delivered and dispatched. Message may be dispatched with an error, though - the goal -of our test bridge is to ensure that messages are successfully delivered and all involved components are working. - -## Full Network Docker Compose Setup - -For a more sophisticated deployment which includes bidirectional header sync, message passing, monitoring dashboards, -etc. see the [Deployments README](./deployments/README.md). - -You should note that you can find images for all the bridge components published on [Docker -Hub](https://hub.docker.com/u/paritytech). - -To run a Rialto node for example, you can use the following command: - -```bash -docker run -p 30333:30333 -p 9933:9933 -p 9944:9944 \ - -it paritytech/rialto-bridge-node --dev --tmp \ - --rpc-cors=all --unsafe-rpc-external -``` - -## Community - -Main hangout for the community is [Element](https://element.io/) (formerly Riot). Element is a chat server like, for -example, Discord. Most discussions around Polkadot and Substrate happen in various Element "rooms" (channels). So, -joining Element might be a good idea, anyway. - -If you are interested in information exchange and development of Polkadot related bridges please feel free to join the -[Polkadot Bridges](https://app.element.io/#/room/#bridges:web3.foundation) Element channel. - -The [Substrate Technical](https://app.element.io/#/room/#substrate-technical:matrix.org) Element channel is most suited -for discussions regarding Substrate itself. +Apart from live Rococo <> Westend bridge, you may spin up local networks and test see how it works locally. More +details may be found in +[this document](https://github.com/paritytech/polkadot-sdk/tree/master//cumulus/parachains/runtimes/bridge-hubs/README.md). diff --git a/bridges/bin/millau/node/Cargo.toml b/bridges/bin/millau/node/Cargo.toml deleted file mode 100644 index 426cb9e863ee1..0000000000000 --- a/bridges/bin/millau/node/Cargo.toml +++ /dev/null @@ -1,61 +0,0 @@ -[package] -name = "millau-bridge-node" -description = "Substrate node compatible with Millau runtime" -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2021" -build = "build.rs" -repository = "https://github.com/paritytech/parity-bridges-common/" -license = "GPL-3.0-or-later WITH Classpath-exception-2.0" - -[dependencies] -clap = { version = "4.4.8", features = ["derive"] } -futures = "0.3.29" -jsonrpsee = { version = "0.16.2", features = ["server"] } -serde_json = "1.0.108" - -# Bridge dependencies - -millau-runtime = { path = "../runtime" } - -# Substrate Dependencies - -sc-consensus-beefy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-consensus-beefy-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-consensus-beefy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -node-inspect = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -mmr-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master"} -sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-executor = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-consensus-grandpa-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-keystore = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-network = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-telemetry = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-transaction-pool-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-network-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } - -[build-dependencies] -substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } - -[features] -default = [] -runtime-benchmarks = [ "millau-runtime/runtime-benchmarks" ] diff --git a/bridges/bin/millau/node/build.rs b/bridges/bin/millau/node/build.rs deleted file mode 100644 index d9b50049e2628..0000000000000 --- a/bridges/bin/millau/node/build.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed}; - -fn main() { - generate_cargo_keys(); - - rerun_if_git_head_changed(); -} diff --git a/bridges/bin/millau/node/src/chain_spec.rs b/bridges/bin/millau/node/src/chain_spec.rs deleted file mode 100644 index 01883bb4ef083..0000000000000 --- a/bridges/bin/millau/node/src/chain_spec.rs +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use millau_runtime::{ - AccountId, AuraConfig, BalancesConfig, BeefyConfig, BridgeRialtoMessagesConfig, - BridgeRialtoParachainMessagesConfig, BridgeWestendGrandpaConfig, GrandpaConfig, - RuntimeGenesisConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, - WASM_BINARY, -}; -use sp_consensus_aura::sr25519::AuthorityId as AuraId; -use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId; -use sp_consensus_grandpa::AuthorityId as GrandpaId; -use sp_core::{sr25519, Pair, Public}; -use sp_runtime::traits::{IdentifyAccount, Verify}; - -/// "Names" of the authorities accounts at local testnet. -const LOCAL_AUTHORITIES_ACCOUNTS: [&str; 5] = ["Alice", "Bob", "Charlie", "Dave", "Eve"]; -/// "Names" of the authorities accounts at development testnet. -const DEV_AUTHORITIES_ACCOUNTS: [&str; 1] = [LOCAL_AUTHORITIES_ACCOUNTS[0]]; -/// "Names" of all possible authorities accounts. -const ALL_AUTHORITIES_ACCOUNTS: [&str; 5] = LOCAL_AUTHORITIES_ACCOUNTS; -/// "Name" of the `sudo` account. -const SUDO_ACCOUNT: &str = "Sudo"; -/// "Name" of the account, which owns the with-Westend GRANDPA pallet. -const WESTEND_GRANDPA_PALLET_OWNER: &str = "Westend.GrandpaOwner"; -/// "Name" of the account, which owns the with-Rialto messages pallet. -const RIALTO_MESSAGES_PALLET_OWNER: &str = "Rialto.MessagesOwner"; -/// "Name" of the account, which owns the with-RialtoParachain messages pallet. -const RIALTO_PARACHAIN_MESSAGES_PALLET_OWNER: &str = "RialtoParachain.MessagesOwner"; - -/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. -pub type ChainSpec = sc_service::GenericChainSpec; - -/// The chain specification option. This is expected to come in from the CLI and -/// is little more than one of a number of alternatives which can easily be converted -/// from a string (`--chain=...`) into a `ChainSpec`. -#[derive(Clone, Debug)] -pub enum Alternative { - /// Whatever the current runtime is, with just Alice as an auth. - Development, - /// Whatever the current runtime is, with simple Alice/Bob/Charlie/Dave/Eve auths. - LocalTestnet, -} - -/// Helper function to generate a crypto pair from seed -pub fn get_from_seed(seed: &str) -> ::Public { - TPublic::Pair::from_string(&format!("//{seed}"), None) - .expect("static values are valid; qed") - .public() -} - -type AccountPublic = ::Signer; - -/// Helper function to generate an account ID from seed -pub fn get_account_id_from_seed(seed: &str) -> AccountId -where - AccountPublic: From<::Public>, -{ - AccountPublic::from(get_from_seed::(seed)).into_account() -} - -/// Helper function to generate an authority key for Aura -pub fn get_authority_keys_from_seed(s: &str) -> (AccountId, AuraId, BeefyId, GrandpaId) { - ( - get_account_id_from_seed::(s), - get_from_seed::(s), - get_from_seed::(s), - get_from_seed::(s), - ) -} - -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" - }) - .as_object() - .expect("Map given; qed") - .clone(), - ); - match self { - Alternative::Development => ChainSpec::from_genesis( - "Millau Development", - "millau_dev", - sc_service::ChainType::Development, - || { - testnet_genesis( - DEV_AUTHORITIES_ACCOUNTS - .into_iter() - .map(get_authority_keys_from_seed) - .collect(), - get_account_id_from_seed::(SUDO_ACCOUNT), - endowed_accounts(), - true, - ) - }, - vec![], - None, - None, - None, - properties, - None, - ), - Alternative::LocalTestnet => ChainSpec::from_genesis( - "Millau Local", - "millau_local", - sc_service::ChainType::Local, - || { - testnet_genesis( - LOCAL_AUTHORITIES_ACCOUNTS - .into_iter() - .map(get_authority_keys_from_seed) - .collect(), - get_account_id_from_seed::(SUDO_ACCOUNT), - endowed_accounts(), - true, - ) - }, - vec![], - None, - None, - None, - properties, - None, - ), - } - } -} - -/// We're using the same set of endowed accounts on all Millau chains (dev/local) to make -/// sure that all accounts, required for bridge to be functional (e.g. relayers fund account, -/// accounts used by relayers in our test deployments, accounts used for demonstration -/// purposes), are all available on these chains. -fn endowed_accounts() -> Vec { - let all_authorities = ALL_AUTHORITIES_ACCOUNTS.iter().flat_map(|x| { - [ - get_account_id_from_seed::(x), - get_account_id_from_seed::(&format!("{x}//stash")), - ] - }); - vec![ - // Sudo account - get_account_id_from_seed::(SUDO_ACCOUNT), - // Regular (unused) accounts - get_account_id_from_seed::("Ferdie"), - get_account_id_from_seed::("Ferdie//stash"), - // Accounts, used by Westend<>Millau bridge - get_account_id_from_seed::(WESTEND_GRANDPA_PALLET_OWNER), - get_account_id_from_seed::("Westend.HeadersRelay1"), - get_account_id_from_seed::("Westend.HeadersRelay2"), - get_account_id_from_seed::("Westend.AssetHubWestendHeaders1"), - get_account_id_from_seed::("Westend.AssetHubWestendHeaders2"), - // Accounts, used by Rialto<>Millau bridge - get_account_id_from_seed::(RIALTO_MESSAGES_PALLET_OWNER), - get_account_id_from_seed::("Rialto.HeadersAndMessagesRelay"), - get_account_id_from_seed::("Rialto.OutboundMessagesRelay.Lane00000001"), - get_account_id_from_seed::("Rialto.InboundMessagesRelay.Lane00000001"), - get_account_id_from_seed::("Rialto.MessagesSender"), - // Accounts, used by RialtoParachain<>Millau bridge - get_account_id_from_seed::(RIALTO_PARACHAIN_MESSAGES_PALLET_OWNER), - get_account_id_from_seed::("RialtoParachain.HeadersAndMessagesRelay1"), - get_account_id_from_seed::("RialtoParachain.HeadersAndMessagesRelay2"), - get_account_id_from_seed::("RialtoParachain.RialtoHeadersRelay1"), - get_account_id_from_seed::("RialtoParachain.RialtoHeadersRelay2"), - get_account_id_from_seed::("RialtoParachain.MessagesSender"), - ] - .into_iter() - .chain(all_authorities) - .collect() -} - -fn session_keys(aura: AuraId, beefy: BeefyId, grandpa: GrandpaId) -> SessionKeys { - SessionKeys { aura, beefy, grandpa } -} - -fn testnet_genesis( - initial_authorities: Vec<(AccountId, AuraId, BeefyId, GrandpaId)>, - root_key: AccountId, - endowed_accounts: Vec, - _enable_println: bool, -) -> RuntimeGenesisConfig { - RuntimeGenesisConfig { - system: SystemConfig { - code: WASM_BINARY.expect("Millau development WASM not available").to_vec(), - ..Default::default() - }, - balances: BalancesConfig { - balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 50)).collect(), - }, - aura: AuraConfig { authorities: Vec::new() }, - beefy: BeefyConfig::default(), - grandpa: GrandpaConfig { authorities: Vec::new(), ..Default::default() }, - sudo: SudoConfig { key: Some(root_key) }, - session: SessionConfig { - keys: initial_authorities - .iter() - .map(|x| { - (x.0.clone(), x.0.clone(), session_keys(x.1.clone(), x.2.clone(), x.3.clone())) - }) - .collect::>(), - }, - bridge_westend_grandpa: BridgeWestendGrandpaConfig { - // for our deployments to avoid multiple same-nonces transactions: - // //Alice is already used to initialize Rialto<->Millau bridge - // => let's use //Westend.GrandpaOwner to initialize Westend->Millau bridge - owner: Some(get_account_id_from_seed::(WESTEND_GRANDPA_PALLET_OWNER)), - ..Default::default() - }, - bridge_rialto_messages: BridgeRialtoMessagesConfig { - owner: Some(get_account_id_from_seed::(RIALTO_MESSAGES_PALLET_OWNER)), - ..Default::default() - }, - bridge_rialto_parachain_messages: BridgeRialtoParachainMessagesConfig { - owner: Some(get_account_id_from_seed::( - RIALTO_PARACHAIN_MESSAGES_PALLET_OWNER, - )), - ..Default::default() - }, - xcm_pallet: Default::default(), - } -} diff --git a/bridges/bin/millau/node/src/cli.rs b/bridges/bin/millau/node/src/cli.rs deleted file mode 100644 index 12499b5718d6d..0000000000000 --- a/bridges/bin/millau/node/src/cli.rs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use clap::Parser; -use sc_cli::RunCmd; - -#[derive(Debug, Parser)] -pub struct Cli { - #[structopt(subcommand)] - pub subcommand: Option, - - #[structopt(flatten)] - pub run: RunCmd, -} - -/// Possible subcommands of the main binary. -#[derive(Debug, Parser)] -#[allow(clippy::large_enum_variant)] -pub enum Subcommand { - /// Key management CLI utilities - #[clap(subcommand)] - Key(sc_cli::KeySubcommand), - - /// Verify a signature for a message, provided on `STDIN`, with a given (public or secret) key. - Verify(sc_cli::VerifyCmd), - - /// Generate a seed that provides a vanity address. - Vanity(sc_cli::VanityCmd), - - /// Sign a message, with a given (secret) key. - Sign(sc_cli::SignCmd), - - /// Build a chain specification. - BuildSpec(sc_cli::BuildSpecCmd), - - /// Validate blocks. - CheckBlock(sc_cli::CheckBlockCmd), - - /// Export blocks. - ExportBlocks(sc_cli::ExportBlocksCmd), - - /// Export the state of a given block into a chain spec. - ExportState(sc_cli::ExportStateCmd), - - /// Import blocks. - ImportBlocks(sc_cli::ImportBlocksCmd), - - /// Remove the whole chain. - PurgeChain(sc_cli::PurgeChainCmd), - - /// Revert the chain to a previous state. - Revert(sc_cli::RevertCmd), - - /// Inspect blocks or extrinsics. - Inspect(node_inspect::cli::InspectCmd), - - /// Benchmark runtime pallets. - #[clap(subcommand)] - Benchmark(frame_benchmarking_cli::BenchmarkCmd), -} diff --git a/bridges/bin/millau/node/src/command.rs b/bridges/bin/millau/node/src/command.rs deleted file mode 100644 index 745b393786e1d..0000000000000 --- a/bridges/bin/millau/node/src/command.rs +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use crate::{ - cli::{Cli, Subcommand}, - service, - service::new_partial, -}; -use frame_benchmarking_cli::BenchmarkCmd; -use millau_runtime::{Block, RuntimeApi}; -use sc_cli::SubstrateCli; -use sc_service::PartialComponents; - -impl SubstrateCli for Cli { - fn impl_name() -> String { - "Millau Bridge Node".into() - } - - fn impl_version() -> String { - env!("CARGO_PKG_VERSION").into() - } - - fn description() -> String { - "Millau Bridge Node".into() - } - - fn author() -> String { - "Parity Technologies".into() - } - - fn support_url() -> String { - "https://github.com/paritytech/parity-bridges-common/".into() - } - - fn copyright_start_year() -> i32 { - 2019 - } - - fn executable_name() -> String { - "millau-bridge-node".into() - } - - fn load_spec(&self, id: &str) -> Result, String> { - Ok(Box::new( - match id { - "" | "dev" => crate::chain_spec::Alternative::Development, - "local" => crate::chain_spec::Alternative::LocalTestnet, - _ => return Err(format!("Unsupported chain specification: {id}")), - } - .load(), - )) - } -} - -/// Parse and run command line arguments -pub fn run() -> sc_cli::Result<()> { - let cli = Cli::from_args(); - // make sure to set correct crypto version. - sp_core::crypto::set_default_ss58_version(sp_core::crypto::Ss58AddressFormat::custom( - millau_runtime::SS58Prefix::get() as u16, - )); - - match &cli.subcommand { - Some(Subcommand::Benchmark(cmd)) => { - let runner = cli.create_runner(cmd)?; - match cmd { - BenchmarkCmd::Pallet(cmd) => - if cfg!(feature = "runtime-benchmarks") { - runner.sync_run(|config| cmd.run::(config)) - } else { - println!( - "Benchmarking wasn't enabled when building the node. \ - You can enable it with `--features runtime-benchmarks`." - ); - Ok(()) - }, - _ => Err("Unsupported benchmarking subcommand".into()), - } - }, - Some(Subcommand::Key(cmd)) => cmd.run(&cli), - Some(Subcommand::Sign(cmd)) => cmd.run(), - Some(Subcommand::Verify(cmd)) => cmd.run(), - Some(Subcommand::Vanity(cmd)) => cmd.run(), - Some(Subcommand::BuildSpec(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run(config.chain_spec, config.network)) - }, - Some(Subcommand::CheckBlock(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - let PartialComponents { client, task_manager, import_queue, .. } = - new_partial(&config)?; - Ok((cmd.run(client, import_queue), task_manager)) - }) - }, - Some(Subcommand::ExportBlocks(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - let PartialComponents { client, task_manager, .. } = new_partial(&config)?; - Ok((cmd.run(client, config.database), task_manager)) - }) - }, - Some(Subcommand::ExportState(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - let PartialComponents { client, task_manager, .. } = new_partial(&config)?; - Ok((cmd.run(client, config.chain_spec), task_manager)) - }) - }, - Some(Subcommand::ImportBlocks(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - let PartialComponents { client, task_manager, import_queue, .. } = - new_partial(&config)?; - Ok((cmd.run(client, import_queue), task_manager)) - }) - }, - Some(Subcommand::PurgeChain(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run(config.database)) - }, - Some(Subcommand::Revert(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - let PartialComponents { client, task_manager, backend, .. } = new_partial(&config)?; - Ok((cmd.run(client, backend, None), task_manager)) - }) - }, - Some(Subcommand::Inspect(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner - .sync_run(|config| cmd.run::(config)) - }, - None => { - let runner = cli.create_runner(&cli.run)?; - runner.run_node_until_exit(|config| async move { - service::new_full(config).map_err(sc_cli::Error::Service) - }) - }, - } -} diff --git a/bridges/bin/millau/node/src/lib.rs b/bridges/bin/millau/node/src/lib.rs deleted file mode 100644 index 382d1c2d7fb1c..0000000000000 --- a/bridges/bin/millau/node/src/lib.rs +++ /dev/null @@ -1,32 +0,0 @@ -// 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 . - -//! Substrate Node Template CLI library. -#![warn(missing_docs)] - -mod chain_spec; -#[macro_use] -mod service; -mod cli; -mod command; - -/// Node run result. -pub type Result = sc_cli::Result<()>; - -/// Run node. -pub fn run() -> Result { - command::run() -} diff --git a/bridges/bin/millau/node/src/main.rs b/bridges/bin/millau/node/src/main.rs deleted file mode 100644 index cf6dd9f733a16..0000000000000 --- a/bridges/bin/millau/node/src/main.rs +++ /dev/null @@ -1,30 +0,0 @@ -// 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 . - -//! Millau bridge node. - -#![warn(missing_docs)] - -mod chain_spec; -#[macro_use] -mod service; -mod cli; -mod command; - -/// Run the Millau Node -fn main() -> sc_cli::Result<()> { - command::run() -} diff --git a/bridges/bin/millau/node/src/service.rs b/bridges/bin/millau/node/src/service.rs deleted file mode 100644 index cb57dd118cc71..0000000000000 --- a/bridges/bin/millau/node/src/service.rs +++ /dev/null @@ -1,479 +0,0 @@ -// 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 . - -//! Service and ServiceFactory implementation. Specialized wrapper over substrate service. - -use jsonrpsee::RpcModule; -use millau_runtime::{self, opaque::Block, RuntimeApi}; -use sc_client_api::{Backend, BlockBackend}; -use sc_consensus_aura::{CompatibilityMode, ImportQueueParams, SlotProportion, StartAuraParams}; -use sc_consensus_grandpa::SharedVoterState; -pub use sc_executor::NativeElseWasmExecutor; -use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY}; -use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; -use sc_telemetry::{Telemetry, TelemetryWorker}; -use sc_transaction_pool_api::OffchainTransactionPoolFactory; -use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; -use std::{sync::Arc, time::Duration}; - -// Our native executor instance. -pub struct ExecutorDispatch; - -impl sc_executor::NativeExecutionDispatch for ExecutorDispatch { - /// Only enable the benchmarking host functions when we actually want to benchmark. - #[cfg(feature = "runtime-benchmarks")] - type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; - /// Otherwise we only use the default Substrate host functions. - #[cfg(not(feature = "runtime-benchmarks"))] - type ExtendHostFunctions = (); - - fn dispatch(method: &str, data: &[u8]) -> Option> { - millau_runtime::api::dispatch(method, data) - } - - fn native_version() -> sc_executor::NativeVersion { - millau_runtime::native_version() - } -} - -type FullClient = - sc_service::TFullClient>; -type FullBackend = sc_service::TFullBackend; -type FullSelectChain = sc_consensus::LongestChain; - -#[allow(clippy::type_complexity)] -pub fn new_partial( - config: &Configuration, -) -> Result< - sc_service::PartialComponents< - FullClient, - FullBackend, - FullSelectChain, - sc_consensus::DefaultImportQueue, - sc_transaction_pool::FullPool, - ( - sc_consensus_grandpa::GrandpaBlockImport< - FullBackend, - Block, - FullClient, - FullSelectChain, - >, - sc_consensus_grandpa::LinkHalf, - sc_consensus_beefy::BeefyVoterLinks, - sc_consensus_beefy::BeefyRPCLinks, - Option, - ), - >, - ServiceError, -> { - let telemetry = config - .telemetry_endpoints - .clone() - .filter(|x| !x.is_empty()) - .map(|endpoints| -> Result<_, sc_telemetry::Error> { - let worker = TelemetryWorker::new(16)?; - let telemetry = worker.handle().new_telemetry(endpoints); - Ok((worker, telemetry)) - }) - .transpose()?; - - let heap_pages = config - .default_heap_pages - .map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ }); - let executor = NativeElseWasmExecutor::::new_with_wasm_executor( - WasmExecutor::builder() - .with_execution_method(config.wasm_method) - .with_onchain_heap_alloc_strategy(heap_pages) - .with_offchain_heap_alloc_strategy(heap_pages) - .with_max_runtime_instances(config.max_runtime_instances) - .with_runtime_cache_size(config.runtime_cache_size) - .build(), - ); - - let (client, backend, keystore_container, task_manager) = - sc_service::new_full_parts::( - config, - telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), - executor, - )?; - let client = Arc::new(client); - - let telemetry = telemetry.map(|(worker, telemetry)| { - task_manager.spawn_handle().spawn("telemetry", None, worker.run()); - telemetry - }); - - let select_chain = sc_consensus::LongestChain::new(backend.clone()); - - let transaction_pool = sc_transaction_pool::BasicPool::new_full( - config.transaction_pool.clone(), - config.role.is_authority().into(), - config.prometheus_registry(), - task_manager.spawn_essential_handle(), - client.clone(), - ); - - let (grandpa_block_import, grandpa_link) = sc_consensus_grandpa::block_import( - client.clone(), - 512, - &client, - select_chain.clone(), - telemetry.as_ref().map(|x| x.handle()), - )?; - - let (beefy_block_import, beefy_voter_links, beefy_rpc_links) = - sc_consensus_beefy::beefy_block_import_and_links( - grandpa_block_import.clone(), - backend.clone(), - client.clone(), - config.prometheus_registry().cloned(), - ); - - let slot_duration = sc_consensus_aura::slot_duration(&*client)?; - - let import_queue = - sc_consensus_aura::import_queue::(ImportQueueParams { - block_import: beefy_block_import, - justification_import: Some(Box::new(grandpa_block_import.clone())), - client: client.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_slot_duration( - *timestamp, - slot_duration, - ); - - Ok((slot, timestamp)) - }, - spawner: &task_manager.spawn_essential_handle(), - registry: config.prometheus_registry(), - check_for_equivocation: Default::default(), - telemetry: telemetry.as_ref().map(|x| x.handle()), - compatibility_mode: CompatibilityMode::None, - })?; - - Ok(sc_service::PartialComponents { - client, - backend, - task_manager, - import_queue, - keystore_container, - select_chain, - transaction_pool, - other: (grandpa_block_import, grandpa_link, beefy_voter_links, beefy_rpc_links, telemetry), - }) -} - -/// Builds a new service for a full client. -pub fn new_full(config: Configuration) -> Result { - use sc_service::WarpSyncParams; - - let sc_service::PartialComponents { - client, - backend, - mut task_manager, - import_queue, - keystore_container, - select_chain, - transaction_pool, - other: (block_import, grandpa_link, beefy_voter_links, beefy_rpc_links, mut telemetry), - } = new_partial(&config)?; - - let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); - - let mut net_config = sc_network::config::FullNetworkConfiguration::new(&config.network); - - // Note: GrandPa is pushed before the Polkadot-specific protocols. This doesn't change - // anything in terms of behaviour, but makes the logs more consistent with the other - // Substrate nodes. - let grandpa_protocol_name = sc_consensus_grandpa::protocol_standard_name( - &client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"), - &config.chain_spec, - ); - net_config.add_notification_protocol(sc_consensus_grandpa::grandpa_peers_set_config( - grandpa_protocol_name.clone(), - )); - - let beefy_gossip_proto_name = - sc_consensus_beefy::gossip_protocol_name(genesis_hash, config.chain_spec.fork_id()); - // `beefy_on_demand_justifications_handler` is given to `beefy-gadget` task to be run, - // while `beefy_req_resp_cfg` is added to `config.network.request_response_protocols`. - let (beefy_on_demand_justifications_handler, beefy_req_resp_cfg) = - sc_consensus_beefy::communication::request_response::BeefyJustifsRequestHandler::new( - genesis_hash, - config.chain_spec.fork_id(), - client.clone(), - config.prometheus_registry().cloned(), - ); - net_config.add_notification_protocol( - sc_consensus_beefy::communication::beefy_peers_set_config(beefy_gossip_proto_name.clone()), - ); - net_config.add_request_response_protocol(beefy_req_resp_cfg); - - let role = config.role.clone(); - let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new( - backend.clone(), - grandpa_link.shared_authority_set().clone(), - Vec::default(), - )); - - let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) = - sc_service::build_network(sc_service::BuildNetworkParams { - config: &config, - net_config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - spawn_handle: task_manager.spawn_handle(), - import_queue, - block_announce_validator_builder: None, - warp_sync_params: Some(WarpSyncParams::WithProvider(warp_sync)), - block_relay: None, - })?; - - if config.offchain_worker.enabled { - use futures::FutureExt; - - task_manager.spawn_handle().spawn( - "offchain-workers-runner", - "offchain-work", - sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions { - runtime_api_provider: client.clone(), - keystore: Some(keystore_container.keystore()), - offchain_db: backend.offchain_storage(), - transaction_pool: Some(OffchainTransactionPoolFactory::new( - transaction_pool.clone(), - )), - network_provider: network.clone(), - is_validator: role.is_authority(), - enable_http_requests: false, - custom_extensions: move |_| vec![], - }) - .run(client.clone(), task_manager.spawn_handle()) - .boxed(), - ); - } - - let force_authoring = config.force_authoring; - let backoff_authoring_blocks: Option<()> = None; - let name = config.network.node_name.clone(); - let enable_grandpa = !config.disable_grandpa; - let prometheus_registry = config.prometheus_registry().cloned(); - let shared_voter_state = SharedVoterState::empty(); - - let rpc_extensions_builder = { - use sc_consensus_grandpa::FinalityProofProvider as GrandpaFinalityProofProvider; - - use mmr_rpc::{Mmr, MmrApiServer}; - use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; - use sc_consensus_beefy_rpc::{Beefy, BeefyApiServer}; - use sc_consensus_grandpa_rpc::{Grandpa, GrandpaApiServer}; - use sc_rpc::DenyUnsafe; - use substrate_frame_rpc_system::{System, SystemApiServer}; - - let backend = backend.clone(); - let client = client.clone(); - let pool = transaction_pool.clone(); - - let justification_stream = grandpa_link.justification_stream(); - let shared_authority_set = grandpa_link.shared_authority_set().clone(); - let shared_voter_state = shared_voter_state.clone(); - - let finality_proof_provider = GrandpaFinalityProofProvider::new_for_service( - backend.clone(), - Some(shared_authority_set.clone()), - ); - - Box::new(move |_, subscription_executor: sc_rpc::SubscriptionTaskExecutor| { - let mut io = RpcModule::new(()); - let map_err = |e| sc_service::Error::Other(format!("{e}")); - io.merge(System::new(client.clone(), pool.clone(), DenyUnsafe::No).into_rpc()) - .map_err(map_err)?; - io.merge(TransactionPayment::new(client.clone()).into_rpc()).map_err(map_err)?; - io.merge( - Grandpa::new( - subscription_executor.clone(), - shared_authority_set.clone(), - shared_voter_state.clone(), - justification_stream.clone(), - finality_proof_provider.clone(), - ) - .into_rpc(), - ) - .map_err(map_err)?; - io.merge( - Beefy::::new( - beefy_rpc_links.from_voter_justif_stream.clone(), - beefy_rpc_links.from_voter_best_beefy_stream.clone(), - subscription_executor, - ) - .map_err(|e| sc_service::Error::Other(format!("{e}")))? - .into_rpc(), - ) - .map_err(map_err)?; - io.merge( - Mmr::new( - client.clone(), - backend - .offchain_storage() - .ok_or("Backend doesn't provide the required offchain storage")?, - ) - .into_rpc(), - ) - .map_err(map_err)?; - Ok(io) - }) - }; - - let _rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams { - network: network.clone(), - client: client.clone(), - keystore: keystore_container.keystore(), - task_manager: &mut task_manager, - transaction_pool: transaction_pool.clone(), - sync_service: sync_service.clone(), - rpc_builder: rpc_extensions_builder, - backend: backend.clone(), - system_rpc_tx, - config, - tx_handler_controller, - telemetry: telemetry.as_mut(), - })?; - - if role.is_authority() { - let proposer_factory = sc_basic_authorship::ProposerFactory::new( - task_manager.spawn_handle(), - client.clone(), - transaction_pool.clone(), - prometheus_registry.as_ref(), - telemetry.as_ref().map(|x| x.handle()), - ); - - let slot_duration = sc_consensus_aura::slot_duration(&*client)?; - - let aura = sc_consensus_aura::start_aura::( - StartAuraParams { - slot_duration, - client: client.clone(), - select_chain, - block_import, - proposer_factory, - 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_slot_duration( - *timestamp, - slot_duration, - ); - - Ok((slot, timestamp)) - }, - force_authoring, - backoff_authoring_blocks, - keystore: keystore_container.keystore(), - sync_oracle: sync_service.clone(), - justification_sync_link: sync_service.clone(), - block_proposal_slot_portion: SlotProportion::new(2f32 / 3f32), - max_block_proposal_slot_portion: None, - telemetry: telemetry.as_ref().map(|x| x.handle()), - compatibility_mode: CompatibilityMode::None, - }, - )?; - - // the AURA authoring task is considered essential, i.e. if it - // fails we take down the service with it. - task_manager - .spawn_essential_handle() - .spawn_blocking("aura", Some("block-authoring"), aura); - } - - // if the node isn't actively participating in consensus then it doesn't - // need a keystore, regardless of which protocol we use below. - let keystore = if role.is_authority() { Some(keystore_container.keystore()) } else { None }; - - let justifications_protocol_name = beefy_on_demand_justifications_handler.protocol_name(); - let payload_provider = sp_consensus_beefy::mmr::MmrRootProvider::new(client.clone()); - let beefy_params = sc_consensus_beefy::BeefyParams { - client: client.clone(), - backend, - payload_provider, - runtime: client, - key_store: keystore.clone(), - network_params: sc_consensus_beefy::BeefyNetworkParams { - network: network.clone(), - sync: sync_service.clone(), - gossip_protocol_name: beefy_gossip_proto_name, - justifications_protocol_name, - _phantom: core::marker::PhantomData::, - }, - min_block_delta: 2, - prometheus_registry: prometheus_registry.clone(), - links: beefy_voter_links, - on_demand_justifications_handler: beefy_on_demand_justifications_handler, - }; - - // Start the BEEFY bridge gadget. - task_manager.spawn_essential_handle().spawn_blocking( - "beefy-gadget", - None, - sc_consensus_beefy::start_beefy_gadget::<_, _, _, _, _, _, _>(beefy_params), - ); - - let grandpa_config = sc_consensus_grandpa::Config { - // FIXME #1578 make this available through chainspec - gossip_duration: Duration::from_millis(333), - justification_generation_period: 512, - name: Some(name), - observer_enabled: false, - keystore, - local_role: role, - telemetry: telemetry.as_ref().map(|x| x.handle()), - protocol_name: grandpa_protocol_name, - }; - - if enable_grandpa { - // start the full GRANDPA voter - // NOTE: non-authorities could run the GRANDPA observer protocol, but at - // this point the full voter should provide better guarantees of block - // and vote data availability than the observer. The observer has not - // been tested extensively yet and having most nodes in a network run it - // could lead to finality stalls. - let grandpa_config = sc_consensus_grandpa::GrandpaParams { - config: grandpa_config, - link: grandpa_link, - network, - sync: sync_service, - voting_rule: sc_consensus_grandpa::VotingRulesBuilder::default().build(), - prometheus_registry, - shared_voter_state, - telemetry: telemetry.as_ref().map(|x| x.handle()), - offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool), - }; - - // the GRANDPA voter task is considered infallible, i.e. - // if it fails we take down the service with it. - task_manager.spawn_essential_handle().spawn_blocking( - "grandpa-voter", - None, - sc_consensus_grandpa::run_grandpa_voter(grandpa_config)?, - ); - } - - network_starter.start_network(); - Ok(task_manager) -} diff --git a/bridges/bin/millau/runtime/Cargo.toml b/bridges/bin/millau/runtime/Cargo.toml deleted file mode 100644 index 7e963d6b74d0b..0000000000000 --- a/bridges/bin/millau/runtime/Cargo.toml +++ /dev/null @@ -1,155 +0,0 @@ -[package] -name = "millau-runtime" -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2021" -repository = "https://github.com/paritytech/parity-bridges-common/" -license = "GPL-3.0-or-later WITH Classpath-exception-2.0" - -[dependencies] -hex-literal = "0.4" -codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } -scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } - -# Bridge dependencies - -bp-header-chain = { path = "../../../primitives/header-chain", default-features = false } -bp-messages = { path = "../../../primitives/messages", default-features = false } -bp-millau = { path = "../../../primitives/chain-millau", default-features = false } -bp-parachains = { path = "../../../primitives/parachains", default-features = false } -bp-polkadot-core = { path = "../../../primitives/polkadot-core", default-features = false } -bp-relayers = { path = "../../../primitives/relayers", default-features = false } -bp-rialto = { path = "../../../primitives/chain-rialto", default-features = false } -bp-rialto-parachain = { path = "../../../primitives/chain-rialto-parachain", default-features = false } -bp-runtime = { path = "../../../primitives/runtime", default-features = false } -bp-westend = { path = "../../../primitives/chain-westend", default-features = false } -bp-xcm-bridge-hub-router = { path = "../../../primitives/xcm-bridge-hub-router", default-features = false } -bridge-runtime-common = { path = "../../runtime-common", default-features = false } -pallet-bridge-grandpa = { path = "../../../modules/grandpa", default-features = false } -pallet-bridge-messages = { path = "../../../modules/messages", default-features = false } -pallet-bridge-parachains = { path = "../../../modules/parachains", default-features = false } -pallet-bridge-relayers = { path = "../../../modules/relayers", default-features = false } -pallet-shift-session-manager = { path = "../../../modules/shift-session-manager", default-features = false } -pallet-xcm-bridge-hub-router = { path = "../../../modules/xcm-bridge-hub-router", default-features = false } - -# Substrate Dependencies - -sp-consensus-beefy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false, optional = true } -frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-beefy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-beefy-mmr = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-mmr = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-offences = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false, features = ["historical"]} -pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-version = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } - -# Polkadot Dependencies -pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } - -[dev-dependencies] -bridge-runtime-common = { path = "../../runtime-common", features = ["integrity-test", "std"] } -env_logger = "0.10" -static_assertions = "1.1" - -[build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } - -[features] -default = [ "std" ] -std = [ - "bp-messages/std", - "bp-millau/std", - "bp-parachains/std", - "bp-polkadot-core/std", - "bp-relayers/std", - "bp-rialto-parachain/std", - "bp-rialto/std", - "bp-runtime/std", - "bp-westend/std", - "bp-xcm-bridge-hub-router/std", - "bridge-runtime-common/std", - "codec/std", - "frame-executive/std", - "frame-support/std", - "frame-system-rpc-runtime-api/std", - "frame-system/std", - "pallet-aura/std", - "pallet-authorship/std", - "pallet-balances/std", - "pallet-beefy-mmr/std", - "pallet-beefy/std", - "pallet-bridge-grandpa/std", - "pallet-bridge-messages/std", - "pallet-bridge-parachains/std", - "pallet-bridge-relayers/std", - "pallet-grandpa/std", - "pallet-mmr/std", - "pallet-offences/std", - "pallet-session/std", - "pallet-shift-session-manager/std", - "pallet-sudo/std", - "pallet-timestamp/std", - "pallet-transaction-payment-rpc-runtime-api/std", - "pallet-transaction-payment/std", - "pallet-utility/std", - "pallet-xcm-bridge-hub-router/std", - "pallet-xcm/std", - "scale-info/std", - "sp-api/std", - "sp-block-builder/std", - "sp-consensus-aura/std", - "sp-consensus-beefy/std", - "sp-core/std", - "sp-inherents/std", - "sp-io/std", - "sp-offchain/std", - "sp-runtime/std", - "sp-session/std", - "sp-std/std", - "sp-transaction-pool/std", - "sp-version/std", - "xcm-builder/std", - "xcm-executor/std", - "xcm/std", -] -runtime-benchmarks = [ - "bridge-runtime-common/runtime-benchmarks", - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "pallet-bridge-grandpa/runtime-benchmarks", - "pallet-bridge-messages/runtime-benchmarks", - "pallet-bridge-parachains/runtime-benchmarks", - "pallet-bridge-relayers/runtime-benchmarks", - "pallet-xcm-bridge-hub-router/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", - "xcm-builder/runtime-benchmarks", -] diff --git a/bridges/bin/millau/runtime/build.rs b/bridges/bin/millau/runtime/build.rs deleted file mode 100644 index 25e220e46fc3b..0000000000000 --- a/bridges/bin/millau/runtime/build.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use substrate_wasm_builder::WasmBuilder; - -fn main() { - WasmBuilder::new() - .with_current_project() - .import_memory() - .export_heap_base() - .disable_runtime_version_section_check() - .build() -} diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs deleted file mode 100644 index a349551a873c0..0000000000000 --- a/bridges/bin/millau/runtime/src/lib.rs +++ /dev/null @@ -1,1300 +0,0 @@ -// 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 . - -//! The Millau runtime. This can be compiled with `#[no_std]`, ready for Wasm. - -#![cfg_attr(not(feature = "std"), no_std)] -// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. -#![recursion_limit = "256"] -// Runtime-generated enums -#![allow(clippy::large_enum_variant)] -// From construct_runtime macro -#![allow(clippy::from_over_into)] - -// Make the WASM binary available. -#[cfg(feature = "std")] -include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); - -pub mod rialto_messages; -pub mod rialto_parachain_messages; -pub mod weights; -pub mod xcm_config; - -use bp_parachains::SingleParaStoredHeaderDataBuilder; -#[cfg(feature = "runtime-benchmarks")] -use bp_relayers::{RewardsAccountOwner, RewardsAccountParams}; -use bp_runtime::HeaderId; -use pallet_grandpa::{ - fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList, -}; -use pallet_transaction_payment::{FeeDetails, Multiplier, RuntimeDispatchInfo}; -use sp_api::impl_runtime_apis; -use sp_consensus_aura::sr25519::AuthorityId as AuraId; -use sp_consensus_beefy::{ecdsa_crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion, ValidatorSet}; -use sp_core::OpaqueMetadata; -use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, - traits::{Block as BlockT, IdentityLookup, Keccak256, NumberFor, OpaqueKeys}, - transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, FixedPointNumber, KeyTypeId, Perquintill, -}; -use sp_std::prelude::*; -#[cfg(feature = "std")] -use sp_version::NativeVersion; -use sp_version::RuntimeVersion; -use xcm_builder::{NetworkExportTable, NetworkExportTableItem}; - -// to be able to use Millau runtime in `bridge-runtime-common` tests -pub use bridge_runtime_common; - -// A few exports that help ease life for downstream crates. -pub use frame_support::{ - construct_runtime, - dispatch::DispatchClass, - parameter_types, - traits::{ - ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, Currency, ExistenceRequirement, - Imbalance, KeyOwnerProofSystem, - }, - weights::{ - constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, IdentityFee, RuntimeDbWeight, - Weight, - }, - StorageValue, -}; - -pub use frame_system::Call as SystemCall; -pub use pallet_balances::Call as BalancesCall; -pub use pallet_bridge_grandpa::Call as BridgeGrandpaCall; -pub use pallet_bridge_messages::Call as MessagesCall; -pub use pallet_bridge_parachains::Call as BridgeParachainsCall; -pub use pallet_sudo::Call as SudoCall; -pub use pallet_timestamp::Call as TimestampCall; -pub use pallet_xcm::Call as XcmCall; - -use bridge_runtime_common::{ - generate_bridge_reject_obsolete_headers_and_messages, - refund_relayer_extension::{ - ActualFeeRefund, RefundBridgedParachainMessages, RefundSignedExtensionAdapter, - RefundableMessagesLane, RefundableParachain, - }, -}; -#[cfg(any(feature = "std", test))] -pub use sp_runtime::BuildStorage; -pub use sp_runtime::{Perbill, Permill}; - -/// An index to a block. -pub type BlockNumber = bp_millau::BlockNumber; - -/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. -pub type Signature = bp_millau::Signature; - -/// Some way of identifying an account on the chain. We intentionally make it equivalent -/// to the public key of our transaction signing scheme. -pub type AccountId = bp_millau::AccountId; - -/// The type for looking up accounts. We don't expect more than 4 billion of them, but you -/// never know... -pub type AccountIndex = u32; - -/// Balance of an account. -pub type Balance = bp_millau::Balance; - -/// Nonce of a transaction in the chain. -pub type Nonce = bp_millau::Nonce; - -/// A hash of some data used by the chain. -pub type Hash = bp_millau::Hash; - -/// Hashing algorithm used by the chain. -pub type Hashing = bp_millau::Hasher; - -/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know -/// the specifics of the runtime. They can then be made to be agnostic over specific formats -/// of data like extrinsics, allowing for them to continue syncing the network through upgrades -/// to even the core data structures. -pub mod opaque { - use super::*; - - pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; - - /// Opaque block header type. - pub type Header = generic::Header; - /// Opaque block type. - pub type Block = generic::Block; - /// Opaque block identifier type. - pub type BlockId = generic::BlockId; -} - -impl_opaque_keys! { - pub struct SessionKeys { - pub aura: Aura, - pub beefy: Beefy, - pub grandpa: Grandpa, - } -} - -/// This runtime version. -#[sp_version::runtime_version] -pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: create_runtime_str!("millau-runtime"), - impl_name: create_runtime_str!("millau-runtime"), - authoring_version: 1, - spec_version: 1, - impl_version: 1, - apis: RUNTIME_API_VERSIONS, - transaction_version: 1, - state_version: 0, -}; - -/// The version information used to identify this runtime when compiled natively. -#[cfg(feature = "std")] -pub fn native_version() -> NativeVersion { - NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } -} - -parameter_types! { - pub const BlockHashCount: BlockNumber = 250; - pub const Version: RuntimeVersion = VERSION; - pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight { - read: 60_000_000, // ~0.06 ms = ~60 µs - write: 200_000_000, // ~0.2 ms = 200 µs - }; - pub const SS58Prefix: u8 = 60; -} - -impl frame_system::Config for Runtime { - /// The basic call filter to use in dispatchable. - type BaseCallFilter = frame_support::traits::Everything; - /// The identifier used to distinguish between accounts. - type AccountId = AccountId; - /// The aggregated dispatch type that is available for extrinsics. - type RuntimeCall = RuntimeCall; - /// The lookup mechanism to get account ID from whatever is passed in dispatchers. - type Lookup = IdentityLookup; - /// The index type for storing how many extrinsics an account has signed. - type Nonce = Nonce; - /// The type for hashing blocks and tries. - type Hash = Hash; - /// The hashing algorithm used. - type Hashing = Hashing; - /// The header type. - type Block = Block; - /// The ubiquitous event type. - type RuntimeEvent = RuntimeEvent; - /// The ubiquitous origin type. - type RuntimeOrigin = RuntimeOrigin; - /// Maximum number of block number to block hash mappings to keep (oldest pruned first). - type BlockHashCount = BlockHashCount; - /// Version of the runtime. - type Version = Version; - /// Provides information about the pallet setup in the runtime. - type PalletInfo = PalletInfo; - /// What to do if a new account is created. - type OnNewAccount = (); - /// What to do if an account is fully reaped from the system. - type OnKilledAccount = (); - /// The data to be stored in an account. - type AccountData = pallet_balances::AccountData; - // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) - /// Weight information for the extrinsics of this pallet. - type SystemWeightInfo = (); - /// Block and extrinsics weights: base values and limits. - type BlockWeights = bp_millau::BlockWeights; - /// The maximum length of a block (in bytes). - type BlockLength = bp_millau::BlockLength; - /// The weight of database operations that the runtime can invoke. - type DbWeight = DbWeight; - /// The designated SS58 prefix of this chain. - type SS58Prefix = SS58Prefix; - /// The set code logic, just the default since we're not a parachain. - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -impl pallet_aura::Config for Runtime { - type AuthorityId = AuraId; - type MaxAuthorities = ConstU32<10>; - type DisabledValidators = (); - type AllowMultipleBlocksPerSlot = ConstBool; -} - -impl pallet_beefy::Config for Runtime { - type BeefyId = BeefyId; - type MaxAuthorities = ConstU32<10>; - type MaxSetIdSessionEntries = ConstU64<0>; - type OnNewValidatorSet = MmrLeaf; - type WeightInfo = (); - type KeyOwnerProof = sp_core::Void; - type EquivocationReportSystem = (); - type MaxNominators = ConstU32<256>; -} - -impl pallet_grandpa::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) - type WeightInfo = (); - type MaxAuthorities = ConstU32<10>; - type MaxSetIdSessionEntries = ConstU64<0>; - type KeyOwnerProof = >::Proof; - type EquivocationReportSystem = - pallet_grandpa::EquivocationReportSystem; - type MaxNominators = ConstU32<256>; -} - -/// MMR helper types. -mod mmr { - use super::Runtime; - pub use pallet_mmr::primitives::*; - - pub type Leaf = <::LeafData as LeafDataProvider>::LeafData; - pub type Hashing = ::Hashing; - pub type Hash = ::Output; -} - -impl pallet_mmr::Config for Runtime { - const INDEXING_PREFIX: &'static [u8] = b"mmr"; - type Hashing = Keccak256; - type OnNewRoot = pallet_beefy_mmr::DepositBeefyDigest; - type WeightInfo = (); - type LeafData = pallet_beefy_mmr::Pallet; -} - -parameter_types! { - /// Version of the produced MMR leaf. - /// - /// The version consists of two parts; - /// - `major` (3 bits) - /// - `minor` (5 bits) - /// - /// `major` should be updated only if decoding the previous MMR Leaf format from the payload - /// is not possible (i.e. backward incompatible change). - /// `minor` should be updated if fields are added to the previous MMR Leaf, which given SCALE - /// encoding does not prevent old leafs from being decoded. - /// - /// Hence we expect `major` to be changed really rarely (think never). - /// See [`MmrLeafVersion`] type documentation for more details. - pub LeafVersion: MmrLeafVersion = MmrLeafVersion::new(0, 0); -} - -pub struct BeefyDummyDataProvider; - -impl sp_consensus_beefy::mmr::BeefyDataProvider<()> for BeefyDummyDataProvider { - fn extra_data() {} -} - -impl pallet_beefy_mmr::Config for Runtime { - type LeafVersion = LeafVersion; - type BeefyAuthorityToMerkleLeaf = pallet_beefy_mmr::BeefyEcdsaToEthereum; - type LeafExtra = (); - type BeefyDataProvider = BeefyDummyDataProvider; -} - -parameter_types! { - pub const MinimumPeriod: u64 = bp_millau::SLOT_DURATION / 2; -} - -impl pallet_timestamp::Config for Runtime { - /// A timestamp: milliseconds since the UNIX epoch. - type Moment = u64; - type OnTimestampSet = Aura; - type MinimumPeriod = MinimumPeriod; - // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) - type WeightInfo = (); -} - -parameter_types! { - pub const ExistentialDeposit: bp_millau::Balance = 500; -} - -impl pallet_balances::Config for Runtime { - /// The type for recording an account's balance. - type Balance = Balance; - /// The ubiquitous event type. - type RuntimeEvent = RuntimeEvent; - type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; - type AccountStore = System; - // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) - type WeightInfo = (); - // For weight estimation, we assume that the most locks on an individual account will be 50. - // This number may need to be adjusted in the future if this assumption no longer holds true. - type MaxLocks = ConstU32<50>; - type MaxReserves = ConstU32<50>; - type ReserveIdentifier = [u8; 8]; - type RuntimeHoldReason = RuntimeHoldReason; - type FreezeIdentifier = (); - type MaxHolds = ConstU32<0>; - type MaxFreezes = ConstU32<0>; -} - -parameter_types! { - pub const TransactionBaseFee: Balance = 0; - pub const TransactionByteFee: Balance = 1; - // values for following parameters are copied from polkadot repo, but it is fine - // not to sync them - we're not going to make Rialto a full copy of one of Polkadot-like chains - pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); - pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(3, 100_000); - pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000u128); - pub MaximumMultiplier: Multiplier = sp_runtime::traits::Bounded::max_value(); -} - -impl pallet_transaction_payment::Config for Runtime { - type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; - type OperationalFeeMultiplier = ConstU8<5>; - type WeightToFee = bp_millau::WeightToFee; - type LengthToFee = ConstantMultiplier; - type FeeMultiplierUpdate = pallet_transaction_payment::TargetedFeeAdjustment< - Runtime, - TargetBlockFullness, - AdjustmentVariable, - MinimumMultiplier, - MaximumMultiplier, - >; - type RuntimeEvent = RuntimeEvent; -} - -impl pallet_sudo::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type WeightInfo = pallet_sudo::weights::SubstrateWeight; -} - -parameter_types! { - /// Authorities are changing every 5 minutes. - pub const Period: BlockNumber = bp_millau::SESSION_LENGTH; - pub const Offset: BlockNumber = 0; - pub const RelayerStakeReserveId: [u8; 8] = *b"brdgrlrs"; - pub ReportLongevity: u64 = Period::get() * 10; -} - -impl pallet_session::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type ValidatorId = ::AccountId; - type ValidatorIdOf = (); - type ShouldEndSession = pallet_session::PeriodicSessions; - type NextSessionRotation = pallet_session::PeriodicSessions; - type SessionManager = pallet_shift_session_manager::Pallet; - type SessionHandler = ::KeyTypeIdProviders; - type Keys = SessionKeys; - // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) - type WeightInfo = (); -} - -impl frame_system::offchain::SendTransactionTypes for Runtime -where - RuntimeCall: From, -{ - type Extrinsic = UncheckedExtrinsic; - type OverarchingCall = RuntimeCall; -} - -impl pallet_authorship::Config for Runtime { - type FindAuthor = pallet_session::FindAccountFromAuthorIndex; - type EventHandler = (); -} - -pub struct FullIdentificationOf; -impl sp_runtime::traits::Convert> for FullIdentificationOf { - fn convert(_: AccountId) -> Option<()> { - Some(()) - } -} - -impl pallet_session::historical::Config for Runtime { - type FullIdentification = (); - type FullIdentificationOf = FullIdentificationOf; -} - -impl pallet_offences::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type IdentificationTuple = pallet_session::historical::IdentificationTuple; - type OnOffenceHandler = (); -} - -impl pallet_bridge_relayers::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Reward = Balance; - type PaymentProcedure = - bp_relayers::PayRewardFromAccount, AccountId>; - type StakeAndSlash = pallet_bridge_relayers::StakeAndSlashNamed< - AccountId, - BlockNumber, - Balances, - RelayerStakeReserveId, - ConstU64<1_000>, - ConstU64<8>, - >; - type WeightInfo = (); -} - -pub type RialtoGrandpaInstance = (); -impl pallet_bridge_grandpa::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type BridgedChain = bp_rialto::Rialto; - type MaxFreeMandatoryHeadersPerBlock = ConstU32<4>; - type HeadersToKeep = ConstU32<{ bp_rialto::DAYS }>; - type WeightInfo = pallet_bridge_grandpa::weights::BridgeWeight; -} - -pub type WestendGrandpaInstance = pallet_bridge_grandpa::Instance1; -impl pallet_bridge_grandpa::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type BridgedChain = bp_westend::Westend; - type MaxFreeMandatoryHeadersPerBlock = ConstU32<4>; - type HeadersToKeep = ConstU32<{ bp_westend::DAYS }>; - type WeightInfo = pallet_bridge_grandpa::weights::BridgeWeight; -} - -impl pallet_shift_session_manager::Config for Runtime {} - -parameter_types! { - pub const MaxMessagesToPruneAtOnce: bp_messages::MessageNonce = 8; - pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_messages::MessageNonce = - bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; - pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce = - bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; - pub const RootAccountForPayments: Option = None; - pub const RialtoChainId: bp_runtime::ChainId = bp_runtime::RIALTO_CHAIN_ID; - pub const RialtoParachainChainId: bp_runtime::ChainId = bp_runtime::RIALTO_PARACHAIN_CHAIN_ID; - pub RialtoActiveOutboundLanes: &'static [bp_messages::LaneId] = &[rialto_messages::XCM_LANE]; - pub RialtoParachainActiveOutboundLanes: &'static [bp_messages::LaneId] = &[rialto_parachain_messages::XCM_LANE]; -} - -/// Instance of the messages pallet used to relay messages to/from Rialto chain. -pub type WithRialtoMessagesInstance = (); - -impl pallet_bridge_messages::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = weights::RialtoMessagesWeightInfo; - type ActiveOutboundLanes = RialtoActiveOutboundLanes; - type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane; - type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane; - - type MaximalOutboundPayloadSize = crate::rialto_messages::ToRialtoMaximalOutboundPayloadSize; - type OutboundPayload = crate::rialto_messages::ToRialtoMessagePayload; - - type InboundPayload = crate::rialto_messages::FromRialtoMessagePayload; - type InboundRelayer = bp_rialto::AccountId; - type DeliveryPayments = (); - - type TargetHeaderChain = crate::rialto_messages::RialtoAsTargetHeaderChain; - type LaneMessageVerifier = crate::rialto_messages::ToRialtoMessageVerifier; - type DeliveryConfirmationPayments = pallet_bridge_relayers::DeliveryConfirmationPaymentsAdapter< - Runtime, - WithRialtoMessagesInstance, - frame_support::traits::ConstU64<100_000>, - >; - type OnMessagesDelivered = (); - - type SourceHeaderChain = crate::rialto_messages::RialtoAsSourceHeaderChain; - type MessageDispatch = crate::rialto_messages::FromRialtoMessageDispatch; - type BridgedChainId = RialtoChainId; -} - -/// Instance of the messages pallet used to relay messages to/from RialtoParachain chain. -pub type WithRialtoParachainMessagesInstance = pallet_bridge_messages::Instance1; - -impl pallet_bridge_messages::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = weights::RialtoParachainMessagesWeightInfo; - type ActiveOutboundLanes = RialtoParachainActiveOutboundLanes; - type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane; - type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane; - - type MaximalOutboundPayloadSize = - crate::rialto_parachain_messages::ToRialtoParachainMaximalOutboundPayloadSize; - type OutboundPayload = crate::rialto_parachain_messages::ToRialtoParachainMessagePayload; - - type InboundPayload = crate::rialto_parachain_messages::FromRialtoParachainMessagePayload; - type InboundRelayer = bp_rialto_parachain::AccountId; - type DeliveryPayments = (); - - type TargetHeaderChain = crate::rialto_parachain_messages::RialtoParachainAsTargetHeaderChain; - type LaneMessageVerifier = crate::rialto_parachain_messages::ToRialtoParachainMessageVerifier; - type DeliveryConfirmationPayments = pallet_bridge_relayers::DeliveryConfirmationPaymentsAdapter< - Runtime, - WithRialtoParachainMessagesInstance, - frame_support::traits::ConstU64<100_000>, - >; - type OnMessagesDelivered = (); - - type SourceHeaderChain = crate::rialto_parachain_messages::RialtoParachainAsSourceHeaderChain; - type MessageDispatch = crate::rialto_parachain_messages::FromRialtoParachainMessageDispatch; - type BridgedChainId = RialtoParachainChainId; -} - -parameter_types! { - pub const RialtoParachainMessagesLane: bp_messages::LaneId = rialto_parachain_messages::XCM_LANE; - pub const RialtoParasPalletName: &'static str = bp_rialto::PARAS_PALLET_NAME; - pub const WestendParasPalletName: &'static str = bp_westend::PARAS_PALLET_NAME; - pub const MaxRialtoParaHeadDataSize: u32 = bp_rialto::MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE; - pub const MaxWestendParaHeadDataSize: u32 = bp_westend::MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE; -} - -/// Instance of the with-Rialto parachains pallet. -pub type WithRialtoParachainsInstance = (); - -impl pallet_bridge_parachains::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_bridge_parachains::weights::BridgeWeight; - type BridgesGrandpaPalletInstance = RialtoGrandpaInstance; - type ParasPalletName = RialtoParasPalletName; - type ParaStoredHeaderDataBuilder = - SingleParaStoredHeaderDataBuilder; - type HeadsToKeep = ConstU32<1024>; - type MaxParaHeadDataSize = MaxRialtoParaHeadDataSize; -} - -/// Instance of the with-Westend parachains pallet. -pub type WithWestendParachainsInstance = pallet_bridge_parachains::Instance1; - -impl pallet_bridge_parachains::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_bridge_parachains::weights::BridgeWeight; - type BridgesGrandpaPalletInstance = WestendGrandpaInstance; - type ParasPalletName = WestendParasPalletName; - type ParaStoredHeaderDataBuilder = - SingleParaStoredHeaderDataBuilder; - type HeadsToKeep = ConstU32<1024>; - type MaxParaHeadDataSize = MaxWestendParaHeadDataSize; -} - -impl pallet_utility::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type PalletsOrigin = OriginCaller; - type WeightInfo = (); -} - -// this config is totally incorrect - the pallet is not actually used at this runtime. We need -// it only to be able to run benchmarks and make required traits (and default weights for tests). -parameter_types! { - pub BridgeTable: Vec - = vec![ - NetworkExportTableItem::new( - xcm_config::RialtoNetwork::get(), - None, - xcm_config::TokenLocation::get(), - Some((xcm_config::TokenAssetId::get(), 1_000_000_000_u128).into()) - ) - ]; -} -impl pallet_xcm_bridge_hub_router::Config for Runtime { - type WeightInfo = (); - - type UniversalLocation = xcm_config::UniversalLocation; - type BridgedNetworkId = xcm_config::RialtoNetwork; - type Bridges = NetworkExportTable; - - type BridgeHubOrigin = frame_system::EnsureRoot; - type ToBridgeHubSender = xcm_config::XcmRouter; - type WithBridgeHubChannel = xcm_config::EmulatedSiblingXcmpChannel; - - type ByteFee = ConstU128<1_000>; - type FeeAsset = xcm_config::TokenAssetId; -} - -construct_runtime!( - pub enum Runtime { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - Sudo: pallet_sudo::{Pallet, Call, Config, Storage, Event}, - Utility: pallet_utility, - - // Must be before session. - Aura: pallet_aura::{Pallet, Config}, - - Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, - - // Consensus support. - Authorship: pallet_authorship::{Pallet, Storage}, - Offences: pallet_offences::{Pallet, Storage, Event}, - Historical: pallet_session::historical::{Pallet}, - - Session: pallet_session::{Pallet, Call, Storage, Event, Config}, - Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event}, - ShiftSessionManager: pallet_shift_session_manager::{Pallet}, - - // BEEFY Bridges support. - Beefy: pallet_beefy::{Pallet, Storage, Config}, - Mmr: pallet_mmr::{Pallet, Storage}, - MmrLeaf: pallet_beefy_mmr::{Pallet, Storage}, - - // Rialto bridge modules. - BridgeRelayers: pallet_bridge_relayers::{Pallet, Call, Storage, Event}, - BridgeRialtoGrandpa: pallet_bridge_grandpa::{Pallet, Call, Storage, Event}, - BridgeRialtoMessages: pallet_bridge_messages::{Pallet, Call, Storage, Event, Config}, - - // Westend bridge modules. - BridgeWestendGrandpa: pallet_bridge_grandpa::::{Pallet, Call, Config, Storage, Event}, - BridgeWestendParachains: pallet_bridge_parachains::::{Pallet, Call, Storage, Event}, - - // RialtoParachain bridge modules. - BridgeRialtoParachains: pallet_bridge_parachains::{Pallet, Call, Storage, Event}, - BridgeRialtoParachainMessages: pallet_bridge_messages::::{Pallet, Call, Storage, Event, Config}, - - // Pallet for sending XCM. - XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event, Origin, Config} = 99, - - // Pallets that are not actually used here (yet?), but we need to run benchmarks on it. - XcmBridgeHubRouter: pallet_xcm_bridge_hub_router::{Pallet, Storage} = 200, - } -); - -generate_bridge_reject_obsolete_headers_and_messages! { - RuntimeCall, AccountId, - // Grandpa - BridgeRialtoGrandpa, BridgeWestendGrandpa, - // Parachains - BridgeRialtoParachains, - //Messages - BridgeRialtoMessages, BridgeRialtoParachainMessages -} - -bp_runtime::generate_static_str_provider!(BridgeRefundRialtoPara2000Lane0Msgs); -/// Signed extension that refunds relayers that are delivering messages from the Rialto parachain. -pub type PriorityBoostPerMessage = ConstU64<324_316_715>; -pub type BridgeRefundRialtoParachainMessages = RefundSignedExtensionAdapter< - RefundBridgedParachainMessages< - Runtime, - RefundableParachain, - RefundableMessagesLane, - ActualFeeRefund, - PriorityBoostPerMessage, - StrBridgeRefundRialtoPara2000Lane0Msgs, - >, ->; - -/// The address format for describing accounts. -pub type Address = AccountId; -/// Block header type as expected by this runtime. -pub type Header = generic::Header; -/// Block type as expected by this runtime. -pub type Block = generic::Block; -/// A Block signed with a Justification -pub type SignedBlock = generic::SignedBlock; -/// BlockId type as expected by this runtime. -pub type BlockId = generic::BlockId; -/// The SignedExtension to the basic transaction logic. -pub type SignedExtra = ( - frame_system::CheckNonZeroSender, - frame_system::CheckSpecVersion, - frame_system::CheckTxVersion, - frame_system::CheckGenesis, - frame_system::CheckEra, - frame_system::CheckNonce, - frame_system::CheckWeight, - pallet_transaction_payment::ChargeTransactionPayment, - BridgeRejectObsoleteHeadersAndMessages, - BridgeRefundRialtoParachainMessages, -); -/// The payload being signed in transactions. -pub type SignedPayload = generic::SignedPayload; -/// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = - generic::UncheckedExtrinsic; -/// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; -/// Executive: handles dispatch to the various modules. -pub type Executive = frame_executive::Executive< - Runtime, - Block, - frame_system::ChainContext, - Runtime, - AllPalletsWithSystem, ->; - -#[cfg(feature = "runtime-benchmarks")] -mod benches { - frame_benchmarking::define_benchmarks!( - [pallet_bridge_messages, MessagesBench::] - [pallet_bridge_messages, MessagesBench::] - [pallet_bridge_grandpa, BridgeRialtoGrandpa] - [pallet_bridge_parachains, ParachainsBench::] - [pallet_bridge_relayers, RelayersBench::] - [pallet_xcm_bridge_hub_router, XcmBridgeHubRouterBench::] - ); -} - -impl_runtime_apis! { - impl sp_api::Core for Runtime { - fn version() -> RuntimeVersion { - VERSION - } - - fn execute_block(block: Block) { - Executive::execute_block(block); - } - - fn initialize_block(header: &::Header) { - Executive::initialize_block(header) - } - } - - impl sp_api::Metadata for Runtime { - fn metadata() -> OpaqueMetadata { - OpaqueMetadata::new(Runtime::metadata().into()) - } - - fn metadata_at_version(version: u32) -> Option { - Runtime::metadata_at_version(version) - } - - fn metadata_versions() -> sp_std::vec::Vec { - Runtime::metadata_versions() - } - } - - impl sp_block_builder::BlockBuilder for Runtime { - fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { - Executive::apply_extrinsic(extrinsic) - } - - fn finalize_block() -> ::Header { - Executive::finalize_block() - } - - fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { - data.create_extrinsics() - } - - fn check_inherents( - block: Block, - data: sp_inherents::InherentData, - ) -> sp_inherents::CheckInherentsResult { - data.check_extrinsics(&block) - } - } - - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Nonce { - System::account_nonce(account) - } - } - - impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { - fn validate_transaction( - source: TransactionSource, - tx: ::Extrinsic, - block_hash: ::Hash, - ) -> TransactionValidity { - Executive::validate_transaction(source, tx, block_hash) - } - } - - impl sp_offchain::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { - Executive::offchain_worker(header) - } - } - - impl sp_consensus_aura::AuraApi for Runtime { - fn slot_duration() -> sp_consensus_aura::SlotDuration { - sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration()) - } - - fn authorities() -> Vec { - Aura::authorities().to_vec() - } - } - - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi< - Block, - Balance, - > for Runtime { - fn query_info(uxt: ::Extrinsic, len: u32) -> RuntimeDispatchInfo { - TransactionPayment::query_info(uxt, len) - } - fn query_fee_details(uxt: ::Extrinsic, len: u32) -> FeeDetails { - TransactionPayment::query_fee_details(uxt, len) - } - fn query_weight_to_fee(weight: Weight) -> Balance { - TransactionPayment::weight_to_fee(weight) - } - fn query_length_to_fee(length: u32) -> Balance { - TransactionPayment::length_to_fee(length) - } - } - - impl sp_session::SessionKeys for Runtime { - fn generate_session_keys(seed: Option>) -> Vec { - SessionKeys::generate(seed) - } - - fn decode_session_keys( - encoded: Vec, - ) -> Option, sp_core::crypto::KeyTypeId)>> { - SessionKeys::decode_into_raw_public_keys(&encoded) - } - } - - impl sp_consensus_beefy::BeefyApi for Runtime { - fn beefy_genesis() -> Option { - Beefy::genesis_block() - } - - fn validator_set() -> Option> { - Beefy::validator_set() - } - - fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: sp_consensus_beefy::EquivocationProof< - NumberFor, - sp_consensus_beefy::ecdsa_crypto::AuthorityId, - sp_consensus_beefy::ecdsa_crypto::Signature - >, - _key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, - ) -> Option<()> { None } - - fn generate_key_ownership_proof( - _set_id: sp_consensus_beefy::ValidatorSetId, - _authority_id: sp_consensus_beefy::ecdsa_crypto::AuthorityId, - ) -> Option { None } - } - - impl pallet_mmr::primitives::MmrApi< - Block, - mmr::Hash, - BlockNumber, - > for Runtime { - fn mmr_root() -> Result { - Ok(Mmr::mmr_root()) - } - - fn mmr_leaf_count() -> Result { - Ok(Mmr::mmr_leaves()) - } - - fn generate_proof( - block_numbers: Vec, - best_known_block_number: Option, - ) -> Result<(Vec, mmr::Proof), mmr::Error> { - Mmr::generate_proof(block_numbers, best_known_block_number).map( - |(leaves, proof)| { - ( - leaves - .into_iter() - .map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf)) - .collect(), - proof, - ) - }, - ) - } - - fn verify_proof(leaves: Vec, proof: mmr::Proof) - -> Result<(), mmr::Error> - { - let leaves = leaves.into_iter().map(|leaf| - leaf.into_opaque_leaf() - .try_decode() - .ok_or(mmr::Error::Verify)).collect::, mmr::Error>>()?; - Mmr::verify_leaves(leaves, proof) - } - - fn verify_proof_stateless( - root: mmr::Hash, - leaves: Vec, - proof: mmr::Proof - ) -> Result<(), mmr::Error> { - let nodes = leaves.into_iter().map(|leaf|mmr::DataOrHash::Data(leaf.into_opaque_leaf())).collect(); - pallet_mmr::verify_leaves_proof::(root, nodes, proof) - } - } - - impl fg_primitives::GrandpaApi for Runtime { - fn current_set_id() -> fg_primitives::SetId { - Grandpa::current_set_id() - } - - fn grandpa_authorities() -> GrandpaAuthorityList { - Grandpa::grandpa_authorities() - } - - fn submit_report_equivocation_unsigned_extrinsic( - equivocation_proof: fg_primitives::EquivocationProof< - ::Hash, - NumberFor, - >, - key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof, - ) -> Option<()> { - let key_owner_proof = key_owner_proof.decode()?; - - Grandpa::submit_unsigned_equivocation_report( - equivocation_proof, - key_owner_proof, - ) - } - - fn generate_key_ownership_proof( - _set_id: fg_primitives::SetId, - _authority_id: GrandpaId, - ) -> Option { - // NOTE: this is the only implementation possible since we've - // defined our key owner proof type as a bottom type (i.e. a type - // with no values). - None - } - } - - impl bp_rialto::RialtoFinalityApi for Runtime { - fn best_finalized() -> Option> { - BridgeRialtoGrandpa::best_finalized() - } - - fn synced_headers_grandpa_info( - ) -> Vec> { - BridgeRialtoGrandpa::synced_headers_grandpa_info() - } - } - - impl bp_westend::WestendFinalityApi for Runtime { - fn best_finalized() -> Option> { - BridgeWestendGrandpa::best_finalized() - } - - fn synced_headers_grandpa_info( - ) -> Vec> { - BridgeWestendGrandpa::synced_headers_grandpa_info() - } - } - - impl bp_bridged_chain::AssetHubWestendFinalityApi for Runtime { - fn best_finalized() -> Option> { - pallet_bridge_parachains::Pallet::< - Runtime, - WithWestendParachainsInstance, - >::best_parachain_head_id::().unwrap_or(None) - } - } - - impl bp_rialto_parachain::RialtoParachainFinalityApi for Runtime { - fn best_finalized() -> Option> { - pallet_bridge_parachains::Pallet::< - Runtime, - WithRialtoParachainsInstance, - >::best_parachain_head_id::().unwrap_or(None) - } - } - - impl bp_rialto::ToRialtoOutboundLaneApi for Runtime { - fn message_details( - lane: bp_messages::LaneId, - begin: bp_messages::MessageNonce, - end: bp_messages::MessageNonce, - ) -> Vec { - bridge_runtime_common::messages_api::outbound_message_details::< - Runtime, - WithRialtoMessagesInstance, - >(lane, begin, end) - } - } - - impl bp_rialto::FromRialtoInboundLaneApi for Runtime { - fn message_details( - lane: bp_messages::LaneId, - messages: Vec<(bp_messages::MessagePayload, bp_messages::OutboundMessageDetails)>, - ) -> Vec { - bridge_runtime_common::messages_api::inbound_message_details::< - Runtime, - WithRialtoMessagesInstance, - >(lane, messages) - } - } - - impl bp_rialto_parachain::ToRialtoParachainOutboundLaneApi for Runtime { - fn message_details( - lane: bp_messages::LaneId, - begin: bp_messages::MessageNonce, - end: bp_messages::MessageNonce, - ) -> Vec { - bridge_runtime_common::messages_api::outbound_message_details::< - Runtime, - WithRialtoParachainMessagesInstance, - >(lane, begin, end) - } - } - - impl bp_rialto_parachain::FromRialtoParachainInboundLaneApi for Runtime { - fn message_details( - lane: bp_messages::LaneId, - messages: Vec<(bp_messages::MessagePayload, bp_messages::OutboundMessageDetails)>, - ) -> Vec { - bridge_runtime_common::messages_api::inbound_message_details::< - Runtime, - WithRialtoParachainMessagesInstance, - >(lane, messages) - } - } - - #[cfg(feature = "runtime-benchmarks")] - impl frame_benchmarking::Benchmark for Runtime { - fn benchmark_metadata(extra: bool) -> ( - Vec, - Vec, - ) { - use frame_benchmarking::{Benchmarking, BenchmarkList}; - use frame_support::traits::StorageInfoTrait; - - use pallet_bridge_messages::benchmarking::Pallet as MessagesBench; - use pallet_bridge_parachains::benchmarking::Pallet as ParachainsBench; - use pallet_bridge_relayers::benchmarking::Pallet as RelayersBench; - use pallet_xcm_bridge_hub_router::benchmarking::Pallet as XcmBridgeHubRouterBench; - - let mut list = Vec::::new(); - list_benchmarks!(list, extra); - - let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) - } - - fn dispatch_benchmark( - config: frame_benchmarking::BenchmarkConfig, - ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{Benchmarking, BenchmarkBatch}; - use frame_support::traits::TrackedStorageKey; - - let whitelist: Vec = vec![ - // Block Number - hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), - // Execution Phase - hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(), - // Event Count - hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(), - // System Events - hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(), - // Caller 0 Account - hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da946c154ffd9992e395af90b5b13cc6f295c77033fce8a9045824a6690bbf99c6db269502f0a8d1d2a008542d5690a0749").to_vec().into(), - ]; - - use bridge_runtime_common::messages_benchmarking::{ - generate_xcm_builder_bridge_message_sample, - prepare_message_delivery_proof_from_grandpa_chain, - prepare_message_delivery_proof_from_parachain, - prepare_message_proof_from_grandpa_chain, - prepare_message_proof_from_parachain, - }; - use pallet_bridge_messages::benchmarking::{ - Pallet as MessagesBench, - Config as MessagesConfig, - MessageDeliveryProofParams, - MessageProofParams, - }; - use pallet_bridge_parachains::benchmarking::{ - Pallet as ParachainsBench, - Config as ParachainsConfig, - }; - use pallet_bridge_relayers::benchmarking::{ - Pallet as RelayersBench, - Config as RelayersConfig, - }; - use pallet_xcm_bridge_hub_router::benchmarking::{ - Pallet as XcmBridgeHubRouterBench, - Config as XcmBridgeHubRouterConfig, - }; - use rialto_messages::WithRialtoMessageBridge; - use rialto_parachain_messages::WithRialtoParachainMessageBridge; - - impl MessagesConfig for Runtime { - fn prepare_message_proof( - params: MessageProofParams, - ) -> (rialto_messages::FromRialtoMessagesProof, Weight) { - prepare_message_proof_from_parachain::< - Runtime, - WithRialtoParachainsInstance, - WithRialtoParachainMessageBridge, - >(params, generate_xcm_builder_bridge_message_sample(xcm::v3::Junctions::Here)) - } - - fn prepare_message_delivery_proof( - params: MessageDeliveryProofParams, - ) -> rialto_messages::ToRialtoMessagesDeliveryProof { - prepare_message_delivery_proof_from_parachain::< - Runtime, - WithRialtoParachainsInstance, - WithRialtoParachainMessageBridge, - >(params) - } - - fn is_relayer_rewarded(relayer: &Self::AccountId) -> bool { - let lane = >::bench_lane_id(); - let bridged_chain_id = bp_runtime::RIALTO_PARACHAIN_CHAIN_ID; - pallet_bridge_relayers::Pallet::::relayer_reward( - relayer, - RewardsAccountParams::new(lane, bridged_chain_id, RewardsAccountOwner::BridgedChain) - ).is_some() - } - } - - impl MessagesConfig for Runtime { - fn prepare_message_proof( - params: MessageProofParams, - ) -> (rialto_messages::FromRialtoMessagesProof, Weight) { - prepare_message_proof_from_grandpa_chain::< - Runtime, - RialtoGrandpaInstance, - WithRialtoMessageBridge, - >(params, generate_xcm_builder_bridge_message_sample(xcm::v3::Junctions::Here)) - } - - fn prepare_message_delivery_proof( - params: MessageDeliveryProofParams, - ) -> rialto_messages::ToRialtoMessagesDeliveryProof { - prepare_message_delivery_proof_from_grandpa_chain::< - Runtime, - RialtoGrandpaInstance, - WithRialtoMessageBridge, - >(params) - } - - fn is_relayer_rewarded(relayer: &Self::AccountId) -> bool { - let lane = >::bench_lane_id(); - let bridged_chain_id = bp_runtime::RIALTO_CHAIN_ID; - pallet_bridge_relayers::Pallet::::relayer_reward( - relayer, - RewardsAccountParams::new(lane, bridged_chain_id, RewardsAccountOwner::BridgedChain) - ).is_some() - } - } - - impl ParachainsConfig for Runtime { - fn parachains() -> Vec { - use bp_runtime::Parachain; - vec![bp_polkadot_core::parachains::ParaId(bp_rialto_parachain::RialtoParachain::PARACHAIN_ID)] - } - - fn prepare_parachain_heads_proof( - parachains: &[bp_polkadot_core::parachains::ParaId], - parachain_head_size: u32, - proof_size: bp_runtime::StorageProofSize, - ) -> ( - pallet_bridge_parachains::RelayBlockNumber, - pallet_bridge_parachains::RelayBlockHash, - bp_polkadot_core::parachains::ParaHeadsProof, - Vec<(bp_polkadot_core::parachains::ParaId, bp_polkadot_core::parachains::ParaHash)>, - ) { - bridge_runtime_common::parachains_benchmarking::prepare_parachain_heads_proof::< - Runtime, - WithRialtoParachainsInstance, - >( - parachains, - parachain_head_size, - proof_size, - ) - } - } - - impl RelayersConfig for Runtime { - fn prepare_rewards_account( - account_params: RewardsAccountParams, - reward: Balance, - ) { - let rewards_account = bp_relayers::PayRewardFromAccount::< - Balances, - AccountId - >::rewards_account(account_params); - Self::deposit_account(rewards_account, reward); - } - - fn deposit_account(account: AccountId, balance: Balance) { - use frame_support::traits::fungible::Mutate; - Balances::mint_into(&account, balance.saturating_add(ExistentialDeposit::get())).unwrap(); - } - } - - impl XcmBridgeHubRouterConfig<()> for Runtime { - fn make_congested() { - xcm_config::EmulatedSiblingXcmpChannel::make_congested() - } - } - - let mut batches = Vec::::new(); - let params = (&config, &whitelist); - - add_benchmarks!(params, batches); - - Ok(batches) - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn call_size() { - const BRIDGES_PALLETS_MAX_CALL_SIZE: usize = 200; - assert!( - core::mem::size_of::>() <= - BRIDGES_PALLETS_MAX_CALL_SIZE - ); - assert!( - core::mem::size_of::>() <= - BRIDGES_PALLETS_MAX_CALL_SIZE - ); - const MAX_CALL_SIZE: usize = 230; // value from polkadot-runtime tests - assert!(core::mem::size_of::() <= MAX_CALL_SIZE); - } -} - -/// TODO: Note: I know this does not belong here, but I don't want to add it to the -/// `chain-asset-hub-westend` or `chain-westend`, because we wont use it for production and I don't -/// want to bring this to the bridges subtree now. Anyway, we plan to retire millau/rialto, so this -/// hack will disappear with that. -pub mod bp_bridged_chain { - use bp_messages::Weight; - pub use bp_polkadot_core::{ - AccountId, AccountInfoStorageMapKeyProvider, AccountPublic, Balance, BlockNumber, Hash, - Hasher, Hashing, Header, Nonce, Perbill, Signature, SignedBlock, UncheckedExtrinsic, - EXTRA_STORAGE_PROOF_SIZE, TX_EXTRA_BYTES, - }; - use bp_runtime::{decl_bridge_finality_runtime_apis, Chain, Parachain}; - - /// `AssetHubWestend` parachain definition - #[derive(Debug, Clone, Copy)] - pub struct AssetHubWestend; - - // AssetHubWestend seems to use the same configuration as all Polkadot-like chains, so we'll use - // Westend primitives here. - impl Chain for AssetHubWestend { - type BlockNumber = BlockNumber; - type Hash = Hash; - type Hasher = Hasher; - type Header = Header; - - type AccountId = AccountId; - type Balance = Balance; - type Nonce = Nonce; - type Signature = Signature; - - fn max_extrinsic_size() -> u32 { - bp_westend::Westend::max_extrinsic_size() - } - - fn max_extrinsic_weight() -> Weight { - bp_westend::Westend::max_extrinsic_weight() - } - } - - impl Parachain for AssetHubWestend { - const PARACHAIN_ID: u32 = 1000; - } - - decl_bridge_finality_runtime_apis!(AssetHubWestend); -} diff --git a/bridges/bin/millau/runtime/src/rialto_messages.rs b/bridges/bin/millau/runtime/src/rialto_messages.rs deleted file mode 100644 index 8b778600f9723..0000000000000 --- a/bridges/bin/millau/runtime/src/rialto_messages.rs +++ /dev/null @@ -1,216 +0,0 @@ -// 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 . - -//! Everything required to serve Millau <-> Rialto messages. - -use crate::{RialtoGrandpaInstance, Runtime, RuntimeOrigin, WithRialtoMessagesInstance}; - -use bp_messages::LaneId; -use bridge_runtime_common::{ - messages::{ - self, source::TargetHeaderChainAdapter, target::SourceHeaderChainAdapter, MessageBridge, - }, - messages_xcm_extension::{SenderAndLane, XcmBlobHauler, XcmBlobHaulerAdapter}, -}; -use frame_support::{parameter_types, weights::Weight}; -use pallet_bridge_relayers::WeightInfoExt as _; -use sp_runtime::RuntimeDebug; -use xcm::latest::prelude::*; -use xcm_builder::HaulBlobExporter; - -/// Default lane that is used to send messages to Rialto. -pub const XCM_LANE: LaneId = LaneId([0, 0, 0, 0]); -/// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge -/// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual -/// tests, confirming that we don't break encoding somewhere between. -pub const BASE_XCM_WEIGHT_TWICE: Weight = crate::xcm_config::BaseXcmWeight::get().saturating_mul(2); - -parameter_types! { - /// Weight credit for our test messages. - /// - /// 2 XCM instructions is for simple `Trap(42)` program, coming through bridge - /// (it is prepended with `UniversalOrigin` instruction). - pub const WeightCredit: Weight = BASE_XCM_WEIGHT_TWICE; - /// Lane used by the with-Rialto bridge. - pub RialtoSenderAndLane: SenderAndLane = SenderAndLane::new(Here.into(), XCM_LANE); - - /// Dummy message used in configuration. - pub DummyXcmMessage: Xcm<()> = Xcm::new(); -} - -/// Message payload for Millau -> Rialto messages. -pub type ToRialtoMessagePayload = messages::source::FromThisChainMessagePayload; - -/// Message verifier for Millau -> Rialto messages. -pub type ToRialtoMessageVerifier = - messages::source::FromThisChainMessageVerifier; - -/// Message payload for Rialto -> Millau messages. -pub type FromRialtoMessagePayload = messages::target::FromBridgedChainMessagePayload; - -/// Messages proof for Rialto -> Millau messages. -pub type FromRialtoMessagesProof = messages::target::FromBridgedChainMessagesProof; - -/// Messages delivery proof for Millau -> Rialto messages. -pub type ToRialtoMessagesDeliveryProof = - messages::source::FromBridgedChainMessagesDeliveryProof; - -/// Call-dispatch based message dispatch for Rialto -> Millau messages. -pub type FromRialtoMessageDispatch = - bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatch< - crate::xcm_config::OnMillauBlobDispatcher, - (), - (), - >; - -/// Maximal outbound payload size of Millau -> Rialto messages. -pub type ToRialtoMaximalOutboundPayloadSize = - messages::source::FromThisChainMaximalOutboundPayloadSize; - -/// Millau <-> Rialto message bridge. -#[derive(RuntimeDebug, Clone, Copy)] -pub struct WithRialtoMessageBridge; - -impl MessageBridge for WithRialtoMessageBridge { - const BRIDGED_MESSAGES_PALLET_NAME: &'static str = bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME; - - type ThisChain = Millau; - type BridgedChain = Rialto; - type BridgedHeaderChain = - pallet_bridge_grandpa::GrandpaChainHeaders; -} - -/// Millau chain from message lane point of view. -#[derive(RuntimeDebug, Clone, Copy)] -pub struct Millau; - -impl messages::UnderlyingChainProvider for Millau { - type Chain = bp_millau::Millau; -} - -impl messages::ThisChainWithMessages for Millau { - type RuntimeOrigin = RuntimeOrigin; -} - -/// Rialto chain from message lane point of view. -#[derive(RuntimeDebug, Clone, Copy)] -pub struct Rialto; -/// Rialto as source header chain. -pub type RialtoAsSourceHeaderChain = SourceHeaderChainAdapter; -/// Rialto as target header chain. -pub type RialtoAsTargetHeaderChain = TargetHeaderChainAdapter; - -impl messages::UnderlyingChainProvider for Rialto { - type Chain = bp_rialto::Rialto; -} - -impl messages::BridgedChainWithMessages for Rialto {} - -/// Export XCM messages to be relayed to Rialto. -pub type ToRialtoBlobExporter = HaulBlobExporter< - XcmBlobHaulerAdapter, - crate::xcm_config::RialtoNetwork, - (), ->; - -/// To-Rialto XCM hauler. -pub struct ToRialtoXcmBlobHauler; - -impl XcmBlobHauler for ToRialtoXcmBlobHauler { - type Runtime = Runtime; - type MessagesInstance = WithRialtoMessagesInstance; - type SenderAndLane = RialtoSenderAndLane; - - type ToSourceChainSender = crate::xcm_config::XcmRouter; - type CongestedMessage = DummyXcmMessage; - type UncongestedMessage = DummyXcmMessage; -} - -impl pallet_bridge_messages::WeightInfoExt for crate::weights::RialtoMessagesWeightInfo { - fn expected_extra_storage_proof_size() -> u32 { - bp_rialto::EXTRA_STORAGE_PROOF_SIZE - } - - fn receive_messages_proof_overhead_from_runtime() -> Weight { - pallet_bridge_relayers::weights::BridgeWeight::::receive_messages_proof_overhead_from_runtime() - } - - fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight { - pallet_bridge_relayers::weights::BridgeWeight::::receive_messages_delivery_proof_overhead_from_runtime() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::{Runtime, WithRialtoMessagesInstance}; - - use bridge_runtime_common::{ - assert_complete_bridge_types, - integrity::{ - assert_complete_bridge_constants, check_message_lane_weights, - AssertBridgeMessagesPalletConstants, AssertBridgePalletNames, AssertChainConstants, - AssertCompleteBridgeConstants, - }, - }; - - #[test] - fn ensure_millau_message_lane_weights_are_correct() { - check_message_lane_weights::( - bp_rialto::EXTRA_STORAGE_PROOF_SIZE, - bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, - bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, - false, - ); - } - - #[test] - fn ensure_bridge_integrity() { - assert_complete_bridge_types!( - runtime: Runtime, - with_bridged_chain_grandpa_instance: RialtoGrandpaInstance, - with_bridged_chain_messages_instance: WithRialtoMessagesInstance, - bridge: WithRialtoMessageBridge, - this_chain: bp_millau::Millau, - bridged_chain: bp_rialto::Rialto, - ); - - assert_complete_bridge_constants::< - Runtime, - RialtoGrandpaInstance, - WithRialtoMessagesInstance, - WithRialtoMessageBridge, - >(AssertCompleteBridgeConstants { - this_chain_constants: AssertChainConstants { - block_length: bp_millau::BlockLength::get(), - block_weights: bp_millau::BlockWeights::get(), - }, - messages_pallet_constants: AssertBridgeMessagesPalletConstants { - max_unrewarded_relayers_in_bridged_confirmation_tx: - bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, - max_unconfirmed_messages_in_bridged_confirmation_tx: - bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, - bridged_chain_id: bp_runtime::RIALTO_CHAIN_ID, - }, - pallet_names: AssertBridgePalletNames { - with_this_chain_messages_pallet_name: bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME, - with_bridged_chain_grandpa_pallet_name: bp_rialto::WITH_RIALTO_GRANDPA_PALLET_NAME, - with_bridged_chain_messages_pallet_name: - bp_rialto::WITH_RIALTO_MESSAGES_PALLET_NAME, - }, - }); - } -} diff --git a/bridges/bin/millau/runtime/src/rialto_parachain_messages.rs b/bridges/bin/millau/runtime/src/rialto_parachain_messages.rs deleted file mode 100644 index 1c4807f0cd332..0000000000000 --- a/bridges/bin/millau/runtime/src/rialto_parachain_messages.rs +++ /dev/null @@ -1,227 +0,0 @@ -// 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 . - -//! Everything required to serve Millau <-> RialtoParachain messages. - -use crate::{ - Runtime, RuntimeOrigin, WithRialtoParachainMessagesInstance, WithRialtoParachainsInstance, -}; - -use bp_messages::LaneId; -use bridge_runtime_common::{ - messages::{ - self, source::TargetHeaderChainAdapter, target::SourceHeaderChainAdapter, MessageBridge, - }, - messages_xcm_extension::{SenderAndLane, XcmBlobHauler, XcmBlobHaulerAdapter}, -}; -use frame_support::{parameter_types, weights::Weight}; -use pallet_bridge_relayers::WeightInfoExt as _; -use sp_runtime::RuntimeDebug; -use xcm::latest::prelude::*; -use xcm_builder::HaulBlobExporter; - -/// Default lane that is used to send messages to Rialto parachain. -pub const XCM_LANE: LaneId = LaneId([0, 0, 0, 0]); -/// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge -/// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual -/// tests, confirming that we don't break encoding somewhere between. -pub const BASE_XCM_WEIGHT_TWICE: Weight = crate::xcm_config::BaseXcmWeight::get().saturating_mul(2); - -parameter_types! { - /// Weight credit for our test messages. - /// - /// 2 XCM instructions is for simple `Trap(42)` program, coming through bridge - /// (it is prepended with `UniversalOrigin` instruction). - pub const WeightCredit: Weight = BASE_XCM_WEIGHT_TWICE; - /// Lane used by the with-RialtoParachain bridge. - pub RialtoParachainSenderAndLane: SenderAndLane = SenderAndLane::new(Here.into(), XCM_LANE); - - /// Dummy message used in configuration. - pub DummyXcmMessage: Xcm<()> = Xcm::new(); -} - -/// Message payload for Millau -> RialtoParachain messages. -pub type ToRialtoParachainMessagePayload = messages::source::FromThisChainMessagePayload; - -/// Message verifier for Millau -> RialtoParachain messages. -pub type ToRialtoParachainMessageVerifier = - messages::source::FromThisChainMessageVerifier; - -/// Message payload for RialtoParachain -> Millau messages. -pub type FromRialtoParachainMessagePayload = messages::target::FromBridgedChainMessagePayload; - -/// Call-dispatch based message dispatch for RialtoParachain -> Millau messages. -pub type FromRialtoParachainMessageDispatch = - bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatch< - crate::xcm_config::OnMillauBlobDispatcher, - (), - (), - >; - -/// Maximal outbound payload size of Millau -> RialtoParachain messages. -pub type ToRialtoParachainMaximalOutboundPayloadSize = - messages::source::FromThisChainMaximalOutboundPayloadSize; - -/// Millau <-> RialtoParachain message bridge. -#[derive(RuntimeDebug, Clone, Copy)] -pub struct WithRialtoParachainMessageBridge; - -impl MessageBridge for WithRialtoParachainMessageBridge { - const BRIDGED_MESSAGES_PALLET_NAME: &'static str = bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME; - - type ThisChain = Millau; - type BridgedChain = RialtoParachain; - type BridgedHeaderChain = pallet_bridge_parachains::ParachainHeaders< - Runtime, - WithRialtoParachainsInstance, - bp_rialto_parachain::RialtoParachain, - >; -} - -/// Millau chain from message lane point of view. -#[derive(RuntimeDebug, Clone, Copy)] -pub struct Millau; - -impl messages::UnderlyingChainProvider for Millau { - type Chain = bp_millau::Millau; -} - -impl messages::ThisChainWithMessages for Millau { - type RuntimeOrigin = RuntimeOrigin; -} - -/// RialtoParachain chain from message lane point of view. -#[derive(RuntimeDebug, Clone, Copy)] -pub struct RialtoParachain; -/// RialtoParachain as source header chain. -pub type RialtoParachainAsSourceHeaderChain = - SourceHeaderChainAdapter; -/// RialtoParachain as target header chain. -pub type RialtoParachainAsTargetHeaderChain = - TargetHeaderChainAdapter; - -impl messages::UnderlyingChainProvider for RialtoParachain { - type Chain = bp_rialto_parachain::RialtoParachain; -} - -impl messages::BridgedChainWithMessages for RialtoParachain {} - -/// Export XCM messages to be relayed to Rialto. -pub type ToRialtoParachainBlobExporter = HaulBlobExporter< - XcmBlobHaulerAdapter, - crate::xcm_config::RialtoParachainNetwork, - (), ->; - -/// To-RialtoParachain XCM hauler. -pub struct ToRialtoParachainXcmBlobHauler; - -impl XcmBlobHauler for ToRialtoParachainXcmBlobHauler { - type Runtime = Runtime; - type MessagesInstance = WithRialtoParachainMessagesInstance; - type SenderAndLane = RialtoParachainSenderAndLane; - - type ToSourceChainSender = crate::xcm_config::XcmRouter; - type CongestedMessage = DummyXcmMessage; - type UncongestedMessage = DummyXcmMessage; -} - -impl pallet_bridge_messages::WeightInfoExt - for crate::weights::RialtoParachainMessagesWeightInfo -{ - fn expected_extra_storage_proof_size() -> u32 { - bp_rialto_parachain::EXTRA_STORAGE_PROOF_SIZE - } - - fn receive_messages_proof_overhead_from_runtime() -> Weight { - pallet_bridge_relayers::weights::BridgeWeight::::receive_messages_proof_overhead_from_runtime() - } - - fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight { - pallet_bridge_relayers::weights::BridgeWeight::::receive_messages_delivery_proof_overhead_from_runtime() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::{ - PriorityBoostPerMessage, RialtoGrandpaInstance, Runtime, - WithRialtoParachainMessagesInstance, - }; - - use bridge_runtime_common::{ - assert_complete_bridge_types, - integrity::{ - assert_complete_bridge_constants, check_message_lane_weights, - AssertBridgeMessagesPalletConstants, AssertBridgePalletNames, AssertChainConstants, - AssertCompleteBridgeConstants, - }, - }; - - #[test] - fn ensure_millau_message_lane_weights_are_correct() { - check_message_lane_weights::( - bp_rialto_parachain::EXTRA_STORAGE_PROOF_SIZE, - bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, - bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, - true, - ); - } - - #[test] - fn ensure_bridge_integrity() { - assert_complete_bridge_types!( - runtime: Runtime, - with_bridged_chain_grandpa_instance: RialtoGrandpaInstance, - with_bridged_chain_messages_instance: WithRialtoParachainMessagesInstance, - bridge: WithRialtoParachainMessageBridge, - this_chain: bp_millau::Millau, - bridged_chain: bp_rialto::Rialto, - ); - - assert_complete_bridge_constants::< - Runtime, - RialtoGrandpaInstance, - WithRialtoParachainMessagesInstance, - WithRialtoParachainMessageBridge, - >(AssertCompleteBridgeConstants { - this_chain_constants: AssertChainConstants { - block_length: bp_millau::BlockLength::get(), - block_weights: bp_millau::BlockWeights::get(), - }, - messages_pallet_constants: AssertBridgeMessagesPalletConstants { - max_unrewarded_relayers_in_bridged_confirmation_tx: - bp_rialto_parachain::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, - max_unconfirmed_messages_in_bridged_confirmation_tx: - bp_rialto_parachain::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, - bridged_chain_id: bp_runtime::RIALTO_PARACHAIN_CHAIN_ID, - }, - pallet_names: AssertBridgePalletNames { - with_this_chain_messages_pallet_name: bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME, - with_bridged_chain_grandpa_pallet_name: bp_rialto::WITH_RIALTO_GRANDPA_PALLET_NAME, - with_bridged_chain_messages_pallet_name: - bp_rialto_parachain::WITH_RIALTO_PARACHAIN_MESSAGES_PALLET_NAME, - }, - }); - - bridge_runtime_common::priority_calculator::ensure_priority_boost_is_sane::< - Runtime, - WithRialtoParachainMessagesInstance, - PriorityBoostPerMessage, - >(1_000_000); - } -} diff --git a/bridges/bin/millau/runtime/src/weights/mod.rs b/bridges/bin/millau/runtime/src/weights/mod.rs deleted file mode 100644 index 801ff9b3c8f68..0000000000000 --- a/bridges/bin/millau/runtime/src/weights/mod.rs +++ /dev/null @@ -1,21 +0,0 @@ -// 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 . - -mod pallet_bridge_messages_messages_bench_runtime_with_rialto_messages_instance; -mod pallet_bridge_messages_messages_bench_runtime_with_rialto_parachain_messages_instance; - -pub use pallet_bridge_messages_messages_bench_runtime_with_rialto_messages_instance::WeightInfo as RialtoMessagesWeightInfo; -pub use pallet_bridge_messages_messages_bench_runtime_with_rialto_parachain_messages_instance::WeightInfo as RialtoParachainMessagesWeightInfo; diff --git a/bridges/bin/millau/runtime/src/weights/pallet_bridge_messages_messages_bench_runtime_with_rialto_messages_instance.rs b/bridges/bin/millau/runtime/src/weights/pallet_bridge_messages_messages_bench_runtime_with_rialto_messages_instance.rs deleted file mode 100644 index b58402d275638..0000000000000 --- a/bridges/bin/millau/runtime/src/weights/pallet_bridge_messages_messages_bench_runtime_with_rialto_messages_instance.rs +++ /dev/null @@ -1,188 +0,0 @@ - -//! Autogenerated weights for `pallet_bridge_messages` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `covid`, CPU: `11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 - -// Executed Command: -// target/release/millau-bridge-node -// benchmark -// pallet -// --chain=dev -// --steps=50 -// --repeat=20 -// --pallet=pallet_bridge_messages -// --extrinsic=* -// --execution=wasm -// --wasm-execution=Compiled -// --heap-pages=4096 -// --output=./bin/millau/runtime/src/weights/ - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; - -/// Weight functions for `pallet_bridge_messages`. -pub struct WeightInfo(PhantomData); -impl pallet_bridge_messages::WeightInfo for WeightInfo { - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) - fn receive_single_message_proof() -> Weight { - // Proof Size summary in bytes: - // Measured: `490` - // Estimated: `57170` - // Minimum execution time: 51_189_000 picoseconds. - Weight::from_parts(52_881_000, 0) - .saturating_add(Weight::from_parts(0, 57170)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) - fn receive_two_messages_proof() -> Weight { - // Proof Size summary in bytes: - // Measured: `490` - // Estimated: `57170` - // Minimum execution time: 65_083_000 picoseconds. - Weight::from_parts(66_878_000, 0) - .saturating_add(Weight::from_parts(0, 57170)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) - fn receive_single_message_proof_with_outbound_lane_state() -> Weight { - // Proof Size summary in bytes: - // Measured: `490` - // Estimated: `57170` - // Minimum execution time: 57_919_000 picoseconds. - Weight::from_parts(58_927_000, 0) - .saturating_add(Weight::from_parts(0, 57170)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) - fn receive_single_message_proof_1_kb() -> Weight { - // Proof Size summary in bytes: - // Measured: `490` - // Estimated: `57170` - // Minimum execution time: 52_202_000 picoseconds. - Weight::from_parts(53_617_000, 0) - .saturating_add(Weight::from_parts(0, 57170)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) - fn receive_single_message_proof_16_kb() -> Weight { - // Proof Size summary in bytes: - // Measured: `490` - // Estimated: `57170` - // Minimum execution time: 74_726_000 picoseconds. - Weight::from_parts(76_379_000, 0) - .saturating_add(Weight::from_parts(0, 57170)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) - /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) - /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) - /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) - /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) - fn receive_delivery_proof_for_single_message() -> Weight { - // Proof Size summary in bytes: - // Measured: `515` - // Estimated: `9584` - // Minimum execution time: 45_156_000 picoseconds. - Weight::from_parts(46_535_000, 0) - .saturating_add(Weight::from_parts(0, 9584)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) - /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) - /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) - /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) - /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) - fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight { - // Proof Size summary in bytes: - // Measured: `532` - // Estimated: `9584` - // Minimum execution time: 44_104_000 picoseconds. - Weight::from_parts(45_602_000, 0) - .saturating_add(Weight::from_parts(0, 9584)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) - /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) - /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) - /// Storage: BridgeRelayers RelayerRewards (r:2 w:2) - /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) - fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight { - // Proof Size summary in bytes: - // Measured: `532` - // Estimated: `12124` - // Minimum execution time: 46_880_000 picoseconds. - Weight::from_parts(48_472_000, 0) - .saturating_add(Weight::from_parts(0, 12124)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), added: 2048, mode: MaxEncodedLen) - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) - /// The range of component `i` is `[128, 2048]`. - /// The range of component `i` is `[128, 2048]`. - fn receive_single_message_proof_with_dispatch(i: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `490` - // Estimated: `57170` - // Minimum execution time: 107_297_000 picoseconds. - Weight::from_parts(98_819_194, 0) - .saturating_add(Weight::from_parts(0, 57170)) - // Standard Error: 2_195 - .saturating_add(Weight::from_parts(448_268, 0).saturating_mul(i.into())) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } -} diff --git a/bridges/bin/millau/runtime/src/weights/pallet_bridge_messages_messages_bench_runtime_with_rialto_parachain_messages_instance.rs b/bridges/bin/millau/runtime/src/weights/pallet_bridge_messages_messages_bench_runtime_with_rialto_parachain_messages_instance.rs deleted file mode 100644 index c71cb11fdc717..0000000000000 --- a/bridges/bin/millau/runtime/src/weights/pallet_bridge_messages_messages_bench_runtime_with_rialto_parachain_messages_instance.rs +++ /dev/null @@ -1,188 +0,0 @@ - -//! Autogenerated weights for `pallet_bridge_messages` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `covid`, CPU: `11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 - -// Executed Command: -// target/release/millau-bridge-node -// benchmark -// pallet -// --chain=dev -// --steps=50 -// --repeat=20 -// --pallet=pallet_bridge_messages -// --extrinsic=* -// --execution=wasm -// --wasm-execution=Compiled -// --heap-pages=4096 -// --output=./bin/millau/runtime/src/weights/ - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; - -/// Weight functions for `pallet_bridge_messages`. -pub struct WeightInfo(PhantomData); -impl pallet_bridge_messages::WeightInfo for WeightInfo { - /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) - /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachainMessages InboundLanes (r:1 w:1) - /// Proof: BridgeRialtoParachainMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) - fn receive_single_message_proof() -> Weight { - // Proof Size summary in bytes: - // Measured: `428` - // Estimated: `56803` - // Minimum execution time: 49_949_000 picoseconds. - Weight::from_parts(51_439_000, 0) - .saturating_add(Weight::from_parts(0, 56803)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) - /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachainMessages InboundLanes (r:1 w:1) - /// Proof: BridgeRialtoParachainMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) - fn receive_two_messages_proof() -> Weight { - // Proof Size summary in bytes: - // Measured: `428` - // Estimated: `56803` - // Minimum execution time: 62_552_000 picoseconds. - Weight::from_parts(64_899_000, 0) - .saturating_add(Weight::from_parts(0, 56803)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) - /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachainMessages InboundLanes (r:1 w:1) - /// Proof: BridgeRialtoParachainMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) - fn receive_single_message_proof_with_outbound_lane_state() -> Weight { - // Proof Size summary in bytes: - // Measured: `428` - // Estimated: `56803` - // Minimum execution time: 56_795_000 picoseconds. - Weight::from_parts(58_441_000, 0) - .saturating_add(Weight::from_parts(0, 56803)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) - /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachainMessages InboundLanes (r:1 w:1) - /// Proof: BridgeRialtoParachainMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) - fn receive_single_message_proof_1_kb() -> Weight { - // Proof Size summary in bytes: - // Measured: `428` - // Estimated: `56803` - // Minimum execution time: 51_340_000 picoseconds. - Weight::from_parts(52_533_000, 0) - .saturating_add(Weight::from_parts(0, 56803)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) - /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachainMessages InboundLanes (r:1 w:1) - /// Proof: BridgeRialtoParachainMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) - fn receive_single_message_proof_16_kb() -> Weight { - // Proof Size summary in bytes: - // Measured: `428` - // Estimated: `56803` - // Minimum execution time: 74_022_000 picoseconds. - Weight::from_parts(75_115_000, 0) - .saturating_add(Weight::from_parts(0, 56803)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) - /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachainMessages OutboundLanes (r:1 w:1) - /// Proof: BridgeRialtoParachainMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) - /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) - /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) - fn receive_delivery_proof_for_single_message() -> Weight { - // Proof Size summary in bytes: - // Measured: `453` - // Estimated: `9217` - // Minimum execution time: 43_296_000 picoseconds. - Weight::from_parts(45_022_000, 0) - .saturating_add(Weight::from_parts(0, 9217)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) - /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachainMessages OutboundLanes (r:1 w:1) - /// Proof: BridgeRialtoParachainMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) - /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) - /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) - fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight { - // Proof Size summary in bytes: - // Measured: `470` - // Estimated: `9217` - // Minimum execution time: 42_618_000 picoseconds. - Weight::from_parts(43_972_000, 0) - .saturating_add(Weight::from_parts(0, 9217)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) - /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachainMessages OutboundLanes (r:1 w:1) - /// Proof: BridgeRialtoParachainMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) - /// Storage: BridgeRelayers RelayerRewards (r:2 w:2) - /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) - fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight { - // Proof Size summary in bytes: - // Measured: `470` - // Estimated: `11757` - // Minimum execution time: 45_954_000 picoseconds. - Weight::from_parts(46_892_000, 0) - .saturating_add(Weight::from_parts(0, 11757)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: BridgeRialtoParachainMessages PalletOperatingMode (r:1 w:0) - /// Proof: BridgeRialtoParachainMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachains ImportedParaHeads (r:1 w:0) - /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: Some(196), added: 1681, mode: MaxEncodedLen) - /// Storage: BridgeRialtoParachainMessages InboundLanes (r:1 w:1) - /// Proof: BridgeRialtoParachainMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) - /// The range of component `i` is `[128, 2048]`. - /// The range of component `i` is `[128, 2048]`. - fn receive_single_message_proof_with_dispatch(i: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `428` - // Estimated: `56803` - // Minimum execution time: 107_766_000 picoseconds. - Weight::from_parts(97_865_035, 0) - .saturating_add(Weight::from_parts(0, 56803)) - // Standard Error: 2_179 - .saturating_add(Weight::from_parts(447_749, 0).saturating_mul(i.into())) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } -} diff --git a/bridges/bin/millau/runtime/src/xcm_config.rs b/bridges/bin/millau/runtime/src/xcm_config.rs deleted file mode 100644 index 45236360ddcc1..0000000000000 --- a/bridges/bin/millau/runtime/src/xcm_config.rs +++ /dev/null @@ -1,410 +0,0 @@ -// 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 . - -//! XCM configurations for the Millau runtime. - -use super::{ - rialto_messages::ToRialtoBlobExporter, - rialto_parachain_messages::ToRialtoParachainBlobExporter, AccountId, AllPalletsWithSystem, - Balances, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, XcmPallet, -}; -use bp_millau::WeightToFee; -use bridge_runtime_common::CustomNetworkId; -use frame_support::{ - parameter_types, - traits::{ConstU32, Everything, Nothing}, - weights::Weight, -}; -use frame_system::EnsureRoot; -use xcm::latest::prelude::*; -use xcm_builder::{ - AccountId32Aliases, CurrencyAdapter as XcmCurrencyAdapter, IsConcrete, MintLocation, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, -}; -use xcm_executor::traits::ExportXcm; - -parameter_types! { - /// The location of the `MLAU` token, from the context of this chain. Since this token is native to this - /// chain, we make it synonymous with it and thus it is the `Here` location, which means "equivalent to - /// the context". - pub const TokenLocation: MultiLocation = Here.into_location(); - /// Token asset identifier. - pub TokenAssetId: AssetId = TokenLocation::get().into(); - /// The Millau network ID. - pub const ThisNetwork: NetworkId = CustomNetworkId::Millau.as_network_id(); - /// The Rialto network ID. - pub const RialtoNetwork: NetworkId = CustomNetworkId::Rialto.as_network_id(); - /// The RialtoParachain network ID. - pub const RialtoParachainNetwork: NetworkId = CustomNetworkId::RialtoParachain.as_network_id(); - - /// Our XCM location ancestry - i.e. our location within the Consensus Universe. - /// - /// Since Kusama is a top-level relay-chain with its own consensus, it's just our network ID. - pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into(); - /// The check account, which holds any native assets that have been teleported out and not back in (yet). - pub CheckAccount: (AccountId, MintLocation) = (XcmPallet::check_account(), MintLocation::Local); -} - -/// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to -/// determine the sovereign account controlled by a location. -pub type SovereignAccountOf = ( - // We can directly alias an `AccountId32` into a local account. - AccountId32Aliases, -); - -/// Our asset transactor. This is what allows us to interest with the runtime facilities from the -/// point of view of XCM-only concepts like `MultiLocation` and `MultiAsset`. -/// -/// Ours is only aware of the Balances pallet, which is mapped to `TokenLocation`. -pub type LocalAssetTransactor = XcmCurrencyAdapter< - // Use this currency: - Balances, - // Use this currency when it is a fungible asset matching the given location or name: - IsConcrete, - // We can convert the MultiLocations with our converter above: - SovereignAccountOf, - // Our chain's account ID type (we can't get away without mentioning it explicitly): - AccountId, - // We track our teleports in/out to keep total issuance correct. - CheckAccount, ->; - -/// The means that we convert the XCM message origin location into a local dispatch origin. -type LocalOriginConverter = ( - // A `Signed` origin of the sovereign account that the original location controls. - SovereignSignedViaLocation, - // The AccountId32 location type can be expressed natively as a `Signed` origin. - SignedAccountId32AsNative, -); - -parameter_types! { - /// The amount of weight an XCM operation takes. This is a safe overestimate. - pub const BaseXcmWeight: Weight = Weight::from_parts(1_000_000_000, 64 * 1024); - /// Maximum number of instructions in a single XCM fragment. A sanity check against weight - /// calculations getting too crazy. - pub const MaxInstructions: u32 = 100; -} - -/// The XCM router. We are not sending messages to sibling/parent/child chains here. -pub type XcmRouter = EmulatedSiblingXcmpChannel; - -/// The barriers one of which must be passed for an XCM message to be executed. -pub type Barrier = ( - // Weight that is paid for may be consumed. - TakeWeightCredit, -); - -/// Dispatches received XCM messages from other chain. -pub type OnMillauBlobDispatcher = xcm_builder::BridgeBlobDispatcher< - crate::xcm_config::XcmRouter, - crate::xcm_config::UniversalLocation, - (), ->; - -/// XCM weigher type. -pub type XcmWeigher = xcm_builder::FixedWeightBounds; - -pub struct XcmConfig; -impl xcm_executor::Config for XcmConfig { - type RuntimeCall = RuntimeCall; - type XcmSender = (); - type AssetTransactor = LocalAssetTransactor; - type OriginConverter = LocalOriginConverter; - type IsReserve = (); - type IsTeleporter = (); - type UniversalLocation = UniversalLocation; - type Barrier = Barrier; - type Weigher = XcmWeigher; - // The weight trader piggybacks on the existing transaction-fee conversion logic. - type Trader = UsingComponents; - type ResponseHandler = XcmPallet; - type AssetTrap = XcmPallet; - type AssetLocker = (); - type AssetExchanger = (); - type AssetClaims = XcmPallet; - type SubscriptionService = XcmPallet; - type PalletInstancesInfo = AllPalletsWithSystem; - type MaxAssetsIntoHolding = ConstU32<64>; - type FeeManager = (); - type MessageExporter = ToRialtoOrRialtoParachainSwitchExporter; - type UniversalAliases = Nothing; - type CallDispatcher = RuntimeCall; - type SafeCallFilter = Everything; - type Aliasers = Nothing; -} - -/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior -/// location of this chain. -pub type LocalOriginToLocation = ( - // Usual Signed origin to be used in XCM as a corresponding AccountId32 - SignedToAccountId32, -); - -#[cfg(feature = "runtime-benchmarks")] -parameter_types! { - pub ReachableDest: Option = None; -} - -impl pallet_xcm::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - // We don't allow any messages to be sent via the transaction yet. This is basically safe to - // enable, (safe the possibility of someone spamming the parachain if they're willing to pay - // the DOT to send from the Relay-chain). But it's useless until we bring in XCM v3 which will - // make `DescendOrigin` a bit more useful. - type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; - type XcmRouter = (); - // Anyone can execute XCM messages locally. - type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; - type XcmExecuteFilter = Everything; - type XcmExecutor = xcm_executor::XcmExecutor; - // Anyone is able to use teleportation regardless of who they are and what they want to - // teleport. - type XcmTeleportFilter = Everything; - // Anyone is able to use reserve transfers regardless of who they are and what they want to - // transfer. - type XcmReserveTransferFilter = Everything; - type Weigher = XcmWeigher; - type UniversalLocation = UniversalLocation; - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; - type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; - type Currency = Balances; - type CurrencyMatcher = (); - type TrustedLockers = (); - type SovereignAccountOf = SovereignAccountOf; - type MaxLockers = frame_support::traits::ConstU32<8>; - type WeightInfo = pallet_xcm::TestWeightInfo; - #[cfg(feature = "runtime-benchmarks")] - type ReachableDest = ReachableDest; - type AdminOrigin = EnsureRoot; - type MaxRemoteLockConsumers = ConstU32<0>; - type RemoteLockConsumerIdentifier = (); -} - -pub struct ToRialtoOrRialtoParachainSwitchExporter; - -impl ExportXcm for ToRialtoOrRialtoParachainSwitchExporter { - type Ticket = (NetworkId, (sp_std::prelude::Vec, XcmHash)); - - fn validate( - network: NetworkId, - channel: u32, - universal_source: &mut Option, - destination: &mut Option, - message: &mut Option>, - ) -> SendResult { - if network == RialtoNetwork::get() { - ToRialtoBlobExporter::validate(network, channel, universal_source, destination, message) - .map(|result| ((RialtoNetwork::get(), result.0), result.1)) - } else if network == RialtoParachainNetwork::get() { - ToRialtoParachainBlobExporter::validate( - network, - channel, - universal_source, - destination, - message, - ) - .map(|result| ((RialtoParachainNetwork::get(), result.0), result.1)) - } else { - Err(SendError::Unroutable) - } - } - - fn deliver(ticket: Self::Ticket) -> Result { - let (network, ticket) = ticket; - if network == RialtoNetwork::get() { - ToRialtoBlobExporter::deliver(ticket) - } else if network == RialtoParachainNetwork::get() { - ToRialtoParachainBlobExporter::deliver(ticket) - } else { - Err(SendError::Unroutable) - } - } -} - -/// Emulating XCMP channel with sibling chain. We don't have required infra here, at Millau, -/// so we have to provide at least something to be able to run benchmarks. -pub struct EmulatedSiblingXcmpChannel; - -impl SendXcm for EmulatedSiblingXcmpChannel { - type Ticket = (); - - fn validate( - _destination: &mut Option, - _message: &mut Option>, - ) -> SendResult { - Ok(((), Default::default())) - } - - fn deliver(_ticket: Self::Ticket) -> Result { - Ok(XcmHash::default()) - } -} - -impl EmulatedSiblingXcmpChannel { - /// Start emulating congested channel. - pub fn make_congested() { - frame_support::storage::unhashed::put(b"EmulatedSiblingXcmpChannel.Congested", &true); - } -} - -impl bp_xcm_bridge_hub_router::XcmChannelStatusProvider for EmulatedSiblingXcmpChannel { - fn is_congested() -> bool { - frame_support::storage::unhashed::get_or_default(b"EmulatedSiblingXcmpChannel.Congested") - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::{ - rialto_messages::FromRialtoMessageDispatch, WithRialtoMessagesInstance, - WithRialtoParachainMessagesInstance, - }; - use bp_messages::{ - target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch}, - LaneId, MessageKey, - }; - use bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatchResult; - use codec::Encode; - use pallet_bridge_messages::OutboundLanes; - use sp_runtime::BuildStorage; - use xcm_executor::XcmExecutor; - - fn new_test_ext() -> sp_io::TestExternalities { - sp_io::TestExternalities::new( - frame_system::GenesisConfig::::default().build_storage().unwrap(), - ) - } - - fn prepare_outbound_xcm_message(destination: NetworkId) -> Xcm { - vec![ExportMessage { - network: destination, - destination: destination.into(), - xcm: vec![Instruction::Trap(42)].into(), - }] - .into() - } - - #[test] - fn xcm_messages_to_rialto_are_sent_using_bridge_exporter() { - new_test_ext().execute_with(|| { - // ensure that the there are no messages queued - assert_eq!( - OutboundLanes::::get( - crate::rialto_messages::XCM_LANE - ) - .latest_generated_nonce, - 0, - ); - - // export message instruction "sends" message to Rialto - XcmExecutor::::execute_xcm_in_credit( - Here, - prepare_outbound_xcm_message(RialtoNetwork::get()), - Default::default(), - Weight::MAX, - Weight::MAX, - ) - .ensure_complete() - .expect("runtime configuration must be correct"); - - // ensure that the message has been queued - assert_eq!( - OutboundLanes::::get( - crate::rialto_messages::XCM_LANE - ) - .latest_generated_nonce, - 1, - ); - }) - } - - #[test] - fn xcm_messages_to_rialto_parachain_are_sent_using_bridge_exporter() { - new_test_ext().execute_with(|| { - // ensure that the there are no messages queued - assert_eq!( - OutboundLanes::::get( - crate::rialto_parachain_messages::XCM_LANE - ) - .latest_generated_nonce, - 0, - ); - - // export message instruction "sends" message to Rialto - XcmExecutor::::execute_xcm_in_credit( - Here, - prepare_outbound_xcm_message(RialtoParachainNetwork::get()), - Default::default(), - Weight::MAX, - Weight::MAX, - ) - .ensure_complete() - .expect("runtime configuration must be correct"); - - // ensure that the message has been queued - assert_eq!( - OutboundLanes::::get( - crate::rialto_parachain_messages::XCM_LANE - ) - .latest_generated_nonce, - 1, - ); - }) - } - - fn prepare_inbound_bridge_message() -> DispatchMessage> { - let xcm = xcm::VersionedXcm::::V3(vec![Instruction::Trap(42)].into()); - let location = - xcm::VersionedInteriorMultiLocation::V3(X1(GlobalConsensus(ThisNetwork::get()))); - // this is the `BridgeMessage` from polkadot xcm builder, but it has no constructor - // or public fields, so just tuple - let bridge_message = (location, xcm).encode(); - DispatchMessage { - key: MessageKey { lane_id: LaneId([0, 0, 0, 0]), nonce: 1 }, - data: DispatchMessageData { payload: Ok(bridge_message) }, - } - } - - #[test] - fn xcm_messages_from_rialto_are_dispatched() { - let incoming_message = prepare_inbound_bridge_message(); - - // we care only about handing message to the XCM dispatcher, so we don't care about its - // actual dispatch - let dispatch_result = FromRialtoMessageDispatch::dispatch(incoming_message); - assert!(matches!( - dispatch_result.dispatch_level_result, - XcmBlobMessageDispatchResult::Dispatched, - )); - } - - #[test] - fn xcm_messages_from_rialto_parachain_are_dispatched() { - let incoming_message = prepare_inbound_bridge_message(); - - // we care only about handing message to the XCM dispatcher, so we don't care about its - // actual dispatch - let dispatch_result = FromRialtoMessageDispatch::dispatch(incoming_message); - assert!(matches!( - dispatch_result.dispatch_level_result, - XcmBlobMessageDispatchResult::Dispatched, - )); - } -} diff --git a/bridges/bin/rialto-parachain/node/Cargo.toml b/bridges/bin/rialto-parachain/node/Cargo.toml deleted file mode 100644 index 053ee24577377..0000000000000 --- a/bridges/bin/rialto-parachain/node/Cargo.toml +++ /dev/null @@ -1,81 +0,0 @@ -[package] -name = "rialto-parachain-collator" -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2021" -repository = "https://github.com/paritytech/parity-bridges-common/" -license = "GPL-3.0-or-later WITH Classpath-exception-2.0" - -[build-dependencies] -substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } - -[[bin]] -name = 'rialto-parachain-collator' - -[features] -default = [] -runtime-benchmarks = [ 'rialto-parachain-runtime/runtime-benchmarks' ] - -[dependencies] -clap = { version = "4.4.8", features = ["derive"] } -log = '0.4.20' -codec = { package = 'parity-scale-codec', version = '3.1.5' } -serde = { version = '1.0', features = ['derive'] } - -# RPC related Dependencies -jsonrpsee = { version = "0.16.2", features = ["server"] } - -# Local Dependencies -rialto-parachain-runtime = { path = '../runtime' } - -# Substrate Dependencies -frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } - -pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } - -substrate-frame-rpc-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -substrate-prometheus-endpoint = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } - -## Substrate Client Dependencies -sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-chain-spec = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-client-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-consensus = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-executor = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-network = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-network-sync = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-rpc = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-rpc-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master"} -sc-telemetry = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-tracing = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } - -## Substrate Primitive Dependencies -sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } - -# Cumulus dependencies -cumulus-client-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -cumulus-client-consensus-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -cumulus-client-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -cumulus-client-network = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -cumulus-client-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -cumulus-relay-chain-interface = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } - -# Polkadot dependencies -polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -polkadot-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } diff --git a/bridges/bin/rialto-parachain/node/build.rs b/bridges/bin/rialto-parachain/node/build.rs deleted file mode 100644 index 8ba8a31e9a79f..0000000000000 --- a/bridges/bin/rialto-parachain/node/build.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed}; - -fn main() { - generate_cargo_keys(); - rerun_if_git_head_changed(); -} diff --git a/bridges/bin/rialto-parachain/node/src/chain_spec.rs b/bridges/bin/rialto-parachain/node/src/chain_spec.rs deleted file mode 100644 index b42c9a6a8f5ee..0000000000000 --- a/bridges/bin/rialto-parachain/node/src/chain_spec.rs +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright 2020-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use cumulus_primitives_core::ParaId; -use rialto_parachain_runtime::{AccountId, AuraId, BridgeMillauMessagesConfig, Signature}; -use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; -use sc_service::ChainType; -use serde::{Deserialize, Serialize}; -use sp_core::{sr25519, Pair, Public}; -use sp_runtime::traits::{IdentifyAccount, Verify}; - -/// "Names" of the authorities accounts at local testnet. -const LOCAL_AUTHORITIES_ACCOUNTS: [&str; 2] = ["Alice", "Bob"]; -/// "Names" of the authorities accounts at development testnet. -const DEV_AUTHORITIES_ACCOUNTS: [&str; 2] = LOCAL_AUTHORITIES_ACCOUNTS; -/// "Names" of all possible authorities accounts. -const ALL_AUTHORITIES_ACCOUNTS: [&str; 2] = LOCAL_AUTHORITIES_ACCOUNTS; -/// "Name" of the `sudo` account. -const SUDO_ACCOUNT: &str = "Sudo"; -/// "Name" of the account, which owns the with-Millau messages pallet. -const MILLAU_MESSAGES_PALLET_OWNER: &str = "Millau.MessagesOwner"; - -/// Specialized `ChainSpec` for the normal parachain runtime. -pub type ChainSpec = - sc_service::GenericChainSpec; - -/// Helper function to generate a crypto pair from seed -pub fn get_from_seed(seed: &str) -> ::Public { - TPublic::Pair::from_string(&format!("//{seed}"), None) - .expect("static values are valid; qed") - .public() -} - -/// The extensions for the [`ChainSpec`]. -#[derive( - Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension, -)] -#[serde(deny_unknown_fields)] -pub struct Extensions { - /// The relay chain of the Parachain. - pub relay_chain: String, - /// The id of the Parachain. - pub para_id: u32, -} - -impl Extensions { - /// Try to get the extension from the given `ChainSpec`. - pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> { - sc_chain_spec::get_extension(chain_spec.extensions()) - } -} - -type AccountPublic = ::Signer; - -/// Helper function to generate an account ID from seed -pub fn get_account_id_from_seed(seed: &str) -> AccountId -where - AccountPublic: From<::Public>, -{ - AccountPublic::from(get_from_seed::(seed)).into_account() -} - -/// We're using the same set of endowed accounts on all RialtoParachain chains (dev/local) to make -/// sure that all accounts, required for bridge to be functional (e.g. relayers fund account, -/// accounts used by relayers in our test deployments, accounts used for demonstration -/// purposes), are all available on these chains. -fn endowed_accounts() -> Vec { - let all_authorities = ALL_AUTHORITIES_ACCOUNTS.iter().flat_map(|x| { - [ - get_account_id_from_seed::(x), - get_account_id_from_seed::(&format!("{x}//stash")), - ] - }); - vec![ - // Sudo account - get_account_id_from_seed::(SUDO_ACCOUNT), - // Regular (unused) accounts - get_account_id_from_seed::("Charlie"), - get_account_id_from_seed::("Dave"), - get_account_id_from_seed::("Eve"), - get_account_id_from_seed::("Ferdie"), - get_account_id_from_seed::("Charlie//stash"), - get_account_id_from_seed::("Dave//stash"), - get_account_id_from_seed::("Eve//stash"), - get_account_id_from_seed::("Ferdie//stash"), - // Accounts, used by RialtoParachain<>Millau bridge - get_account_id_from_seed::(MILLAU_MESSAGES_PALLET_OWNER), - get_account_id_from_seed::("Millau.HeadersAndMessagesRelay1"), - get_account_id_from_seed::("Millau.HeadersAndMessagesRelay2"), - get_account_id_from_seed::("Millau.MessagesSender"), - ] - .into_iter() - .chain(all_authorities) - .collect() -} - -pub fn development_config(id: ParaId) -> ChainSpec { - // Give your base currency a unit name and decimal places - let mut properties = sc_chain_spec::Properties::new(); - properties.insert("tokenSymbol".into(), "UNIT".into()); - properties.insert("tokenDecimals".into(), 12.into()); - - ChainSpec::from_genesis( - // Name - "Development", - // ID - "dev", - ChainType::Local, - move || { - testnet_genesis( - get_account_id_from_seed::(SUDO_ACCOUNT), - DEV_AUTHORITIES_ACCOUNTS.into_iter().map(get_from_seed::).collect(), - endowed_accounts(), - id, - ) - }, - vec![], - None, - None, - None, - None, - Extensions { - relay_chain: "rococo-local".into(), // You MUST set this to the correct network! - para_id: id.into(), - }, - ) -} - -pub fn local_testnet_config(id: ParaId) -> ChainSpec { - // Give your base currency a unit name and decimal places - let mut properties = sc_chain_spec::Properties::new(); - properties.insert("tokenSymbol".into(), "UNIT".into()); - properties.insert("tokenDecimals".into(), 12.into()); - - ChainSpec::from_genesis( - // Name - "Local Testnet", - // ID - "local_testnet", - ChainType::Local, - move || { - testnet_genesis( - get_account_id_from_seed::(SUDO_ACCOUNT), - LOCAL_AUTHORITIES_ACCOUNTS.into_iter().map(get_from_seed::).collect(), - endowed_accounts(), - id, - ) - }, - Vec::new(), - None, - None, - None, - None, - Extensions { - relay_chain: "rococo-local".into(), // You MUST set this to the correct network! - para_id: id.into(), - }, - ) -} - -fn testnet_genesis( - root_key: AccountId, - initial_authorities: Vec, - endowed_accounts: Vec, - id: ParaId, -) -> rialto_parachain_runtime::RuntimeGenesisConfig { - rialto_parachain_runtime::RuntimeGenesisConfig { - system: rialto_parachain_runtime::SystemConfig { - code: rialto_parachain_runtime::WASM_BINARY - .expect("WASM binary was not build, please build it!") - .to_vec(), - ..Default::default() - }, - balances: rialto_parachain_runtime::BalancesConfig { - balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(), - }, - sudo: rialto_parachain_runtime::SudoConfig { key: Some(root_key) }, - parachain_info: rialto_parachain_runtime::ParachainInfoConfig { - parachain_id: id, - ..Default::default() - }, - aura: rialto_parachain_runtime::AuraConfig { authorities: initial_authorities }, - aura_ext: Default::default(), - bridge_millau_messages: BridgeMillauMessagesConfig { - owner: Some(get_account_id_from_seed::(MILLAU_MESSAGES_PALLET_OWNER)), - ..Default::default() - }, - } -} diff --git a/bridges/bin/rialto-parachain/node/src/cli.rs b/bridges/bin/rialto-parachain/node/src/cli.rs deleted file mode 100644 index c8c457752d600..0000000000000 --- a/bridges/bin/rialto-parachain/node/src/cli.rs +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2020-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 . - -#![allow(clippy::large_enum_variant)] - -use crate::chain_spec; -use clap::Parser; -use cumulus_client_cli::{ExportGenesisStateCommand, ExportGenesisWasmCommand}; -use std::path::PathBuf; - -/// Sub-commands supported by the collator. -#[derive(Debug, Parser)] -pub enum Subcommand { - /// Export the genesis state of the parachain. - #[clap(name = "export-genesis-state")] - ExportGenesisState(ExportGenesisStateCommand), - - /// Export the genesis wasm of the parachain. - #[clap(name = "export-genesis-wasm")] - ExportGenesisWasm(ExportGenesisWasmCommand), - - /// Build a chain specification. - BuildSpec(sc_cli::BuildSpecCmd), - - /// Validate blocks. - CheckBlock(sc_cli::CheckBlockCmd), - - /// Export blocks. - ExportBlocks(sc_cli::ExportBlocksCmd), - - /// Export the state of a given block into a chain spec. - ExportState(sc_cli::ExportStateCmd), - - /// Import blocks. - ImportBlocks(sc_cli::ImportBlocksCmd), - - /// Remove the whole chain. - PurgeChain(cumulus_client_cli::PurgeChainCmd), - - /// Revert the chain to a previous state. - Revert(sc_cli::RevertCmd), - - /// The custom benchmark subcommand benchmarking runtime pallets. - #[clap(subcommand)] - Benchmark(frame_benchmarking_cli::BenchmarkCmd), -} - -#[derive(Debug, Parser)] -#[clap( - propagate_version = true, - args_conflicts_with_subcommands = true, - subcommand_negates_reqs = true -)] -pub struct Cli { - #[clap(subcommand)] - pub subcommand: Option, - - #[clap(long)] - pub parachain_id: Option, - - #[clap(flatten)] - pub run: cumulus_client_cli::RunCmd, - - /// Relaychain arguments - #[clap(raw = true)] - pub relaychain_args: Vec, -} - -#[derive(Debug)] -pub struct RelayChainCli { - /// The actual relay chain CLI object. - pub base: polkadot_cli::RunCmd, - - /// Optional chain id that should be passed to the relay chain. - pub chain_id: Option, - - /// The base path that should be used by the relay chain. - pub base_path: Option, -} - -impl RelayChainCli { - /// Parse the relay chain CLI parameters using the para chain `Configuration`. - pub fn new<'a>( - para_config: &sc_service::Configuration, - relay_chain_args: impl Iterator, - ) -> Self { - let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec); - let chain_id = extension.map(|e| e.relay_chain.clone()); - let base_path = para_config.base_path.path().join("rialto-bridge-node"); - Self { - base_path: Some(base_path), - chain_id, - base: polkadot_cli::RunCmd::parse_from(relay_chain_args), - } - } -} diff --git a/bridges/bin/rialto-parachain/node/src/command.rs b/bridges/bin/rialto-parachain/node/src/command.rs deleted file mode 100644 index 50c1857f1c9c8..0000000000000 --- a/bridges/bin/rialto-parachain/node/src/command.rs +++ /dev/null @@ -1,372 +0,0 @@ -// Copyright 2020-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use crate::{ - chain_spec, - cli::{Cli, RelayChainCli, Subcommand}, - service::new_partial, -}; -use cumulus_primitives_core::ParaId; -use frame_benchmarking_cli::BenchmarkCmd; -use log::info; -use rialto_parachain_runtime::{Block, RuntimeApi}; -use sc_cli::{ - ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, - NetworkParams, Result, SharedParams, SubstrateCli, -}; -use sc_service::config::{BasePath, PrometheusConfig}; -use std::net::SocketAddr; - -fn load_spec( - id: &str, - para_id: ParaId, -) -> std::result::Result, String> { - Ok(match id { - "dev" => Box::new(chain_spec::development_config(para_id)), - "" | "local" => Box::new(chain_spec::local_testnet_config(para_id)), - path => Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?), - }) -} - -impl SubstrateCli for Cli { - fn impl_name() -> String { - "Parachain Collator Template".into() - } - - fn impl_version() -> String { - env!("SUBSTRATE_CLI_IMPL_VERSION").into() - } - - fn description() -> String { - format!( - "Parachain Collator Template\n\nThe command-line arguments provided first will be \ - passed to the parachain node, while the arguments provided after -- will be passed \ - to the relaychain node.\n\n\ - {} [parachain-args] -- [relaychain-args]", - Self::executable_name() - ) - } - - fn author() -> String { - env!("CARGO_PKG_AUTHORS").into() - } - - fn support_url() -> String { - "https://github.com/substrate-developer-hub/substrate-parachain-template/issues/new".into() - } - - fn copyright_start_year() -> i32 { - 2017 - } - - fn load_spec(&self, id: &str) -> std::result::Result, String> { - load_spec(id, self.parachain_id.unwrap_or(2000).into()) - } -} - -impl SubstrateCli for RelayChainCli { - fn impl_name() -> String { - "Parachain Collator Template".into() - } - - fn impl_version() -> String { - env!("SUBSTRATE_CLI_IMPL_VERSION").into() - } - - fn description() -> String { - "Parachain Collator Template\n\nThe command-line arguments provided first will be \ - passed to the parachain node, while the arguments provided after -- will be passed \ - to the relaychain node.\n\n\ - parachain-collator [parachain-args] -- [relaychain-args]" - .into() - } - - fn author() -> String { - env!("CARGO_PKG_AUTHORS").into() - } - - fn support_url() -> String { - "https://github.com/substrate-developer-hub/substrate-parachain-template/issues/new".into() - } - - fn copyright_start_year() -> i32 { - 2017 - } - - fn load_spec(&self, id: &str) -> std::result::Result, String> { - polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id) - } -} - -macro_rules! construct_async_run { - (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{ - let runner = $cli.create_runner($cmd)?; - runner.async_run(|$config| { - let $components = new_partial::< - RuntimeApi, - _ - >( - &$config, - crate::service::parachain_build_import_queue, - )?; - let task_manager = $components.task_manager; - { $( $code )* }.map(|v| (v, task_manager)) - }) - }} -} - -/// Parse command line arguments into service configuration. -pub fn run() -> Result<()> { - let cli = Cli::from_args(); - sp_core::crypto::set_default_ss58_version(sp_core::crypto::Ss58AddressFormat::custom( - rialto_parachain_runtime::SS58Prefix::get() as u16, - )); - - match &cli.subcommand { - Some(Subcommand::BuildSpec(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run(config.chain_spec, config.network)) - }, - Some(Subcommand::CheckBlock(cmd)) => { - construct_async_run!(|components, cli, cmd, config| { - Ok(cmd.run(components.client, components.import_queue)) - }) - }, - Some(Subcommand::ExportBlocks(cmd)) => { - construct_async_run!(|components, cli, cmd, config| Ok( - cmd.run(components.client, config.database) - )) - }, - Some(Subcommand::ExportState(cmd)) => { - construct_async_run!(|components, cli, cmd, config| Ok( - cmd.run(components.client, config.chain_spec) - )) - }, - Some(Subcommand::ImportBlocks(cmd)) => { - construct_async_run!(|components, cli, cmd, config| { - Ok(cmd.run(components.client, components.import_queue)) - }) - }, - Some(Subcommand::PurgeChain(cmd)) => { - let runner = cli.create_runner(cmd)?; - - runner.sync_run(|config| { - let polkadot_cli = RelayChainCli::new( - &config, - [RelayChainCli::executable_name()].iter().chain(cli.relaychain_args.iter()), - ); - - let polkadot_config = SubstrateCli::create_configuration( - &polkadot_cli, - &polkadot_cli, - config.tokio_handle.clone(), - ) - .map_err(|err| format!("Relay chain argument error: {err}"))?; - - cmd.run(config, polkadot_config) - }) - }, - Some(Subcommand::Revert(cmd)) => { - construct_async_run!(|components, cli, cmd, config| Ok(cmd.run( - components.client, - components.backend, - None - ))) - }, - Some(Subcommand::ExportGenesisState(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| { - let partials = new_partial::( - &config, - crate::service::parachain_build_import_queue, - )?; - - cmd.run(&*config.chain_spec, &*partials.client) - }) - }, - Some(Subcommand::ExportGenesisWasm(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.sync_run(|_config| { - let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?; - cmd.run(&*spec) - }) - }, - Some(Subcommand::Benchmark(cmd)) => { - let runner = cli.create_runner(cmd)?; - match cmd { - BenchmarkCmd::Pallet(cmd) => - if cfg!(feature = "runtime-benchmarks") { - runner.sync_run(|config| cmd.run::(config)) - } else { - println!( - "Benchmarking wasn't enabled when building the node. \ - You can enable it with `--features runtime-benchmarks`." - ); - Ok(()) - }, - _ => Err("Unsupported benchmarking subcommand".into()), - } - }, - None => { - let runner = cli.create_runner(&cli.run.normalize())?; - let collator_options = cli.run.collator_options(); - - runner.run_node_until_exit(|config| async move { - let para_id = - chain_spec::Extensions::try_get(&*config.chain_spec).map(|e| e.para_id); - - let polkadot_cli = RelayChainCli::new( - &config, - [RelayChainCli::executable_name()].iter().chain(cli.relaychain_args.iter()), - ); - - let id = ParaId::from(cli.parachain_id.or(para_id).expect("Missing ParaId")); - - let polkadot_config = SubstrateCli::create_configuration( - &polkadot_cli, - &polkadot_cli, - config.tokio_handle.clone(), - ) - .map_err(|err| format!("Relay chain argument error: {err}"))?; - - info!("Parachain id: {:?}", id); - info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" }); - - crate::service::start_node(config, polkadot_config, collator_options, id) - .await - .map(|r| r.0) - .map_err(Into::into) - }) - }, - } -} - -impl DefaultConfigurationValues for RelayChainCli { - fn p2p_listen_port() -> u16 { - 30334 - } - - fn rpc_listen_port() -> u16 { - 9945 - } - - fn prometheus_listen_port() -> u16 { - 9616 - } -} - -impl CliConfiguration for RelayChainCli { - fn shared_params(&self) -> &SharedParams { - self.base.base.shared_params() - } - - fn import_params(&self) -> Option<&ImportParams> { - self.base.base.import_params() - } - - fn network_params(&self) -> Option<&NetworkParams> { - self.base.base.network_params() - } - - fn keystore_params(&self) -> Option<&KeystoreParams> { - self.base.base.keystore_params() - } - - fn base_path(&self) -> Result> { - Ok(self - .shared_params() - .base_path()? - .or_else(|| self.base_path.clone().map(Into::into))) - } - - fn rpc_addr(&self, default_listen_port: u16) -> Result> { - self.base.base.rpc_addr(default_listen_port) - } - - fn prometheus_config( - &self, - default_listen_port: u16, - chain_spec: &Box, - ) -> Result> { - self.base.base.prometheus_config(default_listen_port, chain_spec) - } - - fn init( - &self, - _support_url: &String, - _impl_version: &String, - _logger_hook: F, - _config: &sc_service::Configuration, - ) -> Result<()> - where - F: FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Configuration), - { - unreachable!("PolkadotCli is never initialized; qed"); - } - - fn chain_id(&self, is_dev: bool) -> Result { - let chain_id = self.base.base.chain_id(is_dev)?; - - Ok(if chain_id.is_empty() { self.chain_id.clone().unwrap_or_default() } else { chain_id }) - } - - fn role(&self, is_dev: bool) -> Result { - self.base.base.role(is_dev) - } - - fn transaction_pool(&self, is_dev: bool) -> Result { - self.base.base.transaction_pool(is_dev) - } - - fn rpc_methods(&self) -> Result { - self.base.base.rpc_methods() - } - - fn rpc_max_connections(&self) -> Result { - self.base.base.rpc_max_connections() - } - - fn rpc_cors(&self, is_dev: bool) -> Result>> { - self.base.base.rpc_cors(is_dev) - } - - fn default_heap_pages(&self) -> Result> { - self.base.base.default_heap_pages() - } - - fn force_authoring(&self) -> Result { - self.base.base.force_authoring() - } - - fn disable_grandpa(&self) -> Result { - self.base.base.disable_grandpa() - } - - fn max_runtime_instances(&self) -> Result> { - self.base.base.max_runtime_instances() - } - - fn announce_block(&self) -> Result { - self.base.base.announce_block() - } - - fn telemetry_endpoints( - &self, - chain_spec: &Box, - ) -> Result> { - self.base.base.telemetry_endpoints(chain_spec) - } -} diff --git a/bridges/bin/rialto-parachain/node/src/lib.rs b/bridges/bin/rialto-parachain/node/src/lib.rs deleted file mode 100644 index 5dd2a8af861b1..0000000000000 --- a/bridges/bin/rialto-parachain/node/src/lib.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2020-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 . - -pub mod chain_spec; -#[allow(deprecated)] -pub mod service; diff --git a/bridges/bin/rialto-parachain/node/src/main.rs b/bridges/bin/rialto-parachain/node/src/main.rs deleted file mode 100644 index ca93efa067cc9..0000000000000 --- a/bridges/bin/rialto-parachain/node/src/main.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2020-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 . - -//! Substrate Parachain Node Template CLI - -#![warn(missing_docs)] - -mod chain_spec; -#[macro_use] -#[allow(deprecated)] -mod service; -mod cli; -mod command; - -fn main() -> sc_cli::Result<()> { - command::run() -} diff --git a/bridges/bin/rialto-parachain/node/src/service.rs b/bridges/bin/rialto-parachain/node/src/service.rs deleted file mode 100644 index 86c5a7615901c..0000000000000 --- a/bridges/bin/rialto-parachain/node/src/service.rs +++ /dev/null @@ -1,505 +0,0 @@ -// Copyright 2020-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 . - -//! Rialto parachain node service. -//! -//! The code is mostly copy of `polkadot-parachains/src/service.rs` file from Cumulus -//! repository with some parts removed. We have added two RPC extensions to the original -//! service: `pallet_transaction_payment_rpc::TransactionPaymentApi` and -//! `substrate_frame_rpc_system::SystemApi`. - -// std -use std::{sync::Arc, time::Duration}; - -// Local Runtime Types -use rialto_parachain_runtime::RuntimeApi; - -// Cumulus Imports -use cumulus_client_cli::CollatorOptions; -use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion}; -use cumulus_client_consensus_common::{ - ParachainBlockImport as TParachainBlockImport, ParachainConsensus, -}; -use cumulus_client_network::RequireSecondedInBlockAnnounce; -use cumulus_client_service::{ - prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams, -}; -use cumulus_primitives_core::ParaId; -use cumulus_relay_chain_interface::RelayChainInterface; -use sc_consensus::ImportQueue; -// Substrate Imports -use sc_executor::{ - HeapAllocStrategy, NativeElseWasmExecutor, NativeExecutionDispatch, WasmExecutor, - DEFAULT_HEAP_ALLOC_STRATEGY, -}; -use sc_network::{config::FullNetworkConfiguration, NetworkBlock}; -use sc_network_sync::SyncingService; -use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager}; -use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; -use sp_api::ConstructRuntimeApi; -use sp_keystore::KeystorePtr; -use sp_runtime::traits::BlakeTwo256; -use substrate_prometheus_endpoint::Registry; - -// Runtime type overrides -type BlockNumber = u32; -type Header = sp_runtime::generic::Header; -pub type Block = sp_runtime::generic::Block; - -type ParachainClient = - TFullClient>; -type ParachainBackend = TFullBackend; -type ParachainBlockImport = - TParachainBlockImport>, ParachainBackend>; - -pub type ParachainRuntimeExecutor = ExecutorDispatch; - -// Our native executor instance. -pub struct ExecutorDispatch; - -impl NativeExecutionDispatch for ExecutorDispatch { - type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; - - fn dispatch(method: &str, data: &[u8]) -> Option> { - rialto_parachain_runtime::api::dispatch(method, data) - } - - fn native_version() -> sc_executor::NativeVersion { - rialto_parachain_runtime::native_version() - } -} - -/// Starts a `ServiceBuilder` for a full service. -/// -/// Use this macro if you don't actually need the full service, but just the builder in order to -/// be able to perform chain operations. -#[allow(clippy::type_complexity)] -pub fn new_partial( - config: &Configuration, - build_import_queue: BIQ, -) -> Result< - PartialComponents< - ParachainClient, - ParachainBackend, - (), - sc_consensus::DefaultImportQueue, - sc_transaction_pool::FullPool>, - (ParachainBlockImport, Option, Option), - >, - sc_service::Error, -> -where - RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt - + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder, - sc_client_api::StateBackendFor: sp_api::StateBackend, - BIQ: FnOnce( - Arc>, - ParachainBlockImport, - &Configuration, - Option, - &TaskManager, - ) -> Result, sc_service::Error>, -{ - let telemetry = config - .telemetry_endpoints - .clone() - .filter(|x| !x.is_empty()) - .map(|endpoints| -> Result<_, sc_telemetry::Error> { - let worker = TelemetryWorker::new(16)?; - let telemetry = worker.handle().new_telemetry(endpoints); - Ok((worker, telemetry)) - }) - .transpose()?; - - let heap_pages = config - .default_heap_pages - .map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ }); - let executor = - sc_executor::NativeElseWasmExecutor::::new_with_wasm_executor( - WasmExecutor::builder() - .with_execution_method(config.wasm_method) - .with_onchain_heap_alloc_strategy(heap_pages) - .with_offchain_heap_alloc_strategy(heap_pages) - .with_max_runtime_instances(config.max_runtime_instances) - .with_runtime_cache_size(config.runtime_cache_size) - .build(), - ); - - let (client, backend, keystore_container, task_manager) = - sc_service::new_full_parts::( - config, - telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), - executor, - )?; - let client = Arc::new(client); - - let telemetry_worker_handle = telemetry.as_ref().map(|(worker, _)| worker.handle()); - - let telemetry = telemetry.map(|(worker, telemetry)| { - task_manager.spawn_handle().spawn("telemetry", None, worker.run()); - telemetry - }); - - let transaction_pool = sc_transaction_pool::BasicPool::new_full( - config.transaction_pool.clone(), - config.role.is_authority().into(), - config.prometheus_registry(), - task_manager.spawn_essential_handle(), - client.clone(), - ); - - let block_import = ParachainBlockImport::new(client.clone(), backend.clone()); - - let import_queue = build_import_queue( - client.clone(), - block_import.clone(), - config, - telemetry.as_ref().map(|telemetry| telemetry.handle()), - &task_manager, - )?; - - let params = PartialComponents { - backend, - client, - import_queue, - keystore_container, - task_manager, - transaction_pool, - select_chain: (), - other: (block_import, telemetry, telemetry_worker_handle), - }; - - Ok(params) -} - -/// Start a node with the given parachain `Configuration` and relay chain `Configuration`. -/// -/// This is the actual implementation that is abstract over the executor and the runtime api. -#[sc_tracing::logging::prefix_logs_with("Parachain")] -async fn start_node_impl( - parachain_config: Configuration, - polkadot_config: Configuration, - collator_options: CollatorOptions, - id: ParaId, - rpc_ext_builder: RB, - build_import_queue: BIQ, - build_consensus: BIC, -) -> sc_service::error::Result<(TaskManager, Arc>)> -where - RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt - + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder - + cumulus_primitives_core::CollectCollationInfo, - sc_client_api::StateBackendFor: sp_api::StateBackend, - RB: Fn( - sc_rpc_api::DenyUnsafe, - Arc>, - Arc>>, - ) -> Result, sc_service::Error> - + Send - + Clone - + 'static, - BIQ: FnOnce( - Arc>, - ParachainBlockImport, - &Configuration, - Option, - &TaskManager, - ) -> Result, sc_service::Error>, - BIC: FnOnce( - Arc>, - ParachainBlockImport, - Option<&Registry>, - Option, - &TaskManager, - Arc, - Arc>>, - Arc>, - KeystorePtr, - bool, - ) -> Result>, sc_service::Error>, -{ - let parachain_config = prepare_node_config(parachain_config); - - let params = new_partial::(¶chain_config, build_import_queue)?; - let (block_import, mut telemetry, telemetry_worker_handle) = params.other; - - let mut task_manager = params.task_manager; - let (relay_chain_interface, collator_key) = - cumulus_client_service::build_relay_chain_interface( - polkadot_config, - ¶chain_config, - telemetry_worker_handle, - &mut task_manager, - collator_options, - None, - ) - .await - .map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?; - - let client = params.client.clone(); - let backend = params.backend.clone(); - let block_announce_validator = - RequireSecondedInBlockAnnounce::new(relay_chain_interface.clone(), id); - - let force_authoring = parachain_config.force_authoring; - let validator = parachain_config.role.is_authority(); - let prometheus_registry = parachain_config.prometheus_registry().cloned(); - let transaction_pool = params.transaction_pool.clone(); - let import_queue_service = params.import_queue.service(); - let net_config = FullNetworkConfiguration::new(¶chain_config.network); - - let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) = - sc_service::build_network(sc_service::BuildNetworkParams { - config: ¶chain_config, - net_config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - spawn_handle: task_manager.spawn_handle(), - import_queue: params.import_queue, - block_announce_validator_builder: Some(Box::new(|_| { - Box::new(block_announce_validator) - })), - warp_sync_params: None, - block_relay: None, - })?; - - let rpc_client = client.clone(); - let rpc_transaction_pool = transaction_pool.clone(); - let rpc_extensions_builder = Box::new(move |deny_unsafe, _| { - rpc_ext_builder(deny_unsafe, rpc_client.clone(), rpc_transaction_pool.clone()) - }); - - sc_service::spawn_tasks(sc_service::SpawnTasksParams { - rpc_builder: rpc_extensions_builder.clone(), - client: client.clone(), - transaction_pool: transaction_pool.clone(), - task_manager: &mut task_manager, - config: parachain_config, - keystore: params.keystore_container.keystore(), - backend: backend.clone(), - network: network.clone(), - sync_service: sync_service.clone(), - system_rpc_tx, - tx_handler_controller, - telemetry: telemetry.as_mut(), - })?; - - let announce_block = { - let sync_service = sync_service.clone(); - Arc::new(move |hash, data| sync_service.announce_block(hash, data)) - }; - - let relay_chain_slot_duration = Duration::from_secs(6); - - let overseer_handle = relay_chain_interface - .overseer_handle() - .map_err(|e| sc_service::Error::Application(Box::new(e)))?; - - if validator { - let parachain_consensus = build_consensus( - client.clone(), - block_import, - prometheus_registry.as_ref(), - telemetry.as_ref().map(|t| t.handle()), - &task_manager, - relay_chain_interface.clone(), - transaction_pool, - sync_service.clone(), - params.keystore_container.keystore(), - force_authoring, - )?; - - let spawner = task_manager.spawn_handle(); - - let params = StartCollatorParams { - para_id: id, - block_status: client.clone(), - announce_block, - client: client.clone(), - task_manager: &mut task_manager, - relay_chain_interface, - spawner, - parachain_consensus, - import_queue: import_queue_service, - collator_key: collator_key.expect("Command line arguments do not allow this. qed"), - relay_chain_slot_duration, - recovery_handle: Box::new(overseer_handle), - sync_service, - }; - - start_collator(params).await?; - } else { - let params = StartFullNodeParams { - client: client.clone(), - announce_block, - task_manager: &mut task_manager, - para_id: id, - relay_chain_interface, - relay_chain_slot_duration, - import_queue: import_queue_service, - recovery_handle: Box::new(overseer_handle), - sync_service, - }; - - start_full_node(params)?; - } - - start_network.start_network(); - - Ok((task_manager, client)) -} - -/// Build the import queue for the the parachain runtime. -#[allow(clippy::type_complexity)] -pub fn parachain_build_import_queue( - client: Arc>, - block_import: ParachainBlockImport, - config: &Configuration, - telemetry: Option, - task_manager: &TaskManager, -) -> Result, sc_service::Error> { - let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; - - cumulus_client_consensus_aura::import_queue::< - sp_consensus_aura::sr25519::AuthorityPair, - _, - _, - _, - _, - _, - >(cumulus_client_consensus_aura::ImportQueueParams { - block_import, - client, - 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_slot_duration( - *timestamp, - slot_duration, - ); - - Ok((slot, timestamp)) - }, - registry: config.prometheus_registry(), - spawner: &task_manager.spawn_essential_handle(), - telemetry, - }) - .map_err(Into::into) -} - -/// Start a normal parachain node. -pub async fn start_node( - parachain_config: Configuration, - polkadot_config: Configuration, - collator_options: CollatorOptions, - id: ParaId, -) -> sc_service::error::Result<(TaskManager, Arc>)> { - start_node_impl::( - parachain_config, - polkadot_config, - collator_options, - id, - |_deny_unsafe, client, pool| { - use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; - use sc_rpc::DenyUnsafe; - use substrate_frame_rpc_system::{System, SystemApiServer}; - - let mut io = jsonrpsee::RpcModule::new(()); - let map_err = |e| sc_service::Error::Other(format!("{e}")); - io.merge(System::new(client.clone(), pool, DenyUnsafe::No).into_rpc()) - .map_err(map_err)?; - io.merge(TransactionPayment::new(client).into_rpc()).map_err(map_err)?; - Ok(io) - }, - parachain_build_import_queue, - |client, - block_import, - prometheus_registry, - telemetry, - task_manager, - relay_chain_interface, - transaction_pool, - sync_oracle, - keystore, - force_authoring| { - let client2 = client.clone(); - let block_import2 = block_import; - let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; - - let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording( - task_manager.spawn_handle(), - client, - transaction_pool, - prometheus_registry, - telemetry.clone(), - ); - - Ok(AuraConsensus::build::( - BuildAuraConsensusParams { - proposer_factory, - create_inherent_data_providers: move |_, (relay_parent, validation_data)| { - let relay_chain_interface = relay_chain_interface.clone(); - async move { - let parachain_inherent = - cumulus_primitives_parachain_inherent::ParachainInherentData::create_at( - relay_parent, - &relay_chain_interface, - &validation_data, - id, - ).await; - let time = sp_timestamp::InherentDataProvider::from_system_time(); - - let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *time, - slot_duration, - ); - - let parachain_inherent = parachain_inherent.ok_or_else(|| { - Box::::from( - "Failed to create parachain inherent", - ) - })?; - Ok((slot, time, parachain_inherent)) - } - }, - block_import: block_import2, - para_client: client2, - backoff_authoring_blocks: Option::<()>::None, - sync_oracle, - keystore, - force_authoring, - slot_duration, - // We got around 1000ms for proposing - block_proposal_slot_portion: SlotProportion::new(1f32 / 12f32), - telemetry, - max_block_proposal_slot_portion: None, - }, - )) - }, - ) - .await -} diff --git a/bridges/bin/rialto-parachain/runtime/Cargo.toml b/bridges/bin/rialto-parachain/runtime/Cargo.toml deleted file mode 100644 index 0715e7a2927ae..0000000000000 --- a/bridges/bin/rialto-parachain/runtime/Cargo.toml +++ /dev/null @@ -1,146 +0,0 @@ -[package] -name = "rialto-parachain-runtime" -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2021" -repository = "https://github.com/paritytech/parity-bridges-common/" -license = "GPL-3.0-or-later WITH Classpath-exception-2.0" - -[build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } - -[dependencies] -codec = { package = 'parity-scale-codec', version = '3.1.5', default-features = false, features = ['derive']} -hex-literal = "0.4" -scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } - -# Bridge depedencies - -bp-header-chain = { path = "../../../primitives/header-chain", default-features = false } -bp-messages = { path = "../../../primitives/messages", default-features = false } -bp-millau = { path = "../../../primitives/chain-millau", default-features = false } -bp-polkadot-core = { path = "../../../primitives/polkadot-core", default-features = false } -bp-relayers = { path = "../../../primitives/relayers", default-features = false } -bp-runtime = { path = "../../../primitives/runtime", default-features = false } -bp-rialto-parachain = { path = "../../../primitives/chain-rialto-parachain", default-features = false } -bridge-runtime-common = { path = "../../runtime-common", default-features = false } -pallet-bridge-grandpa = { path = "../../../modules/grandpa", default-features = false } -pallet-bridge-messages = { path = "../../../modules/messages", default-features = false } -pallet-bridge-relayers = { path = "../../../modules/relayers", default-features = false } - -# Substrate Dependencies -## Substrate Primitive Dependencies -sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-version = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } - -## Substrate FRAME Dependencies -frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false, optional = true } -frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false, optional = true } -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } - -## Substrate Pallet Dependencies -pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } - -# Cumulus Dependencies -cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -cumulus-pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -cumulus-primitives-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -parachain-info = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } - -# Polkadot Dependencies -polkadot-parachain-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } - -[dev-dependencies] -bridge-runtime-common = { path = "../../runtime-common", features = ["integrity-test"] } -static_assertions = "1.1" - -[features] -default = [ 'std' ] -runtime-benchmarks = [ - 'bridge-runtime-common/runtime-benchmarks', - 'frame-benchmarking', - 'frame-support/runtime-benchmarks', - 'frame-system-benchmarking/runtime-benchmarks', - 'frame-system/runtime-benchmarks', - 'pallet-balances/runtime-benchmarks', - 'pallet-bridge-grandpa/runtime-benchmarks', - 'pallet-bridge-messages/runtime-benchmarks', - 'pallet-bridge-relayers/runtime-benchmarks', - 'pallet-timestamp/runtime-benchmarks', - 'pallet-xcm/runtime-benchmarks', - 'sp-runtime/runtime-benchmarks', - 'xcm-builder/runtime-benchmarks', -] -std = [ - "bp-messages/std", - "bp-millau/std", - "bp-relayers/std", - "bp-rialto-parachain/std", - "bp-runtime/std", - "bridge-runtime-common/std", - "codec/std", - "cumulus-pallet-aura-ext/std", - "cumulus-pallet-parachain-system/std", - "cumulus-pallet-xcm/std", - "cumulus-pallet-xcmp-queue/std", - "cumulus-primitives-core/std", - "cumulus-primitives-timestamp/std", - "frame-executive/std", - "frame-support/std", - "frame-system-rpc-runtime-api/std", - "frame-system/std", - "pallet-aura/std", - "pallet-balances/std", - "pallet-bridge-grandpa/std", - "pallet-bridge-messages/std", - "pallet-bridge-relayers/std", - "pallet-sudo/std", - "pallet-timestamp/std", - "pallet-transaction-payment-rpc-runtime-api/std", - "pallet-transaction-payment/std", - "pallet-xcm/std", - "parachain-info/std", - "polkadot-parachain-primitives/std", - "scale-info/std", - "sp-api/std", - "sp-block-builder/std", - "sp-consensus-aura/std", - "sp-core/std", - "sp-inherents/std", - "sp-io/std", - "sp-offchain/std", - "sp-runtime/std", - "sp-session/std", - "sp-std/std", - "sp-transaction-pool/std", - "sp-version/std", - "xcm-builder/std", - "xcm-executor/std", - "xcm/std", -] diff --git a/bridges/bin/rialto-parachain/runtime/build.rs b/bridges/bin/rialto-parachain/runtime/build.rs deleted file mode 100644 index 692e270bbbae3..0000000000000 --- a/bridges/bin/rialto-parachain/runtime/build.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use substrate_wasm_builder::WasmBuilder; - -fn main() { - WasmBuilder::new() - .with_current_project() - .export_heap_base() - .import_memory() - .disable_runtime_version_section_check() - .build() -} diff --git a/bridges/bin/rialto-parachain/runtime/src/lib.rs b/bridges/bin/rialto-parachain/runtime/src/lib.rs deleted file mode 100644 index e64932d1a443f..0000000000000 --- a/bridges/bin/rialto-parachain/runtime/src/lib.rs +++ /dev/null @@ -1,975 +0,0 @@ -// 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 . - -//! The Rialto parachain runtime. This can be compiled with `#[no_std]`, ready for Wasm. -//! -//! Originally a copy of runtime from . - -#![cfg_attr(not(feature = "std"), no_std)] -// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. -#![recursion_limit = "256"] - -// Make the WASM binary available. -#[cfg(feature = "std")] -include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); - -use bridge_runtime_common::generate_bridge_reject_obsolete_headers_and_messages; -use codec::{Decode, Encode}; -use cumulus_pallet_parachain_system::AnyRelayNumber; -use scale_info::TypeInfo; -use sp_api::impl_runtime_apis; -use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; -use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, - traits::{AccountIdLookup, Block as BlockT, DispatchInfoOf, SignedExtension}, - transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError}, - ApplyExtrinsicResult, -}; - -use sp_std::prelude::*; -#[cfg(feature = "std")] -use sp_version::NativeVersion; -use sp_version::RuntimeVersion; - -// A few exports that help ease life for downstream crates. -use bp_runtime::HeaderId; -pub use frame_support::{ - construct_runtime, - dispatch::DispatchClass, - match_types, parameter_types, - traits::{ConstBool, ConstU32, Everything, IsInVec, Nothing, Randomness}, - weights::{ - constants::{ - BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND, - }, - IdentityFee, Weight, - }, - StorageValue, -}; -pub use frame_system::{Call as SystemCall, EnsureRoot}; -pub use pallet_balances::Call as BalancesCall; -pub use pallet_sudo::Call as SudoCall; -pub use pallet_timestamp::Call as TimestampCall; -pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; -#[cfg(any(feature = "std", test))] -pub use sp_runtime::BuildStorage; -pub use sp_runtime::{MultiAddress, Perbill, Permill}; - -pub use bp_rialto_parachain::{ - AccountId, Balance, BlockLength, BlockNumber, BlockWeights, Hash, Hasher as Hashing, Header, - Nonce, Signature, MAXIMUM_BLOCK_WEIGHT, -}; - -pub use pallet_bridge_grandpa::Call as BridgeGrandpaCall; -pub use pallet_bridge_messages::Call as MessagesCall; -pub use pallet_xcm::Call as XcmCall; - -// Polkadot & XCM imports -use bridge_runtime_common::CustomNetworkId; -use pallet_xcm::XcmPassthrough; -use polkadot_parachain_primitives::primitives::Sibling; -use xcm::latest::prelude::*; -use xcm_builder::{ - AccountId32Aliases, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, - NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, - SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, -}; -use xcm_executor::{Config, XcmExecutor}; - -pub mod millau_messages; - -// generate signed extension that rejects obsolete bridge transactions -generate_bridge_reject_obsolete_headers_and_messages! { - RuntimeCall, AccountId, - // Grandpa - BridgeMillauGrandpa, - // Messages - BridgeMillauMessages -} - -/// Dummy signed extension that does nothing. -/// -/// We're using it to have the same set of signed extensions on all parachains with bridge pallets -/// deployed (bridge hubs and rialto parachain). -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] -pub struct DummyBridgeRefundMillauMessages; - -impl SignedExtension for DummyBridgeRefundMillauMessages { - const IDENTIFIER: &'static str = "DummyBridgeRefundMillauMessages"; - type AccountId = AccountId; - type Call = RuntimeCall; - type AdditionalSigned = (); - type Pre = (); - - fn additional_signed(&self) -> Result { - Ok(()) - } - - fn pre_dispatch( - self, - _who: &Self::AccountId, - _call: &Self::Call, - _info: &DispatchInfoOf, - _len: usize, - ) -> Result { - Ok(()) - } -} - -/// The address format for describing accounts. -pub type Address = MultiAddress; -/// Block type as expected by this runtime. -pub type Block = generic::Block; -/// A Block signed with a Justification -pub type SignedBlock = generic::SignedBlock; -/// BlockId type as expected by this runtime. -pub type BlockId = generic::BlockId; -/// The SignedExtension to the basic transaction logic. -pub type SignedExtra = ( - frame_system::CheckNonZeroSender, - frame_system::CheckSpecVersion, - frame_system::CheckTxVersion, - frame_system::CheckGenesis, - frame_system::CheckEra, - frame_system::CheckNonce, - frame_system::CheckWeight, - pallet_transaction_payment::ChargeTransactionPayment, - BridgeRejectObsoleteHeadersAndMessages, - DummyBridgeRefundMillauMessages, -); -/// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = - generic::UncheckedExtrinsic; -/// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; -/// Executive: handles dispatch to the various modules. -pub type Executive = frame_executive::Executive< - Runtime, - Block, - frame_system::ChainContext, - Runtime, - AllPalletsWithSystem, ->; - -impl_opaque_keys! { - pub struct SessionKeys { - pub aura: Aura, - } -} - -/// This runtime version. -#[sp_version::runtime_version] -pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: create_runtime_str!("template-parachain"), - impl_name: create_runtime_str!("template-parachain"), - authoring_version: 1, - spec_version: 1, - impl_version: 0, - apis: RUNTIME_API_VERSIONS, - transaction_version: 1, - state_version: 0, -}; - -/// This determines the average expected block time that we are targeting. -/// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`. -/// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked -/// up by `pallet_aura` to implement `fn slot_duration()`. -/// -/// Change this to adjust the block time. -pub const MILLISECS_PER_BLOCK: u64 = 12000; - -pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; - -pub const EPOCH_DURATION_IN_BLOCKS: u32 = 10 * MINUTES; - -// Time is measured by number of blocks. -pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); -pub const HOURS: BlockNumber = MINUTES * 60; -pub const DAYS: BlockNumber = HOURS * 24; - -// Unit = the base number of indivisible units for balances -pub const UNIT: Balance = 1_000_000_000_000; -pub const MILLIUNIT: Balance = 1_000_000_000; -pub const MICROUNIT: Balance = 1_000_000; - -// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks. -pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); - -/// The version information used to identify this runtime when compiled natively. -#[cfg(feature = "std")] -pub fn native_version() -> NativeVersion { - NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } -} - -parameter_types! { - pub const BlockHashCount: BlockNumber = 250; - pub const Version: RuntimeVersion = VERSION; - pub const SS58Prefix: u8 = 48; -} - -// Configure FRAME pallets to include in runtime. - -impl frame_system::Config for Runtime { - /// The identifier used to distinguish between accounts. - type AccountId = AccountId; - /// The aggregated dispatch type that is available for extrinsics. - type RuntimeCall = RuntimeCall; - /// The lookup mechanism to get account ID from whatever is passed in dispatchers. - type Lookup = AccountIdLookup; - /// The index type for storing how many extrinsics an account has signed. - type Nonce = Nonce; - /// The type for hashing blocks and tries. - type Hash = Hash; - /// The hashing algorithm used. - type Hashing = Hashing; - /// The header type. - type Block = Block; - /// The ubiquitous event type. - type RuntimeEvent = RuntimeEvent; - /// The ubiquitous origin type. - type RuntimeOrigin = RuntimeOrigin; - /// Maximum number of block number to block hash mappings to keep (oldest pruned first). - type BlockHashCount = BlockHashCount; - /// Runtime version. - type Version = Version; - /// Converts a module to an index of this module in the runtime. - type PalletInfo = PalletInfo; - type AccountData = pallet_balances::AccountData; - /// What to do if a new account is created. - type OnNewAccount = (); - /// What to do if an account is fully reaped from the system. - type OnKilledAccount = (); - /// The weight of database operations that the runtime can invoke. - type DbWeight = (); - /// The basic call filter to use in dispatchable. - type BaseCallFilter = Everything; - /// Weight information for the extrinsics of this pallet. - type SystemWeightInfo = (); - /// Block & extrinsics weights: base values and limits. - type BlockWeights = BlockWeights; - /// The maximum length of a block (in bytes). - type BlockLength = BlockLength; - /// This is used as an identifier of the chain. 42 is the generic substrate prefix. - type SS58Prefix = SS58Prefix; - /// The action to take on a Runtime Upgrade - type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -parameter_types! { - pub const MinimumPeriod: u64 = SLOT_DURATION / 2; -} - -impl pallet_timestamp::Config for Runtime { - /// A timestamp: milliseconds since the Unix epoch. - type Moment = u64; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - -parameter_types! { - pub const ExistentialDeposit: u128 = MILLIUNIT; - pub const TransferFee: u128 = MILLIUNIT; - pub const CreationFee: u128 = MILLIUNIT; - pub const TransactionByteFee: u128 = MICROUNIT; - pub const OperationalFeeMultiplier: u8 = 5; -} - -impl pallet_balances::Config for Runtime { - /// The type for recording an account's balance. - type Balance = Balance; - /// The ubiquitous event type. - type RuntimeEvent = RuntimeEvent; - type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; - type AccountStore = System; - type WeightInfo = pallet_balances::weights::SubstrateWeight; - type MaxLocks = ConstU32<50>; - type MaxReserves = ConstU32<50>; - type ReserveIdentifier = [u8; 8]; - type RuntimeHoldReason = RuntimeHoldReason; - type FreezeIdentifier = (); - type MaxHolds = ConstU32<0>; - type MaxFreezes = ConstU32<0>; -} - -impl pallet_transaction_payment::Config for Runtime { - type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; - type OperationalFeeMultiplier = OperationalFeeMultiplier; - type WeightToFee = IdentityFee; - type LengthToFee = IdentityFee; - type FeeMultiplierUpdate = (); - type RuntimeEvent = RuntimeEvent; -} - -impl pallet_sudo::Config for Runtime { - type RuntimeCall = RuntimeCall; - type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_sudo::weights::SubstrateWeight; -} - -parameter_types! { - pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); - pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); -} - -impl cumulus_pallet_parachain_system::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type OnSystemEvent = (); - type SelfParaId = parachain_info::Pallet; - type OutboundXcmpMessageSource = XcmpQueue; - type DmpMessageHandler = DmpQueue; - type ReservedDmpWeight = ReservedDmpWeight; - type XcmpMessageHandler = XcmpQueue; - type ReservedXcmpWeight = ReservedXcmpWeight; - type CheckAssociatedRelayNumber = AnyRelayNumber; -} - -impl parachain_info::Config for Runtime {} - -impl cumulus_pallet_aura_ext::Config for Runtime {} - -parameter_types! { - pub const RelayLocation: MultiLocation = MultiLocation::parent(); - pub const RelayNetwork: NetworkId = CustomNetworkId::Rialto.as_network_id(); - pub RelayOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); - pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into(); - /// The Millau network ID. - pub const MillauNetwork: NetworkId = CustomNetworkId::Millau.as_network_id(); - /// The RialtoParachain network ID. - pub const ThisNetwork: NetworkId = CustomNetworkId::RialtoParachain.as_network_id(); -} - -/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used -/// when determining ownership of accounts for asset transacting and when attempting to use XCM -/// `Transact` in order to determine the dispatch Origin. -pub type LocationToAccountId = ( - // The parent (Relay-chain) origin converts to the default `AccountId`. - ParentIsPreset, - // Sibling parachain origins convert to AccountId via the `ParaId::into`. - SiblingParachainConvertsVia, - // Straight up local `AccountId32` origins just alias directly to `AccountId`. - AccountId32Aliases, -); - -/// Means for transacting assets on this chain. -pub type LocalAssetTransactor = CurrencyAdapter< - // Use this currency: - Balances, - // Use this currency when it is a fungible asset matching the given location or name: - IsConcrete, - // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID: - LocationToAccountId, - // Our chain's account ID type (we can't get away without mentioning it explicitly): - AccountId, - // We don't track any teleports. - (), ->; - -/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance, -/// ready for dispatching a transaction with XCM `Transact`. There is an `OriginKind` which can -/// biases the kind of local `Origin` it will become. -pub type XcmOriginToTransactDispatchOrigin = ( - // Sovereign account converter; this attempts to derive an `AccountId` from the origin location - // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for - // foreign chains who want to have a local sovereign account on this chain which they control. - SovereignSignedViaLocation, - // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when - // recognised. - RelayChainAsNative, - // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when - // recognised. - SiblingParachainAsNative, - // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a - // transaction from the Root origin. - ParentAsSuperuser, - // Native signed account converter; this just converts an `AccountId32` origin into a normal - // `Origin::Signed` origin of the same 32-byte value. - SignedAccountId32AsNative, - // Xcm origins can be represented natively under the Xcm pallet's Xcm origin. - XcmPassthrough, -); - -// TODO: until https://github.com/paritytech/parity-bridges-common/issues/1417 is fixed (in either way), -// the following constant must match the similar constant in the Millau runtime. - -parameter_types! { - /// The amount of weight an XCM operation takes. We don't care much about those values as we're on testnet. - pub const UnitWeightCost: Weight = Weight::from_parts(1_000_000, 1024); - // One UNIT buys 1 second of weight. - pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), UNIT); - pub const MaxInstructions: u32 = 100; - pub const MaxAuthorities: u32 = 100_000; - pub MaxAssetsIntoHolding: u32 = 64; -} - -match_types! { - pub type ParentOrParentsUnitPlurality: impl Contains = { - MultiLocation { parents: 1, interior: Here } | - MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) } - }; -} - -pub type Barrier = TakeWeightCredit; - -/// Dispatches received XCM messages from other chain. -pub type OnRialtoParachainBlobDispatcher = - xcm_builder::BridgeBlobDispatcher; - -/// XCM weigher type. -pub type XcmWeigher = FixedWeightBounds; - -pub struct XcmConfig; -impl Config for XcmConfig { - type RuntimeCall = RuntimeCall; - type XcmSender = (); - type AssetTransactor = LocalAssetTransactor; - type OriginConverter = XcmOriginToTransactDispatchOrigin; - type IsReserve = NativeAsset; - type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of UNIT - type UniversalLocation = UniversalLocation; - type Barrier = Barrier; - type Weigher = XcmWeigher; - type Trader = UsingComponents, RelayLocation, AccountId, Balances, ()>; - type ResponseHandler = PolkadotXcm; - type AssetTrap = PolkadotXcm; - type AssetClaims = PolkadotXcm; - type SubscriptionService = PolkadotXcm; - type PalletInstancesInfo = (); - type MaxAssetsIntoHolding = MaxAssetsIntoHolding; - type AssetLocker = (); - type AssetExchanger = (); - type FeeManager = (); - type MessageExporter = millau_messages::ToMillauBlobExporter; - type UniversalAliases = Nothing; - type CallDispatcher = RuntimeCall; - type SafeCallFilter = Everything; - type Aliasers = Nothing; -} - -/// No local origins on this chain are allowed to dispatch XCM sends/executions. -pub type LocalOriginToLocation = SignedToAccountId32; - -/// The XCM router. We are not sending messages to sibling/parent/child chains here. -pub type XcmRouter = (); - -#[cfg(feature = "runtime-benchmarks")] -parameter_types! { - pub ReachableDest: Option = None; -} - -impl pallet_xcm::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type SendXcmOrigin = EnsureXcmOrigin; - type XcmRouter = XcmRouter; - type ExecuteXcmOrigin = EnsureXcmOrigin; - type XcmExecuteFilter = Everything; - type XcmExecutor = XcmExecutor; - type XcmTeleportFilter = Everything; - type XcmReserveTransferFilter = Everything; - type Weigher = XcmWeigher; - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; - type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; - type Currency = Balances; - type CurrencyMatcher = (); - type TrustedLockers = (); - type SovereignAccountOf = (); - type MaxLockers = frame_support::traits::ConstU32<8>; - type UniversalLocation = UniversalLocation; - type WeightInfo = pallet_xcm::TestWeightInfo; - #[cfg(feature = "runtime-benchmarks")] - type ReachableDest = ReachableDest; - type AdminOrigin = frame_system::EnsureRoot; - type MaxRemoteLockConsumers = ConstU32<0>; - type RemoteLockConsumerIdentifier = (); -} - -impl cumulus_pallet_xcm::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; -} - -impl cumulus_pallet_xcmp_queue::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; - type ChannelInfo = ParachainSystem; - type VersionWrapper = (); - type ExecuteOverweightOrigin = EnsureRoot; - type ControllerOrigin = EnsureRoot; - type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; - type WeightInfo = (); - type PriceForSiblingDelivery = (); -} - -impl cumulus_pallet_dmp_queue::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; - type ExecuteOverweightOrigin = frame_system::EnsureRoot; -} - -impl pallet_aura::Config for Runtime { - type AuthorityId = AuraId; - type DisabledValidators = (); - type MaxAuthorities = MaxAuthorities; - type AllowMultipleBlocksPerSlot = ConstBool; -} - -impl pallet_bridge_relayers::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Reward = Balance; - type PaymentProcedure = - bp_relayers::PayRewardFromAccount, AccountId>; - type StakeAndSlash = (); - type WeightInfo = (); -} - -pub type MillauGrandpaInstance = (); -impl pallet_bridge_grandpa::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type BridgedChain = bp_millau::Millau; - type MaxFreeMandatoryHeadersPerBlock = ConstU32<4>; - type HeadersToKeep = ConstU32<{ bp_millau::DAYS as u32 }>; - type WeightInfo = pallet_bridge_grandpa::weights::BridgeWeight; -} - -parameter_types! { - pub const MaxMessagesToPruneAtOnce: bp_messages::MessageNonce = 8; - pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_messages::MessageNonce = - bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; - pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce = - bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; - pub const RootAccountForPayments: Option = None; - pub const BridgedChainId: bp_runtime::ChainId = bp_runtime::MILLAU_CHAIN_ID; - pub ActiveOutboundLanes: &'static [bp_messages::LaneId] = &[millau_messages::XCM_LANE]; -} - -/// Instance of the messages pallet used to relay messages to/from Millau chain. -pub type WithMillauMessagesInstance = (); - -impl pallet_bridge_messages::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_bridge_messages::weights::BridgeWeight; - type ActiveOutboundLanes = ActiveOutboundLanes; - type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane; - type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane; - - type MaximalOutboundPayloadSize = crate::millau_messages::ToMillauMaximalOutboundPayloadSize; - type OutboundPayload = crate::millau_messages::ToMillauMessagePayload; - - type InboundPayload = crate::millau_messages::FromMillauMessagePayload; - type InboundRelayer = bp_millau::AccountId; - type DeliveryPayments = (); - - type TargetHeaderChain = crate::millau_messages::MillauAsTargetHeaderChain; - type LaneMessageVerifier = crate::millau_messages::ToMillauMessageVerifier; - type DeliveryConfirmationPayments = pallet_bridge_relayers::DeliveryConfirmationPaymentsAdapter< - Runtime, - WithMillauMessagesInstance, - frame_support::traits::ConstU128<100_000>, - >; - type OnMessagesDelivered = (); - - type SourceHeaderChain = crate::millau_messages::MillauAsSourceHeaderChain; - type MessageDispatch = crate::millau_messages::FromMillauMessageDispatch; - type BridgedChainId = BridgedChainId; -} - -// Create the runtime by composing the FRAME pallets that were previously configured. -construct_runtime!( - pub enum Runtime { - System: frame_system::{Pallet, Call, Storage, Config, Event}, - Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, - Sudo: pallet_sudo::{Pallet, Call, Storage, Config, Event}, - TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, - - ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event} = 20, - ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21, - - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 30, - - Aura: pallet_aura::{Pallet, Config}, - AuraExt: cumulus_pallet_aura_ext::{Pallet, Config}, - - // XCM helpers. - XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 50, - PolkadotXcm: pallet_xcm::{Pallet, Call, Event, Origin} = 51, - CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event, Origin} = 52, - DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event} = 53, - - // Millau bridge modules. - BridgeRelayers: pallet_bridge_relayers::{Pallet, Call, Storage, Event}, - BridgeMillauGrandpa: pallet_bridge_grandpa::{Pallet, Call, Storage, Event}, - BridgeMillauMessages: pallet_bridge_messages::{Pallet, Call, Storage, Event, Config}, - } -); - -impl_runtime_apis! { - impl sp_api::Core for Runtime { - fn version() -> RuntimeVersion { - VERSION - } - - fn execute_block(block: Block) { - Executive::execute_block(block) - } - - fn initialize_block(header: &::Header) { - Executive::initialize_block(header) - } - } - - impl sp_api::Metadata for Runtime { - fn metadata() -> OpaqueMetadata { - OpaqueMetadata::new(Runtime::metadata().into()) - } - - fn metadata_at_version(version: u32) -> Option { - Runtime::metadata_at_version(version) - } - - fn metadata_versions() -> sp_std::vec::Vec { - Runtime::metadata_versions() - } - } - - impl sp_block_builder::BlockBuilder for Runtime { - fn apply_extrinsic( - extrinsic: ::Extrinsic, - ) -> ApplyExtrinsicResult { - Executive::apply_extrinsic(extrinsic) - } - - fn finalize_block() -> ::Header { - Executive::finalize_block() - } - - fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { - data.create_extrinsics() - } - - fn check_inherents( - block: Block, - data: sp_inherents::InherentData, - ) -> sp_inherents::CheckInherentsResult { - data.check_extrinsics(&block) - } - } - - impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { - fn validate_transaction( - source: TransactionSource, - tx: ::Extrinsic, - block_hash: ::Hash, - ) -> TransactionValidity { - Executive::validate_transaction(source, tx, block_hash) - } - } - - impl sp_offchain::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { - Executive::offchain_worker(header) - } - } - - impl sp_session::SessionKeys for Runtime { - fn decode_session_keys( - encoded: Vec, - ) -> Option, KeyTypeId)>> { - SessionKeys::decode_into_raw_public_keys(&encoded) - } - - fn generate_session_keys(seed: Option>) -> Vec { - SessionKeys::generate(seed) - } - } - - impl sp_consensus_aura::AuraApi for Runtime { - fn slot_duration() -> sp_consensus_aura::SlotDuration { - sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration()) - } - - fn authorities() -> Vec { - Aura::authorities().to_vec() - } - } - - impl cumulus_primitives_core::CollectCollationInfo for Runtime { - fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { - ParachainSystem::collect_collation_info(header) - } - } - - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Nonce { - System::account_nonce(account) - } - } - - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi for Runtime { - fn query_info( - uxt: ::Extrinsic, - len: u32, - ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo { - TransactionPayment::query_info(uxt, len) - } - fn query_fee_details( - uxt: ::Extrinsic, - len: u32, - ) -> pallet_transaction_payment::FeeDetails { - TransactionPayment::query_fee_details(uxt, len) - } - fn query_weight_to_fee(weight: Weight) -> Balance { - TransactionPayment::weight_to_fee(weight) - } - fn query_length_to_fee(length: u32) -> Balance { - TransactionPayment::length_to_fee(length) - } - } - - impl bp_millau::MillauFinalityApi for Runtime { - fn best_finalized() -> Option> { - BridgeMillauGrandpa::best_finalized() - } - - fn synced_headers_grandpa_info( - ) -> Vec> { - BridgeMillauGrandpa::synced_headers_grandpa_info() - } - } - - impl bp_millau::ToMillauOutboundLaneApi for Runtime { - fn message_details( - lane: bp_messages::LaneId, - begin: bp_messages::MessageNonce, - end: bp_messages::MessageNonce, - ) -> Vec { - bridge_runtime_common::messages_api::outbound_message_details::< - Runtime, - WithMillauMessagesInstance, - >(lane, begin, end) - } - } - - impl bp_millau::FromMillauInboundLaneApi for Runtime { - fn message_details( - lane: bp_messages::LaneId, - messages: Vec<(bp_messages::MessagePayload, bp_messages::OutboundMessageDetails)>, - ) -> Vec { - bridge_runtime_common::messages_api::inbound_message_details::< - Runtime, - WithMillauMessagesInstance, - >(lane, messages) - } - } - - #[cfg(feature = "runtime-benchmarks")] - impl frame_benchmarking::Benchmark for Runtime { - fn benchmark_metadata(_extra: bool) -> ( - Vec, - Vec, - ) { - todo!("TODO: fix or remove") - } - - fn dispatch_benchmark( - config: frame_benchmarking::BenchmarkConfig - ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark}; - use frame_support::traits::TrackedStorageKey; - - use frame_system_benchmarking::Pallet as SystemBench; - impl frame_system_benchmarking::Config for Runtime {} - - let whitelist: Vec = vec![ - // Block Number - hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), - // Total Issuance - hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(), - // Execution Phase - hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(), - // Event Count - hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(), - // System Events - hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(), - ]; - - let mut batches = Vec::::new(); - let params = (&config, &whitelist); - - add_benchmark!(params, batches, frame_system, SystemBench::); - add_benchmark!(params, batches, pallet_balances, Balances); - add_benchmark!(params, batches, pallet_timestamp, Timestamp); - - Ok(batches) - } - } -} - -struct CheckInherents; - -impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { - fn check_inherents( - block: &Block, - relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof, - ) -> sp_inherents::CheckInherentsResult { - let relay_chain_slot = relay_state_proof - .read_slot() - .expect("Could not read the relay chain slot from the proof"); - - let inherent_data = - cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration( - relay_chain_slot, - sp_std::time::Duration::from_secs(6), - ) - .create_inherent_data() - .expect("Could not create the timestamp inherent data"); - - inherent_data.check_extrinsics(block) - } -} - -cumulus_pallet_parachain_system::register_validate_block!( - Runtime = Runtime, - BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::, - CheckInherents = CheckInherents, -); - -#[cfg(test)] -mod tests { - use super::*; - use crate::millau_messages::{FromMillauMessageDispatch, XCM_LANE}; - use bp_messages::{ - target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch}, - LaneId, MessageKey, - }; - use bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatchResult; - use codec::Encode; - use pallet_bridge_messages::OutboundLanes; - use sp_runtime::{generic::Era, traits::Zero}; - use xcm_executor::XcmExecutor; - - fn new_test_ext() -> sp_io::TestExternalities { - sp_io::TestExternalities::new( - frame_system::GenesisConfig::::default().build_storage().unwrap(), - ) - } - - fn prepare_outbound_xcm_message(destination: NetworkId) -> Xcm { - vec![ExportMessage { - network: destination, - destination: destination.into(), - xcm: vec![Instruction::Trap(42)].into(), - }] - .into() - } - - #[test] - fn xcm_messages_to_millau_are_sent_using_bridge_exporter() { - new_test_ext().execute_with(|| { - // ensure that the there are no messages queued - assert_eq!( - OutboundLanes::::get(XCM_LANE) - .latest_generated_nonce, - 0, - ); - - // export message instruction "sends" message to Rialto - XcmExecutor::::execute_xcm_in_credit( - Here, - prepare_outbound_xcm_message(MillauNetwork::get()), - Default::default(), - Weight::MAX, - Weight::MAX, - ) - .ensure_complete() - .expect("runtime configuration must be correct"); - - // ensure that the message has been queued - assert_eq!( - OutboundLanes::::get(XCM_LANE) - .latest_generated_nonce, - 1, - ); - }) - } - - fn prepare_inbound_bridge_message() -> DispatchMessage> { - let xcm = xcm::VersionedXcm::::V3(vec![Instruction::Trap(42)].into()); - let location = - xcm::VersionedInteriorMultiLocation::V3(X1(GlobalConsensus(ThisNetwork::get()))); - // this is the `BridgeMessage` from polkadot xcm builder, but it has no constructor - // or public fields, so just tuple - let bridge_message = (location, xcm).encode(); - DispatchMessage { - key: MessageKey { lane_id: LaneId([0, 0, 0, 0]), nonce: 1 }, - data: DispatchMessageData { payload: Ok(bridge_message) }, - } - } - - #[test] - fn xcm_messages_from_millau_are_dispatched() { - new_test_ext().execute_with(|| { - let incoming_message = prepare_inbound_bridge_message(); - - // we care only about handing message to the XCM dispatcher, so we don't care about its - // actual dispatch - let dispatch_result = FromMillauMessageDispatch::dispatch(incoming_message); - assert!(matches!( - dispatch_result.dispatch_level_result, - XcmBlobMessageDispatchResult::NotDispatched(_), - )); - }); - } - - #[test] - fn ensure_signed_extension_definition_is_correct() { - use bp_polkadot_core::SuffixedCommonSignedExtensionExt; - - sp_io::TestExternalities::default().execute_with(|| { - frame_system::BlockHash::::insert(BlockNumber::zero(), Hash::default()); - let payload: SignedExtra = ( - frame_system::CheckNonZeroSender::new(), - frame_system::CheckSpecVersion::new(), - frame_system::CheckTxVersion::new(), - frame_system::CheckGenesis::new(), - frame_system::CheckEra::from(Era::Immortal), - frame_system::CheckNonce::from(10), - frame_system::CheckWeight::new(), - pallet_transaction_payment::ChargeTransactionPayment::from(10), - BridgeRejectObsoleteHeadersAndMessages, - DummyBridgeRefundMillauMessages, - ); - let indirect_payload = bp_rialto_parachain::SignedExtension::from_params( - VERSION.spec_version, - VERSION.transaction_version, - bp_runtime::TransactionEra::Immortal, - System::block_hash(BlockNumber::zero()), - 10, - 10, - (((), ()), ((), ())), - ); - assert_eq!(payload.encode(), indirect_payload.encode()); - assert_eq!( - payload.additional_signed().unwrap().encode(), - indirect_payload.additional_signed().unwrap().encode() - ) - }); - } -} diff --git a/bridges/bin/rialto-parachain/runtime/src/millau_messages.rs b/bridges/bin/rialto-parachain/runtime/src/millau_messages.rs deleted file mode 100644 index b75a3d520b78a..0000000000000 --- a/bridges/bin/rialto-parachain/runtime/src/millau_messages.rs +++ /dev/null @@ -1,206 +0,0 @@ -// 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 . - -//! Everything required to serve Millau <-> RialtoParachain messages. - -// TODO: this is almost exact copy of `millau_messages.rs` from Rialto runtime. -// Should be extracted to a separate crate and reused here. - -use crate::{MillauGrandpaInstance, Runtime, RuntimeOrigin, WithMillauMessagesInstance}; - -use bp_messages::LaneId; -use bridge_runtime_common::{ - messages::{ - self, source::TargetHeaderChainAdapter, target::SourceHeaderChainAdapter, MessageBridge, - }, - messages_xcm_extension::{SenderAndLane, XcmBlobHauler, XcmBlobHaulerAdapter}, -}; -use frame_support::{parameter_types, weights::Weight}; -use sp_runtime::RuntimeDebug; -use xcm::latest::prelude::*; -use xcm_builder::HaulBlobExporter; - -/// Default lane that is used to send messages to Millau. -pub const XCM_LANE: LaneId = LaneId([0, 0, 0, 0]); -/// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge -/// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual -/// tests, confirming that we don't break encoding somewhere between. -pub const BASE_XCM_WEIGHT_TWICE: Weight = crate::UnitWeightCost::get().saturating_mul(2); - -parameter_types! { - /// Weight credit for our test messages. - /// - /// 2 XCM instructions is for simple `Trap(42)` program, coming through bridge - /// (it is prepended with `UniversalOrigin` instruction). - pub const WeightCredit: Weight = BASE_XCM_WEIGHT_TWICE; - /// Lane used by the with-Millau bridge. - pub MullauSenderAndLane: SenderAndLane = SenderAndLane::new(Here.into(), XCM_LANE); - - /// Dummy message used in configuration. - pub DummyXcmMessage: Xcm<()> = Xcm::new(); -} - -/// Message payload for RialtoParachain -> Millau messages. -pub type ToMillauMessagePayload = messages::source::FromThisChainMessagePayload; - -/// Message verifier for RialtoParachain -> Millau messages. -pub type ToMillauMessageVerifier = - messages::source::FromThisChainMessageVerifier; - -/// Message payload for Millau -> RialtoParachain messages. -pub type FromMillauMessagePayload = messages::target::FromBridgedChainMessagePayload; - -/// Call-dispatch based message dispatch for Millau -> RialtoParachain messages. -pub type FromMillauMessageDispatch = - bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatch< - crate::OnRialtoParachainBlobDispatcher, - (), - (), - >; - -/// Messages proof for Millau -> RialtoParachain messages. -pub type FromMillauMessagesProof = messages::target::FromBridgedChainMessagesProof; - -/// Messages delivery proof for RialtoParachain -> Millau messages. -pub type ToMillauMessagesDeliveryProof = - messages::source::FromBridgedChainMessagesDeliveryProof; - -/// Maximal outbound payload size of Rialto -> Millau messages. -pub type ToMillauMaximalOutboundPayloadSize = - messages::source::FromThisChainMaximalOutboundPayloadSize; - -/// Millau <-> RialtoParachain message bridge. -#[derive(RuntimeDebug, Clone, Copy)] -pub struct WithMillauMessageBridge; - -impl MessageBridge for WithMillauMessageBridge { - const BRIDGED_MESSAGES_PALLET_NAME: &'static str = - bp_rialto_parachain::WITH_RIALTO_PARACHAIN_MESSAGES_PALLET_NAME; - - type ThisChain = RialtoParachain; - type BridgedChain = Millau; - type BridgedHeaderChain = - pallet_bridge_grandpa::GrandpaChainHeaders; -} - -/// RialtoParachain chain from message lane point of view. -#[derive(RuntimeDebug, Clone, Copy)] -pub struct RialtoParachain; - -impl messages::UnderlyingChainProvider for RialtoParachain { - type Chain = bp_rialto_parachain::RialtoParachain; -} - -impl messages::ThisChainWithMessages for RialtoParachain { - type RuntimeOrigin = RuntimeOrigin; -} - -/// Millau chain from message lane point of view. -#[derive(RuntimeDebug, Clone, Copy)] -pub struct Millau; -/// Millau as source header chain. -pub type MillauAsSourceHeaderChain = SourceHeaderChainAdapter; -/// Millau as target header chain. -pub type MillauAsTargetHeaderChain = TargetHeaderChainAdapter; - -impl messages::UnderlyingChainProvider for Millau { - type Chain = bp_millau::Millau; -} - -impl messages::BridgedChainWithMessages for Millau {} - -/// Export XCM messages to be relayed to Millau. -pub type ToMillauBlobExporter = - HaulBlobExporter, crate::MillauNetwork, ()>; - -/// To-Millau XCM hauler. -pub struct ToMillauXcmBlobHauler; - -impl XcmBlobHauler for ToMillauXcmBlobHauler { - type Runtime = Runtime; - type MessagesInstance = WithMillauMessagesInstance; - type SenderAndLane = MullauSenderAndLane; - - type ToSourceChainSender = crate::XcmRouter; - type CongestedMessage = DummyXcmMessage; - type UncongestedMessage = DummyXcmMessage; -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::{MillauGrandpaInstance, Runtime, WithMillauMessagesInstance}; - use bridge_runtime_common::{ - assert_complete_bridge_types, - integrity::{ - assert_complete_bridge_constants, check_message_lane_weights, - AssertBridgeMessagesPalletConstants, AssertBridgePalletNames, AssertChainConstants, - AssertCompleteBridgeConstants, - }, - }; - - #[test] - fn ensure_millau_message_lane_weights_are_correct() { - check_message_lane_weights::< - bp_rialto_parachain::RialtoParachain, - Runtime, - WithMillauMessagesInstance, - >( - bp_millau::EXTRA_STORAGE_PROOF_SIZE, - bp_rialto_parachain::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, - bp_rialto_parachain::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, - false, - ); - } - - #[test] - fn ensure_bridge_integrity() { - assert_complete_bridge_types!( - runtime: Runtime, - with_bridged_chain_grandpa_instance: MillauGrandpaInstance, - with_bridged_chain_messages_instance: WithMillauMessagesInstance, - bridge: WithMillauMessageBridge, - this_chain: bp_rialto_parachain::RialtoParachain, - bridged_chain: bp_millau::Millau, - ); - - assert_complete_bridge_constants::< - Runtime, - MillauGrandpaInstance, - WithMillauMessagesInstance, - WithMillauMessageBridge, - >(AssertCompleteBridgeConstants { - this_chain_constants: AssertChainConstants { - block_length: bp_rialto_parachain::BlockLength::get(), - block_weights: bp_rialto_parachain::BlockWeights::get(), - }, - messages_pallet_constants: AssertBridgeMessagesPalletConstants { - max_unrewarded_relayers_in_bridged_confirmation_tx: - bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, - max_unconfirmed_messages_in_bridged_confirmation_tx: - bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, - bridged_chain_id: bp_runtime::MILLAU_CHAIN_ID, - }, - pallet_names: AssertBridgePalletNames { - with_this_chain_messages_pallet_name: - bp_rialto_parachain::WITH_RIALTO_PARACHAIN_MESSAGES_PALLET_NAME, - with_bridged_chain_grandpa_pallet_name: bp_millau::WITH_MILLAU_GRANDPA_PALLET_NAME, - with_bridged_chain_messages_pallet_name: - bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME, - }, - }); - } -} diff --git a/bridges/bin/rialto/node/Cargo.toml b/bridges/bin/rialto/node/Cargo.toml deleted file mode 100644 index b2d54e5160983..0000000000000 --- a/bridges/bin/rialto/node/Cargo.toml +++ /dev/null @@ -1,61 +0,0 @@ -[[bin]] -name = "rialto-bridge-node-execute-worker" -path = "src/workers/execute-worker.rs" - -[[bin]] -name = "rialto-bridge-node-prepare-worker" -path = "src/workers/prepare-worker.rs" - -[package] -name = "rialto-bridge-node" -description = "Substrate node compatible with Rialto runtime" -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2021" -build = "build.rs" -repository = "https://github.com/paritytech/parity-bridges-common/" -license = "GPL-3.0-or-later WITH Classpath-exception-2.0" - -[dependencies] -clap = { version = "4.4.8", features = ["derive"] } -serde_json = "1.0.108" - -# Bridge dependencies - -rialto-runtime = { path = "../runtime" } - -# Substrate Dependencies - -sp-consensus-beefy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -node-inspect = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master"} -sc-executor = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sc-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } - -# Polkadot Dependencies -polkadot-node-core-pvf = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -polkadot-node-core-pvf-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -polkadot-node-core-pvf-execute-worker = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -polkadot-node-core-pvf-prepare-worker = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -polkadot-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false, features = [ "full-node" ] } - -[build-dependencies] -substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } - -[features] -default = [] -runtime-benchmarks = [ - "polkadot-service/runtime-benchmarks", - "rialto-runtime/runtime-benchmarks", -] diff --git a/bridges/bin/rialto/node/build.rs b/bridges/bin/rialto/node/build.rs deleted file mode 100644 index d9b50049e2628..0000000000000 --- a/bridges/bin/rialto/node/build.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed}; - -fn main() { - generate_cargo_keys(); - - rerun_if_git_head_changed(); -} diff --git a/bridges/bin/rialto/node/src/chain_spec.rs b/bridges/bin/rialto/node/src/chain_spec.rs deleted file mode 100644 index 6d1180d12a985..0000000000000 --- a/bridges/bin/rialto/node/src/chain_spec.rs +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use polkadot_primitives::v6::{AssignmentId, ValidatorId}; -use rialto_runtime::{ - AccountId, BabeConfig, BalancesConfig, BeefyConfig, BridgeMillauMessagesConfig, - ConfigurationConfig, GrandpaConfig, RuntimeGenesisConfig, SessionConfig, SessionKeys, - Signature, SudoConfig, SystemConfig, WASM_BINARY, -}; -use serde_json::json; -use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; -use sp_consensus_babe::AuthorityId as BabeId; -use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId; -use sp_consensus_grandpa::AuthorityId as GrandpaId; -use sp_core::{sr25519, Pair, Public}; -use sp_runtime::traits::{IdentifyAccount, Verify}; - -/// "Names" of the authorities accounts at local testnet. -const LOCAL_AUTHORITIES_ACCOUNTS: [&str; 5] = ["Alice", "Bob", "Charlie", "Dave", "Eve"]; -/// "Names" of the authorities accounts at development testnet. -const DEV_AUTHORITIES_ACCOUNTS: [&str; 1] = [LOCAL_AUTHORITIES_ACCOUNTS[0]]; -/// "Names" of all possible authorities accounts. -const ALL_AUTHORITIES_ACCOUNTS: [&str; 5] = LOCAL_AUTHORITIES_ACCOUNTS; -/// "Name" of the `sudo` account. -const SUDO_ACCOUNT: &str = "Sudo"; -/// "Name" of the account, which owns the with-Millau messages pallet. -const MILLAU_MESSAGES_PALLET_OWNER: &str = "Millau.MessagesOwner"; - -/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. -pub type ChainSpec = - sc_service::GenericChainSpec; - -/// The chain specification option. This is expected to come in from the CLI and -/// is little more than one of a number of alternatives which can easily be converted -/// from a string (`--chain=...`) into a `ChainSpec`. -#[derive(Clone, Debug)] -pub enum Alternative { - /// Whatever the current runtime is, with just Alice as an auth. - Development, - /// Whatever the current runtime is, with simple Alice/Bob/Charlie/Dave/Eve auths. - LocalTestnet, -} - -/// Helper function to generate a crypto pair from seed -pub fn get_from_seed(seed: &str) -> ::Public { - TPublic::Pair::from_string(&format!("//{seed}"), None) - .expect("static values are valid; qed") - .public() -} - -type AccountPublic = ::Signer; - -/// Helper function to generate an account ID from seed -pub fn get_account_id_from_seed(seed: &str) -> AccountId -where - AccountPublic: From<::Public>, -{ - AccountPublic::from(get_from_seed::(seed)).into_account() -} - -/// Helper function to generate authority keys. -pub fn get_authority_keys_from_seed( - s: &str, -) -> (AccountId, BabeId, BeefyId, GrandpaId, ValidatorId, AssignmentId, AuthorityDiscoveryId) { - ( - get_account_id_from_seed::(s), - get_from_seed::(s), - get_from_seed::(s), - get_from_seed::(s), - get_from_seed::(s), - get_from_seed::(s), - get_from_seed::(s), - ) -} - -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" - }) - .as_object() - .expect("Map given; qed") - .clone(), - ); - match self { - Alternative::Development => ChainSpec::from_genesis( - "Rialto Development", - "rialto_dev", - sc_service::ChainType::Development, - || { - testnet_genesis( - DEV_AUTHORITIES_ACCOUNTS - .into_iter() - .map(get_authority_keys_from_seed) - .collect(), - get_account_id_from_seed::(SUDO_ACCOUNT), - endowed_accounts(), - true, - ) - }, - vec![], - None, - None, - None, - properties, - Default::default(), - ), - Alternative::LocalTestnet => ChainSpec::from_genesis( - "Rialto Local", - "rialto_local", - sc_service::ChainType::Local, - || { - testnet_genesis( - LOCAL_AUTHORITIES_ACCOUNTS - .into_iter() - .map(get_authority_keys_from_seed) - .collect(), - get_account_id_from_seed::(SUDO_ACCOUNT), - endowed_accounts(), - true, - ) - }, - vec![], - None, - None, - None, - properties, - Default::default(), - ), - } - } -} - -/// We're using the same set of endowed accounts on all Millau chains (dev/local) to make -/// sure that all accounts, required for bridge to be functional (e.g. relayers fund account, -/// accounts used by relayers in our test deployments, accounts used for demonstration -/// purposes), are all available on these chains. -fn endowed_accounts() -> Vec { - let all_authorities = ALL_AUTHORITIES_ACCOUNTS.iter().flat_map(|x| { - [ - get_account_id_from_seed::(x), - get_account_id_from_seed::(&format!("{x}//stash")), - ] - }); - vec![ - // Sudo account - get_account_id_from_seed::(SUDO_ACCOUNT), - // Regular (unused) accounts - get_account_id_from_seed::("Ferdie"), - get_account_id_from_seed::("Ferdie//stash"), - // Accounts, used by Rialto<>Millau bridge - get_account_id_from_seed::(MILLAU_MESSAGES_PALLET_OWNER), - get_account_id_from_seed::("Millau.HeadersAndMessagesRelay"), - get_account_id_from_seed::("Millau.OutboundMessagesRelay.Lane00000001"), - get_account_id_from_seed::("Millau.InboundMessagesRelay.Lane00000001"), - get_account_id_from_seed::("Millau.MessagesSender"), - ] - .into_iter() - .chain(all_authorities) - .collect() -} - -fn session_keys( - babe: BabeId, - beefy: BeefyId, - grandpa: GrandpaId, - para_validator: ValidatorId, - para_assignment: AssignmentId, - authority_discovery: AuthorityDiscoveryId, -) -> SessionKeys { - SessionKeys { babe, beefy, grandpa, para_validator, para_assignment, authority_discovery } -} - -fn testnet_genesis( - initial_authorities: Vec<( - AccountId, - BabeId, - BeefyId, - GrandpaId, - ValidatorId, - AssignmentId, - AuthorityDiscoveryId, - )>, - root_key: AccountId, - endowed_accounts: Vec, - _enable_println: bool, -) -> RuntimeGenesisConfig { - RuntimeGenesisConfig { - system: SystemConfig { - code: WASM_BINARY.expect("Rialto development WASM not available").to_vec(), - ..Default::default() - }, - balances: BalancesConfig { - balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 50)).collect(), - }, - babe: BabeConfig { - authorities: Vec::new(), - epoch_config: Some(rialto_runtime::BABE_GENESIS_EPOCH_CONFIG), - ..Default::default() - }, - beefy: BeefyConfig::default(), - grandpa: GrandpaConfig { authorities: Vec::new(), ..Default::default() }, - sudo: SudoConfig { key: Some(root_key) }, - session: SessionConfig { - keys: initial_authorities - .iter() - .map(|x| { - ( - x.0.clone(), - x.0.clone(), - session_keys( - x.1.clone(), - x.2.clone(), - x.3.clone(), - x.4.clone(), - x.5.clone(), - x.6.clone(), - ), - ) - }) - .collect::>(), - }, - authority_discovery: Default::default(), - hrmp: Default::default(), - // this configuration is exact copy of configuration from Polkadot repo - // (see /node/service/src/chain_spec.rs:default_parachains_host_configuration) - configuration: ConfigurationConfig { - config: polkadot_runtime_parachains::configuration::HostConfiguration { - validation_upgrade_cooldown: 2u32, - validation_upgrade_delay: 2, - code_retention_period: 1200, - max_code_size: polkadot_primitives::v6::MAX_CODE_SIZE, - max_pov_size: polkadot_primitives::v6::MAX_POV_SIZE, - max_head_data_size: 32 * 1024, - group_rotation_frequency: 20, - max_upward_queue_count: 8, - max_upward_queue_size: 1024 * 1024, - max_downward_message_size: 1024 * 1024, - max_upward_message_size: 50 * 1024, - max_upward_message_num_per_candidate: 5, - hrmp_sender_deposit: 0, - hrmp_recipient_deposit: 0, - hrmp_channel_max_capacity: 8, - hrmp_channel_max_total_size: 8 * 1024, - hrmp_max_parachain_inbound_channels: 4, - hrmp_channel_max_message_size: 1024 * 1024, - hrmp_max_parachain_outbound_channels: 4, - hrmp_max_message_num_per_candidate: 5, - dispute_period: 6, - no_show_slots: 2, - n_delay_tranches: 25, - needed_approvals: 2, - relay_vrf_modulo_samples: 2, - zeroth_delay_tranche_width: 0, - minimum_validation_upgrade_delay: 5, - ..Default::default() - }, - }, - paras: Default::default(), - bridge_millau_messages: BridgeMillauMessagesConfig { - owner: Some(get_account_id_from_seed::(MILLAU_MESSAGES_PALLET_OWNER)), - ..Default::default() - }, - xcm_pallet: Default::default(), - } -} diff --git a/bridges/bin/rialto/node/src/cli.rs b/bridges/bin/rialto/node/src/cli.rs deleted file mode 100644 index 521f2268bdc5e..0000000000000 --- a/bridges/bin/rialto/node/src/cli.rs +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use clap::Parser; -use sc_cli::RunCmd; - -#[derive(Debug, Parser)] -pub struct Cli { - #[structopt(subcommand)] - pub subcommand: Option, - - #[structopt(flatten)] - pub run: RunCmd, -} - -/// Possible subcommands of the main binary. -#[derive(Debug, Parser)] -#[allow(clippy::large_enum_variant)] -pub enum Subcommand { - /// Key management CLI utilities - #[clap(subcommand)] - Key(sc_cli::KeySubcommand), - - /// Verify a signature for a message, provided on `STDIN`, with a given (public or secret) key. - Verify(sc_cli::VerifyCmd), - - /// Generate a seed that provides a vanity address. - Vanity(sc_cli::VanityCmd), - - /// Sign a message, with a given (secret) key. - Sign(sc_cli::SignCmd), - - /// Build a chain specification. - BuildSpec(sc_cli::BuildSpecCmd), - - /// Validate blocks. - CheckBlock(sc_cli::CheckBlockCmd), - - /// Export blocks. - ExportBlocks(sc_cli::ExportBlocksCmd), - - /// Export the state of a given block into a chain spec. - ExportState(sc_cli::ExportStateCmd), - - /// Import blocks. - ImportBlocks(sc_cli::ImportBlocksCmd), - - /// Remove the whole chain. - PurgeChain(sc_cli::PurgeChainCmd), - - /// Revert the chain to a previous state. - Revert(sc_cli::RevertCmd), - - /// Inspect blocks or extrinsics. - Inspect(node_inspect::cli::InspectCmd), - - /// Benchmark runtime pallets. - #[command(subcommand)] - Benchmark(frame_benchmarking_cli::BenchmarkCmd), -} - -/// Validation worker command. -#[derive(Debug, Parser)] -pub struct ValidationWorkerCommand { - /// The path to the validation host's socket. - #[arg(long)] - pub socket_path: String, - /// Calling node implementation version - #[arg(long)] - pub node_impl_version: String, -} diff --git a/bridges/bin/rialto/node/src/command.rs b/bridges/bin/rialto/node/src/command.rs deleted file mode 100644 index 397f8a3e24e9b..0000000000000 --- a/bridges/bin/rialto/node/src/command.rs +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use crate::cli::{Cli, Subcommand}; -use frame_benchmarking_cli::BenchmarkCmd; -use rialto_runtime::{Block, RuntimeApi}; -use sc_cli::SubstrateCli; - -impl SubstrateCli for Cli { - fn impl_name() -> String { - "Rialto Bridge Node".into() - } - - fn impl_version() -> String { - env!("CARGO_PKG_VERSION").into() - } - - fn description() -> String { - "Rialto Bridge Node".into() - } - - fn author() -> String { - "Parity Technologies".into() - } - - fn support_url() -> String { - "https://github.com/paritytech/parity-bridges-common/".into() - } - - fn copyright_start_year() -> i32 { - 2019 - } - - fn executable_name() -> String { - "rialto-bridge-node".into() - } - - fn load_spec(&self, id: &str) -> Result, String> { - Ok(Box::new( - match id { - "" | "dev" => crate::chain_spec::Alternative::Development, - "local" => crate::chain_spec::Alternative::LocalTestnet, - _ => return Err(format!("Unsupported chain specification: {id}")), - } - .load(), - )) - } -} - -// Rialto native executor instance. -pub struct ExecutorDispatch; - -impl sc_executor::NativeExecutionDispatch for ExecutorDispatch { - type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; - - fn dispatch(method: &str, data: &[u8]) -> Option> { - rialto_runtime::api::dispatch(method, data) - } - - fn native_version() -> sc_executor::NativeVersion { - rialto_runtime::native_version() - } -} - -/// Parse and run command line arguments -pub fn run() -> sc_cli::Result<()> { - let cli = Cli::from_args(); - sp_core::crypto::set_default_ss58_version(sp_core::crypto::Ss58AddressFormat::custom( - rialto_runtime::SS58Prefix::get() as u16, - )); - - match &cli.subcommand { - Some(Subcommand::Benchmark(cmd)) => { - let runner = cli.create_runner(cmd)?; - match cmd { - BenchmarkCmd::Pallet(cmd) => - if cfg!(feature = "runtime-benchmarks") { - runner.sync_run(|config| cmd.run::(config)) - } else { - println!( - "Benchmarking wasn't enabled when building the node. \ - You can enable it with `--features runtime-benchmarks`." - ); - Ok(()) - }, - _ => Err("Unsupported benchmarking subcommand".into()), - } - }, - Some(Subcommand::Key(cmd)) => cmd.run(&cli), - Some(Subcommand::Sign(cmd)) => cmd.run(), - Some(Subcommand::Verify(cmd)) => cmd.run(), - Some(Subcommand::Vanity(cmd)) => cmd.run(), - Some(Subcommand::BuildSpec(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run(config.chain_spec, config.network)) - }, - Some(Subcommand::CheckBlock(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|mut config| { - let (client, _, import_queue, task_manager) = - polkadot_service::new_chain_ops(&mut config, None).map_err(service_error)?; - Ok((cmd.run(client, import_queue), task_manager)) - }) - }, - Some(Subcommand::ExportBlocks(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|mut config| { - let (client, _, _, task_manager) = - polkadot_service::new_chain_ops(&mut config, None).map_err(service_error)?; - Ok((cmd.run(client, config.database), task_manager)) - }) - }, - Some(Subcommand::ExportState(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|mut config| { - let (client, _, _, task_manager) = - polkadot_service::new_chain_ops(&mut config, None).map_err(service_error)?; - Ok((cmd.run(client, config.chain_spec), task_manager)) - }) - }, - Some(Subcommand::ImportBlocks(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|mut config| { - let (client, _, import_queue, task_manager) = - polkadot_service::new_chain_ops(&mut config, None).map_err(service_error)?; - Ok((cmd.run(client, import_queue), task_manager)) - }) - }, - Some(Subcommand::PurgeChain(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run(config.database)) - }, - Some(Subcommand::Revert(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.async_run(|mut config| { - let (client, backend, _, task_manager) = - polkadot_service::new_chain_ops(&mut config, None).map_err(service_error)?; - Ok((cmd.run(client, backend, None), task_manager)) - }) - }, - Some(Subcommand::Inspect(cmd)) => { - let runner = cli.create_runner(cmd)?; - runner.sync_run(|config| cmd.run::(config)) - }, - None => { - let runner = cli.create_runner(&cli.run)?; - - runner.run_node_until_exit(|config| async move { - polkadot_service::new_full( - config, - polkadot_service::NewFullParams { - is_parachain_node: polkadot_service::IsParachainNode::No, - grandpa_pause: None, - enable_beefy: true, - jaeger_agent: None, - telemetry_worker_handle: None, - node_version: None, - workers_path: None, - workers_names: Some(( - "rialto-bridge-node-prepare-worker".to_string(), - "rialto-bridge-node-execute-worker".to_string(), - )), - overseer_gen: polkadot_service::overseer::RealOverseerGen, - overseer_message_channel_capacity_override: None, - malus_finality_delay: None, - hwbench: None, - }, - ) - .map(|full| full.task_manager) - .map_err(service_error) - }) - }, - } -} - -// We don't want to change 'service.rs' too much to ease future updates => it'll keep using -// its own error enum like original polkadot service does. -fn service_error(err: polkadot_service::Error) -> sc_cli::Error { - sc_cli::Error::Application(Box::new(err)) -} diff --git a/bridges/bin/rialto/node/src/main.rs b/bridges/bin/rialto/node/src/main.rs deleted file mode 100644 index 6dea84a309b26..0000000000000 --- a/bridges/bin/rialto/node/src/main.rs +++ /dev/null @@ -1,28 +0,0 @@ -// 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 . - -//! Rialto bridge node. - -#![warn(missing_docs)] - -mod chain_spec; -mod cli; -mod command; - -/// Run the Rialto Node -fn main() -> sc_cli::Result<()> { - command::run() -} diff --git a/bridges/bin/rialto/node/src/workers/execute-worker.rs b/bridges/bin/rialto/node/src/workers/execute-worker.rs deleted file mode 100644 index 72cab799d753e..0000000000000 --- a/bridges/bin/rialto/node/src/workers/execute-worker.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Polkadot. - -// Polkadot 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. - -// Polkadot 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 Polkadot. If not, see . - -//! Execute worker. - -polkadot_node_core_pvf_common::decl_worker_main!( - "execute-worker", - polkadot_node_core_pvf_execute_worker::worker_entrypoint, - env!("SUBSTRATE_CLI_IMPL_VERSION") -); diff --git a/bridges/bin/rialto/node/src/workers/prepare-worker.rs b/bridges/bin/rialto/node/src/workers/prepare-worker.rs deleted file mode 100644 index 695f66cc7b7d3..0000000000000 --- a/bridges/bin/rialto/node/src/workers/prepare-worker.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Polkadot. - -// Polkadot 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. - -// Polkadot 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 Polkadot. If not, see . - -//! Prepare worker. - -polkadot_node_core_pvf_common::decl_worker_main!( - "prepare-worker", - polkadot_node_core_pvf_prepare_worker::worker_entrypoint, - env!("SUBSTRATE_CLI_IMPL_VERSION") -); diff --git a/bridges/bin/rialto/runtime/Cargo.toml b/bridges/bin/rialto/runtime/Cargo.toml deleted file mode 100644 index 5ef7d53bed4a1..0000000000000 --- a/bridges/bin/rialto/runtime/Cargo.toml +++ /dev/null @@ -1,153 +0,0 @@ -[package] -name = "rialto-runtime" -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2021" -repository = "https://github.com/paritytech/parity-bridges-common/" -license = "GPL-3.0-or-later WITH Classpath-exception-2.0" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } -scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } - -# Bridge dependencies - -bp-header-chain = { path = "../../../primitives/header-chain", default-features = false } -bp-messages = { path = "../../../primitives/messages", default-features = false } -bp-millau = { path = "../../../primitives/chain-millau", default-features = false } -bp-relayers = { path = "../../../primitives/relayers", default-features = false } -bp-rialto = { path = "../../../primitives/chain-rialto", default-features = false } -bp-runtime = { path = "../../../primitives/runtime", default-features = false } -bridge-runtime-common = { path = "../../runtime-common", default-features = false } -pallet-bridge-beefy = { path = "../../../modules/beefy", default-features = false } -pallet-bridge-grandpa = { path = "../../../modules/grandpa", default-features = false } -pallet-bridge-messages = { path = "../../../modules/messages", default-features = false } -pallet-bridge-relayers = { path = "../../../modules/relayers", default-features = false } -pallet-shift-session-manager = { path = "../../../modules/shift-session-manager", default-features = false } - -# Substrate Dependencies - -sp-consensus-beefy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false, optional = true } -frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false, optional = true } -frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-babe = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-beefy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-beefy-mmr = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-message-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-mmr = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-offences = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false, features = ["historical"]} -pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-consensus-babe = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-version = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } - -# Polkadot (parachain) Dependencies -pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } - -[dev-dependencies] -bridge-runtime-common = { path = "../../runtime-common", features = ["integrity-test"] } -env_logger = "0.10" -static_assertions = "1.1" - -[build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } - -[features] -default = [ "std" ] -std = [ - "bp-messages/std", - "bp-millau/std", - "bp-relayers/std", - "bp-rialto/std", - "bp-runtime/std", - "bridge-runtime-common/std", - "codec/std", - "frame-benchmarking/std", - "frame-executive/std", - "frame-support/std", - "frame-system-rpc-runtime-api/std", - "frame-system/std", - "pallet-authority-discovery/std", - "pallet-authorship/std", - "pallet-babe/std", - "pallet-balances/std", - "pallet-beefy-mmr/std", - "pallet-beefy/std", - "pallet-bridge-beefy/std", - "pallet-bridge-grandpa/std", - "pallet-bridge-messages/std", - "pallet-bridge-relayers/std", - "pallet-grandpa/std", - "pallet-message-queue/std", - "pallet-mmr/std", - "pallet-offences/std", - "pallet-session/std", - "pallet-shift-session-manager/std", - "pallet-sudo/std", - "pallet-timestamp/std", - "pallet-transaction-payment-rpc-runtime-api/std", - "pallet-transaction-payment/std", - "pallet-xcm/std", - "polkadot-primitives/std", - "polkadot-runtime-common/std", - "polkadot-runtime-parachains/std", - "scale-info/std", - "sp-api/std", - "sp-authority-discovery/std", - "sp-block-builder/std", - "sp-consensus-babe/std", - "sp-consensus-beefy/std", - "sp-core/std", - "sp-inherents/std", - "sp-io/std", - "sp-offchain/std", - "sp-runtime/std", - "sp-session/std", - "sp-std/std", - "sp-transaction-pool/std", - "sp-version/std", - "xcm-builder/std", - "xcm-executor/std", - "xcm/std", -] -runtime-benchmarks = [ - "bridge-runtime-common/runtime-benchmarks", - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "pallet-bridge-grandpa/runtime-benchmarks", - "pallet-bridge-messages/runtime-benchmarks", - "pallet-bridge-relayers/runtime-benchmarks", - "pallet-message-queue/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks", - "polkadot-runtime-common/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", - "xcm-builder/runtime-benchmarks", -] diff --git a/bridges/bin/rialto/runtime/build.rs b/bridges/bin/rialto/runtime/build.rs deleted file mode 100644 index 25e220e46fc3b..0000000000000 --- a/bridges/bin/rialto/runtime/build.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use substrate_wasm_builder::WasmBuilder; - -fn main() { - WasmBuilder::new() - .with_current_project() - .import_memory() - .export_heap_base() - .disable_runtime_version_section_check() - .build() -} diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs deleted file mode 100644 index 684b3e5bf466f..0000000000000 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ /dev/null @@ -1,1074 +0,0 @@ -// 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 . - -//! The Rialto runtime. This can be compiled with `#[no_std]`, ready for Wasm. - -#![cfg_attr(not(feature = "std"), no_std)] -// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. -#![recursion_limit = "256"] -// Runtime-generated enums -#![allow(clippy::large_enum_variant)] -// From construct_runtime macro -#![allow(clippy::from_over_into)] - -// Make the WASM binary available. -#[cfg(feature = "std")] -include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); - -pub mod millau_messages; -pub mod parachains; -pub mod xcm_config; - -use bp_runtime::HeaderId; -use pallet_grandpa::{ - fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList, -}; -use pallet_transaction_payment::{FeeDetails, Multiplier, RuntimeDispatchInfo}; -use polkadot_primitives::Id as ParaId; -use polkadot_runtime_parachains::runtime_api_impl::{ - v7 as parachains_runtime_api_impl, vstaging as parachains_staging_runtime_api_impl, -}; -use sp_api::impl_runtime_apis; -use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; -use sp_consensus_beefy::{ecdsa_crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion, ValidatorSet}; -use sp_core::OpaqueMetadata; -use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, - traits::{AccountIdLookup, Block as BlockT, Keccak256, NumberFor, OpaqueKeys}, - transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, FixedPointNumber, KeyTypeId, Perquintill, -}; -use sp_std::{collections::btree_map::BTreeMap, prelude::*}; -#[cfg(feature = "std")] -use sp_version::NativeVersion; -use sp_version::RuntimeVersion; - -// A few exports that help ease life for downstream crates. -pub use frame_support::{ - construct_runtime, - dispatch::DispatchClass, - parameter_types, - traits::{ - ConstU32, ConstU64, ConstU8, Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem, - }, - weights::{constants::WEIGHT_REF_TIME_PER_SECOND, IdentityFee, RuntimeDbWeight, Weight}, - StorageValue, -}; - -pub use frame_system::Call as SystemCall; -pub use pallet_balances::Call as BalancesCall; -pub use pallet_bridge_beefy::Call as BridgeBeefyCall; -pub use pallet_bridge_grandpa::Call as BridgeGrandpaCall; -pub use pallet_bridge_messages::Call as MessagesCall; -pub use pallet_sudo::Call as SudoCall; -pub use pallet_timestamp::Call as TimestampCall; -pub use pallet_xcm::Call as XcmCall; - -#[cfg(any(feature = "std", test))] -pub use sp_runtime::BuildStorage; -pub use sp_runtime::{Perbill, Permill}; - -/// An index to a block. -pub type BlockNumber = bp_rialto::BlockNumber; - -/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. -pub type Signature = bp_rialto::Signature; - -/// Some way of identifying an account on the chain. We intentionally make it equivalent -/// to the public key of our transaction signing scheme. -pub type AccountId = bp_rialto::AccountId; - -/// The type for looking up accounts. We don't expect more than 4 billion of them, but you -/// never know... -pub type AccountIndex = u32; - -/// Balance of an account. -pub type Balance = bp_rialto::Balance; - -/// Nonce of a transaction in the chain. -pub type Nonce = bp_rialto::Nonce; - -/// A hash of some data used by the chain. -pub type Hash = bp_rialto::Hash; - -/// Hashing algorithm used by the chain. -pub type Hashing = bp_rialto::Hasher; - -/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know -/// the specifics of the runtime. They can then be made to be agnostic over specific formats -/// of data like extrinsics, allowing for them to continue syncing the network through upgrades -/// to even the core data structures. -pub mod opaque { - use super::*; - - pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; - - /// Opaque block header type. - pub type Header = generic::Header; - /// Opaque block type. - pub type Block = generic::Block; - /// Opaque block identifier type. - pub type BlockId = generic::BlockId; -} - -impl_opaque_keys! { - pub struct SessionKeys { - pub babe: Babe, - pub grandpa: Grandpa, - pub beefy: Beefy, - pub para_validator: Initializer, - pub para_assignment: SessionInfo, - pub authority_discovery: AuthorityDiscovery, - } -} - -/// This runtime version. -#[sp_version::runtime_version] -pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: create_runtime_str!("rialto-runtime"), - impl_name: create_runtime_str!("rialto-runtime"), - authoring_version: 1, - spec_version: 1, - impl_version: 1, - apis: RUNTIME_API_VERSIONS, - transaction_version: 1, - state_version: 1, -}; - -/// The version information used to identify this runtime when compiled natively. -#[cfg(feature = "std")] -pub fn native_version() -> NativeVersion { - NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } -} - -parameter_types! { - pub const BlockHashCount: BlockNumber = 250; - pub const Version: RuntimeVersion = VERSION; - pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight { - read: 60_000_000, // ~0.06 ms = ~60 µs - write: 200_000_000, // ~0.2 ms = 200 µs - }; - pub const SS58Prefix: u8 = 48; -} - -impl frame_system::Config for Runtime { - /// The basic call filter to use in dispatchable. - type BaseCallFilter = frame_support::traits::Everything; - /// The identifier used to distinguish between accounts. - type AccountId = AccountId; - /// The aggregated dispatch type that is available for extrinsics. - type RuntimeCall = RuntimeCall; - /// The lookup mechanism to get account ID from whatever is passed in dispatchers. - type Lookup = AccountIdLookup; - /// The index type for storing how many extrinsics an account has signed. - type Nonce = Nonce; - /// The type for hashing blocks and tries. - type Hash = Hash; - /// The hashing algorithm used. - type Hashing = Hashing; - /// The header type. - type Block = Block; - /// The ubiquitous event type. - type RuntimeEvent = RuntimeEvent; - /// The ubiquitous origin type. - type RuntimeOrigin = RuntimeOrigin; - /// Maximum number of block number to block hash mappings to keep (oldest pruned first). - type BlockHashCount = BlockHashCount; - /// Version of the runtime. - type Version = Version; - /// Provides information about the pallet setup in the runtime. - type PalletInfo = PalletInfo; - /// What to do if a new account is created. - type OnNewAccount = (); - /// What to do if an account is fully reaped from the system. - type OnKilledAccount = (); - /// The data to be stored in an account. - type AccountData = pallet_balances::AccountData; - // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) - /// Weight information for the extrinsics of this pallet. - type SystemWeightInfo = (); - /// Block and extrinsics weights: base values and limits. - type BlockWeights = bp_rialto::BlockWeights; - /// The maximum length of a block (in bytes). - type BlockLength = bp_rialto::BlockLength; - /// The weight of database operations that the runtime can invoke. - type DbWeight = DbWeight; - /// The designated SS58 prefix of this chain. - type SS58Prefix = SS58Prefix; - /// The set code logic, just the default since we're not a parachain. - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -/// The BABE epoch configuration at genesis. -pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration = - sp_consensus_babe::BabeEpochConfiguration { - c: bp_rialto::time_units::PRIMARY_PROBABILITY, - allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryVRFSlots, - }; - -parameter_types! { - pub const EpochDuration: u64 = bp_rialto::EPOCH_DURATION_IN_SLOTS as u64; - pub const ExpectedBlockTime: bp_rialto::Moment = bp_rialto::time_units::MILLISECS_PER_BLOCK; - pub ReportLongevity: u64 = EpochDuration::get() * 10; -} - -impl pallet_babe::Config for Runtime { - type EpochDuration = EpochDuration; - type ExpectedBlockTime = ExpectedBlockTime; - // session module is the trigger - type EpochChangeTrigger = pallet_babe::ExternalTrigger; - - type DisabledValidators = (); - - type WeightInfo = (); - - type MaxAuthorities = ConstU32<10>; - - // equivocation related configuration - we don't expect any equivocations in our testnets - type KeyOwnerProof = sp_core::Void; - type EquivocationReportSystem = (); - - type MaxNominators = ConstU32<256>; -} - -impl pallet_beefy::Config for Runtime { - type BeefyId = BeefyId; - type MaxAuthorities = ConstU32<10>; - type MaxSetIdSessionEntries = ConstU64<0>; - type OnNewValidatorSet = MmrLeaf; - type WeightInfo = (); - type KeyOwnerProof = sp_core::Void; - type EquivocationReportSystem = (); - type MaxNominators = ConstU32<256>; -} - -impl pallet_grandpa::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) - type WeightInfo = (); - type MaxAuthorities = ConstU32<10>; - type MaxSetIdSessionEntries = ConstU64<0>; - type KeyOwnerProof = >::Proof; - type EquivocationReportSystem = - pallet_grandpa::EquivocationReportSystem; - type MaxNominators = ConstU32<256>; -} - -impl pallet_mmr::Config for Runtime { - const INDEXING_PREFIX: &'static [u8] = b"mmr"; - type Hashing = Keccak256; - type LeafData = pallet_beefy_mmr::Pallet; - type OnNewRoot = pallet_beefy_mmr::DepositBeefyDigest; - type WeightInfo = (); -} - -parameter_types! { - /// Version of the produced MMR leaf. - /// - /// The version consists of two parts; - /// - `major` (3 bits) - /// - `minor` (5 bits) - /// - /// `major` should be updated only if decoding the previous MMR Leaf format from the payload - /// is not possible (i.e. backward incompatible change). - /// `minor` should be updated if fields are added to the previous MMR Leaf, which given SCALE - /// encoding does not prevent old leafs from being decoded. - /// - /// Hence we expect `major` to be changed really rarely (think never). - /// See [`MmrLeafVersion`] type documentation for more details. - pub LeafVersion: MmrLeafVersion = MmrLeafVersion::new(0, 0); -} - -pub struct BeefyDummyDataProvider; - -impl sp_consensus_beefy::mmr::BeefyDataProvider<()> for BeefyDummyDataProvider { - fn extra_data() {} -} - -impl pallet_beefy_mmr::Config for Runtime { - type LeafVersion = LeafVersion; - type BeefyAuthorityToMerkleLeaf = pallet_beefy_mmr::BeefyEcdsaToEthereum; - type LeafExtra = (); - type BeefyDataProvider = BeefyDummyDataProvider; -} - -parameter_types! { - pub const MinimumPeriod: u64 = bp_rialto::SLOT_DURATION / 2; -} - -impl pallet_timestamp::Config for Runtime { - /// A timestamp: milliseconds since the UNIX epoch. - type Moment = bp_rialto::Moment; - type OnTimestampSet = Babe; - type MinimumPeriod = MinimumPeriod; - // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) - type WeightInfo = (); -} - -parameter_types! { - pub const ExistentialDeposit: bp_rialto::Balance = 500; -} - -impl pallet_balances::Config for Runtime { - /// The type for recording an account's balance. - type Balance = Balance; - /// The ubiquitous event type. - type RuntimeEvent = RuntimeEvent; - type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; - type AccountStore = System; - // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) - type WeightInfo = (); - // For weight estimation, we assume that the most locks on an individual account will be 50. - // This number may need to be adjusted in the future if this assumption no longer holds true. - type MaxLocks = ConstU32<50>; - type MaxReserves = ConstU32<50>; - type ReserveIdentifier = [u8; 8]; - type RuntimeHoldReason = RuntimeHoldReason; - type FreezeIdentifier = (); - type MaxHolds = ConstU32<0>; - type MaxFreezes = ConstU32<0>; -} - -parameter_types! { - pub const TransactionBaseFee: Balance = 0; - pub const TransactionByteFee: Balance = 1; - // values for following parameters are copied from polkadot repo, but it is fine - // not to sync them - we're not going to make Rialto a full copy of one of Polkadot-like chains - pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); - pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(3, 100_000); - pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000u128); - pub MaximumMultiplier: Multiplier = sp_runtime::traits::Bounded::max_value(); -} - -impl pallet_transaction_payment::Config for Runtime { - type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; - type OperationalFeeMultiplier = ConstU8<5>; - type WeightToFee = bp_rialto::WeightToFee; - type LengthToFee = bp_rialto::WeightToFee; - type FeeMultiplierUpdate = pallet_transaction_payment::TargetedFeeAdjustment< - Runtime, - TargetBlockFullness, - AdjustmentVariable, - MinimumMultiplier, - MaximumMultiplier, - >; - type RuntimeEvent = RuntimeEvent; -} - -impl pallet_sudo::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type WeightInfo = pallet_sudo::weights::SubstrateWeight; -} - -impl pallet_session::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type ValidatorId = ::AccountId; - type ValidatorIdOf = (); - type ShouldEndSession = Babe; - type NextSessionRotation = Babe; - type SessionManager = pallet_shift_session_manager::Pallet; - type SessionHandler = ::KeyTypeIdProviders; - type Keys = SessionKeys; - // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) - type WeightInfo = (); -} - -impl pallet_authorship::Config for Runtime { - type FindAuthor = pallet_session::FindAccountFromAuthorIndex; - type EventHandler = (); -} - -pub struct FullIdentificationOf; -impl sp_runtime::traits::Convert> for FullIdentificationOf { - fn convert(_: AccountId) -> Option<()> { - Some(()) - } -} - -impl pallet_session::historical::Config for Runtime { - type FullIdentification = (); - type FullIdentificationOf = FullIdentificationOf; -} - -impl pallet_offences::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type IdentificationTuple = pallet_session::historical::IdentificationTuple; - type OnOffenceHandler = (); -} - -impl pallet_authority_discovery::Config for Runtime { - type MaxAuthorities = ConstU32<10>; -} - -impl pallet_bridge_relayers::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Reward = Balance; - type PaymentProcedure = - bp_relayers::PayRewardFromAccount, AccountId>; - type StakeAndSlash = (); - type WeightInfo = (); -} - -pub type MillauGrandpaInstance = (); -impl pallet_bridge_grandpa::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type BridgedChain = bp_millau::Millau; - type MaxFreeMandatoryHeadersPerBlock = ConstU32<4>; - type HeadersToKeep = ConstU32<{ bp_millau::DAYS as u32 }>; - type WeightInfo = pallet_bridge_grandpa::weights::BridgeWeight; -} - -impl pallet_shift_session_manager::Config for Runtime {} - -parameter_types! { - pub const MaxMessagesToPruneAtOnce: bp_messages::MessageNonce = 8; - pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_messages::MessageNonce = - bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; - pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce = - bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; - pub const RootAccountForPayments: Option = None; - pub const BridgedChainId: bp_runtime::ChainId = bp_runtime::MILLAU_CHAIN_ID; - pub ActiveOutboundLanes: &'static [bp_messages::LaneId] = &[millau_messages::XCM_LANE]; -} - -/// Instance of the messages pallet used to relay messages to/from Millau chain. -pub type WithMillauMessagesInstance = (); - -impl pallet_bridge_messages::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_bridge_messages::weights::BridgeWeight; - type ActiveOutboundLanes = ActiveOutboundLanes; - type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane; - type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane; - - type MaximalOutboundPayloadSize = crate::millau_messages::ToMillauMaximalOutboundPayloadSize; - type OutboundPayload = crate::millau_messages::ToMillauMessagePayload; - - type InboundPayload = crate::millau_messages::FromMillauMessagePayload; - type InboundRelayer = bp_millau::AccountId; - type DeliveryPayments = (); - - type TargetHeaderChain = crate::millau_messages::MillauAsTargetHeaderChain; - type LaneMessageVerifier = crate::millau_messages::ToMillauMessageVerifier; - type DeliveryConfirmationPayments = pallet_bridge_relayers::DeliveryConfirmationPaymentsAdapter< - Runtime, - WithMillauMessagesInstance, - frame_support::traits::ConstU128<100_000>, - >; - type OnMessagesDelivered = (); - - type SourceHeaderChain = crate::millau_messages::MillauAsSourceHeaderChain; - type MessageDispatch = crate::millau_messages::FromMillauMessageDispatch; - type BridgedChainId = BridgedChainId; -} - -pub type MillauBeefyInstance = (); -impl pallet_bridge_beefy::Config for Runtime { - type MaxRequests = frame_support::traits::ConstU32<16>; - type CommitmentsToKeep = frame_support::traits::ConstU32<8>; - type BridgedChain = bp_millau::Millau; -} - -construct_runtime!( - pub enum Runtime { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - Sudo: pallet_sudo::{Pallet, Call, Config, Storage, Event}, - - // Must be before session. - Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned}, - - Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, - - // Consensus support. - // Authorship must be before session in order to note author in the correct session and era - // for im-online. - Authorship: pallet_authorship::{Pallet, Storage}, - Offences: pallet_offences::{Pallet, Storage, Event}, - Historical: pallet_session::historical::{Pallet}, - - AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config}, - Session: pallet_session::{Pallet, Call, Storage, Event, Config}, - Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event}, - ShiftSessionManager: pallet_shift_session_manager::{Pallet}, - - // BEEFY Bridges support. - Beefy: pallet_beefy::{Pallet, Storage, Config}, - Mmr: pallet_mmr::{Pallet, Storage}, - MmrLeaf: pallet_beefy_mmr::{Pallet, Storage}, - - // Millau bridge modules. - BridgeRelayers: pallet_bridge_relayers::{Pallet, Call, Storage, Event}, - BridgeMillauGrandpa: pallet_bridge_grandpa::{Pallet, Call, Storage, Event}, - BridgeMillauMessages: pallet_bridge_messages::{Pallet, Call, Storage, Event, Config}, - - // Millau bridge modules (BEEFY based). - BridgeMillauBeefy: pallet_bridge_beefy::{Pallet, Call, Storage}, - - // Parachain modules. - ParachainsOrigin: polkadot_runtime_parachains::origin::{Pallet, Origin}, - Configuration: polkadot_runtime_parachains::configuration::{Pallet, Call, Storage, Config}, - Shared: polkadot_runtime_parachains::shared::{Pallet, Call, Storage}, - ParaInclusion: polkadot_runtime_parachains::inclusion::{Pallet, Call, Storage, Event}, - ParasInherent: polkadot_runtime_parachains::paras_inherent::{Pallet, Call, Storage, Inherent}, - Scheduler: polkadot_runtime_parachains::scheduler::{Pallet, Storage}, - Paras: polkadot_runtime_parachains::paras::{Pallet, Call, Storage, Event, Config, ValidateUnsigned}, - Initializer: polkadot_runtime_parachains::initializer::{Pallet, Call, Storage}, - Dmp: polkadot_runtime_parachains::dmp::{Pallet, Storage}, - Hrmp: polkadot_runtime_parachains::hrmp::{Pallet, Call, Storage, Event, Config}, - SessionInfo: polkadot_runtime_parachains::session_info::{Pallet, Storage}, - ParaSessionInfo: polkadot_runtime_parachains::session_info::{Pallet, Storage}, - ParasDisputes: polkadot_runtime_parachains::disputes::{Pallet, Call, Storage, Event}, - ParasSlashing: polkadot_runtime_parachains::disputes::slashing::{Pallet, Call, Storage, ValidateUnsigned}, - ParaAssignmentProvider: polkadot_runtime_parachains::assigner_parachains::{Pallet}, - MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event}, - - // Parachain Onboarding Pallets - Registrar: polkadot_runtime_common::paras_registrar::{Pallet, Call, Storage, Event}, - Slots: polkadot_runtime_common::slots::{Pallet, Call, Storage, Event}, - ParasSudoWrapper: polkadot_runtime_common::paras_sudo_wrapper::{Pallet, Call}, - - // Pallet for sending XCM. - XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event, Origin, Config} = 99, - } -); - -/// The address format for describing accounts. -pub type Address = sp_runtime::MultiAddress; -/// Block header type as expected by this runtime. -pub type Header = generic::Header; -/// Block type as expected by this runtime. -pub type Block = generic::Block; -/// A Block signed with a Justification -pub type SignedBlock = generic::SignedBlock; -/// BlockId type as expected by this runtime. -pub type BlockId = generic::BlockId; -/// The SignedExtension to the basic transaction logic. -pub type SignedExtra = ( - frame_system::CheckNonZeroSender, - frame_system::CheckSpecVersion, - frame_system::CheckTxVersion, - frame_system::CheckGenesis, - frame_system::CheckEra, - frame_system::CheckNonce, - frame_system::CheckWeight, - pallet_transaction_payment::ChargeTransactionPayment, -); -/// The payload being signed in transactions. -pub type SignedPayload = generic::SignedPayload; -/// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = - generic::UncheckedExtrinsic; -/// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; -/// Executive: handles dispatch to the various modules. -pub type Executive = frame_executive::Executive< - Runtime, - Block, - frame_system::ChainContext, - Runtime, - AllPalletsWithSystem, ->; - -/// MMR helper types. -mod mmr { - use super::Runtime; - pub use pallet_mmr::primitives::*; - - pub type Leaf = <::LeafData as LeafDataProvider>::LeafData; - pub type Hashing = ::Hashing; - pub type Hash = ::Output; -} - -impl_runtime_apis! { - impl sp_api::Core for Runtime { - fn version() -> RuntimeVersion { - VERSION - } - - fn execute_block(block: Block) { - Executive::execute_block(block); - } - - fn initialize_block(header: &::Header) { - Executive::initialize_block(header) - } - } - - impl sp_api::Metadata for Runtime { - fn metadata() -> OpaqueMetadata { - OpaqueMetadata::new(Runtime::metadata().into()) - } - - fn metadata_at_version(version: u32) -> Option { - Runtime::metadata_at_version(version) - } - - fn metadata_versions() -> sp_std::vec::Vec { - Runtime::metadata_versions() - } - } - - impl sp_block_builder::BlockBuilder for Runtime { - fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { - Executive::apply_extrinsic(extrinsic) - } - - fn finalize_block() -> ::Header { - Executive::finalize_block() - } - - fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { - data.create_extrinsics() - } - - fn check_inherents( - block: Block, - data: sp_inherents::InherentData, - ) -> sp_inherents::CheckInherentsResult { - data.check_extrinsics(&block) - } - } - - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Nonce { - System::account_nonce(account) - } - } - - impl sp_consensus_beefy::BeefyApi for Runtime { - fn beefy_genesis() -> Option { - Beefy::genesis_block() - } - - fn validator_set() -> Option> { - Beefy::validator_set() - } - - fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: sp_consensus_beefy::EquivocationProof< - NumberFor, - sp_consensus_beefy::ecdsa_crypto::AuthorityId, - sp_consensus_beefy::ecdsa_crypto::Signature - >, - _key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, - ) -> Option<()> { None } - - fn generate_key_ownership_proof( - _set_id: sp_consensus_beefy::ValidatorSetId, - _authority_id: sp_consensus_beefy::ecdsa_crypto::AuthorityId, - ) -> Option { None } - } - - impl pallet_mmr::primitives::MmrApi< - Block, - mmr::Hash, - BlockNumber, - > for Runtime { - fn mmr_root() -> Result { - Ok(Mmr::mmr_root()) - } - - fn mmr_leaf_count() -> Result { - Ok(Mmr::mmr_leaves()) - } - - fn generate_proof( - block_numbers: Vec, - best_known_block_number: Option, - ) -> Result<(Vec, mmr::Proof), mmr::Error> { - Mmr::generate_proof(block_numbers, best_known_block_number).map( - |(leaves, proof)| { - ( - leaves - .into_iter() - .map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf)) - .collect(), - proof, - ) - }, - ) - } - - fn verify_proof(leaves: Vec, proof: mmr::Proof) - -> Result<(), mmr::Error> - { - let leaves = leaves.into_iter().map(|leaf| - leaf.into_opaque_leaf() - .try_decode() - .ok_or(mmr::Error::Verify)).collect::, mmr::Error>>()?; - Mmr::verify_leaves(leaves, proof) - } - - fn verify_proof_stateless( - root: mmr::Hash, - leaves: Vec, - proof: mmr::Proof - ) -> Result<(), mmr::Error> { - let nodes = leaves.into_iter().map(|leaf|mmr::DataOrHash::Data(leaf.into_opaque_leaf())).collect(); - pallet_mmr::verify_leaves_proof::(root, nodes, proof) - } - } - - impl bp_millau::MillauFinalityApi for Runtime { - fn best_finalized() -> Option> { - BridgeMillauGrandpa::best_finalized() - } - - fn synced_headers_grandpa_info( - ) -> Vec> { - BridgeMillauGrandpa::synced_headers_grandpa_info() - } - } - - impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { - fn validate_transaction( - source: TransactionSource, - tx: ::Extrinsic, - block_hash: ::Hash, - ) -> TransactionValidity { - Executive::validate_transaction(source, tx, block_hash) - } - } - - impl sp_offchain::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { - Executive::offchain_worker(header) - } - } - - impl sp_consensus_babe::BabeApi for Runtime { - fn configuration() -> sp_consensus_babe::BabeConfiguration { - // The choice of `c` parameter (where `1 - c` represents the - // probability of a slot being empty), is done in accordance to the - // slot duration and expected target block time, for safely - // resisting network delays of maximum two seconds. - // - sp_consensus_babe::BabeConfiguration { - slot_duration: Babe::slot_duration(), - epoch_length: EpochDuration::get(), - c: BABE_GENESIS_EPOCH_CONFIG.c, - authorities: Babe::authorities().to_vec(), - randomness: Babe::randomness(), - allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots, - } - } - - fn current_epoch_start() -> sp_consensus_babe::Slot { - Babe::current_epoch_start() - } - - fn current_epoch() -> sp_consensus_babe::Epoch { - Babe::current_epoch() - } - - fn next_epoch() -> sp_consensus_babe::Epoch { - Babe::next_epoch() - } - - fn generate_key_ownership_proof( - _slot: sp_consensus_babe::Slot, - _authority_id: sp_consensus_babe::AuthorityId, - ) -> Option { - None - } - - fn submit_report_equivocation_unsigned_extrinsic( - equivocation_proof: sp_consensus_babe::EquivocationProof<::Header>, - key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof, - ) -> Option<()> { - let key_owner_proof = key_owner_proof.decode()?; - - Babe::submit_unsigned_equivocation_report( - equivocation_proof, - key_owner_proof, - ) - } - } - - #[api_version(8)] - impl polkadot_primitives::runtime_api::ParachainHost for Runtime { - fn validators() -> Vec { - parachains_runtime_api_impl::validators::() - } - - fn validator_groups() -> (Vec>, polkadot_primitives::GroupRotationInfo) { - parachains_runtime_api_impl::validator_groups::() - } - - fn availability_cores() -> Vec> { - parachains_runtime_api_impl::availability_cores::() - } - - fn persisted_validation_data(para_id: ParaId, assumption: polkadot_primitives::OccupiedCoreAssumption) - -> Option> { - parachains_runtime_api_impl::persisted_validation_data::(para_id, assumption) - } - - fn assumed_validation_data( - para_id: ParaId, - expected_persisted_validation_data_hash: Hash, - ) -> Option<(polkadot_primitives::PersistedValidationData, polkadot_primitives::ValidationCodeHash)> { - parachains_runtime_api_impl::assumed_validation_data::( - para_id, - expected_persisted_validation_data_hash, - ) - } - - fn check_validation_outputs( - para_id: ParaId, - outputs: polkadot_primitives::CandidateCommitments, - ) -> bool { - parachains_runtime_api_impl::check_validation_outputs::(para_id, outputs) - } - - fn session_index_for_child() -> polkadot_primitives::SessionIndex { - parachains_runtime_api_impl::session_index_for_child::() - } - - fn validation_code(para_id: ParaId, assumption: polkadot_primitives::OccupiedCoreAssumption) - -> Option { - parachains_runtime_api_impl::validation_code::(para_id, assumption) - } - - fn candidate_pending_availability(para_id: ParaId) -> Option> { - parachains_runtime_api_impl::candidate_pending_availability::(para_id) - } - - fn candidate_events() -> Vec> { - parachains_runtime_api_impl::candidate_events::(|ev| { - match ev { - RuntimeEvent::ParaInclusion(ev) => { - Some(ev) - } - _ => None, - } - }) - } - - fn session_info(index: polkadot_primitives::SessionIndex) -> Option { - parachains_runtime_api_impl::session_info::(index) - } - - fn session_executor_params(session_index: polkadot_primitives::SessionIndex) -> Option { - parachains_runtime_api_impl::session_executor_params::(session_index) - } - - fn dmq_contents(recipient: ParaId) -> Vec> { - parachains_runtime_api_impl::dmq_contents::(recipient) - } - - fn inbound_hrmp_channels_contents( - recipient: ParaId - ) -> BTreeMap>> { - parachains_runtime_api_impl::inbound_hrmp_channels_contents::(recipient) - } - - fn validation_code_by_hash(hash: polkadot_primitives::ValidationCodeHash) -> Option { - parachains_runtime_api_impl::validation_code_by_hash::(hash) - } - - fn on_chain_votes() -> Option> { - parachains_runtime_api_impl::on_chain_votes::() - } - - fn submit_pvf_check_statement( - stmt: polkadot_primitives::PvfCheckStatement, - signature: polkadot_primitives::ValidatorSignature - ) { - parachains_runtime_api_impl::submit_pvf_check_statement::(stmt, signature) - } - - fn pvfs_require_precheck() -> Vec { - parachains_runtime_api_impl::pvfs_require_precheck::() - } - - fn validation_code_hash(para_id: ParaId, assumption: polkadot_primitives::OccupiedCoreAssumption) - -> Option - { - parachains_runtime_api_impl::validation_code_hash::(para_id, assumption) - } - - fn disputes() -> Vec<(polkadot_primitives::SessionIndex, polkadot_primitives::CandidateHash, polkadot_primitives::DisputeState)> { - parachains_runtime_api_impl::get_session_disputes::() - } - - fn unapplied_slashes( - ) -> Vec<(polkadot_primitives::SessionIndex, polkadot_primitives::CandidateHash, polkadot_primitives::slashing::PendingSlashes)> { - parachains_runtime_api_impl::unapplied_slashes::() - } - - fn key_ownership_proof( - validator_id: polkadot_primitives::ValidatorId, - ) -> Option { - use codec::Encode; - - Historical::prove((polkadot_primitives::PARACHAIN_KEY_TYPE_ID, validator_id)) - .map(|p| p.encode()) - .map(polkadot_primitives::slashing::OpaqueKeyOwnershipProof::new) - } - - fn submit_report_dispute_lost( - dispute_proof: polkadot_primitives::slashing::DisputeProof, - key_ownership_proof: polkadot_primitives::slashing::OpaqueKeyOwnershipProof, - ) -> Option<()> { - parachains_runtime_api_impl::submit_unsigned_slashing_report::( - dispute_proof, - key_ownership_proof, - ) - } - - fn minimum_backing_votes() -> u32 { - parachains_runtime_api_impl::minimum_backing_votes::() - } - - fn para_backing_state(para_id: ParaId) -> Option { - parachains_runtime_api_impl::backing_state::(para_id) - } - - fn async_backing_params() -> polkadot_primitives::AsyncBackingParams { - parachains_runtime_api_impl::async_backing_params::() - } - - fn disabled_validators() -> Vec { - parachains_staging_runtime_api_impl::disabled_validators::() - } - - } - - impl sp_authority_discovery::AuthorityDiscoveryApi for Runtime { - fn authorities() -> Vec { - parachains_runtime_api_impl::relevant_authority_ids::() - } - } - - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi< - Block, - Balance, - > for Runtime { - fn query_info(uxt: ::Extrinsic, len: u32) -> RuntimeDispatchInfo { - TransactionPayment::query_info(uxt, len) - } - fn query_fee_details(uxt: ::Extrinsic, len: u32) -> FeeDetails { - TransactionPayment::query_fee_details(uxt, len) - } - fn query_weight_to_fee(weight: Weight) -> Balance { - TransactionPayment::weight_to_fee(weight) - } - fn query_length_to_fee(length: u32) -> Balance { - TransactionPayment::length_to_fee(length) - } - } - - impl sp_session::SessionKeys for Runtime { - fn generate_session_keys(seed: Option>) -> Vec { - SessionKeys::generate(seed) - } - - fn decode_session_keys( - encoded: Vec, - ) -> Option, sp_core::crypto::KeyTypeId)>> { - SessionKeys::decode_into_raw_public_keys(&encoded) - } - } - - impl fg_primitives::GrandpaApi for Runtime { - fn current_set_id() -> fg_primitives::SetId { - Grandpa::current_set_id() - } - - fn grandpa_authorities() -> GrandpaAuthorityList { - Grandpa::grandpa_authorities() - } - - fn submit_report_equivocation_unsigned_extrinsic( - equivocation_proof: fg_primitives::EquivocationProof< - ::Hash, - NumberFor, - >, - key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof, - ) -> Option<()> { - let key_owner_proof = key_owner_proof.decode()?; - - Grandpa::submit_unsigned_equivocation_report( - equivocation_proof, - key_owner_proof, - ) - } - - fn generate_key_ownership_proof( - _set_id: fg_primitives::SetId, - _authority_id: GrandpaId, - ) -> Option { - // NOTE: this is the only implementation possible since we've - // defined our key owner proof type as a bottom type (i.e. a type - // with no values). - None - } - } - - impl bp_millau::ToMillauOutboundLaneApi for Runtime { - fn message_details( - lane: bp_messages::LaneId, - begin: bp_messages::MessageNonce, - end: bp_messages::MessageNonce, - ) -> Vec { - bridge_runtime_common::messages_api::outbound_message_details::< - Runtime, - WithMillauMessagesInstance, - >(lane, begin, end) - } - } - - impl bp_millau::FromMillauInboundLaneApi for Runtime { - fn message_details( - lane: bp_messages::LaneId, - messages: Vec<(bp_messages::MessagePayload, bp_messages::OutboundMessageDetails)>, - ) -> Vec { - bridge_runtime_common::messages_api::inbound_message_details::< - Runtime, - WithMillauMessagesInstance, - >(lane, messages) - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn call_size() { - const BRIDGES_PALLETS_MAX_CALL_SIZE: usize = 200; - assert!( - core::mem::size_of::>() <= - BRIDGES_PALLETS_MAX_CALL_SIZE - ); - assert!( - core::mem::size_of::>() <= - BRIDGES_PALLETS_MAX_CALL_SIZE - ); - // Largest inner Call is `pallet_session::Call` with a size of 224 bytes. This size is a - // result of large `SessionKeys` struct. - // Total size of Rialto runtime Call is 232. - const MAX_CALL_SIZE: usize = 232; - assert!(core::mem::size_of::() <= MAX_CALL_SIZE); - } -} diff --git a/bridges/bin/rialto/runtime/src/millau_messages.rs b/bridges/bin/rialto/runtime/src/millau_messages.rs deleted file mode 100644 index 03e4c494cf2a4..0000000000000 --- a/bridges/bin/rialto/runtime/src/millau_messages.rs +++ /dev/null @@ -1,200 +0,0 @@ -// 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 . - -//! Everything required to serve Millau <-> Rialto messages. - -use crate::{MillauGrandpaInstance, Runtime, RuntimeOrigin, WithMillauMessagesInstance}; - -use bp_messages::LaneId; -use bridge_runtime_common::{ - messages::{ - self, source::TargetHeaderChainAdapter, target::SourceHeaderChainAdapter, MessageBridge, - }, - messages_xcm_extension::{SenderAndLane, XcmBlobHauler, XcmBlobHaulerAdapter}, -}; -use frame_support::{parameter_types, weights::Weight}; -use sp_runtime::RuntimeDebug; -use xcm::latest::prelude::*; -use xcm_builder::HaulBlobExporter; - -/// Lane that is used for XCM messages exchange. -pub const XCM_LANE: LaneId = LaneId([0, 0, 0, 0]); -/// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge -/// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual -/// tests, confirming that we don't break encoding somewhere between. -pub const BASE_XCM_WEIGHT_TWICE: Weight = crate::xcm_config::BaseXcmWeight::get().saturating_mul(2); - -parameter_types! { - /// Weight credit for our test messages. - /// - /// 2 XCM instructions is for simple `Trap(42)` program, coming through bridge - /// (it is prepended with `UniversalOrigin` instruction). - pub const WeightCredit: Weight = BASE_XCM_WEIGHT_TWICE; - /// Lane used by the with-Millau bridge. - pub MullauSenderAndLane: SenderAndLane = SenderAndLane::new(Here.into(), XCM_LANE); - - /// Dummy message used in configuration. - pub DummyXcmMessage: Xcm<()> = Xcm::new(); -} - -/// Message payload for Rialto -> Millau messages. -pub type ToMillauMessagePayload = messages::source::FromThisChainMessagePayload; - -/// Message verifier for Rialto -> Millau messages. -pub type ToMillauMessageVerifier = - messages::source::FromThisChainMessageVerifier; - -/// Message payload for Millau -> Rialto messages. -pub type FromMillauMessagePayload = messages::target::FromBridgedChainMessagePayload; - -/// Call-dispatch based message dispatch for Millau -> Rialto messages. -pub type FromMillauMessageDispatch = - bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatch< - crate::xcm_config::OnRialtoBlobDispatcher, - (), - (), - >; - -/// Messages proof for Millau -> Rialto messages. -pub type FromMillauMessagesProof = messages::target::FromBridgedChainMessagesProof; - -/// Messages delivery proof for Rialto -> Millau messages. -pub type ToMillauMessagesDeliveryProof = - messages::source::FromBridgedChainMessagesDeliveryProof; - -/// Maximal outbound payload size of Rialto -> Millau messages. -pub type ToMillauMaximalOutboundPayloadSize = - messages::source::FromThisChainMaximalOutboundPayloadSize; - -/// Millau <-> Rialto message bridge. -#[derive(RuntimeDebug, Clone, Copy)] -pub struct WithMillauMessageBridge; - -impl MessageBridge for WithMillauMessageBridge { - const BRIDGED_MESSAGES_PALLET_NAME: &'static str = bp_rialto::WITH_RIALTO_MESSAGES_PALLET_NAME; - - type ThisChain = Rialto; - type BridgedChain = Millau; - type BridgedHeaderChain = - pallet_bridge_grandpa::GrandpaChainHeaders; -} - -/// Rialto chain from message lane point of view. -#[derive(RuntimeDebug, Clone, Copy)] -pub struct Rialto; - -impl messages::UnderlyingChainProvider for Rialto { - type Chain = bp_rialto::Rialto; -} - -impl messages::ThisChainWithMessages for Rialto { - type RuntimeOrigin = RuntimeOrigin; -} - -/// Millau chain from message lane point of view. -#[derive(RuntimeDebug, Clone, Copy)] -pub struct Millau; -/// Millau as source header chain. -pub type MillauAsSourceHeaderChain = SourceHeaderChainAdapter; -/// Millau as target header chain. -pub type MillauAsTargetHeaderChain = TargetHeaderChainAdapter; - -impl messages::UnderlyingChainProvider for Millau { - type Chain = bp_millau::Millau; -} - -impl messages::BridgedChainWithMessages for Millau {} - -/// Export XCM messages to be relayed to Millau. -pub type ToMillauBlobExporter = HaulBlobExporter< - XcmBlobHaulerAdapter, - crate::xcm_config::MillauNetwork, - (), ->; - -/// To-Millau XCM hauler. -pub struct ToMillauXcmBlobHauler; - -impl XcmBlobHauler for ToMillauXcmBlobHauler { - type Runtime = Runtime; - type MessagesInstance = WithMillauMessagesInstance; - type SenderAndLane = MullauSenderAndLane; - - type ToSourceChainSender = crate::xcm_config::XcmRouter; - type CongestedMessage = DummyXcmMessage; - type UncongestedMessage = DummyXcmMessage; -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::{MillauGrandpaInstance, Runtime, WithMillauMessagesInstance}; - use bridge_runtime_common::{ - assert_complete_bridge_types, - integrity::{ - assert_complete_bridge_constants, check_message_lane_weights, - AssertBridgeMessagesPalletConstants, AssertBridgePalletNames, AssertChainConstants, - AssertCompleteBridgeConstants, - }, - }; - - #[test] - fn ensure_millau_message_lane_weights_are_correct() { - check_message_lane_weights::( - bp_millau::EXTRA_STORAGE_PROOF_SIZE, - bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, - bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, - false, - ); - } - - #[test] - fn ensure_bridge_integrity() { - assert_complete_bridge_types!( - runtime: Runtime, - with_bridged_chain_grandpa_instance: MillauGrandpaInstance, - with_bridged_chain_messages_instance: WithMillauMessagesInstance, - bridge: WithMillauMessageBridge, - this_chain: bp_rialto::Rialto, - bridged_chain: bp_millau::Millau, - ); - - assert_complete_bridge_constants::< - Runtime, - MillauGrandpaInstance, - WithMillauMessagesInstance, - WithMillauMessageBridge, - >(AssertCompleteBridgeConstants { - this_chain_constants: AssertChainConstants { - block_length: bp_rialto::BlockLength::get(), - block_weights: bp_rialto::BlockWeights::get(), - }, - messages_pallet_constants: AssertBridgeMessagesPalletConstants { - max_unrewarded_relayers_in_bridged_confirmation_tx: - bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, - max_unconfirmed_messages_in_bridged_confirmation_tx: - bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, - bridged_chain_id: bp_runtime::MILLAU_CHAIN_ID, - }, - pallet_names: AssertBridgePalletNames { - with_this_chain_messages_pallet_name: bp_rialto::WITH_RIALTO_MESSAGES_PALLET_NAME, - with_bridged_chain_grandpa_pallet_name: bp_millau::WITH_MILLAU_GRANDPA_PALLET_NAME, - with_bridged_chain_messages_pallet_name: - bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME, - }, - }); - } -} diff --git a/bridges/bin/rialto/runtime/src/parachains.rs b/bridges/bin/rialto/runtime/src/parachains.rs deleted file mode 100644 index 972edbf35286e..0000000000000 --- a/bridges/bin/rialto/runtime/src/parachains.rs +++ /dev/null @@ -1,274 +0,0 @@ -// 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 . - -//! Parachains support in Rialto runtime. - -use crate::{ - xcm_config, AccountId, Babe, Balance, Balances, BlockNumber, ParaAssignmentProvider, Registrar, - Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, ShiftSessionManager, Slots, - UncheckedExtrinsic, -}; - -use frame_support::{ - parameter_types, - traits::{KeyOwnerProofSystem, ProcessMessage, ProcessMessageError}, - weights::{Weight, WeightMeter}, -}; -use frame_system::EnsureRoot; -use polkadot_primitives::v6::{ValidatorId, ValidatorIndex}; -use polkadot_runtime_common::{paras_registrar, paras_sudo_wrapper, slots}; -use polkadot_runtime_parachains::{ - configuration as parachains_configuration, disputes as parachains_disputes, - disputes::slashing as parachains_slashing, - dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, - inclusion::{AggregateMessageOrigin, UmpQueueId}, - initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, - paras_inherent as parachains_paras_inherent, scheduler as parachains_scheduler, - session_info as parachains_session_info, shared as parachains_shared, -}; -use sp_core::crypto::KeyTypeId; -use sp_runtime::transaction_validity::TransactionPriority; -use xcm::latest::Junction; - -impl frame_system::offchain::SendTransactionTypes for Runtime -where - RuntimeCall: From, -{ - type Extrinsic = UncheckedExtrinsic; - type OverarchingCall = RuntimeCall; -} - -/// Special `RewardValidators` that does nothing ;) -pub struct RewardValidators; -impl polkadot_runtime_parachains::inclusion::RewardValidators for RewardValidators { - fn reward_backing(_: impl IntoIterator) {} - fn reward_bitfields(_: impl IntoIterator) {} -} - -// all required parachain modules from `polkadot-runtime-parachains` crate - -impl parachains_configuration::Config for Runtime { - type WeightInfo = parachains_configuration::TestWeightInfo; -} - -impl parachains_dmp::Config for Runtime {} - -impl parachains_hrmp::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; - type ChannelManager = EnsureRoot; - type Currency = Balances; - type WeightInfo = parachains_hrmp::TestWeightInfo; -} - -impl parachains_inclusion::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RewardValidators = RewardValidators; - type DisputesHandler = (); - type MessageQueue = crate::MessageQueue; - type WeightInfo = (); -} - -impl parachains_initializer::Config for Runtime { - type Randomness = pallet_babe::RandomnessFromOneEpochAgo; - type ForceOrigin = EnsureRoot; - type WeightInfo = (); -} - -impl parachains_disputes::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RewardValidators = (); - type SlashingHandler = (); - type WeightInfo = parachains_disputes::TestWeightInfo; -} - -impl parachains_slashing::Config for Runtime { - type KeyOwnerProofSystem = (); - type KeyOwnerProof = - >::Proof; - type KeyOwnerIdentification = >::IdentificationTuple; - type HandleReports = (); - type WeightInfo = parachains_slashing::TestWeightInfo; - type BenchmarkingConfig = parachains_slashing::BenchConfig<200>; -} - -impl parachains_origin::Config for Runtime {} - -parameter_types! { - pub const ParasUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); -} - -impl parachains_paras::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = ParasWeightInfo; - type UnsignedPriority = ParasUnsignedPriority; - type QueueFootprinter = crate::ParaInclusion; - type NextSessionRotation = Babe; - type OnNewHead = Registrar; -} - -/// Test weight for the `Paras` pallet. -/// -/// We can't use `parachains_paras::TestWeightInfo` anymore, because it returns `Weight::MAX` -/// where we need some real-world weights. We'll use zero weights here, though to avoid -/// adding benchmarks to Rialto runtime. -pub struct ParasWeightInfo; - -impl parachains_paras::WeightInfo for ParasWeightInfo { - fn force_set_current_code(_c: u32) -> Weight { - Weight::zero() - } - fn force_set_current_head(_s: u32) -> Weight { - Weight::zero() - } - - fn force_set_most_recent_context() -> Weight { - Weight::zero() - } - - fn force_schedule_code_upgrade(_c: u32) -> Weight { - Weight::zero() - } - fn force_note_new_head(_s: u32) -> Weight { - Weight::zero() - } - fn force_queue_action() -> Weight { - Weight::zero() - } - fn add_trusted_validation_code(_c: u32) -> Weight { - Weight::zero() - } - fn poke_unused_validation_code() -> Weight { - Weight::zero() - } - fn include_pvf_check_statement_finalize_upgrade_accept() -> Weight { - Weight::zero() - } - fn include_pvf_check_statement_finalize_upgrade_reject() -> Weight { - Weight::zero() - } - fn include_pvf_check_statement_finalize_onboarding_accept() -> Weight { - Weight::zero() - } - fn include_pvf_check_statement_finalize_onboarding_reject() -> Weight { - Weight::zero() - } - fn include_pvf_check_statement() -> Weight { - Weight::zero() - } -} - -impl parachains_paras_inherent::Config for Runtime { - type WeightInfo = parachains_paras_inherent::TestWeightInfo; -} - -impl polkadot_runtime_parachains::assigner_parachains::Config for Runtime {} - -impl parachains_scheduler::Config for Runtime { - type AssignmentProvider = ParaAssignmentProvider; -} - -impl parachains_session_info::Config for Runtime { - type ValidatorSet = ShiftSessionManager; -} - -impl parachains_shared::Config for Runtime {} - -parameter_types! { - /// Amount of weight that can be spent per block to service messages. - /// - /// # WARNING - /// - /// This is not a good value for para-chains since the `Scheduler` - /// already uses up to 80 percent block weight. - pub MessageQueueServiceWeight: Weight = crate::Perbill::from_percent(20) * bp_rialto::BlockWeights::get().max_block; - pub const MessageQueueHeapSize: u32 = 32 * 1024; - pub const MessageQueueMaxStale: u32 = 96; -} - -/// Message processor to handle any messages that were enqueued into the `MessageQueue` pallet. -pub struct MessageProcessor; -impl ProcessMessage for MessageProcessor { - type Origin = AggregateMessageOrigin; - - fn process_message( - message: &[u8], - origin: Self::Origin, - meter: &mut WeightMeter, - id: &mut [u8; 32], - ) -> Result { - let para = match origin { - AggregateMessageOrigin::Ump(UmpQueueId::Para(para)) => para, - }; - xcm_builder::ProcessXcmMessage::< - Junction, - xcm_executor::XcmExecutor, - RuntimeCall, - >::process_message(message, Junction::Parachain(para.into()), meter, id) - } -} - -impl pallet_message_queue::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Size = u32; - type HeapSize = MessageQueueHeapSize; - type MaxStale = MessageQueueMaxStale; - type ServiceWeight = MessageQueueServiceWeight; - #[cfg(not(feature = "runtime-benchmarks"))] - type MessageProcessor = MessageProcessor; - #[cfg(feature = "runtime-benchmarks")] - type MessageProcessor = - pallet_message_queue::mock_helpers::NoopMessageProcessor; - type QueueChangeHandler = crate::ParaInclusion; - type WeightInfo = (); - type QueuePausedQuery = (); -} - -// required onboarding pallets. We're not going to use auctions or crowdloans, so they're missing - -parameter_types! { - pub const ParaDeposit: Balance = 0; - pub const DataDepositPerByte: Balance = 0; -} - -impl paras_registrar::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; - type Currency = Balances; - type OnSwap = Slots; - type ParaDeposit = ParaDeposit; - type DataDepositPerByte = DataDepositPerByte; - type WeightInfo = paras_registrar::TestWeightInfo; -} - -parameter_types! { - pub const LeasePeriod: BlockNumber = 10 * bp_rialto::MINUTES; -} - -impl slots::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type Registrar = Registrar; - type LeasePeriod = LeasePeriod; - type WeightInfo = slots::TestWeightInfo; - type LeaseOffset = (); - type ForceOrigin = EnsureRoot; -} - -impl paras_sudo_wrapper::Config for Runtime {} diff --git a/bridges/bin/rialto/runtime/src/xcm_config.rs b/bridges/bin/rialto/runtime/src/xcm_config.rs deleted file mode 100644 index caac064f81534..0000000000000 --- a/bridges/bin/rialto/runtime/src/xcm_config.rs +++ /dev/null @@ -1,280 +0,0 @@ -// 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 . - -//! XCM configurations for the Rialto runtime. - -use super::{ - millau_messages::ToMillauBlobExporter, AccountId, AllPalletsWithSystem, Balances, Runtime, - RuntimeCall, RuntimeEvent, RuntimeOrigin, XcmPallet, -}; -use bp_rialto::WeightToFee; -use bridge_runtime_common::CustomNetworkId; -use frame_support::{ - parameter_types, - traits::{ConstU32, Everything, Nothing}, - weights::Weight, -}; -use frame_system::EnsureRoot; -use xcm::latest::prelude::*; -use xcm_builder::{ - AccountId32Aliases, CurrencyAdapter as XcmCurrencyAdapter, IsConcrete, MintLocation, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, -}; - -parameter_types! { - /// The location of the `MLAU` token, from the context of this chain. Since this token is native to this - /// chain, we make it synonymous with it and thus it is the `Here` location, which means "equivalent to - /// the context". - pub const TokenLocation: MultiLocation = Here.into_location(); - /// The Rialto network ID. - pub const ThisNetwork: NetworkId = CustomNetworkId::Rialto.as_network_id(); - /// The Millau network ID. - pub const MillauNetwork: NetworkId = CustomNetworkId::Millau.as_network_id(); - - /// Our XCM location ancestry - i.e. our location within the Consensus Universe. - /// - /// Since Polkadot is a top-level relay-chain with its own consensus, it's just our network ID. - pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into(); - /// The check account, which holds any native assets that have been teleported out and not back in (yet). - pub CheckAccount: (AccountId, MintLocation) = (XcmPallet::check_account(), MintLocation::Local); -} - -/// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to -/// determine the sovereign account controlled by a location. -pub type SovereignAccountOf = ( - // We can directly alias an `AccountId32` into a local account. - AccountId32Aliases, -); - -/// Our asset transactor. This is what allows us to interest with the runtime facilities from the -/// point of view of XCM-only concepts like `MultiLocation` and `MultiAsset`. -/// -/// Ours is only aware of the Balances pallet, which is mapped to `TokenLocation`. -pub type LocalAssetTransactor = XcmCurrencyAdapter< - // Use this currency: - Balances, - // Use this currency when it is a fungible asset matching the given location or name: - IsConcrete, - // We can convert the MultiLocations with our converter above: - SovereignAccountOf, - // Our chain's account ID type (we can't get away without mentioning it explicitly): - AccountId, - // We track our teleports in/out to keep total issuance correct. - CheckAccount, ->; - -/// The means that we convert the XCM message origin location into a local dispatch origin. -type LocalOriginConverter = ( - // A `Signed` origin of the sovereign account that the original location controls. - SovereignSignedViaLocation, - // The AccountId32 location type can be expressed natively as a `Signed` origin. - SignedAccountId32AsNative, -); - -parameter_types! { - /// The amount of weight an XCM operation takes. This is a safe overestimate. - pub const BaseXcmWeight: Weight = Weight::from_parts(1_000_000_000, 64 * 1024); - /// Maximum number of instructions in a single XCM fragment. A sanity check against weight - /// calculations getting too crazy. - pub const MaxInstructions: u32 = 100; -} - -/// The XCM router. We are not sending messages to sibling/parent/child chains here. -pub type XcmRouter = (); - -/// The barriers one of which must be passed for an XCM message to be executed. -pub type Barrier = ( - // Weight that is paid for may be consumed. - TakeWeightCredit, -); - -/// Dispatches received XCM messages from other chain. -pub type OnRialtoBlobDispatcher = xcm_builder::BridgeBlobDispatcher< - crate::xcm_config::XcmRouter, - crate::xcm_config::UniversalLocation, - (), ->; - -/// Incoming XCM weigher type. -pub type XcmWeigher = xcm_builder::FixedWeightBounds; - -pub struct XcmConfig; -impl xcm_executor::Config for XcmConfig { - type RuntimeCall = RuntimeCall; - type XcmSender = (); - type AssetTransactor = LocalAssetTransactor; - type OriginConverter = LocalOriginConverter; - type IsReserve = (); - type IsTeleporter = (); - type UniversalLocation = UniversalLocation; - type Barrier = Barrier; - type Weigher = XcmWeigher; - // The weight trader piggybacks on the existing transaction-fee conversion logic. - type Trader = UsingComponents; - type ResponseHandler = XcmPallet; - type AssetTrap = XcmPallet; - type AssetLocker = (); - type AssetExchanger = (); - type AssetClaims = XcmPallet; - type SubscriptionService = XcmPallet; - type PalletInstancesInfo = AllPalletsWithSystem; - type MaxAssetsIntoHolding = ConstU32<64>; - type FeeManager = (); - type MessageExporter = ToMillauBlobExporter; - type UniversalAliases = Nothing; - type CallDispatcher = RuntimeCall; - type SafeCallFilter = Everything; - type Aliasers = Nothing; -} - -/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior -/// location of this chain. -pub type LocalOriginToLocation = ( - // Usual Signed origin to be used in XCM as a corresponding AccountId32 - SignedToAccountId32, -); - -#[cfg(feature = "runtime-benchmarks")] -parameter_types! { - pub ReachableDest: Option = None; -} - -impl pallet_xcm::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - // We don't allow any messages to be sent via the transaction yet. This is basically safe to - // enable, (safe the possibility of someone spamming the parachain if they're willing to pay - // the DOT to send from the Relay-chain). But it's useless until we bring in XCM v3 which will - // make `DescendOrigin` a bit more useful. - type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; - type XcmRouter = XcmRouter; - // Anyone can execute XCM messages locally. - type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; - type XcmExecuteFilter = Everything; - type XcmExecutor = xcm_executor::XcmExecutor; - // Anyone is able to use teleportation regardless of who they are and what they want to - // teleport. - type XcmTeleportFilter = Everything; - // Anyone is able to use reserve transfers regardless of who they are and what they want to - // transfer. - type XcmReserveTransferFilter = Everything; - type Weigher = XcmWeigher; - type UniversalLocation = UniversalLocation; - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; - type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; - type Currency = Balances; - type CurrencyMatcher = (); - type TrustedLockers = (); - type SovereignAccountOf = SovereignAccountOf; - type MaxLockers = frame_support::traits::ConstU32<8>; - type WeightInfo = pallet_xcm::TestWeightInfo; - #[cfg(feature = "runtime-benchmarks")] - type ReachableDest = ReachableDest; - type AdminOrigin = EnsureRoot; - type MaxRemoteLockConsumers = ConstU32<0>; - type RemoteLockConsumerIdentifier = (); -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::{ - millau_messages::{FromMillauMessageDispatch, XCM_LANE}, - WithMillauMessagesInstance, - }; - use bp_messages::{ - target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch}, - LaneId, MessageKey, - }; - use bridge_runtime_common::messages_xcm_extension::XcmBlobMessageDispatchResult; - use codec::Encode; - use pallet_bridge_messages::OutboundLanes; - use sp_runtime::BuildStorage; - use xcm_executor::XcmExecutor; - - fn new_test_ext() -> sp_io::TestExternalities { - sp_io::TestExternalities::new( - frame_system::GenesisConfig::::default().build_storage().unwrap(), - ) - } - - fn prepare_outbound_xcm_message(destination: NetworkId) -> Xcm { - vec![ExportMessage { - network: destination, - destination: destination.into(), - xcm: vec![Instruction::Trap(42)].into(), - }] - .into() - } - - #[test] - fn xcm_messages_to_millau_are_sent_using_bridge_exporter() { - new_test_ext().execute_with(|| { - // ensure that the there are no messages queued - assert_eq!( - OutboundLanes::::get(XCM_LANE) - .latest_generated_nonce, - 0, - ); - - // export message instruction "sends" message to Rialto - XcmExecutor::::execute_xcm_in_credit( - Here, - prepare_outbound_xcm_message(MillauNetwork::get()), - Default::default(), - Weight::MAX, - Weight::MAX, - ) - .ensure_complete() - .expect("runtime configuration must be correct"); - - // ensure that the message has been queued - assert_eq!( - OutboundLanes::::get(XCM_LANE) - .latest_generated_nonce, - 1, - ); - }) - } - - fn prepare_inbound_bridge_message() -> DispatchMessage> { - let xcm = xcm::VersionedXcm::::V3(vec![Instruction::Trap(42)].into()); - let location = - xcm::VersionedInteriorMultiLocation::V3(X1(GlobalConsensus(ThisNetwork::get()))); - // this is the `BridgeMessage` from polkadot xcm builder, but it has no constructor - // or public fields, so just tuple - let bridge_message = (location, xcm).encode(); - DispatchMessage { - key: MessageKey { lane_id: LaneId([0, 0, 0, 0]), nonce: 1 }, - data: DispatchMessageData { payload: Ok(bridge_message) }, - } - } - - #[test] - fn xcm_messages_from_millau_are_dispatched() { - let incoming_message = prepare_inbound_bridge_message(); - - // we care only about handing message to the XCM dispatcher, so we don't care about its - // actual dispatch - let dispatch_result = FromMillauMessageDispatch::dispatch(incoming_message); - assert!(matches!( - dispatch_result.dispatch_level_result, - XcmBlobMessageDispatchResult::NotDispatched(_), - )); - } -} diff --git a/bridges/bin/runtime-common/src/lib.rs b/bridges/bin/runtime-common/src/lib.rs index ae6f40b142145..d3b3b21061d05 100644 --- a/bridges/bin/runtime-common/src/lib.rs +++ b/bridges/bin/runtime-common/src/lib.rs @@ -22,7 +22,6 @@ use crate::messages_call_ext::MessagesCallSubType; use pallet_bridge_grandpa::CallSubType as GrandpaCallSubType; use pallet_bridge_parachains::CallSubType as ParachainsCallSubtype; use sp_runtime::transaction_validity::TransactionValidity; -use xcm::v3::NetworkId; pub mod messages; pub mod messages_api; @@ -92,8 +91,8 @@ where /// ```nocompile /// generate_bridge_reject_obsolete_headers_and_messages!{ /// Call, AccountId -/// BridgeRialtoGrandpa, BridgeWestendGrandpa, -/// BridgeRialtoParachains +/// BridgeRococoGrandpa, BridgeRococoMessages, +/// BridgeRococoParachains /// } /// ``` /// @@ -147,42 +146,6 @@ macro_rules! generate_bridge_reject_obsolete_headers_and_messages { }; } -/// A mapping over `NetworkId`. -/// Since `NetworkId` doesn't include `Millau`, `Rialto` and `RialtoParachain`, we create some -/// synthetic associations between these chains and `NetworkId` chains. -pub enum CustomNetworkId { - /// The Millau network ID, associated with Kusama. - Millau, - /// The Rialto network ID, associated with Polkadot. - Rialto, - /// The RialtoParachain network ID, associated with Westend. - RialtoParachain, -} - -impl TryFrom for CustomNetworkId { - type Error = (); - - fn try_from(chain: bp_runtime::ChainId) -> Result { - Ok(match chain { - bp_runtime::MILLAU_CHAIN_ID => Self::Millau, - bp_runtime::RIALTO_CHAIN_ID => Self::Rialto, - bp_runtime::RIALTO_PARACHAIN_CHAIN_ID => Self::RialtoParachain, - _ => return Err(()), - }) - } -} - -impl CustomNetworkId { - /// Converts self to XCM' network id. - pub const fn as_network_id(&self) -> NetworkId { - match *self { - CustomNetworkId::Millau => NetworkId::Kusama, - CustomNetworkId::Rialto => NetworkId::Polkadot, - CustomNetworkId::RialtoParachain => NetworkId::Westend, - } - } -} - #[cfg(test)] mod tests { use crate::BridgeRuntimeFilterCall; diff --git a/bridges/bin/runtime-common/src/mock.rs b/bridges/bin/runtime-common/src/mock.rs index 45ef790d74482..943a98284a5e7 100644 --- a/bridges/bin/runtime-common/src/mock.rs +++ b/bridges/bin/runtime-common/src/mock.rs @@ -14,12 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! A mock runtime for testing different stuff in the crate. We've been using Millau -//! runtime for that before, but it has two drawbacks: -//! -//! - circular dependencies between this crate and Millau runtime; -//! -//! - we can't use (e.g. as git subtree or by copying) this crate in repo without Millau. +//! A mock runtime for testing different stuff in the crate. #![cfg(test)] diff --git a/bridges/bin/runtime-common/src/priority_calculator.rs b/bridges/bin/runtime-common/src/priority_calculator.rs index fd10344812517..a597fb9e2f492 100644 --- a/bridges/bin/runtime-common/src/priority_calculator.rs +++ b/bridges/bin/runtime-common/src/priority_calculator.rs @@ -27,6 +27,7 @@ use frame_support::traits::Get; use sp_runtime::transaction_validity::TransactionPriority; // reexport everything from `integrity_tests` module +#[allow(unused_imports)] pub use integrity_tests::*; /// Compute priority boost for message delivery transaction that delivers diff --git a/bridges/docs/high-level-overview.md b/bridges/docs/high-level-overview.md index 42efc8100bd08..d6d6fb3f0996d 100644 --- a/bridges/docs/high-level-overview.md +++ b/bridges/docs/high-level-overview.md @@ -1,7 +1,7 @@ # High-Level Bridge Documentation This document gives a brief, abstract description of main components that may be found in this repository. If you want -to see how we're using them to build Rococo <> Wococo (Kusama <> Polkadot) bridge, please refer to the [Polkadot <> +to see how we're using them to build Rococo <> Westend (Kusama <> Polkadot) bridge, please refer to the [Polkadot <> Kusama Bridge](./polkadot-kusama-bridge-overview.md). ## Purpose diff --git a/bridges/modules/grandpa/src/weights.rs b/bridges/modules/grandpa/src/weights.rs index 89ed70d13ac33..a75e7b5a8e4ad 100644 --- a/bridges/modules/grandpa/src/weights.rs +++ b/bridges/modules/grandpa/src/weights.rs @@ -23,7 +23,7 @@ //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// target/release/millau-bridge-node +// target/release/unknown-bridge-node // benchmark // pallet // --chain=dev @@ -58,39 +58,39 @@ pub trait WeightInfo { /// Those weights are test only and must never be used in production. pub struct BridgeWeight(PhantomData); impl WeightInfo for BridgeWeight { - /// Storage: BridgeRialtoGrandpa PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownGrandpa PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa PalletOperatingMode (max_values: Some(1), max_size: Some(1), + /// Proof: BridgeUnknownGrandpa PalletOperatingMode (max_values: Some(1), max_size: Some(1), /// added: 496, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa RequestCount (r:1 w:1) + /// Storage: BridgeUnknownGrandpa RequestCount (r:1 w:1) /// - /// Proof: BridgeRialtoGrandpa RequestCount (max_values: Some(1), max_size: Some(4), added: 499, - /// mode: MaxEncodedLen) + /// Proof: BridgeUnknownGrandpa RequestCount (max_values: Some(1), max_size: Some(4), added: + /// 499, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa BestFinalized (r:1 w:1) + /// Storage: BridgeUnknownGrandpa BestFinalized (r:1 w:1) /// - /// Proof: BridgeRialtoGrandpa BestFinalized (max_values: Some(1), max_size: Some(36), added: + /// Proof: BridgeUnknownGrandpa BestFinalized (max_values: Some(1), max_size: Some(36), added: /// 531, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa CurrentAuthoritySet (r:1 w:0) + /// Storage: BridgeUnknownGrandpa CurrentAuthoritySet (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa CurrentAuthoritySet (max_values: Some(1), max_size: Some(209), + /// Proof: BridgeUnknownGrandpa CurrentAuthoritySet (max_values: Some(1), max_size: Some(209), /// added: 704, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHashesPointer (r:1 w:1) + /// Storage: BridgeUnknownGrandpa ImportedHashesPointer (r:1 w:1) /// - /// Proof: BridgeRialtoGrandpa ImportedHashesPointer (max_values: Some(1), max_size: Some(4), + /// Proof: BridgeUnknownGrandpa ImportedHashesPointer (max_values: Some(1), max_size: Some(4), /// added: 499, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHashes (r:1 w:1) + /// Storage: BridgeUnknownGrandpa ImportedHashes (r:1 w:1) /// - /// Proof: BridgeRialtoGrandpa ImportedHashes (max_values: Some(14400), max_size: Some(36), + /// Proof: BridgeUnknownGrandpa ImportedHashes (max_values: Some(14400), max_size: Some(36), /// added: 2016, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:0 w:2) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:0 w:2) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// /// The range of component `p` is `[1, 4]`. @@ -113,39 +113,39 @@ impl WeightInfo for BridgeWeight { // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: BridgeRialtoGrandpa PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownGrandpa PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa PalletOperatingMode (max_values: Some(1), max_size: Some(1), + /// Proof: BridgeUnknownGrandpa PalletOperatingMode (max_values: Some(1), max_size: Some(1), /// added: 496, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa RequestCount (r:1 w:1) + /// Storage: BridgeUnknownGrandpa RequestCount (r:1 w:1) /// - /// Proof: BridgeRialtoGrandpa RequestCount (max_values: Some(1), max_size: Some(4), added: 499, - /// mode: MaxEncodedLen) + /// Proof: BridgeUnknownGrandpa RequestCount (max_values: Some(1), max_size: Some(4), added: + /// 499, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa BestFinalized (r:1 w:1) + /// Storage: BridgeUnknownGrandpa BestFinalized (r:1 w:1) /// - /// Proof: BridgeRialtoGrandpa BestFinalized (max_values: Some(1), max_size: Some(36), added: + /// Proof: BridgeUnknownGrandpa BestFinalized (max_values: Some(1), max_size: Some(36), added: /// 531, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa CurrentAuthoritySet (r:1 w:0) + /// Storage: BridgeUnknownGrandpa CurrentAuthoritySet (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa CurrentAuthoritySet (max_values: Some(1), max_size: Some(209), + /// Proof: BridgeUnknownGrandpa CurrentAuthoritySet (max_values: Some(1), max_size: Some(209), /// added: 704, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHashesPointer (r:1 w:1) + /// Storage: BridgeUnknownGrandpa ImportedHashesPointer (r:1 w:1) /// - /// Proof: BridgeRialtoGrandpa ImportedHashesPointer (max_values: Some(1), max_size: Some(4), + /// Proof: BridgeUnknownGrandpa ImportedHashesPointer (max_values: Some(1), max_size: Some(4), /// added: 499, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHashes (r:1 w:1) + /// Storage: BridgeUnknownGrandpa ImportedHashes (r:1 w:1) /// - /// Proof: BridgeRialtoGrandpa ImportedHashes (max_values: Some(14400), max_size: Some(36), + /// Proof: BridgeUnknownGrandpa ImportedHashes (max_values: Some(14400), max_size: Some(36), /// added: 2016, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:0 w:2) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:0 w:2) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// /// The range of component `p` is `[1, 4]`. diff --git a/bridges/modules/messages/src/weights.rs b/bridges/modules/messages/src/weights.rs index 5b6863984ec78..5bf7d56756079 100644 --- a/bridges/modules/messages/src/weights.rs +++ b/bridges/modules/messages/src/weights.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 . -//! Autogenerated weights for RialtoMessages +//! Autogenerated weights for pallet_bridge_messages //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` @@ -23,13 +23,13 @@ //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// target/release/millau-bridge-node +// target/release/unknown-bridge-node // benchmark // pallet // --chain=dev // --steps=50 // --repeat=20 -// --pallet=RialtoMessages +// --pallet=pallet_bridge_messages // --extrinsic=* // --execution=wasm // --wasm-execution=Compiled @@ -48,7 +48,7 @@ use frame_support::{ }; use sp_std::marker::PhantomData; -/// Weight functions needed for RialtoMessages. +/// Weight functions needed for pallet_bridge_messages. pub trait WeightInfo { fn receive_single_message_proof() -> Weight; fn receive_two_messages_proof() -> Weight; @@ -61,24 +61,24 @@ pub trait WeightInfo { fn receive_single_message_proof_with_dispatch(i: u32) -> Weight; } -/// Weights for `RialtoMessages` that are generated using one of the Bridge testnets. +/// Weights for `pallet_bridge_messages` that are generated using one of the Bridge testnets. /// /// Those weights are test only and must never be used in production. pub struct BridgeWeight(PhantomData); impl WeightInfo for BridgeWeight { - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages InboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// Proof: BridgeUnknownMessages InboundLanes (max_values: None, max_size: Some(49180), added: /// 51655, mode: MaxEncodedLen) fn receive_single_message_proof() -> Weight { // Proof Size summary in bytes: @@ -89,19 +89,19 @@ impl WeightInfo for BridgeWeight { .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages InboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// Proof: BridgeUnknownMessages InboundLanes (max_values: None, max_size: Some(49180), added: /// 51655, mode: MaxEncodedLen) fn receive_two_messages_proof() -> Weight { // Proof Size summary in bytes: @@ -112,19 +112,19 @@ impl WeightInfo for BridgeWeight { .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages InboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// Proof: BridgeUnknownMessages InboundLanes (max_values: None, max_size: Some(49180), added: /// 51655, mode: MaxEncodedLen) fn receive_single_message_proof_with_outbound_lane_state() -> Weight { // Proof Size summary in bytes: @@ -135,19 +135,19 @@ impl WeightInfo for BridgeWeight { .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages InboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// Proof: BridgeUnknownMessages InboundLanes (max_values: None, max_size: Some(49180), added: /// 51655, mode: MaxEncodedLen) fn receive_single_message_proof_1_kb() -> Weight { // Proof Size summary in bytes: @@ -158,19 +158,19 @@ impl WeightInfo for BridgeWeight { .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages InboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// Proof: BridgeUnknownMessages InboundLanes (max_values: None, max_size: Some(49180), added: /// 51655, mode: MaxEncodedLen) fn receive_single_message_proof_16_kb() -> Weight { // Proof Size summary in bytes: @@ -181,19 +181,19 @@ impl WeightInfo for BridgeWeight { .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages OutboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: + /// Proof: BridgeUnknownMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: /// 539, mode: MaxEncodedLen) /// /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) @@ -209,19 +209,19 @@ impl WeightInfo for BridgeWeight { .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages OutboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: + /// Proof: BridgeUnknownMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: /// 539, mode: MaxEncodedLen) /// /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) @@ -237,19 +237,19 @@ impl WeightInfo for BridgeWeight { .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages OutboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: + /// Proof: BridgeUnknownMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: /// 539, mode: MaxEncodedLen) /// /// Storage: BridgeRelayers RelayerRewards (r:2 w:2) @@ -265,19 +265,19 @@ impl WeightInfo for BridgeWeight { .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages InboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// Proof: BridgeUnknownMessages InboundLanes (max_values: None, max_size: Some(49180), added: /// 51655, mode: MaxEncodedLen) /// /// The range of component `i` is `[128, 2048]`. @@ -296,19 +296,19 @@ impl WeightInfo for BridgeWeight { // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages InboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// Proof: BridgeUnknownMessages InboundLanes (max_values: None, max_size: Some(49180), added: /// 51655, mode: MaxEncodedLen) fn receive_single_message_proof() -> Weight { // Proof Size summary in bytes: @@ -319,19 +319,19 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages InboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// Proof: BridgeUnknownMessages InboundLanes (max_values: None, max_size: Some(49180), added: /// 51655, mode: MaxEncodedLen) fn receive_two_messages_proof() -> Weight { // Proof Size summary in bytes: @@ -342,19 +342,19 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages InboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// Proof: BridgeUnknownMessages InboundLanes (max_values: None, max_size: Some(49180), added: /// 51655, mode: MaxEncodedLen) fn receive_single_message_proof_with_outbound_lane_state() -> Weight { // Proof Size summary in bytes: @@ -365,19 +365,19 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages InboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// Proof: BridgeUnknownMessages InboundLanes (max_values: None, max_size: Some(49180), added: /// 51655, mode: MaxEncodedLen) fn receive_single_message_proof_1_kb() -> Weight { // Proof Size summary in bytes: @@ -388,19 +388,19 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages InboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// Proof: BridgeUnknownMessages InboundLanes (max_values: None, max_size: Some(49180), added: /// 51655, mode: MaxEncodedLen) fn receive_single_message_proof_16_kb() -> Weight { // Proof Size summary in bytes: @@ -411,19 +411,19 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages OutboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: + /// Proof: BridgeUnknownMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: /// 539, mode: MaxEncodedLen) /// /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) @@ -439,19 +439,19 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages OutboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: + /// Proof: BridgeUnknownMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: /// 539, mode: MaxEncodedLen) /// /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) @@ -467,19 +467,19 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages OutboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: + /// Proof: BridgeUnknownMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: /// 539, mode: MaxEncodedLen) /// /// Storage: BridgeRelayers RelayerRewards (r:2 w:2) @@ -495,19 +495,19 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } - /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownMessages PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// Proof: BridgeUnknownMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), /// added: 497, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// Storage: BridgeUnknownMessages InboundLanes (r:1 w:1) /// - /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// Proof: BridgeUnknownMessages InboundLanes (max_values: None, max_size: Some(49180), added: /// 51655, mode: MaxEncodedLen) /// /// The range of component `i` is `[128, 2048]`. diff --git a/bridges/modules/parachains/src/weights.rs b/bridges/modules/parachains/src/weights.rs index 9182ec466117b..abddc87689470 100644 --- a/bridges/modules/parachains/src/weights.rs +++ b/bridges/modules/parachains/src/weights.rs @@ -23,7 +23,7 @@ //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// target/release/millau-bridge-node +// target/release/unknown-bridge-node // benchmark // pallet // --chain=dev @@ -60,29 +60,29 @@ pub trait WeightInfo { /// Those weights are test only and must never be used in production. pub struct BridgeWeight(PhantomData); impl WeightInfo for BridgeWeight { - /// Storage: BridgeRialtoParachains PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownParachains PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), + /// Proof: BridgeUnknownParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), /// added: 496, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ParasInfo (r:1 w:1) + /// Storage: BridgeUnknownParachains ParasInfo (r:1 w:1) /// - /// Proof: BridgeRialtoParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: + /// Proof: BridgeUnknownParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: /// 555, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1) + /// Storage: BridgeUnknownParachains ImportedParaHashes (r:1 w:1) /// - /// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size: + /// Proof: BridgeUnknownParachains ImportedParaHashes (max_values: Some(1024), max_size: /// Some(64), added: 1549, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1) + /// Storage: BridgeUnknownParachains ImportedParaHeads (r:0 w:1) /// - /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: + /// Proof: BridgeUnknownParachains ImportedParaHeads (max_values: Some(1024), max_size: /// Some(196), added: 1681, mode: MaxEncodedLen) /// /// The range of component `p` is `[1, 2]`. @@ -97,29 +97,29 @@ impl WeightInfo for BridgeWeight { .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } - /// Storage: BridgeRialtoParachains PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownParachains PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), + /// Proof: BridgeUnknownParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), /// added: 496, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ParasInfo (r:1 w:1) + /// Storage: BridgeUnknownParachains ParasInfo (r:1 w:1) /// - /// Proof: BridgeRialtoParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: + /// Proof: BridgeUnknownParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: /// 555, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1) + /// Storage: BridgeUnknownParachains ImportedParaHashes (r:1 w:1) /// - /// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size: + /// Proof: BridgeUnknownParachains ImportedParaHashes (max_values: Some(1024), max_size: /// Some(64), added: 1549, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1) + /// Storage: BridgeUnknownParachains ImportedParaHeads (r:0 w:1) /// - /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: + /// Proof: BridgeUnknownParachains ImportedParaHeads (max_values: Some(1024), max_size: /// Some(196), added: 1681, mode: MaxEncodedLen) fn submit_parachain_heads_with_1kb_proof() -> Weight { // Proof Size summary in bytes: @@ -130,29 +130,29 @@ impl WeightInfo for BridgeWeight { .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } - /// Storage: BridgeRialtoParachains PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownParachains PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), + /// Proof: BridgeUnknownParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), /// added: 496, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ParasInfo (r:1 w:1) + /// Storage: BridgeUnknownParachains ParasInfo (r:1 w:1) /// - /// Proof: BridgeRialtoParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: + /// Proof: BridgeUnknownParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: /// 555, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1) + /// Storage: BridgeUnknownParachains ImportedParaHashes (r:1 w:1) /// - /// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size: + /// Proof: BridgeUnknownParachains ImportedParaHashes (max_values: Some(1024), max_size: /// Some(64), added: 1549, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1) + /// Storage: BridgeUnknownParachains ImportedParaHeads (r:0 w:1) /// - /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: + /// Proof: BridgeUnknownParachains ImportedParaHeads (max_values: Some(1024), max_size: /// Some(196), added: 1681, mode: MaxEncodedLen) fn submit_parachain_heads_with_16kb_proof() -> Weight { // Proof Size summary in bytes: @@ -167,29 +167,29 @@ impl WeightInfo for BridgeWeight { // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: BridgeRialtoParachains PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownParachains PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), + /// Proof: BridgeUnknownParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), /// added: 496, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ParasInfo (r:1 w:1) + /// Storage: BridgeUnknownParachains ParasInfo (r:1 w:1) /// - /// Proof: BridgeRialtoParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: + /// Proof: BridgeUnknownParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: /// 555, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1) + /// Storage: BridgeUnknownParachains ImportedParaHashes (r:1 w:1) /// - /// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size: + /// Proof: BridgeUnknownParachains ImportedParaHashes (max_values: Some(1024), max_size: /// Some(64), added: 1549, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1) + /// Storage: BridgeUnknownParachains ImportedParaHeads (r:0 w:1) /// - /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: + /// Proof: BridgeUnknownParachains ImportedParaHeads (max_values: Some(1024), max_size: /// Some(196), added: 1681, mode: MaxEncodedLen) /// /// The range of component `p` is `[1, 2]`. @@ -204,29 +204,29 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } - /// Storage: BridgeRialtoParachains PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownParachains PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), + /// Proof: BridgeUnknownParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), /// added: 496, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ParasInfo (r:1 w:1) + /// Storage: BridgeUnknownParachains ParasInfo (r:1 w:1) /// - /// Proof: BridgeRialtoParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: + /// Proof: BridgeUnknownParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: /// 555, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1) + /// Storage: BridgeUnknownParachains ImportedParaHashes (r:1 w:1) /// - /// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size: + /// Proof: BridgeUnknownParachains ImportedParaHashes (max_values: Some(1024), max_size: /// Some(64), added: 1549, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1) + /// Storage: BridgeUnknownParachains ImportedParaHeads (r:0 w:1) /// - /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: + /// Proof: BridgeUnknownParachains ImportedParaHeads (max_values: Some(1024), max_size: /// Some(196), added: 1681, mode: MaxEncodedLen) fn submit_parachain_heads_with_1kb_proof() -> Weight { // Proof Size summary in bytes: @@ -237,29 +237,29 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } - /// Storage: BridgeRialtoParachains PalletOperatingMode (r:1 w:0) + /// Storage: BridgeUnknownParachains PalletOperatingMode (r:1 w:0) /// - /// Proof: BridgeRialtoParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), + /// Proof: BridgeUnknownParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), /// added: 496, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// Storage: BridgeUnknownGrandpa ImportedHeaders (r:1 w:0) /// - /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// Proof: BridgeUnknownGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), /// added: 2048, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ParasInfo (r:1 w:1) + /// Storage: BridgeUnknownParachains ParasInfo (r:1 w:1) /// - /// Proof: BridgeRialtoParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: + /// Proof: BridgeUnknownParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: /// 555, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1) + /// Storage: BridgeUnknownParachains ImportedParaHashes (r:1 w:1) /// - /// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size: + /// Proof: BridgeUnknownParachains ImportedParaHashes (max_values: Some(1024), max_size: /// Some(64), added: 1549, mode: MaxEncodedLen) /// - /// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1) + /// Storage: BridgeUnknownParachains ImportedParaHeads (r:0 w:1) /// - /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: + /// Proof: BridgeUnknownParachains ImportedParaHeads (max_values: Some(1024), max_size: /// Some(196), added: 1681, mode: MaxEncodedLen) fn submit_parachain_heads_with_16kb_proof() -> Weight { // Proof Size summary in bytes: diff --git a/bridges/modules/parachains/src/weights_ext.rs b/bridges/modules/parachains/src/weights_ext.rs index 13bc9ad2bbce0..393086a85690f 100644 --- a/bridges/modules/parachains/src/weights_ext.rs +++ b/bridges/modules/parachains/src/weights_ext.rs @@ -31,7 +31,7 @@ use frame_support::weights::{RuntimeDbWeight, Weight}; pub const DEFAULT_PARACHAIN_HEAD_SIZE: u32 = 384; /// Number of extra bytes (excluding size of storage value itself) of storage proof, built at -/// the Rialto chain. +/// some generic chain. pub const EXTRA_STORAGE_PROOF_SIZE: u32 = 1024; /// Extended weight info. diff --git a/bridges/modules/relayers/src/weights.rs b/bridges/modules/relayers/src/weights.rs index 2e064a3936df3..c2c065b0c0a27 100644 --- a/bridges/modules/relayers/src/weights.rs +++ b/bridges/modules/relayers/src/weights.rs @@ -23,7 +23,7 @@ //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// target/release/millau-bridge-node +// target/release/rip-bridge-node // benchmark // pallet // --chain=dev diff --git a/bridges/modules/shift-session-manager/Cargo.toml b/bridges/modules/shift-session-manager/Cargo.toml deleted file mode 100644 index e70dd6ace16e4..0000000000000 --- a/bridges/modules/shift-session-manager/Cargo.toml +++ /dev/null @@ -1,38 +0,0 @@ -[package] -name = "pallet-shift-session-manager" -description = "A Substrate Runtime module that selects 2/3 of initial validators for every session" -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2021" -license = "GPL-3.0-or-later WITH Classpath-exception-2.0" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } -scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } - -# Substrate Dependencies - -frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-staking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } - -[dev-dependencies] -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-state-machine = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } - -[features] -default = [ "std" ] -std = [ - "codec/std", - "frame-support/std", - "frame-system/std", - "pallet-session/std", - "scale-info/std", - "sp-staking/std", - "sp-std/std", -] -try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime" ] diff --git a/bridges/modules/shift-session-manager/README.md b/bridges/modules/shift-session-manager/README.md deleted file mode 100644 index 8dfbfd416e3cc..0000000000000 --- a/bridges/modules/shift-session-manager/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# Shift Session Manager Pallet - -**THIS PALLET IS NOT INTENDED TO BE USED IN PRODUCTION** - -The pallet does not provide any calls or runtime storage entries. It only provides implementation of the -`pallet_session::SessionManager`. This implementation, starting from session `3` selects two thirds of initial -validators and changes the set on every session. We are using it at our testnets ([Rialto](../../bin/rialto/) and -[Millau](../../bin/millau/)) to be sure that the set changes every session. On well-known production chains -(like Kusama and Polkadot) the alternative is the set of [nPoS](https://research.web3.foundation/en/latest/polkadot/NPoS/index.html) -pallets, which selects validators, based on their nominations. diff --git a/bridges/modules/shift-session-manager/src/lib.rs b/bridges/modules/shift-session-manager/src/lib.rs deleted file mode 100644 index 49690842418ce..0000000000000 --- a/bridges/modules/shift-session-manager/src/lib.rs +++ /dev/null @@ -1,259 +0,0 @@ -// 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 . - -//! Substrate session manager that selects 2/3 validators from initial set, -//! starting from session 2. - -#![cfg_attr(not(feature = "std"), no_std)] - -use frame_support::traits::{ValidatorSet, ValidatorSetWithIdentification}; -use sp_std::prelude::*; - -pub use pallet::*; - -#[frame_support::pallet] -pub mod pallet { - use super::*; - use frame_support::pallet_prelude::*; - use frame_system::pallet_prelude::*; - - #[pallet::config] - #[pallet::disable_frame_system_supertrait_check] - pub trait Config: pallet_session::Config {} - - #[pallet::pallet] - #[pallet::without_storage_info] - pub struct Pallet(PhantomData); - - #[pallet::hooks] - impl Hooks> for Pallet {} - - #[pallet::call] - impl Pallet {} - - /// Validators of first two sessions. - #[pallet::storage] - pub(super) type InitialValidators = StorageValue<_, Vec>; -} - -impl ValidatorSet for Pallet { - type ValidatorId = T::ValidatorId; - type ValidatorIdOf = T::ValidatorIdOf; - - fn session_index() -> sp_staking::SessionIndex { - pallet_session::Pallet::::current_index() - } - - fn validators() -> Vec { - pallet_session::Pallet::::validators() - } -} - -impl ValidatorSetWithIdentification for Pallet { - type Identification = (); - type IdentificationOf = (); -} - -impl pallet_session::SessionManager for Pallet { - fn end_session(_: sp_staking::SessionIndex) {} - fn start_session(_: sp_staking::SessionIndex) {} - fn new_session(session_index: sp_staking::SessionIndex) -> Option> { - // we don't want to add even more fields to genesis config => just return None - if session_index == 0 || session_index == 1 { - return None - } - - // the idea that on first call (i.e. when session 1 ends) we're reading current - // set of validators from session module (they are initial validators) and save - // in our 'local storage'. - // then for every session we select (deterministically) 2/3 of these initial - // validators to serve validators of new session - let available_validators = InitialValidators::::get().unwrap_or_else(|| { - let validators = >::validators(); - InitialValidators::::put(validators.clone()); - validators - }); - - Some(Self::select_validators(session_index, &available_validators)) - } -} - -impl Pallet { - /// Select validators for session. - fn select_validators( - session_index: sp_staking::SessionIndex, - available_validators: &[T::ValidatorId], - ) -> Vec { - let available_validators_count = available_validators.len(); - let count = sp_std::cmp::max(1, 2 * available_validators_count / 3); - let offset = session_index as usize % available_validators_count; - let end = offset + count; - let session_validators = match end.overflowing_sub(available_validators_count) { - (wrapped_end, false) if wrapped_end != 0 => available_validators[offset..] - .iter() - .chain(available_validators[..wrapped_end].iter()) - .cloned() - .collect(), - _ => available_validators[offset..end].to_vec(), - }; - - session_validators - } -} - -#[cfg(test)] -mod tests { - // From construct_runtime macro - #![allow(clippy::from_over_into)] - - use super::*; - use frame_support::{ - parameter_types, - sp_runtime::{ - testing::UintAuthorityId, - traits::{BlakeTwo256, ConvertInto, IdentityLookup}, - BuildStorage, Perbill, RuntimeAppPublic, - }, - weights::Weight, - }; - use sp_core::H256; - use sp_io::TestExternalities; - use sp_state_machine::BasicExternalities; - - type AccountId = u64; - - type Block = frame_system::mocking::MockBlock; - - frame_support::construct_runtime! { - pub enum TestRuntime { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet}, - } - } - - parameter_types! { - pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0); - pub const MaximumBlockLength: u32 = 2 * 1024; - pub const AvailableBlockRatio: Perbill = Perbill::one(); - } - - impl frame_system::Config for TestRuntime { - type RuntimeOrigin = RuntimeOrigin; - type Nonce = u64; - type RuntimeCall = RuntimeCall; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = AccountId; - type Lookup = IdentityLookup; - type Block = Block; - type RuntimeEvent = (); - type BlockHashCount = frame_support::traits::ConstU64<250>; - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type BaseCallFilter = frame_support::traits::Everything; - type SystemWeightInfo = (); - type BlockWeights = (); - type BlockLength = (); - type DbWeight = (); - type SS58Prefix = (); - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; - } - - parameter_types! { - pub const Period: u64 = 1; - pub const Offset: u64 = 0; - } - - impl pallet_session::Config for TestRuntime { - type RuntimeEvent = (); - type ValidatorId = ::AccountId; - type ValidatorIdOf = ConvertInto; - type ShouldEndSession = pallet_session::PeriodicSessions; - type NextSessionRotation = pallet_session::PeriodicSessions; - type SessionManager = (); - type SessionHandler = TestSessionHandler; - type Keys = UintAuthorityId; - type WeightInfo = (); - } - - impl Config for TestRuntime {} - - pub struct TestSessionHandler; - impl pallet_session::SessionHandler for TestSessionHandler { - const KEY_TYPE_IDS: &'static [sp_runtime::KeyTypeId] = &[UintAuthorityId::ID]; - - fn on_genesis_session(_validators: &[(AccountId, Ks)]) { - } - - fn on_new_session( - _: bool, - _: &[(AccountId, Ks)], - _: &[(AccountId, Ks)], - ) { - } - - fn on_disabled(_: u32) {} - } - - fn new_test_ext() -> TestExternalities { - let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - - let keys = vec![ - (1, 1, UintAuthorityId(1)), - (2, 2, UintAuthorityId(2)), - (3, 3, UintAuthorityId(3)), - (4, 4, UintAuthorityId(4)), - (5, 5, UintAuthorityId(5)), - ]; - - BasicExternalities::execute_with_storage(&mut t, || { - for (ref k, ..) in &keys { - frame_system::Pallet::::inc_providers(k); - } - }); - - pallet_session::GenesisConfig:: { keys } - .assimilate_storage(&mut t) - .unwrap(); - TestExternalities::new(t) - } - - #[test] - fn shift_session_manager_works() { - new_test_ext().execute_with(|| { - let all_accs = vec![1, 2, 3, 4, 5]; - - // at least 1 validator is selected - assert_eq!(Pallet::::select_validators(0, &[1]), vec![1],); - - // at session#0, shift is also 0 - assert_eq!(Pallet::::select_validators(0, &all_accs), vec![1, 2, 3],); - - // at session#1, shift is also 1 - assert_eq!(Pallet::::select_validators(1, &all_accs), vec![2, 3, 4],); - - // at session#3, we're wrapping - assert_eq!(Pallet::::select_validators(3, &all_accs), vec![4, 5, 1],); - - // at session#5, we're starting from the beginning again - assert_eq!(Pallet::::select_validators(5, &all_accs), vec![1, 2, 3],); - }); - } -} diff --git a/bridges/modules/xcm-bridge-hub-router/src/weights.rs b/bridges/modules/xcm-bridge-hub-router/src/weights.rs index 62936e997f3cd..b0c8fc6252cd5 100644 --- a/bridges/modules/xcm-bridge-hub-router/src/weights.rs +++ b/bridges/modules/xcm-bridge-hub-router/src/weights.rs @@ -23,7 +23,7 @@ //! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// target/release/millau-bridge-node +// target/release/rip-bridge-node // benchmark // pallet // --chain=dev diff --git a/bridges/primitives/chain-millau/Cargo.toml b/bridges/primitives/chain-millau/Cargo.toml deleted file mode 100644 index 5ea9d36f9f7b1..0000000000000 --- a/bridges/primitives/chain-millau/Cargo.toml +++ /dev/null @@ -1,62 +0,0 @@ -[package] -name = "bp-millau" -description = "Primitives of Millau runtime." -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2021" -license = "GPL-3.0-or-later WITH Classpath-exception-2.0" - -[dependencies] - -# TODO: Consume `fixed-hash` from crates.io when the following fix is published: -# https://github.com/paritytech/parity-common/commit/d3a9327124a66e52ca1114bb8640c02c18c134b8 -# Expected in a version > 0.8.0 -fixed-hash = { git = "https://github.com/paritytech/parity-common", branch = "master", default-features = false } -hash256-std-hasher = { version = "0.15.2", default-features = false } -impl-codec = { version = "0.6", default-features = false } -impl-serde = { version = "0.4.0", default-features = false } -parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] } -scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } -serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } - -# Bridge Dependencies - -bp-beefy = { path = "../beefy", default-features = false } -bp-header-chain = { path = "../header-chain", default-features = false } -bp-messages = { path = "../messages", default-features = false } -bp-runtime = { path = "../runtime", default-features = false } - -# Substrate Based Dependencies - -frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-trie = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } - -[features] -default = [ "std" ] -std = [ - "bp-beefy/std", - "bp-header-chain/std", - "bp-messages/std", - "bp-runtime/std", - "fixed-hash/std", - "frame-support/std", - "frame-system/std", - "hash256-std-hasher/std", - "impl-codec/std", - "impl-serde/std", - "parity-util-mem/std", - "scale-info/std", - "serde/std", - "sp-api/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", - "sp-trie/std", -] diff --git a/bridges/primitives/chain-millau/src/lib.rs b/bridges/primitives/chain-millau/src/lib.rs deleted file mode 100644 index 0c31287166661..0000000000000 --- a/bridges/primitives/chain-millau/src/lib.rs +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -#![cfg_attr(not(feature = "std"), no_std)] -// RuntimeApi generated functions -#![allow(clippy::too_many_arguments)] - -mod millau_hash; - -use bp_beefy::ChainWithBeefy; -use bp_header_chain::ChainWithGrandpa; -use bp_messages::MessageNonce; -use bp_runtime::{decl_bridge_finality_runtime_apis, decl_bridge_runtime_apis, Chain}; -use frame_support::{ - dispatch::DispatchClass, - weights::{constants::WEIGHT_REF_TIME_PER_SECOND, IdentityFee, Weight}, -}; -use frame_system::limits; -use scale_info::TypeInfo; -use serde::{Deserialize, Serialize}; -use sp_core::{storage::StateVersion, Hasher as HasherT}; -use sp_runtime::{ - traits::{IdentifyAccount, Verify}, - MultiSignature, MultiSigner, Perbill, RuntimeDebug, -}; -use sp_std::prelude::*; -use sp_trie::{LayoutV0, LayoutV1, TrieConfiguration}; - -use sp_runtime::traits::Keccak256; - -pub use millau_hash::MillauHash; - -/// Number of extra bytes (excluding size of storage value itself) of storage proof, built at -/// Millau chain. This mostly depends on number of entries (and their density) in the storage trie. -/// Some reserve is reserved to account future chain growth. -pub const EXTRA_STORAGE_PROOF_SIZE: u32 = 1024; - -/// Number of bytes, included in the signed Millau transaction apart from the encoded call itself. -/// -/// Can be computed by subtracting encoded call size from raw transaction size. -pub const TX_EXTRA_BYTES: u32 = 103; - -/// Maximum weight of single Millau block. -/// -/// This represents 0.5 seconds of compute assuming a target block time of six seconds. -/// -/// Max PoV size is set to max value, since it isn't important for relay/standalone chains. -pub const MAXIMUM_BLOCK_WEIGHT: Weight = - Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), u64::MAX); - -/// Represents the portion of a block that will be used by Normal extrinsics. -pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); - -/// Maximal number of unrewarded relayer entries in Millau confirmation transaction. -pub const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = 128; - -/// Maximal number of unconfirmed messages in Millau confirmation transaction. -pub const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 128; - -/// The target length of a session (how often authorities change) on Millau measured in of number of -/// blocks. -/// -/// Note that since this is a target sessions may change before/after this time depending on network -/// conditions. -pub const SESSION_LENGTH: BlockNumber = 5 * time_units::MINUTES; - -/// Maximal number of GRANDPA authorities at Millau. -pub const MAX_AUTHORITIES_COUNT: u32 = 5; - -/// Reasonable number of headers in the `votes_ancestries` on Millau chain. -/// -/// See [`bp-header-chain::ChainWithGrandpa`] for more details. -pub const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = 8; - -/// Approximate average header size in `votes_ancestries` field of justification on Millau chain. -/// -/// See [`bp-header-chain::ChainWithGrandpa`] for more details. -pub const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = 256; - -/// Approximate maximal header size on Millau chain. -/// -/// We expect maximal header to have digest item with the new authorities set for every consensus -/// engine (GRANDPA, Babe, BEEFY, ...) - so we multiply it by 3. And also -/// `AVERAGE_HEADER_SIZE_IN_JUSTIFICATION` bytes for other stuff. -/// -/// See [`bp-header-chain::ChainWithGrandpa`] for more details. -pub const MAX_HEADER_SIZE: u32 = MAX_AUTHORITIES_COUNT - .saturating_mul(3) - .saturating_add(AVERAGE_HEADER_SIZE_IN_JUSTIFICATION); - -/// Re-export `time_units` to make usage easier. -pub use time_units::*; - -/// Human readable time units defined in terms of number of blocks. -pub mod time_units { - use super::BlockNumber; - - pub const MILLISECS_PER_BLOCK: u64 = 6000; - pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; - - pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); - pub const HOURS: BlockNumber = MINUTES * 60; - pub const DAYS: BlockNumber = HOURS * 24; -} - -/// Block number type used in Millau. -pub type BlockNumber = u64; - -/// Hash type used in Millau. -pub type Hash = ::Out; - -/// Type of object that can produce hashes on Millau. -pub type Hasher = BlakeTwoAndKeccak256; - -/// The header type used by Millau. -pub type Header = sp_runtime::generic::Header; - -/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. -pub type Signature = MultiSignature; - -/// Some way of identifying an account on the chain. We intentionally make it equivalent -/// to the public key of our transaction signing scheme. -pub type AccountId = <::Signer as IdentifyAccount>::AccountId; - -/// Public key of the chain account that may be used to verify signatures. -pub type AccountSigner = MultiSigner; - -/// Balance of an account. -pub type Balance = u64; - -/// Nonce of a transaction in the chain. -pub type Nonce = u32; - -/// Weight-to-Fee type used by Millau. -pub type WeightToFee = IdentityFee; - -/// Millau chain. -#[derive(RuntimeDebug)] -pub struct Millau; - -impl Chain for Millau { - type BlockNumber = BlockNumber; - type Hash = Hash; - type Hasher = Hasher; - type Header = Header; - - type AccountId = AccountId; - type Balance = Balance; - type Nonce = Nonce; - type Signature = Signature; - - fn max_extrinsic_size() -> u32 { - *BlockLength::get().max.get(DispatchClass::Normal) - } - - fn max_extrinsic_weight() -> Weight { - BlockWeights::get() - .get(DispatchClass::Normal) - .max_extrinsic - .unwrap_or(Weight::MAX) - } -} - -impl ChainWithGrandpa for Millau { - const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = WITH_MILLAU_GRANDPA_PALLET_NAME; - const MAX_AUTHORITIES_COUNT: u32 = MAX_AUTHORITIES_COUNT; - const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = - REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY; - const MAX_HEADER_SIZE: u32 = MAX_HEADER_SIZE; - const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = AVERAGE_HEADER_SIZE_IN_JUSTIFICATION; -} - -impl ChainWithBeefy for Millau { - type CommitmentHasher = Keccak256; - type MmrHashing = Keccak256; - type MmrHash = ::Output; - type BeefyMmrLeafExtra = (); - type AuthorityId = bp_beefy::EcdsaValidatorId; - type AuthorityIdToMerkleLeaf = bp_beefy::BeefyEcdsaToEthereum; -} - -/// Millau Hasher (Blake2-256 ++ Keccak-256) implementation. -#[derive(PartialEq, Eq, Clone, Copy, RuntimeDebug, TypeInfo, Serialize, Deserialize)] -pub struct BlakeTwoAndKeccak256; - -impl sp_core::Hasher for BlakeTwoAndKeccak256 { - type Out = MillauHash; - type StdHasher = hash256_std_hasher::Hash256StdHasher; - const LENGTH: usize = 64; - - fn hash(s: &[u8]) -> Self::Out { - let mut combined_hash = MillauHash::default(); - combined_hash.as_mut()[..32].copy_from_slice(&sp_io::hashing::blake2_256(s)); - combined_hash.as_mut()[32..].copy_from_slice(&sp_io::hashing::keccak_256(s)); - combined_hash - } -} - -impl sp_runtime::traits::Hash for BlakeTwoAndKeccak256 { - type Output = MillauHash; - - fn trie_root(input: Vec<(Vec, Vec)>, state_version: StateVersion) -> Self::Output { - match state_version { - StateVersion::V0 => LayoutV0::::trie_root(input), - StateVersion::V1 => LayoutV1::::trie_root(input), - } - } - - fn ordered_trie_root(input: Vec>, state_version: StateVersion) -> Self::Output { - match state_version { - StateVersion::V0 => LayoutV0::::ordered_trie_root(input), - StateVersion::V1 => LayoutV1::::ordered_trie_root(input), - } - } -} - -frame_support::parameter_types! { - pub BlockLength: limits::BlockLength = - limits::BlockLength::max_with_normal_ratio(2 * 1024 * 1024, NORMAL_DISPATCH_RATIO); - pub BlockWeights: limits::BlockWeights = - limits::BlockWeights::with_sensible_defaults(MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO); -} - -/// Name of the With-Millau GRANDPA pallet instance that is deployed at bridged chains. -pub const WITH_MILLAU_GRANDPA_PALLET_NAME: &str = "BridgeMillauGrandpa"; -/// Name of the With-Millau messages pallet instance that is deployed at bridged chains. -pub const WITH_MILLAU_MESSAGES_PALLET_NAME: &str = "BridgeMillauMessages"; -/// Name of the transaction payment pallet at the Millau runtime. -pub const TRANSACTION_PAYMENT_PALLET_NAME: &str = "TransactionPayment"; - -decl_bridge_runtime_apis!(millau, grandpa); diff --git a/bridges/primitives/chain-millau/src/millau_hash.rs b/bridges/primitives/chain-millau/src/millau_hash.rs deleted file mode 100644 index 8851c319dd451..0000000000000 --- a/bridges/primitives/chain-millau/src/millau_hash.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use parity_util_mem::MallocSizeOf; -use scale_info::TypeInfo; -use sp_runtime::traits::CheckEqual; - -// `sp_core::H512` can't be used, because it doesn't implement `CheckEqual`, which is required -// by `frame_system::Config::Hash`. - -fixed_hash::construct_fixed_hash! { - /// Hash type used in Millau chain. - #[derive(MallocSizeOf, TypeInfo)] - pub struct MillauHash(64); -} - -impl_serde::impl_fixed_hash_serde!(MillauHash, 64); -impl_codec::impl_fixed_hash_codec!(MillauHash, 64); - -impl CheckEqual for MillauHash { - #[cfg(feature = "std")] - fn check_equal(&self, other: &Self) { - use sp_core::hexdisplay::HexDisplay; - if self != other { - println!( - "Hash: given={}, expected={}", - HexDisplay::from(self.as_fixed_bytes()), - HexDisplay::from(other.as_fixed_bytes()), - ); - } - } - - #[cfg(not(feature = "std"))] - fn check_equal(&self, other: &Self) { - use frame_support::Printable; - - if self != other { - "Hash not equal".print(); - self.as_bytes().print(); - other.as_bytes().print(); - } - } -} diff --git a/bridges/primitives/chain-rialto-parachain/Cargo.toml b/bridges/primitives/chain-rialto-parachain/Cargo.toml deleted file mode 100644 index 0122c508e2b92..0000000000000 --- a/bridges/primitives/chain-rialto-parachain/Cargo.toml +++ /dev/null @@ -1,39 +0,0 @@ -[package] -name = "bp-rialto-parachain" -description = "Primitives of Rialto parachain runtime." -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2021" -license = "GPL-3.0-or-later WITH Classpath-exception-2.0" - -[dependencies] - -# Bridge Dependencies - -bp-bridge-hub-cumulus = { path = "../chain-bridge-hub-cumulus", 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 - -frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } - -[features] -default = [ "std" ] -std = [ - "bp-bridge-hub-cumulus/std", - "bp-messages/std", - "bp-runtime/std", - "frame-support/std", - "frame-system/std", - "sp-api/std", - "sp-core/std", - "sp-runtime/std", - "sp-std/std", -] diff --git a/bridges/primitives/chain-rialto-parachain/src/lib.rs b/bridges/primitives/chain-rialto-parachain/src/lib.rs deleted file mode 100644 index 18655503edddf..0000000000000 --- a/bridges/primitives/chain-rialto-parachain/src/lib.rs +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -#![cfg_attr(not(feature = "std"), no_std)] -// RuntimeApi generated functions -#![allow(clippy::too_many_arguments)] - -use bp_messages::MessageNonce; -use bp_runtime::{decl_bridge_runtime_apis, Chain, Parachain}; -use frame_support::{ - dispatch::DispatchClass, - weights::{constants::WEIGHT_REF_TIME_PER_SECOND, IdentityFee, Weight}, -}; -use frame_system::limits; -use sp_core::Hasher as HasherT; -use sp_runtime::{ - traits::{BlakeTwo256, IdentifyAccount, Verify}, - MultiSignature, MultiSigner, Perbill, RuntimeDebug, -}; - -/// Identifier of RialtoParachain in the Rialto relay chain. -/// -/// This identifier is not something that is declared either by Rialto or RialtoParachain. This -/// is an identifier of registration. So in theory it may be changed. But since bridge is going -/// to be deployed after parachain registration AND since parachain de-registration is highly -/// likely impossible, it is fine to declare this constant here. -pub const RIALTO_PARACHAIN_ID: u32 = 2000; - -/// Number of extra bytes (excluding size of storage value itself) of storage proof, built at -/// RialtoParachain chain. This mostly depends on number of entries (and their density) in the -/// storage trie. Some reserve is reserved to account future chain growth. -pub const EXTRA_STORAGE_PROOF_SIZE: u32 = 1024; - -/// Can be computed by subtracting encoded call size from raw transaction size. -pub const TX_EXTRA_BYTES: u32 = 104; - -/// Maximal weight of single RialtoParachain block. -/// -/// This represents two seconds of compute assuming a target block time of six seconds. -/// -/// Max PoV size is set to `5Mb` as all Cumulus-based parachains do. -pub const MAXIMUM_BLOCK_WEIGHT: Weight = - Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), 5 * 1024 * 1024); - -/// Represents the portion of a block that will be used by Normal extrinsics. -pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); - -/// Maximal number of unrewarded relayer entries in Rialto confirmation transaction. -pub const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = 1024; - -/// Maximal number of unconfirmed messages in Rialto confirmation transaction. -pub const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 1024; - -/// Block number type used in Rialto. -pub type BlockNumber = u32; - -/// Hash type used in Rialto. -pub type Hash = ::Out; - -/// The type of object that can produce hashes on Rialto. -pub type Hasher = BlakeTwo256; - -/// The header type used by Rialto. -pub type Header = sp_runtime::generic::Header; - -/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. -pub type Signature = MultiSignature; - -/// Some way of identifying an account on the chain. We intentionally make it equivalent -/// to the public key of our transaction signing scheme. -pub type AccountId = <::Signer as IdentifyAccount>::AccountId; - -/// Public key of the chain account that may be used to verify signatures. -pub type AccountSigner = MultiSigner; - -/// Balance of an account. -pub type Balance = u128; - -/// An instant or duration in time. -pub type Moment = u64; - -/// Nonce of a transaction in the parachain. -pub type Nonce = u32; - -/// Weight-to-Fee type used by Rialto parachain. -pub type WeightToFee = IdentityFee; - -/// Rialto parachain. -#[derive(RuntimeDebug)] -pub struct RialtoParachain; - -impl Chain for RialtoParachain { - type BlockNumber = BlockNumber; - type Hash = Hash; - type Hasher = Hasher; - type Header = Header; - - type AccountId = AccountId; - type Balance = Balance; - type Nonce = Nonce; - type Signature = Signature; - - fn max_extrinsic_size() -> u32 { - *BlockLength::get().max.get(DispatchClass::Normal) - } - - fn max_extrinsic_weight() -> Weight { - BlockWeights::get() - .get(DispatchClass::Normal) - .max_extrinsic - .unwrap_or(Weight::MAX) - } -} - -impl Parachain for RialtoParachain { - const PARACHAIN_ID: u32 = RIALTO_PARACHAIN_ID; -} - -// Technically this is incorrect, because rialto-parachain isn't a bridge hub, but we're -// trying to keep it close to the bridge hubs code (at least in this aspect). -pub use bp_bridge_hub_cumulus::SignedExtension; - -frame_support::parameter_types! { - pub BlockLength: limits::BlockLength = - limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); - pub BlockWeights: limits::BlockWeights = - limits::BlockWeights::with_sensible_defaults(MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO); -} - -/// Name of the With-Rialto-Parachain messages pallet instance that is deployed at bridged chains. -pub const WITH_RIALTO_PARACHAIN_MESSAGES_PALLET_NAME: &str = "BridgeRialtoParachainMessages"; -/// Name of the transaction payment pallet at the Rialto parachain runtime. -pub const TRANSACTION_PAYMENT_PALLET_NAME: &str = "TransactionPayment"; - -decl_bridge_runtime_apis!(rialto_parachain); diff --git a/bridges/primitives/chain-rialto/Cargo.toml b/bridges/primitives/chain-rialto/Cargo.toml deleted file mode 100644 index 083abbd545840..0000000000000 --- a/bridges/primitives/chain-rialto/Cargo.toml +++ /dev/null @@ -1,38 +0,0 @@ -[package] -name = "bp-rialto" -description = "Primitives of Rialto runtime." -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2021" -license = "GPL-3.0-or-later WITH Classpath-exception-2.0" - -[dependencies] - -# Bridge Dependencies - -bp-header-chain = { path = "../header-chain", default-features = false } -bp-messages = { path = "../messages", default-features = false } -bp-runtime = { path = "../runtime", default-features = false } - -# Substrate Based Dependencies - -frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } -sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false } - -[features] -default = [ "std" ] -std = [ - "bp-header-chain/std", - "bp-messages/std", - "bp-runtime/std", - "frame-support/std", - "frame-system/std", - "sp-api/std", - "sp-core/std", - "sp-runtime/std", - "sp-std/std", -] diff --git a/bridges/primitives/chain-rialto/src/lib.rs b/bridges/primitives/chain-rialto/src/lib.rs deleted file mode 100644 index 9d5215c10292a..0000000000000 --- a/bridges/primitives/chain-rialto/src/lib.rs +++ /dev/null @@ -1,210 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -#![cfg_attr(not(feature = "std"), no_std)] -// RuntimeApi generated functions -#![allow(clippy::too_many_arguments)] - -use bp_header_chain::ChainWithGrandpa; -use bp_messages::MessageNonce; -use bp_runtime::{decl_bridge_finality_runtime_apis, decl_bridge_runtime_apis, Chain}; -use frame_support::{ - dispatch::DispatchClass, - weights::{constants::WEIGHT_REF_TIME_PER_SECOND, IdentityFee, Weight}, -}; -use frame_system::limits; -use sp_core::Hasher as HasherT; -use sp_runtime::{ - traits::{BlakeTwo256, IdentifyAccount, Verify}, - MultiSignature, MultiSigner, Perbill, RuntimeDebug, -}; - -/// Number of extra bytes (excluding size of storage value itself) of storage proof, built at -/// Rialto chain. This mostly depends on number of entries (and their density) in the storage trie. -/// Some reserve is reserved to account future chain growth. -pub const EXTRA_STORAGE_PROOF_SIZE: u32 = 1024; - -/// Number of bytes, included in the signed Rialto transaction apart from the encoded call itself. -/// -/// Can be computed by subtracting encoded call size from raw transaction size. -pub const TX_EXTRA_BYTES: u32 = 104; - -/// Maximal weight of single Rialto block. -/// -/// This represents two seconds of compute assuming a target block time of six seconds. -/// -/// Max PoV size is set to max value, since it isn't important for relay/standalone chains. -pub const MAXIMUM_BLOCK_WEIGHT: Weight = - Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), u64::MAX); - -/// Represents the portion of a block that will be used by Normal extrinsics. -pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); - -/// Maximal number of unrewarded relayer entries in Rialto confirmation transaction. -pub const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = 1024; - -/// Maximal number of unconfirmed messages in Rialto confirmation transaction. -pub const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 1024; - -/// The target length of a session (how often authorities change) on Rialto measured in of number of -/// blocks. -/// -/// Note that since this is a target sessions may change before/after this time depending on network -/// conditions. -pub const SESSION_LENGTH: BlockNumber = 4; - -/// Maximal number of GRANDPA authorities at Rialto. -pub const MAX_AUTHORITIES_COUNT: u32 = 5; - -/// Reasonable number of headers in the `votes_ancestries` on Rialto chain. -/// -/// See [`bp-header-chain::ChainWithGrandpa`] for more details. -pub const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = 8; - -/// Approximate average header size in `votes_ancestries` field of justification on Rialto chain. -/// -/// See [`bp-header-chain::ChainWithGrandpa`] for more details. -pub const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = 256; - -/// Approximate maximal header size on Rialto chain. -/// -/// We expect maximal header to have digest item with the new authorities set for every consensus -/// engine (GRANDPA, Babe, BEEFY, ...) - so we multiply it by 3. And also -/// `AVERAGE_HEADER_SIZE_IN_JUSTIFICATION` bytes for other stuff. -/// -/// See [`bp-header-chain::ChainWithGrandpa`] for more details. -pub const MAX_HEADER_SIZE: u32 = MAX_AUTHORITIES_COUNT - .saturating_mul(3) - .saturating_add(AVERAGE_HEADER_SIZE_IN_JUSTIFICATION); - -/// Maximal size of encoded `bp_parachains::ParaStoredHeaderData` structure among all Rialto -/// parachains. -/// -/// It includes the block number and state root, so it shall be near 40 bytes, but let's have some -/// reserve. -pub const MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE: u32 = 128; - -/// Re-export `time_units` to make usage easier. -pub use time_units::*; - -/// Human readable time units defined in terms of number of blocks. -pub mod time_units { - use super::{BlockNumber, SESSION_LENGTH}; - - pub const MILLISECS_PER_BLOCK: u64 = 6000; - pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; - - pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); - pub const HOURS: BlockNumber = MINUTES * 60; - pub const DAYS: BlockNumber = HOURS * 24; - - pub const EPOCH_DURATION_IN_SLOTS: BlockNumber = SESSION_LENGTH; - - // 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks. - pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); -} - -/// Block number type used in Rialto. -pub type BlockNumber = u32; - -/// Hash type used in Rialto. -pub type Hash = ::Out; - -/// The type of object that can produce hashes on Rialto. -pub type Hasher = BlakeTwo256; - -/// The header type used by Rialto. -pub type Header = sp_runtime::generic::Header; - -/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. -pub type Signature = MultiSignature; - -/// Some way of identifying an account on the chain. We intentionally make it equivalent -/// to the public key of our transaction signing scheme. -pub type AccountId = <::Signer as IdentifyAccount>::AccountId; - -/// Public key of the chain account that may be used to verify signatures. -pub type AccountSigner = MultiSigner; - -/// Balance of an account. -pub type Balance = u128; - -/// An instant or duration in time. -pub type Moment = u64; - -/// Nonce of a transaction in the chain. -pub type Nonce = u32; - -/// Weight-to-Fee type used by Rialto. -pub type WeightToFee = IdentityFee; - -/// Rialto chain. -#[derive(RuntimeDebug)] -pub struct Rialto; - -impl Chain for Rialto { - type BlockNumber = BlockNumber; - type Hash = Hash; - type Hasher = Hasher; - type Header = Header; - - type AccountId = AccountId; - type Balance = Balance; - type Nonce = Nonce; - type Signature = Signature; - - fn max_extrinsic_size() -> u32 { - *BlockLength::get().max.get(DispatchClass::Normal) - } - - fn max_extrinsic_weight() -> Weight { - BlockWeights::get() - .get(DispatchClass::Normal) - .max_extrinsic - .unwrap_or(Weight::MAX) - } -} - -impl ChainWithGrandpa for Rialto { - const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = WITH_RIALTO_GRANDPA_PALLET_NAME; - const MAX_AUTHORITIES_COUNT: u32 = MAX_AUTHORITIES_COUNT; - const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = - REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY; - const MAX_HEADER_SIZE: u32 = MAX_HEADER_SIZE; - const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = AVERAGE_HEADER_SIZE_IN_JUSTIFICATION; -} - -frame_support::parameter_types! { - pub BlockLength: limits::BlockLength = - limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); - pub BlockWeights: limits::BlockWeights = - limits::BlockWeights::with_sensible_defaults(MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO); -} - -/// Name of the With-Rialto GRANDPA pallet instance that is deployed at bridged chains. -pub const WITH_RIALTO_GRANDPA_PALLET_NAME: &str = "BridgeRialtoGrandpa"; -/// Name of the With-Rialto messages pallet instance that is deployed at bridged chains. -pub const WITH_RIALTO_MESSAGES_PALLET_NAME: &str = "BridgeRialtoMessages"; -/// Name of the With-Rialto parachains bridge pallet instance that is deployed at bridged chains. -pub const WITH_RIALTO_BRIDGE_PARAS_PALLET_NAME: &str = "BridgeRialtoParachains"; - -/// Name of the parachain registrar pallet in the Rialto runtime. -pub const PARAS_REGISTRAR_PALLET_NAME: &str = "Registrar"; - -/// Name of the parachains pallet in the Rialto runtime. -pub const PARAS_PALLET_NAME: &str = "Paras"; - -decl_bridge_runtime_apis!(rialto, grandpa); diff --git a/bridges/primitives/runtime/src/chain.rs b/bridges/primitives/runtime/src/chain.rs index e1809e145248f..b78023efb1b86 100644 --- a/bridges/primitives/runtime/src/chain.rs +++ b/bridges/primitives/runtime/src/chain.rs @@ -280,7 +280,7 @@ pub type TransactionEraOf = crate::TransactionEra, HashOf /// - constants that are stringified names of runtime API methods: /// - `BEST_FINALIZED__HEADER_METHOD` /// - `_ACCEPTED__FINALITY_PROOFS_METHOD` -/// The name of the chain has to be specified in snake case (e.g. `rialto_parachain`). +/// The name of the chain has to be specified in snake case (e.g. `bridge_hub_polkadot`). #[macro_export] macro_rules! decl_bridge_finality_runtime_apis { ($chain: ident $(, $consensus: ident => $justification_type: ty)?) => { @@ -332,7 +332,7 @@ macro_rules! decl_bridge_finality_runtime_apis { /// - `FromInboundLaneApi` /// - constants that are stringified names of runtime API methods: /// - `FROM__MESSAGE_DETAILS_METHOD`, -/// The name of the chain has to be specified in snake case (e.g. `rialto_parachain`). +/// The name of the chain has to be specified in snake case (e.g. `bridge_hub_polkadot`). #[macro_export] macro_rules! decl_bridge_messages_runtime_apis { ($chain: ident) => { @@ -390,7 +390,7 @@ macro_rules! decl_bridge_messages_runtime_apis { /// Convenience macro that declares bridge finality runtime apis, bridge messages runtime apis /// and related constants for a chain. -/// The name of the chain has to be specified in snake case (e.g. `rialto_parachain`). +/// The name of the chain has to be specified in snake case (e.g. `bridge_hub_polkadot`). #[macro_export] macro_rules! decl_bridge_runtime_apis { ($chain: ident $(, $consensus: ident)?) => { diff --git a/bridges/primitives/runtime/src/lib.rs b/bridges/primitives/runtime/src/lib.rs index e5277d8db6a84..0b6f90fd934ff 100644 --- a/bridges/primitives/runtime/src/lib.rs +++ b/bridges/primitives/runtime/src/lib.rs @@ -61,15 +61,6 @@ pub use sp_runtime::paste; /// Use this when something must be shared among all instances. pub const NO_INSTANCE_ID: ChainId = [0, 0, 0, 0]; -/// Rialto chain id. -pub const RIALTO_CHAIN_ID: ChainId = *b"rlto"; - -/// RialtoParachain chain id. -pub const RIALTO_PARACHAIN_CHAIN_ID: ChainId = *b"rlpa"; - -/// Millau chain id. -pub const MILLAU_CHAIN_ID: ChainId = *b"mlau"; - /// Polkadot chain id. pub const POLKADOT_CHAIN_ID: ChainId = *b"pdot"; @@ -277,18 +268,6 @@ pub fn storage_map_final_key( StorageKey(final_key) } -/// This is how a storage key of storage parameter (`parameter_types! { storage Param: bool = false; -/// }`) is computed. -/// -/// Copied from `frame_support::parameter_types` macro. -pub fn storage_parameter_key(parameter_name: &str) -> StorageKey { - let mut buffer = Vec::with_capacity(1 + parameter_name.len() + 1); - buffer.push(b':'); - buffer.extend_from_slice(parameter_name.as_bytes()); - buffer.push(b':'); - StorageKey(sp_io::hashing::twox_128(&buffer).to_vec()) -} - /// This is how a storage key of storage value is computed. /// /// Copied from `frame_support::storage::storage_prefix`. @@ -574,14 +553,6 @@ where mod tests { use super::*; - #[test] - fn storage_parameter_key_works() { - assert_eq!( - storage_parameter_key("MillauToRialtoConversionRate"), - StorageKey(hex_literal::hex!("58942375551bb0af1682f72786b59d04").to_vec()), - ); - } - #[test] fn storage_value_key_works() { assert_eq!( diff --git a/bridges/relays/bin-substrate/Cargo.toml b/bridges/relays/bin-substrate/Cargo.toml index b4e69816e59c4..b1ebcbbdcee9b 100644 --- a/bridges/relays/bin-substrate/Cargo.toml +++ b/bridges/relays/bin-substrate/Cargo.toml @@ -25,19 +25,12 @@ strum = { version = "0.25.0", features = ["derive"] } bp-header-chain = { path = "../../primitives/header-chain" } bp-messages = { path = "../../primitives/messages" } bp-parachains = { path = "../../primitives/parachains" } -bp-millau = { path = "../../primitives/chain-millau" } bp-polkadot-bulletin = { path = "../../primitives/chain-polkadot-bulletin" } bp-polkadot-core = { path = "../../primitives/polkadot-core" } -bp-rialto = { path = "../../primitives/chain-rialto" } -bp-rialto-parachain = { path = "../../primitives/chain-rialto-parachain" } bp-runtime = { path = "../../primitives/runtime" } bridge-runtime-common = { path = "../../bin/runtime-common" } -millau-runtime = { path = "../../bin/millau/runtime" } pallet-bridge-parachains = { path = "../../modules/parachains" } parachains-relay = { path = "../parachains" } -relay-millau-client = { path = "../client-millau" } -relay-rialto-client = { path = "../client-rialto" } -relay-rialto-parachain-client = { path = "../client-rialto-parachain" } relay-bridge-hub-kusama-client = { path = "../client-bridge-hub-kusama" } relay-bridge-hub-polkadot-client = { path = "../client-bridge-hub-polkadot" } relay-bridge-hub-rococo-client = { path = "../client-bridge-hub-rococo" } @@ -51,10 +44,6 @@ relay-substrate-client = { path = "../client-substrate" } relay-utils = { path = "../utils" } relay-westend-client = { path = "../client-westend" } relay-wococo-client = { path = "../client-wococo" } -rialto-runtime = { path = "../../bin/rialto/runtime" } -# we are not using this runtime to craft call or transactions, but we still need it -# to prepare large XCM messages -rialto-parachain-runtime = { path = "../../bin/rialto-parachain/runtime" } substrate-relay-helper = { path = "../lib-substrate-relay" } # Substrate Dependencies @@ -63,14 +52,6 @@ frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = " sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -# Polkadot Dependencies -polkadot-parachain-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } - [dev-dependencies] bp-test-utils = { path = "../../primitives/test-utils" } hex-literal = "0.4" diff --git a/bridges/relays/bin-substrate/src/bridges/mod.rs b/bridges/relays/bin-substrate/src/bridges/mod.rs index 5a6bf72d0c523..5a40b80cb9321 100644 --- a/bridges/relays/bin-substrate/src/bridges/mod.rs +++ b/bridges/relays/bin-substrate/src/bridges/mod.rs @@ -18,8 +18,5 @@ pub mod kusama_polkadot; pub mod polkadot_bulletin; -pub mod rialto_millau; -pub mod rialto_parachain_millau; pub mod rococo_westend; pub mod rococo_wococo; -pub mod westend_millau; diff --git a/bridges/relays/bin-substrate/src/bridges/rialto_millau/millau_headers_to_rialto.rs b/bridges/relays/bin-substrate/src/bridges/rialto_millau/millau_headers_to_rialto.rs deleted file mode 100644 index 7fd5513a27295..0000000000000 --- a/bridges/relays/bin-substrate/src/bridges/rialto_millau/millau_headers_to_rialto.rs +++ /dev/null @@ -1,74 +0,0 @@ -// 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 . - -//! Millau-to-Rialto headers sync entrypoint. - -use crate::cli::bridge::{ - CliBridgeBase, MessagesCliBridge, RelayToRelayEquivocationDetectionCliBridge, - RelayToRelayHeadersCliBridge, -}; -use substrate_relay_helper::{ - equivocation::{ - DirectReportGrandpaEquivocationCallBuilder, SubstrateEquivocationDetectionPipeline, - }, - finality::{DirectSubmitGrandpaFinalityProofCallBuilder, SubstrateFinalitySyncPipeline}, - finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline}, -}; - -/// Description of Millau -> Rialto finalized headers bridge. -#[derive(Clone, Debug)] -pub struct MillauFinalityToRialto; - -impl SubstrateFinalityPipeline for MillauFinalityToRialto { - type SourceChain = relay_millau_client::Millau; - type TargetChain = relay_rialto_client::Rialto; - - type FinalityEngine = GrandpaFinalityEngine; -} - -impl SubstrateFinalitySyncPipeline for MillauFinalityToRialto { - type SubmitFinalityProofCallBuilder = DirectSubmitGrandpaFinalityProofCallBuilder< - Self, - rialto_runtime::Runtime, - rialto_runtime::MillauGrandpaInstance, - >; -} - -impl SubstrateEquivocationDetectionPipeline for MillauFinalityToRialto { - type ReportEquivocationCallBuilder = - DirectReportGrandpaEquivocationCallBuilder; -} - -/// `Millau` to `Rialto` bridge definition. -pub struct MillauToRialtoCliBridge {} - -impl CliBridgeBase for MillauToRialtoCliBridge { - type Source = relay_millau_client::Millau; - type Target = relay_rialto_client::Rialto; -} - -impl RelayToRelayHeadersCliBridge for MillauToRialtoCliBridge { - type Finality = MillauFinalityToRialto; -} - -impl RelayToRelayEquivocationDetectionCliBridge for MillauToRialtoCliBridge { - type Equivocation = MillauFinalityToRialto; -} - -impl MessagesCliBridge for MillauToRialtoCliBridge { - type MessagesLane = - crate::bridges::rialto_millau::millau_messages_to_rialto::MillauMessagesToRialto; -} diff --git a/bridges/relays/bin-substrate/src/bridges/rialto_millau/millau_messages_to_rialto.rs b/bridges/relays/bin-substrate/src/bridges/rialto_millau/millau_messages_to_rialto.rs deleted file mode 100644 index e6a2ef1a85660..0000000000000 --- a/bridges/relays/bin-substrate/src/bridges/rialto_millau/millau_messages_to_rialto.rs +++ /dev/null @@ -1,47 +0,0 @@ -// 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 . - -//! Millau-to-Rialto messages sync entrypoint. - -use relay_millau_client::Millau; -use relay_rialto_client::Rialto; -use substrate_relay_helper::messages_lane::{ - DirectReceiveMessagesDeliveryProofCallBuilder, DirectReceiveMessagesProofCallBuilder, - SubstrateMessageLane, -}; - -/// Description of Millau -> Rialto messages bridge. -#[derive(Clone, Debug)] -pub struct MillauMessagesToRialto; - -impl SubstrateMessageLane for MillauMessagesToRialto { - type SourceChain = Millau; - type TargetChain = Rialto; - - type ReceiveMessagesProofCallBuilder = DirectReceiveMessagesProofCallBuilder< - Self, - rialto_runtime::Runtime, - rialto_runtime::WithMillauMessagesInstance, - >; - type ReceiveMessagesDeliveryProofCallBuilder = DirectReceiveMessagesDeliveryProofCallBuilder< - Self, - millau_runtime::Runtime, - millau_runtime::WithRialtoMessagesInstance, - >; - - type SourceBatchCallBuilder = (); - type TargetBatchCallBuilder = (); -} diff --git a/bridges/relays/bin-substrate/src/bridges/rialto_millau/mod.rs b/bridges/relays/bin-substrate/src/bridges/rialto_millau/mod.rs deleted file mode 100644 index 2353b58ce616e..0000000000000 --- a/bridges/relays/bin-substrate/src/bridges/rialto_millau/mod.rs +++ /dev/null @@ -1,22 +0,0 @@ -// 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 . - -//! Declaration of all bridges between Rialto and Millau. - -pub mod millau_headers_to_rialto; -pub mod millau_messages_to_rialto; -pub mod rialto_headers_to_millau; -pub mod rialto_messages_to_millau; diff --git a/bridges/relays/bin-substrate/src/bridges/rialto_millau/rialto_headers_to_millau.rs b/bridges/relays/bin-substrate/src/bridges/rialto_millau/rialto_headers_to_millau.rs deleted file mode 100644 index d9b98d77784e7..0000000000000 --- a/bridges/relays/bin-substrate/src/bridges/rialto_millau/rialto_headers_to_millau.rs +++ /dev/null @@ -1,74 +0,0 @@ -// 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 . - -//! Rialto-to-Millau headers sync entrypoint. - -use crate::cli::bridge::{ - CliBridgeBase, MessagesCliBridge, RelayToRelayEquivocationDetectionCliBridge, - RelayToRelayHeadersCliBridge, -}; -use substrate_relay_helper::{ - equivocation::{ - DirectReportGrandpaEquivocationCallBuilder, SubstrateEquivocationDetectionPipeline, - }, - finality::{DirectSubmitGrandpaFinalityProofCallBuilder, SubstrateFinalitySyncPipeline}, - finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline}, -}; - -/// Description of Millau -> Rialto finalized headers bridge. -#[derive(Clone, Debug)] -pub struct RialtoFinalityToMillau; - -impl SubstrateFinalityPipeline for RialtoFinalityToMillau { - type SourceChain = relay_rialto_client::Rialto; - type TargetChain = relay_millau_client::Millau; - - type FinalityEngine = GrandpaFinalityEngine; -} - -impl SubstrateFinalitySyncPipeline for RialtoFinalityToMillau { - type SubmitFinalityProofCallBuilder = DirectSubmitGrandpaFinalityProofCallBuilder< - Self, - millau_runtime::Runtime, - millau_runtime::RialtoGrandpaInstance, - >; -} - -impl SubstrateEquivocationDetectionPipeline for RialtoFinalityToMillau { - type ReportEquivocationCallBuilder = - DirectReportGrandpaEquivocationCallBuilder; -} - -/// `Rialto` to `Millau` bridge definition. -pub struct RialtoToMillauCliBridge {} - -impl CliBridgeBase for RialtoToMillauCliBridge { - type Source = relay_rialto_client::Rialto; - type Target = relay_millau_client::Millau; -} - -impl RelayToRelayHeadersCliBridge for RialtoToMillauCliBridge { - type Finality = RialtoFinalityToMillau; -} - -impl RelayToRelayEquivocationDetectionCliBridge for RialtoToMillauCliBridge { - type Equivocation = RialtoFinalityToMillau; -} - -impl MessagesCliBridge for RialtoToMillauCliBridge { - type MessagesLane = - crate::bridges::rialto_millau::rialto_messages_to_millau::RialtoMessagesToMillau; -} diff --git a/bridges/relays/bin-substrate/src/bridges/rialto_millau/rialto_messages_to_millau.rs b/bridges/relays/bin-substrate/src/bridges/rialto_millau/rialto_messages_to_millau.rs deleted file mode 100644 index b45239fb9a91e..0000000000000 --- a/bridges/relays/bin-substrate/src/bridges/rialto_millau/rialto_messages_to_millau.rs +++ /dev/null @@ -1,47 +0,0 @@ -// 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 . - -//! Rialto-to-Millau messages sync entrypoint. - -use relay_millau_client::Millau; -use relay_rialto_client::Rialto; -use substrate_relay_helper::messages_lane::{ - DirectReceiveMessagesDeliveryProofCallBuilder, DirectReceiveMessagesProofCallBuilder, - SubstrateMessageLane, -}; - -/// Description of Rialto -> Millau messages bridge. -#[derive(Clone, Debug)] -pub struct RialtoMessagesToMillau; - -impl SubstrateMessageLane for RialtoMessagesToMillau { - type SourceChain = Rialto; - type TargetChain = Millau; - - type ReceiveMessagesProofCallBuilder = DirectReceiveMessagesProofCallBuilder< - Self, - millau_runtime::Runtime, - millau_runtime::WithRialtoMessagesInstance, - >; - type ReceiveMessagesDeliveryProofCallBuilder = DirectReceiveMessagesDeliveryProofCallBuilder< - Self, - rialto_runtime::Runtime, - rialto_runtime::WithMillauMessagesInstance, - >; - - type SourceBatchCallBuilder = (); - type TargetBatchCallBuilder = (); -} diff --git a/bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/millau_headers_to_rialto_parachain.rs b/bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/millau_headers_to_rialto_parachain.rs deleted file mode 100644 index 051057e217665..0000000000000 --- a/bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/millau_headers_to_rialto_parachain.rs +++ /dev/null @@ -1,95 +0,0 @@ -// 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 . - -//! Millau-to-RialtoParachain headers sync entrypoint. - -// 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 . - -//! Millau-to-RialtoParachain headers sync entrypoint. - -use crate::cli::bridge::{ - CliBridgeBase, MessagesCliBridge, RelayToRelayEquivocationDetectionCliBridge, - RelayToRelayHeadersCliBridge, -}; -use substrate_relay_helper::{ - equivocation::{ - DirectReportGrandpaEquivocationCallBuilder, SubstrateEquivocationDetectionPipeline, - }, - finality::SubstrateFinalitySyncPipeline, - finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline}, -}; - -substrate_relay_helper::generate_submit_finality_proof_call_builder!( - MillauFinalityToRialtoParachain, - MillauFinalityToRialtoParachainCallBuilder, - relay_rialto_parachain_client::RuntimeCall::BridgeMillauGrandpa, - relay_rialto_parachain_client::BridgeGrandpaCall::submit_finality_proof -); - -/// Description of Millau -> Rialto finalized headers bridge. -#[derive(Clone, Debug)] -pub struct MillauFinalityToRialtoParachain; - -impl SubstrateFinalityPipeline for MillauFinalityToRialtoParachain { - type SourceChain = relay_millau_client::Millau; - type TargetChain = relay_rialto_parachain_client::RialtoParachain; - - type FinalityEngine = GrandpaFinalityEngine; -} - -impl SubstrateFinalitySyncPipeline for MillauFinalityToRialtoParachain { - type SubmitFinalityProofCallBuilder = MillauFinalityToRialtoParachainCallBuilder; -} - -impl SubstrateEquivocationDetectionPipeline for MillauFinalityToRialtoParachain { - type ReportEquivocationCallBuilder = - DirectReportGrandpaEquivocationCallBuilder; -} - -/// `Millau` to `RialtoParachain` bridge definition. -pub struct MillauToRialtoParachainCliBridge {} - -impl CliBridgeBase for MillauToRialtoParachainCliBridge { - type Source = relay_millau_client::Millau; - type Target = relay_rialto_parachain_client::RialtoParachain; -} - -impl RelayToRelayHeadersCliBridge for MillauToRialtoParachainCliBridge { - type Finality = MillauFinalityToRialtoParachain; -} - -impl RelayToRelayEquivocationDetectionCliBridge for MillauToRialtoParachainCliBridge { - type Equivocation = MillauFinalityToRialtoParachain; -} - -impl MessagesCliBridge for MillauToRialtoParachainCliBridge { - type MessagesLane = - crate::bridges::rialto_parachain_millau::millau_messages_to_rialto_parachain::MillauMessagesToRialtoParachain; -} diff --git a/bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/millau_messages_to_rialto_parachain.rs b/bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/millau_messages_to_rialto_parachain.rs deleted file mode 100644 index 8fedd22a40abe..0000000000000 --- a/bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/millau_messages_to_rialto_parachain.rs +++ /dev/null @@ -1,51 +0,0 @@ -// 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 . - -//! Millau-to-RialtoParachain messages sync entrypoint. - -use relay_millau_client::Millau; -use relay_rialto_parachain_client::RialtoParachain; -use substrate_relay_helper::{ - messages_lane::{DirectReceiveMessagesDeliveryProofCallBuilder, SubstrateMessageLane}, - UtilityPalletBatchCallBuilder, -}; - -substrate_relay_helper::generate_receive_message_proof_call_builder!( - MillauMessagesToRialtoParachain, - MillauMessagesToRialtoParachainReceiveMessagesProofCallBuilder, - relay_rialto_parachain_client::RuntimeCall::BridgeMillauMessages, - relay_rialto_parachain_client::BridgeMessagesCall::receive_messages_proof -); - -/// Description of Millau -> RialtoParachain messages bridge. -#[derive(Clone, Debug)] -pub struct MillauMessagesToRialtoParachain; - -impl SubstrateMessageLane for MillauMessagesToRialtoParachain { - type SourceChain = Millau; - type TargetChain = RialtoParachain; - - type ReceiveMessagesProofCallBuilder = - MillauMessagesToRialtoParachainReceiveMessagesProofCallBuilder; - type ReceiveMessagesDeliveryProofCallBuilder = DirectReceiveMessagesDeliveryProofCallBuilder< - Self, - millau_runtime::Runtime, - millau_runtime::WithRialtoParachainMessagesInstance, - >; - - type SourceBatchCallBuilder = UtilityPalletBatchCallBuilder; - type TargetBatchCallBuilder = (); -} diff --git a/bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/mod.rs b/bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/mod.rs deleted file mode 100644 index f0613d1511eb3..0000000000000 --- a/bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/mod.rs +++ /dev/null @@ -1,22 +0,0 @@ -// 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 . - -//! Declaration of all bridges between Rialto Parachain and Millau. - -pub mod millau_headers_to_rialto_parachain; -pub mod millau_messages_to_rialto_parachain; -pub mod rialto_parachain_messages_to_millau; -pub mod rialto_parachains_to_millau; diff --git a/bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/rialto_parachain_messages_to_millau.rs b/bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/rialto_parachain_messages_to_millau.rs deleted file mode 100644 index e19953eac554d..0000000000000 --- a/bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/rialto_parachain_messages_to_millau.rs +++ /dev/null @@ -1,51 +0,0 @@ -// 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 . - -//! RialtoParachain-to-Millau messages sync entrypoint. - -use relay_millau_client::Millau; -use relay_rialto_parachain_client::RialtoParachain; -use substrate_relay_helper::{ - messages_lane::{DirectReceiveMessagesProofCallBuilder, SubstrateMessageLane}, - UtilityPalletBatchCallBuilder, -}; - -substrate_relay_helper::generate_receive_message_delivery_proof_call_builder!( - RialtoParachainMessagesToMillau, - RialtoParachainMessagesToMillauReceiveMessagesDeliveryProofCallBuilder, - relay_rialto_parachain_client::RuntimeCall::BridgeMillauMessages, - relay_rialto_parachain_client::BridgeMessagesCall::receive_messages_delivery_proof -); - -/// Description of RialtoParachain -> Millau messages bridge. -#[derive(Clone, Debug)] -pub struct RialtoParachainMessagesToMillau; - -impl SubstrateMessageLane for RialtoParachainMessagesToMillau { - type SourceChain = RialtoParachain; - type TargetChain = Millau; - - type ReceiveMessagesProofCallBuilder = DirectReceiveMessagesProofCallBuilder< - Self, - millau_runtime::Runtime, - millau_runtime::WithRialtoParachainMessagesInstance, - >; - type ReceiveMessagesDeliveryProofCallBuilder = - RialtoParachainMessagesToMillauReceiveMessagesDeliveryProofCallBuilder; - - type SourceBatchCallBuilder = (); - type TargetBatchCallBuilder = UtilityPalletBatchCallBuilder; -} diff --git a/bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/rialto_parachains_to_millau.rs b/bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/rialto_parachains_to_millau.rs deleted file mode 100644 index 6b2a1332144dc..0000000000000 --- a/bridges/relays/bin-substrate/src/bridges/rialto_parachain_millau/rialto_parachains_to_millau.rs +++ /dev/null @@ -1,65 +0,0 @@ -// 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 . - -//! Rialto-to-Millau parachains sync entrypoint. - -use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge, ParachainToRelayHeadersCliBridge}; -use relay_millau_client::Millau; -use relay_rialto_client::Rialto; -use relay_rialto_parachain_client::RialtoParachain; -use substrate_relay_helper::parachains::{ - DirectSubmitParachainHeadsCallBuilder, SubstrateParachainsPipeline, -}; - -/// Rialto-to-Millau parachains sync description. -#[derive(Clone, Debug)] -pub struct RialtoParachainsToMillau; - -impl SubstrateParachainsPipeline for RialtoParachainsToMillau { - type SourceParachain = RialtoParachain; - type SourceRelayChain = Rialto; - type TargetChain = Millau; - - type SubmitParachainHeadsCallBuilder = RialtoParachainsToMillauSubmitParachainHeadsCallBuilder; -} - -/// `submit_parachain_heads` call builder for Rialto-to-Millau parachains sync pipeline. -pub type RialtoParachainsToMillauSubmitParachainHeadsCallBuilder = - DirectSubmitParachainHeadsCallBuilder< - RialtoParachainsToMillau, - millau_runtime::Runtime, - millau_runtime::WithRialtoParachainsInstance, - >; - -/// `RialtoParachain` to `Millau` bridge definition. -pub struct RialtoParachainToMillauCliBridge {} - -impl CliBridgeBase for RialtoParachainToMillauCliBridge { - type Source = RialtoParachain; - type Target = Millau; -} - -impl ParachainToRelayHeadersCliBridge for RialtoParachainToMillauCliBridge { - type SourceRelay = Rialto; - type ParachainFinality = RialtoParachainsToMillau; - type RelayFinality = - crate::bridges::rialto_millau::rialto_headers_to_millau::RialtoFinalityToMillau; -} - -impl MessagesCliBridge for RialtoParachainToMillauCliBridge { - type MessagesLane = - crate::bridges::rialto_parachain_millau::rialto_parachain_messages_to_millau::RialtoParachainMessagesToMillau; -} diff --git a/bridges/relays/bin-substrate/src/bridges/westend_millau/mod.rs b/bridges/relays/bin-substrate/src/bridges/westend_millau/mod.rs deleted file mode 100644 index 10bc19241ce12..0000000000000 --- a/bridges/relays/bin-substrate/src/bridges/westend_millau/mod.rs +++ /dev/null @@ -1,20 +0,0 @@ -// 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 . - -//! Declaration of all bridges between Westend and Millau. - -pub mod westend_headers_to_millau; -pub mod westend_parachains_to_millau; diff --git a/bridges/relays/bin-substrate/src/bridges/westend_millau/westend_headers_to_millau.rs b/bridges/relays/bin-substrate/src/bridges/westend_millau/westend_headers_to_millau.rs deleted file mode 100644 index afbbd064d1fe0..0000000000000 --- a/bridges/relays/bin-substrate/src/bridges/westend_millau/westend_headers_to_millau.rs +++ /dev/null @@ -1,54 +0,0 @@ -// 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 . - -//! Westend-to-Millau headers sync entrypoint. - -use crate::cli::bridge::{CliBridgeBase, RelayToRelayHeadersCliBridge}; -use substrate_relay_helper::{ - finality::{DirectSubmitGrandpaFinalityProofCallBuilder, SubstrateFinalitySyncPipeline}, - finality_base::{engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalityPipeline}, -}; - -/// Description of Westend -> Millau finalized headers bridge. -#[derive(Clone, Debug)] -pub struct WestendFinalityToMillau; - -impl SubstrateFinalityPipeline for WestendFinalityToMillau { - type SourceChain = relay_westend_client::Westend; - type TargetChain = relay_millau_client::Millau; - - type FinalityEngine = GrandpaFinalityEngine; -} - -impl SubstrateFinalitySyncPipeline for WestendFinalityToMillau { - type SubmitFinalityProofCallBuilder = DirectSubmitGrandpaFinalityProofCallBuilder< - Self, - millau_runtime::Runtime, - millau_runtime::WestendGrandpaInstance, - >; -} - -/// `Westend` to `Millau` bridge definition. -pub struct WestendToMillauCliBridge {} - -impl CliBridgeBase for WestendToMillauCliBridge { - type Source = relay_westend_client::Westend; - type Target = relay_millau_client::Millau; -} - -impl RelayToRelayHeadersCliBridge for WestendToMillauCliBridge { - type Finality = WestendFinalityToMillau; -} diff --git a/bridges/relays/bin-substrate/src/bridges/westend_millau/westend_parachains_to_millau.rs b/bridges/relays/bin-substrate/src/bridges/westend_millau/westend_parachains_to_millau.rs deleted file mode 100644 index 96023dc430a28..0000000000000 --- a/bridges/relays/bin-substrate/src/bridges/westend_millau/westend_parachains_to_millau.rs +++ /dev/null @@ -1,90 +0,0 @@ -// 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 . - -//! Westend-to-Millau parachains sync entrypoint. - -use crate::cli::bridge::{CliBridgeBase, ParachainToRelayHeadersCliBridge}; -use relay_millau_client::Millau; -use relay_westend_client::Westend; -use substrate_relay_helper::parachains::{ - DirectSubmitParachainHeadsCallBuilder, SubstrateParachainsPipeline, -}; - -/// Westend-to-Millau parachains sync description. -#[derive(Clone, Debug)] -pub struct WestendParachainsToMillau; - -impl SubstrateParachainsPipeline for WestendParachainsToMillau { - type SourceParachain = relay_asset_hub_westend_client::AssetHubWestend; - type SourceRelayChain = Westend; - type TargetChain = Millau; - - type SubmitParachainHeadsCallBuilder = WestendParachainsToMillauSubmitParachainHeadsCallBuilder; -} - -/// `submit_parachain_heads` call builder for Rialto-to-Millau parachains sync pipeline. -pub type WestendParachainsToMillauSubmitParachainHeadsCallBuilder = - DirectSubmitParachainHeadsCallBuilder< - WestendParachainsToMillau, - millau_runtime::Runtime, - millau_runtime::WithWestendParachainsInstance, - >; - -/// `WestendParachain` to `Millau` bridge definition. -pub struct AssetHubWestendToMillauCliBridge {} - -impl ParachainToRelayHeadersCliBridge for AssetHubWestendToMillauCliBridge { - type SourceRelay = Westend; - type ParachainFinality = WestendParachainsToMillau; - type RelayFinality = - crate::bridges::westend_millau::westend_headers_to_millau::WestendFinalityToMillau; -} - -impl CliBridgeBase for AssetHubWestendToMillauCliBridge { - type Source = relay_asset_hub_westend_client::AssetHubWestend; - type Target = Millau; -} - -/// TODO: Note: I know this does not belong here, but I don't want to add it to the -/// `chain-asset-hub-westend` or `chain-westend`, because we wont use it for production and I don't -/// want to bring this to the bridges subtree now. Anyway, we plan to retire millau/rialto, so this -/// hack will disappear with that. -pub mod relay_asset_hub_westend_client { - use bp_runtime::{ChainId, UnderlyingChainProvider}; - use relay_substrate_client::Chain; - use std::time::Duration; - - /// `AssetHubWestend` parachain definition - #[derive(Debug, Clone, Copy)] - pub struct AssetHubWestend; - - impl UnderlyingChainProvider for AssetHubWestend { - type Chain = millau_runtime::bp_bridged_chain::AssetHubWestend; - } - - // Westmint seems to use the same configuration as all Polkadot-like chains, so we'll use - // Westend primitives here. - impl Chain for AssetHubWestend { - const ID: ChainId = bp_runtime::ASSET_HUB_WESTEND_CHAIN_ID; - const NAME: &'static str = "Westmint"; - const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = - millau_runtime::bp_bridged_chain::BEST_FINALIZED_ASSETHUBWESTEND_HEADER_METHOD; - const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(6); - - type SignedBlock = bp_polkadot_core::SignedBlock; - type Call = (); - } -} diff --git a/bridges/relays/bin-substrate/src/chains/millau.rs b/bridges/relays/bin-substrate/src/chains/millau.rs deleted file mode 100644 index f60d60386e9ba..0000000000000 --- a/bridges/relays/bin-substrate/src/chains/millau.rs +++ /dev/null @@ -1,75 +0,0 @@ -// 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 . - -//! Millau chain specification for CLI. - -use crate::cli::{encode_message::CliEncodeMessage, CliChain}; -use bp_runtime::EncodedOrDecodedCall; -use bridge_runtime_common::CustomNetworkId; -use relay_millau_client::Millau; -use relay_substrate_client::SimpleRuntimeVersion; -use xcm_executor::traits::ExportXcm; - -impl CliEncodeMessage for Millau { - fn encode_wire_message( - target: xcm::v3::NetworkId, - at_target_xcm: xcm::v3::Xcm<()>, - ) -> anyhow::Result> { - anyhow::ensure!( - [ - CustomNetworkId::Rialto.as_network_id(), - CustomNetworkId::RialtoParachain.as_network_id() - ] - .contains(&target), - anyhow::format_err!("Unsupported target chain: {:?}", target) - ); - - Ok(millau_runtime::xcm_config::ToRialtoOrRialtoParachainSwitchExporter::validate( - target, - 0, - &mut Some(Self::dummy_universal_source()?), - &mut Some(target.into()), - &mut Some(at_target_xcm), - ) - .map_err(|e| anyhow::format_err!("Failed to prepare outbound message: {:?}", e))? - .0 - .1 - .0) - } - - fn encode_execute_xcm( - message: xcm::VersionedXcm, - ) -> anyhow::Result> { - Ok(millau_runtime::RuntimeCall::XcmPallet(millau_runtime::XcmCall::execute { - message: Box::new(message), - max_weight: Self::estimate_execute_xcm_weight(), - }) - .into()) - } -} - -impl CliChain for Millau { - const RUNTIME_VERSION: Option = - Some(SimpleRuntimeVersion::from_runtime_version(&millau_runtime::VERSION)); -} - -/// TODO: Note: I know this does not belong here, but I don't want to add it to the -/// `chain-asset-hub-westend` or `chain-westend`, because we wont use it for production and I don't -/// want to bring this to the bridges subtree now. Anyway, we plan to retire millau/rialto, so this -/// hack will disappear with that. -impl CliChain for crate::bridges::westend_millau::westend_parachains_to_millau::relay_asset_hub_westend_client::AssetHubWestend { - const RUNTIME_VERSION: Option = None; -} diff --git a/bridges/relays/bin-substrate/src/chains/mod.rs b/bridges/relays/bin-substrate/src/chains/mod.rs index c9a55e9e900f0..442236997c8ba 100644 --- a/bridges/relays/bin-substrate/src/chains/mod.rs +++ b/bridges/relays/bin-substrate/src/chains/mod.rs @@ -17,95 +17,8 @@ //! Chain-specific relayer configuration. mod kusama; -mod millau; mod polkadot; mod polkadot_bulletin; -mod rialto; -mod rialto_parachain; mod rococo; mod westend; mod wococo; - -#[cfg(test)] -mod tests { - use crate::cli::encode_message; - use bp_messages::source_chain::TargetHeaderChain; - use bp_runtime::Chain as _; - use codec::Encode; - use relay_millau_client::Millau; - use relay_rialto_client::Rialto; - use relay_substrate_client::{ChainWithTransactions, SignParam, UnsignedTransaction}; - - #[test] - fn maximal_rialto_to_millau_message_size_is_computed_correctly() { - use rialto_runtime::millau_messages::MillauAsTargetHeaderChain; - - let maximal_message_size = encode_message::compute_maximal_message_size( - bp_rialto::Rialto::max_extrinsic_size(), - bp_millau::Millau::max_extrinsic_size(), - ); - - let message = vec![42; maximal_message_size as _]; - assert_eq!(MillauAsTargetHeaderChain::verify_message(&message), Ok(())); - - let message = vec![42; (maximal_message_size + 1) as _]; - assert!(MillauAsTargetHeaderChain::verify_message(&message).is_err()); - } - - #[test] - fn maximal_size_remark_to_rialto_is_generated_correctly() { - assert!( - bridge_runtime_common::messages::target::maximal_incoming_message_size( - bp_rialto::Rialto::max_extrinsic_size() - ) > bp_millau::Millau::max_extrinsic_size(), - "We can't actually send maximal messages to Rialto from Millau, because Millau extrinsics can't be that large", - ) - } - #[test] - fn rialto_tx_extra_bytes_constant_is_correct() { - let rialto_call = rialto_runtime::RuntimeCall::System(rialto_runtime::SystemCall::remark { - remark: vec![], - }); - let rialto_tx = Rialto::sign_transaction( - SignParam { - spec_version: 1, - transaction_version: 1, - genesis_hash: Default::default(), - signer: sp_keyring::AccountKeyring::Alice.pair(), - }, - UnsignedTransaction::new(rialto_call.clone().into(), 0), - ) - .unwrap(); - let extra_bytes_in_transaction = rialto_tx.encode().len() - rialto_call.encode().len(); - assert!( - bp_rialto::TX_EXTRA_BYTES as usize >= extra_bytes_in_transaction, - "Hardcoded number of extra bytes in Rialto transaction {} is lower than actual value: {}", - bp_rialto::TX_EXTRA_BYTES, - extra_bytes_in_transaction, - ); - } - - #[test] - fn millau_tx_extra_bytes_constant_is_correct() { - let millau_call = millau_runtime::RuntimeCall::System(millau_runtime::SystemCall::remark { - remark: vec![], - }); - let millau_tx = Millau::sign_transaction( - SignParam { - spec_version: 0, - transaction_version: 0, - genesis_hash: Default::default(), - signer: sp_keyring::AccountKeyring::Alice.pair(), - }, - UnsignedTransaction::new(millau_call.clone().into(), 0), - ) - .unwrap(); - let extra_bytes_in_transaction = millau_tx.encode().len() - millau_call.encode().len(); - assert!( - bp_millau::TX_EXTRA_BYTES as usize >= extra_bytes_in_transaction, - "Hardcoded number of extra bytes in Millau transaction {} is lower than actual value: {}", - bp_millau::TX_EXTRA_BYTES, - extra_bytes_in_transaction, - ); - } -} diff --git a/bridges/relays/bin-substrate/src/chains/rialto.rs b/bridges/relays/bin-substrate/src/chains/rialto.rs deleted file mode 100644 index 30bc7eb13ca99..0000000000000 --- a/bridges/relays/bin-substrate/src/chains/rialto.rs +++ /dev/null @@ -1,62 +0,0 @@ -// 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 . - -//! Rialto chain specification for CLI. - -use crate::cli::{encode_message::CliEncodeMessage, CliChain}; -use bp_runtime::EncodedOrDecodedCall; -use bridge_runtime_common::CustomNetworkId; -use relay_rialto_client::Rialto; -use relay_substrate_client::SimpleRuntimeVersion; -use xcm_executor::traits::ExportXcm; - -impl CliEncodeMessage for Rialto { - fn encode_wire_message( - target: xcm::v3::NetworkId, - at_target_xcm: xcm::v3::Xcm<()>, - ) -> anyhow::Result> { - anyhow::ensure!( - target == CustomNetworkId::Millau.as_network_id(), - anyhow::format_err!("Unsupported target chain: {:?}", target) - ); - - Ok(rialto_runtime::millau_messages::ToMillauBlobExporter::validate( - target, - 0, - &mut Some(Self::dummy_universal_source()?), - &mut Some(target.into()), - &mut Some(at_target_xcm), - ) - .map_err(|e| anyhow::format_err!("Failed to prepare outbound message: {:?}", e))? - .0 - .0) - } - - fn encode_execute_xcm( - message: xcm::VersionedXcm, - ) -> anyhow::Result> { - Ok(rialto_runtime::RuntimeCall::XcmPallet(rialto_runtime::XcmCall::execute { - message: Box::new(message), - max_weight: Self::estimate_execute_xcm_weight(), - }) - .into()) - } -} - -impl CliChain for Rialto { - const RUNTIME_VERSION: Option = - Some(SimpleRuntimeVersion::from_runtime_version(&rialto_runtime::VERSION)); -} diff --git a/bridges/relays/bin-substrate/src/chains/rialto_parachain.rs b/bridges/relays/bin-substrate/src/chains/rialto_parachain.rs deleted file mode 100644 index 872d96981d0bf..0000000000000 --- a/bridges/relays/bin-substrate/src/chains/rialto_parachain.rs +++ /dev/null @@ -1,65 +0,0 @@ -// 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 . - -//! Rialto parachain specification for CLI. - -use crate::cli::{encode_message::CliEncodeMessage, CliChain}; -use bp_runtime::EncodedOrDecodedCall; -use bridge_runtime_common::CustomNetworkId; -use relay_rialto_parachain_client::RialtoParachain; -use relay_substrate_client::SimpleRuntimeVersion; -use xcm_executor::traits::ExportXcm; - -impl CliEncodeMessage for RialtoParachain { - fn encode_wire_message( - target: xcm::v3::NetworkId, - at_target_xcm: xcm::v3::Xcm<()>, - ) -> anyhow::Result> { - anyhow::ensure!( - target == CustomNetworkId::Millau.as_network_id(), - anyhow::format_err!("Unsupported target chain: {:?}", target) - ); - - Ok(rialto_parachain_runtime::millau_messages::ToMillauBlobExporter::validate( - target, - 0, - &mut Some(Self::dummy_universal_source()?), - &mut Some(target.into()), - &mut Some(at_target_xcm), - ) - .map_err(|e| anyhow::format_err!("Failed to prepare outbound message: {:?}", e))? - .0 - .0) - } - - fn encode_execute_xcm( - message: xcm::VersionedXcm, - ) -> anyhow::Result> { - type RuntimeCall = relay_rialto_parachain_client::RuntimeCall; - type XcmCall = relay_rialto_parachain_client::runtime_types::pallet_xcm::pallet::Call; - - let xcm_call = XcmCall::execute { - message: Box::new(unsafe { std::mem::transmute(message) }), - max_weight: Self::estimate_execute_xcm_weight(), - }; - - Ok(RuntimeCall::PolkadotXcm(xcm_call).into()) - } -} - -impl CliChain for RialtoParachain { - const RUNTIME_VERSION: Option = None; -} diff --git a/bridges/relays/bin-substrate/src/cli/bridge.rs b/bridges/relays/bin-substrate/src/cli/bridge.rs index 0c1483b348b1a..cc6dc8e43574e 100644 --- a/bridges/relays/bin-substrate/src/cli/bridge.rs +++ b/bridges/relays/bin-substrate/src/cli/bridge.rs @@ -29,10 +29,6 @@ use substrate_relay_helper::{ #[strum(serialize_all = "kebab_case")] /// Supported full bridges (headers + messages). pub enum FullBridge { - MillauToRialto, - RialtoToMillau, - MillauToRialtoParachain, - RialtoParachainToMillau, BridgeHubRococoToBridgeHubWococo, BridgeHubWococoToBridgeHubRococo, BridgeHubRococoToBridgeHubWestend, diff --git a/bridges/relays/bin-substrate/src/cli/chain_schema.rs b/bridges/relays/bin-substrate/src/cli/chain_schema.rs index bbc95d7dcdbd1..5c2161acdbd70 100644 --- a/bridges/relays/bin-substrate/src/cli/chain_schema.rs +++ b/bridges/relays/bin-substrate/src/cli/chain_schema.rs @@ -129,29 +129,6 @@ macro_rules! declare_chain_connection_params_cli_schema { }; } -/// Helper trait to override transaction parameters differently. -pub trait TransactionParamsProvider { - /// Returns `true` if transaction parameters are defined by this provider. - fn is_defined(&self) -> bool; - /// Returns transaction parameters. - fn transaction_params( - &self, - ) -> anyhow::Result>>; - - /// Returns transaction parameters, defined by `self` provider or, if they're not defined, - /// defined by `other` provider. - fn transaction_params_or( - &self, - other: &T, - ) -> anyhow::Result>> { - if self.is_defined() { - self.transaction_params::() - } else { - other.transaction_params::() - } - } -} - /// Create chain-specific set of signing parameters. #[macro_export] macro_rules! declare_chain_signing_params_cli_schema { @@ -239,15 +216,12 @@ macro_rules! declare_chain_signing_params_cli_schema { suri_password.as_deref() ).map_err(|e| anyhow::format_err!("{:?}", e)) } - } - - #[allow(dead_code)] - impl TransactionParamsProvider for [<$chain SigningParams>] { - fn is_defined(&self) -> bool { - self.[<$chain_prefix _signer>].is_some() || self.[<$chain_prefix _signer_file>].is_some() - } - fn transaction_params(&self) -> anyhow::Result>> { + /// Return transaction parameters. + #[allow(dead_code)] + pub fn transaction_params( + &self, + ) -> anyhow::Result>> { Ok(TransactionParams { mortality: self.transactions_mortality()?, signer: self.to_keypair::()?, @@ -310,7 +284,7 @@ mod tests { target_transactions_mortality: None, } - .to_keypair::() + .to_keypair::() .map(|p| p.public()) .map_err(drop), Ok(alice.public()), @@ -327,7 +301,7 @@ mod tests { target_transactions_mortality: None, } - .to_keypair::() + .to_keypair::() .map(|p| p.public()) .map_err(drop), Ok(bob.public()), @@ -344,7 +318,7 @@ mod tests { target_transactions_mortality: None, } - .to_keypair::() + .to_keypair::() .map(|p| p.public()) .map_err(drop), Ok(bob_with_alice_password.public()), @@ -361,7 +335,7 @@ mod tests { target_transactions_mortality: None, } - .to_keypair::() + .to_keypair::() .map(|p| p.public()) .map_err(drop), Ok(alice.public()), diff --git a/bridges/relays/bin-substrate/src/cli/detect_equivocations.rs b/bridges/relays/bin-substrate/src/cli/detect_equivocations.rs index bc456e025499e..704839db0e66f 100644 --- a/bridges/relays/bin-substrate/src/cli/detect_equivocations.rs +++ b/bridges/relays/bin-substrate/src/cli/detect_equivocations.rs @@ -20,11 +20,6 @@ use crate::{ kusama_headers_to_bridge_hub_polkadot::KusamaToBridgeHubPolkadotCliBridge, polkadot_headers_to_bridge_hub_kusama::PolkadotToBridgeHubKusamaCliBridge, }, - rialto_millau::{ - millau_headers_to_rialto::MillauToRialtoCliBridge, - rialto_headers_to_millau::RialtoToMillauCliBridge, - }, - rialto_parachain_millau::millau_headers_to_rialto_parachain::MillauToRialtoParachainCliBridge, rococo_wococo::{ rococo_headers_to_bridge_hub_wococo::RococoToBridgeHubWococoCliBridge, wococo_headers_to_bridge_hub_rococo::WococoToBridgeHubRococoCliBridge, @@ -58,9 +53,6 @@ pub struct DetectEquivocations { #[strum(serialize_all = "kebab_case")] /// Equivocations detection bridge. pub enum DetectEquivocationsBridge { - MillauToRialto, - RialtoToMillau, - MillauToRialtoParachain, RococoToBridgeHubWococo, WococoToBridgeHubRococo, KusamaToBridgeHubPolkadot, @@ -90,9 +82,6 @@ where } } -impl EquivocationsDetector for MillauToRialtoCliBridge {} -impl EquivocationsDetector for RialtoToMillauCliBridge {} -impl EquivocationsDetector for MillauToRialtoParachainCliBridge {} impl EquivocationsDetector for RococoToBridgeHubWococoCliBridge {} impl EquivocationsDetector for WococoToBridgeHubRococoCliBridge {} impl EquivocationsDetector for KusamaToBridgeHubPolkadotCliBridge {} @@ -102,10 +91,6 @@ impl DetectEquivocations { /// Run the command. pub async fn run(self) -> anyhow::Result<()> { match self.bridge { - DetectEquivocationsBridge::MillauToRialto => MillauToRialtoCliBridge::start(self), - DetectEquivocationsBridge::RialtoToMillau => RialtoToMillauCliBridge::start(self), - DetectEquivocationsBridge::MillauToRialtoParachain => - MillauToRialtoParachainCliBridge::start(self), DetectEquivocationsBridge::RococoToBridgeHubWococo => RococoToBridgeHubWococoCliBridge::start(self), DetectEquivocationsBridge::WococoToBridgeHubRococo => diff --git a/bridges/relays/bin-substrate/src/cli/encode_message.rs b/bridges/relays/bin-substrate/src/cli/encode_message.rs deleted file mode 100644 index 646075e832679..0000000000000 --- a/bridges/relays/bin-substrate/src/cli/encode_message.rs +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use crate::cli::{ExplicitOrMaximal, HexBytes}; -use bp_runtime::EncodedOrDecodedCall; -use bridge_runtime_common::CustomNetworkId; -use codec::Encode; -use frame_support::weights::Weight; -use relay_substrate_client::Chain; -use structopt::StructOpt; -use xcm::latest::prelude::*; - -/// All possible messages that may be delivered to generic Substrate chain. -/// -/// Note this enum may be used in the context of both Source (as part of `encode-call`) -/// and Target chain (as part of `encode-message/send-message`). -#[derive(StructOpt, Debug, PartialEq, Eq)] -pub enum Message { - /// Raw bytes for the message. - Raw { - /// Raw message bytes. - data: HexBytes, - }, - /// Message with given size. - Sized { - /// Sized of the message. - size: ExplicitOrMaximal, - }, -} - -/// Raw, SCALE-encoded message payload used in expected deployment. -pub type RawMessage = Vec; - -pub trait CliEncodeMessage: Chain { - /// Returns dummy `AccountId32` universal source given this network id. - fn dummy_universal_source() -> anyhow::Result { - use xcm::v3::prelude::*; - - let this_network = CustomNetworkId::try_from(Self::ID) - .map(|n| n.as_network_id()) - .map_err(|_| anyhow::format_err!("Unsupported chain: {:?}", Self::ID))?; - Ok(X2( - GlobalConsensus(this_network), - AccountId32 { network: Some(this_network), id: [0u8; 32] }, - )) - } - - /// Returns XCM blob that is passed to the `send_message` function of the messages pallet - /// and then is sent over the wire. - fn encode_wire_message(target: NetworkId, at_target_xcm: Xcm<()>) -> anyhow::Result>; - /// Encode an `execute` XCM call of the XCM pallet. - fn encode_execute_xcm( - message: xcm::VersionedXcm, - ) -> anyhow::Result>; - - /// Estimate value of `max_weight` argument for the `execute` XCM call of the XCM pallet. - fn estimate_execute_xcm_weight() -> Weight { - // we are only executing XCM on our testnets and 1/100 of max extrinsic weight is ok - Self::max_extrinsic_weight() / 100 - } -} - -/// Encode message payload passed through CLI flags. -pub(crate) fn encode_message( - message: &Message, -) -> anyhow::Result { - Ok(match message { - Message::Raw { ref data } => data.0.clone(), - Message::Sized { ref size } => { - let destination = CustomNetworkId::try_from(Target::ID) - .map(|n| n.as_network_id()) - .map_err(|_| anyhow::format_err!("Unsupported target chain: {:?}", Target::ID))?; - let expected_size = match *size { - ExplicitOrMaximal::Explicit(size) => size, - ExplicitOrMaximal::Maximal => compute_maximal_message_size( - Source::max_extrinsic_size(), - Target::max_extrinsic_size(), - ), - } as usize; - - let at_target_xcm = vec![ExpectPallet { - index: 0, - name: vec![42; expected_size], - module_name: vec![], - crate_major: 0, - min_crate_minor: 0, - }] - .into(); - let at_target_xcm_size = - Source::encode_wire_message(destination, at_target_xcm)?.encoded_size(); - let at_target_xcm_overhead = at_target_xcm_size.saturating_sub(expected_size); - let at_target_xcm = vec![ExpectPallet { - index: 0, - name: vec![42; expected_size.saturating_sub(at_target_xcm_overhead)], - module_name: vec![], - crate_major: 0, - min_crate_minor: 0, - }] - .into(); - - xcm::VersionedXcm::<()>::V3( - vec![ExportMessage { - network: destination, - destination: destination.into(), - xcm: at_target_xcm, - }] - .into(), - ) - .encode() - }, - }) -} - -/// Compute maximal message size, given max extrinsic size at source and target chains. -pub(crate) fn compute_maximal_message_size( - maximal_source_extrinsic_size: u32, - maximal_target_extrinsic_size: u32, -) -> u32 { - // assume that both signed extensions and other arguments fit 1KB - let service_tx_bytes_on_source_chain = 1024; - let maximal_source_extrinsic_size = - maximal_source_extrinsic_size - service_tx_bytes_on_source_chain; - let maximal_message_size = - bridge_runtime_common::messages::target::maximal_incoming_message_size( - maximal_target_extrinsic_size, - ); - std::cmp::min(maximal_message_size, maximal_source_extrinsic_size) -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::cli::send_message::decode_xcm; - use bp_runtime::Chain; - use relay_millau_client::Millau; - use relay_rialto_client::Rialto; - - fn approximate_message_size(xcm_msg_len: usize) -> usize { - xcm_msg_len + Source::dummy_universal_source().unwrap().encoded_size() - } - - #[test] - fn encode_explicit_size_message_works() { - let msg = encode_message::(&Message::Sized { - size: ExplicitOrMaximal::Explicit(100), - }) - .unwrap(); - // since it isn't the returned XCM what is sent over the wire, we can only check if - // it is close to what we need - assert!( - (1f64 - (approximate_message_size::(msg.len()) as f64) / 100_f64).abs() < 0.1 - ); - // check that it decodes to valid xcm - let _ = decode_xcm::<()>(msg).unwrap(); - } - - #[test] - fn encode_maximal_size_message_works() { - let maximal_size = compute_maximal_message_size( - Rialto::max_extrinsic_size(), - Millau::max_extrinsic_size(), - ); - - let msg = - encode_message::(&Message::Sized { size: ExplicitOrMaximal::Maximal }) - .unwrap(); - // since it isn't the returned XCM what is sent over the wire, we can only check if - // it is close to what we need - assert!( - (1f64 - approximate_message_size::(msg.len()) as f64 / maximal_size as f64) - .abs() < 0.1 - ); - // check that it decodes to valid xcm - let _ = decode_xcm::<()>(msg).unwrap(); - } -} diff --git a/bridges/relays/bin-substrate/src/cli/init_bridge.rs b/bridges/relays/bin-substrate/src/cli/init_bridge.rs index 415897aeba94c..21d95b4bfa0ea 100644 --- a/bridges/relays/bin-substrate/src/cli/init_bridge.rs +++ b/bridges/relays/bin-substrate/src/cli/init_bridge.rs @@ -27,11 +27,6 @@ use crate::{ polkadot_bulletin_headers_to_bridge_hub_polkadot::PolkadotBulletinToBridgeHubPolkadotCliBridge, polkadot_headers_to_polkadot_bulletin::PolkadotToPolkadotBulletinCliBridge, }, - rialto_millau::{ - millau_headers_to_rialto::MillauToRialtoCliBridge, - rialto_headers_to_millau::RialtoToMillauCliBridge, - }, - rialto_parachain_millau::millau_headers_to_rialto_parachain::MillauToRialtoParachainCliBridge, rococo_westend::{ rococo_headers_to_bridge_hub_westend::RococoToBridgeHubWestendCliBridge, westend_headers_to_bridge_hub_rococo::WestendToBridgeHubRococoCliBridge, @@ -40,7 +35,6 @@ use crate::{ rococo_headers_to_bridge_hub_wococo::RococoToBridgeHubWococoCliBridge, wococo_headers_to_bridge_hub_rococo::WococoToBridgeHubRococoCliBridge, }, - westend_millau::westend_headers_to_millau::WestendToMillauCliBridge, }, cli::{bridge::CliBridgeBase, chain_schema::*}, }; @@ -72,10 +66,6 @@ pub struct InitBridge { #[strum(serialize_all = "kebab_case")] /// Bridge to initialize. pub enum InitBridgeName { - MillauToRialto, - RialtoToMillau, - WestendToMillau, - MillauToRialtoParachain, RococoToBridgeHubWococo, WococoToBridgeHubRococo, KusamaToBridgeHubPolkadot, @@ -126,72 +116,6 @@ where } } -impl BridgeInitializer for MillauToRialtoCliBridge { - type Engine = GrandpaFinalityEngine; - - fn encode_init_bridge( - init_data: >::InitializationData, - ) -> ::Call { - rialto_runtime::SudoCall::sudo { - call: Box::new(rialto_runtime::BridgeGrandpaCall::initialize { init_data }.into()), - } - .into() - } -} - -impl BridgeInitializer for MillauToRialtoParachainCliBridge { - type Engine = GrandpaFinalityEngine; - - fn encode_init_bridge( - init_data: >::InitializationData, - ) -> ::Call { - type RuntimeCall = relay_rialto_parachain_client::RuntimeCall; - type BridgeGrandpaCall = relay_rialto_parachain_client::BridgeGrandpaCall; - type SudoCall = relay_rialto_parachain_client::SudoCall; - - let initialize_call = - RuntimeCall::BridgeMillauGrandpa(BridgeGrandpaCall::initialize { init_data }); - - RuntimeCall::Sudo(SudoCall::sudo { call: Box::new(initialize_call) }) - } -} - -impl BridgeInitializer for RialtoToMillauCliBridge { - type Engine = GrandpaFinalityEngine; - - fn encode_init_bridge( - init_data: >::InitializationData, - ) -> ::Call { - let initialize_call = millau_runtime::BridgeGrandpaCall::< - millau_runtime::Runtime, - millau_runtime::RialtoGrandpaInstance, - >::initialize { - init_data, - }; - millau_runtime::SudoCall::sudo { call: Box::new(initialize_call.into()) }.into() - } -} - -impl BridgeInitializer for WestendToMillauCliBridge { - type Engine = GrandpaFinalityEngine; - - fn encode_init_bridge( - init_data: >::InitializationData, - ) -> ::Call { - // at Westend -> Millau initialization we're not using sudo, because otherwise - // our deployments may fail, because we need to initialize both Rialto -> Millau - // and Westend -> Millau bridge. => since there's single possible sudo account, - // one of transaction may fail with duplicate nonce error - millau_runtime::BridgeGrandpaCall::< - millau_runtime::Runtime, - millau_runtime::WestendGrandpaInstance, - >::initialize { - init_data, - } - .into() - } -} - impl BridgeInitializer for RococoToBridgeHubWococoCliBridge { type Engine = GrandpaFinalityEngine; @@ -305,11 +229,6 @@ impl InitBridge { /// Run the command. pub async fn run(self) -> anyhow::Result<()> { match self.bridge { - InitBridgeName::MillauToRialto => MillauToRialtoCliBridge::init_bridge(self), - InitBridgeName::RialtoToMillau => RialtoToMillauCliBridge::init_bridge(self), - InitBridgeName::WestendToMillau => WestendToMillauCliBridge::init_bridge(self), - InitBridgeName::MillauToRialtoParachain => - MillauToRialtoParachainCliBridge::init_bridge(self), InitBridgeName::RococoToBridgeHubWococo => RococoToBridgeHubWococoCliBridge::init_bridge(self), InitBridgeName::WococoToBridgeHubRococo => diff --git a/bridges/relays/bin-substrate/src/cli/mod.rs b/bridges/relays/bin-substrate/src/cli/mod.rs index 890fd9efb34ed..580463ef9f9ed 100644 --- a/bridges/relays/bin-substrate/src/cli/mod.rs +++ b/bridges/relays/bin-substrate/src/cli/mod.rs @@ -16,8 +16,6 @@ //! Deal with CLI args of substrate-to-substrate relay. -use std::convert::TryInto; - use async_std::prelude::*; use codec::{Decode, Encode}; use futures::{select, FutureExt}; @@ -31,18 +29,14 @@ use bp_messages::LaneId; use relay_substrate_client::SimpleRuntimeVersion; pub(crate) mod bridge; -pub(crate) mod encode_message; -pub(crate) mod send_message; mod chain_schema; mod detect_equivocations; mod init_bridge; -mod register_parachain; mod relay_headers; mod relay_headers_and_messages; mod relay_messages; mod relay_parachains; -mod resubmit_transactions; /// The target that will be used when publishing logs related to this pallet. pub const LOG_TARGET: &str = "bridge"; @@ -77,16 +71,6 @@ pub enum Command { /// /// Sends initialization transaction to bootstrap the bridge with current finalized block data. InitBridge(init_bridge::InitBridge), - /// Send custom message over the bridge. - /// - /// Allows interacting with the bridge by sending messages over `Messages` component. - /// The message is being sent to the source chain, delivered to the target chain and dispatched - /// there. - SendMessage(send_message::SendMessage), - /// Resubmit transactions with increased tip if they are stalled. - ResubmitTransactions(resubmit_transactions::ResubmitTransactions), - /// Register parachain. - RegisterParachain(register_parachain::RegisterParachain), /// Relay parachain heads. RelayParachains(relay_parachains::RelayParachains), /// Detect and report equivocations. @@ -121,9 +105,6 @@ impl Command { Self::RelayMessages(arg) => arg.run().await?, Self::RelayHeadersAndMessages(arg) => arg.run().await?, Self::InitBridge(arg) => arg.run().await?, - Self::SendMessage(arg) => arg.run().await?, - Self::ResubmitTransactions(arg) => arg.run().await?, - Self::RegisterParachain(arg) => arg.run().await?, Self::RelayParachains(arg) => arg.run().await?, Self::DetectEquivocations(arg) => arg.run().await?, } @@ -169,33 +150,7 @@ arg_enum! { } } -/// Generic balance type. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct Balance(pub u128); - -impl std::fmt::Display for Balance { - fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { - use num_format::{Locale, ToFormattedString}; - write!(fmt, "{}", self.0.to_formatted_string(&Locale::en)) - } -} - -impl std::str::FromStr for Balance { - type Err = ::Err; - - fn from_str(s: &str) -> Result { - Ok(Self(s.parse()?)) - } -} - -impl Balance { - /// Cast balance to `u64` type, panicking if it's too large. - pub fn cast(&self) -> u64 { - self.0.try_into().expect("Balance is too high for this chain.") - } -} - -// Bridge-supported network definition. +/// Bridge-supported network definition. /// /// Used to abstract away CLI commands. pub trait CliChain: relay_substrate_client::Chain { diff --git a/bridges/relays/bin-substrate/src/cli/register_parachain.rs b/bridges/relays/bin-substrate/src/cli/register_parachain.rs deleted file mode 100644 index 90464335166e8..0000000000000 --- a/bridges/relays/bin-substrate/src/cli/register_parachain.rs +++ /dev/null @@ -1,324 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use crate::cli::{chain_schema::*, Balance}; - -use codec::Encode; -use frame_support::Twox64Concat; -use num_traits::Zero; -use polkadot_parachain_primitives::primitives::{ - HeadData as ParaHeadData, Id as ParaId, ValidationCode as ParaValidationCode, -}; -use polkadot_runtime_common::{ - paras_registrar::Call as ParaRegistrarCall, slots::Call as ParaSlotsCall, -}; -use polkadot_runtime_parachains::paras::ParaLifecycle; -use relay_substrate_client::{AccountIdOf, CallOf, Chain, Client, UnsignedTransaction}; -use relay_utils::{TrackedTransactionStatus, TransactionTracker}; -use rialto_runtime::SudoCall; -use sp_core::{ - storage::{well_known_keys::CODE, StorageKey}, - Pair, -}; -use structopt::StructOpt; -use strum::{EnumString, EnumVariantNames, VariantNames}; - -/// Name of the `NextFreeParaId` value in the `polkadot_runtime_common::paras_registrar` pallet. -const NEXT_FREE_PARA_ID_STORAGE_NAME: &str = "NextFreeParaId"; -/// Name of the `ParaLifecycles` map in the `polkadot_runtime_parachains::paras` pallet. -const PARAS_LIFECYCLES_STORAGE_NAME: &str = "ParaLifecycles"; - -/// Register parachain. -#[derive(StructOpt, Debug, PartialEq, Eq)] -pub struct RegisterParachain { - /// A parachain to register. - #[structopt(possible_values = Parachain::VARIANTS, case_insensitive = true)] - parachain: Parachain, - /// Parachain deposit. - #[structopt(long, default_value = "0")] - deposit: Balance, - /// Lease begin. - #[structopt(long, default_value = "0")] - lease_begin: u32, - /// Lease end. - #[structopt(long, default_value = "256")] - lease_end: u32, - #[structopt(flatten)] - relay_connection: RelaychainConnectionParams, - #[structopt(flatten)] - relay_sign: RelaychainSigningParams, - #[structopt(flatten)] - para_connection: ParachainConnectionParams, -} - -/// Parachain to register. -#[derive(Debug, EnumString, EnumVariantNames, PartialEq, Eq)] -#[strum(serialize_all = "kebab_case")] -pub enum Parachain { - RialtoParachain, -} - -macro_rules! select_bridge { - ($bridge: expr, $generic: tt) => { - match $bridge { - Parachain::RialtoParachain => { - type Relaychain = relay_rialto_client::Rialto; - type Parachain = relay_rialto_parachain_client::RialtoParachain; - - use bp_rialto::{PARAS_PALLET_NAME, PARAS_REGISTRAR_PALLET_NAME}; - - $generic - }, - } - }; -} - -impl RegisterParachain { - /// Run the command. - pub async fn run(self) -> anyhow::Result<()> { - select_bridge!(self.parachain, { - let relay_client = self.relay_connection.into_client::().await?; - let relay_sign = self.relay_sign.to_keypair::()?; - let para_client = self.para_connection.into_client::().await?; - - // hopefully we're the only actor that is registering parachain right now - // => read next parachain id - let para_id_key = bp_runtime::storage_value_final_key( - PARAS_REGISTRAR_PALLET_NAME.as_bytes(), - NEXT_FREE_PARA_ID_STORAGE_NAME.as_bytes(), - ); - let para_id: ParaId = relay_client - .storage_value(StorageKey(para_id_key.to_vec()), None) - .await? - .unwrap_or(polkadot_primitives::v6::LOWEST_PUBLIC_ID) - .max(polkadot_primitives::v6::LOWEST_PUBLIC_ID); - log::info!(target: "bridge", "Going to reserve parachain id: {:?}", para_id); - - // step 1: reserve a parachain id - let relay_sudo_account: AccountIdOf = relay_sign.public().into(); - let reserve_parachain_id_call: CallOf = - ParaRegistrarCall::reserve {}.into(); - let reserve_result = relay_client - .submit_and_watch_signed_extrinsic(&relay_sign, move |_, transaction_nonce| { - Ok(UnsignedTransaction::new( - reserve_parachain_id_call.into(), - transaction_nonce, - )) - }) - .await? - .wait() - .await; - if reserve_result == TrackedTransactionStatus::Lost { - return Err(anyhow::format_err!( - "Failed to finalize `reserve-parachain-id` transaction" - )) - } - log::info!(target: "bridge", "Reserved parachain id: {:?}", para_id); - - // step 2: register parathread - let para_genesis_header = para_client.header_by_number(Zero::zero()).await?; - let para_code = para_client - .raw_storage_value(StorageKey(CODE.to_vec()), Some(para_genesis_header.hash())) - .await? - .ok_or_else(|| { - anyhow::format_err!("Cannot fetch validation code of {}", Parachain::NAME) - })? - .0; - log::info!( - target: "bridge", - "Going to register parachain {:?}: genesis len = {} code len = {}", - para_id, - para_genesis_header.encode().len(), - para_code.len(), - ); - let register_parathread_call: CallOf = ParaRegistrarCall::register { - id: para_id, - genesis_head: ParaHeadData(para_genesis_header.encode()), - validation_code: ParaValidationCode(para_code), - } - .into(); - let register_result = relay_client - .submit_and_watch_signed_extrinsic(&relay_sign, move |_, transaction_nonce| { - Ok(UnsignedTransaction::new(register_parathread_call.into(), transaction_nonce)) - }) - .await? - .wait() - .await; - if register_result == TrackedTransactionStatus::Lost { - return Err(anyhow::format_err!( - "Failed to finalize `register-parathread` transaction" - )) - } - log::info!(target: "bridge", "Registered parachain: {:?}. Waiting for onboarding", para_id); - - // wait until parathread is onboarded - let para_state_key = bp_runtime::storage_map_final_key::( - PARAS_PALLET_NAME, - PARAS_LIFECYCLES_STORAGE_NAME, - ¶_id.encode(), - ); - wait_para_state( - &relay_client, - ¶_state_key.0, - &[ParaLifecycle::Onboarding, ParaLifecycle::Parathread], - ParaLifecycle::Parathread, - ) - .await?; - - // step 3: force parachain leases - let lease_begin = self.lease_begin; - let lease_end = self.lease_end; - let para_deposit = self.deposit.cast().into(); - log::info!( - target: "bridge", - "Going to force leases of parachain {:?}: [{}; {}]", - para_id, - lease_begin, - lease_end, - ); - let force_lease_call: CallOf = SudoCall::sudo { - call: Box::new( - ParaSlotsCall::force_lease { - para: para_id, - leaser: relay_sudo_account.clone(), - amount: para_deposit, - period_begin: lease_begin, - period_count: lease_end.saturating_sub(lease_begin).saturating_add(1), - } - .into(), - ), - } - .into(); - relay_client - .submit_signed_extrinsic(&relay_sign, move |_, transaction_nonce| { - Ok(UnsignedTransaction::new(force_lease_call.into(), transaction_nonce)) - }) - .await?; - log::info!(target: "bridge", "Registered parachain leases: {:?}. Waiting for onboarding", para_id); - - // wait until parachain is onboarded - wait_para_state( - &relay_client, - ¶_state_key.0, - &[ - ParaLifecycle::Onboarding, - ParaLifecycle::UpgradingParathread, - ParaLifecycle::Parathread, - ], - ParaLifecycle::Parachain, - ) - .await?; - - Ok(()) - }) - } -} - -/// Wait until parachain state is changed. -async fn wait_para_state( - relay_client: &Client, - para_state_key: &[u8], - from_states: &[ParaLifecycle], - to_state: ParaLifecycle, -) -> anyhow::Result<()> { - loop { - let para_state: ParaLifecycle = relay_client - .storage_value(StorageKey(para_state_key.to_vec()), None) - .await? - .ok_or_else(|| { - anyhow::format_err!( - "Cannot fetch next free parachain lifecycle from the runtime storage of {}", - Relaychain::NAME, - ) - })?; - if para_state == to_state { - log::info!(target: "bridge", "Parachain state is now: {:?}", to_state); - return Ok(()) - } - if !from_states.contains(¶_state) { - return Err(anyhow::format_err!("Invalid parachain lifecycle: {:?}", para_state)) - } - - log::info!(target: "bridge", "Parachain state: {:?}. Waiting for {:?}", para_state, to_state); - async_std::task::sleep(Relaychain::AVERAGE_BLOCK_INTERVAL).await; - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn register_rialto_parachain() { - let register_parachain = RegisterParachain::from_iter(vec![ - "register-parachain", - "rialto-parachain", - "--parachain-host", - "127.0.0.1", - "--parachain-port", - "11949", - "--relaychain-host", - "127.0.0.1", - "--relaychain-port", - "9944", - "--relaychain-signer", - "//Alice", - "--deposit", - "42", - "--lease-begin", - "100", - "--lease-end", - "200", - ]); - - assert_eq!( - register_parachain, - RegisterParachain { - parachain: Parachain::RialtoParachain, - deposit: Balance(42), - lease_begin: 100, - lease_end: 200, - relay_connection: RelaychainConnectionParams { - relaychain_host: "127.0.0.1".into(), - relaychain_port: 9944, - relaychain_secure: false, - relaychain_runtime_version: RelaychainRuntimeVersionParams { - relaychain_version_mode: RuntimeVersionType::Bundle, - relaychain_spec_version: None, - relaychain_transaction_version: None, - } - }, - relay_sign: RelaychainSigningParams { - relaychain_signer: Some("//Alice".into()), - relaychain_signer_password: None, - relaychain_signer_file: None, - relaychain_signer_password_file: None, - relaychain_transactions_mortality: None, - }, - para_connection: ParachainConnectionParams { - parachain_host: "127.0.0.1".into(), - parachain_port: 11949, - parachain_secure: false, - parachain_runtime_version: ParachainRuntimeVersionParams { - parachain_version_mode: RuntimeVersionType::Bundle, - parachain_spec_version: None, - parachain_transaction_version: None, - } - }, - } - ); - } -} diff --git a/bridges/relays/bin-substrate/src/cli/relay_headers.rs b/bridges/relays/bin-substrate/src/cli/relay_headers.rs index d3a7fa09367df..95d93387a0728 100644 --- a/bridges/relays/bin-substrate/src/cli/relay_headers.rs +++ b/bridges/relays/bin-substrate/src/cli/relay_headers.rs @@ -27,16 +27,10 @@ use crate::bridges::{ polkadot_bulletin_headers_to_bridge_hub_polkadot::PolkadotBulletinToBridgeHubPolkadotCliBridge, polkadot_headers_to_polkadot_bulletin::PolkadotToPolkadotBulletinCliBridge, }, - rialto_millau::{ - millau_headers_to_rialto::MillauToRialtoCliBridge, - rialto_headers_to_millau::RialtoToMillauCliBridge, - }, - rialto_parachain_millau::millau_headers_to_rialto_parachain::MillauToRialtoParachainCliBridge, rococo_wococo::{ rococo_headers_to_bridge_hub_wococo::RococoToBridgeHubWococoCliBridge, wococo_headers_to_bridge_hub_rococo::WococoToBridgeHubRococoCliBridge, }, - westend_millau::westend_headers_to_millau::WestendToMillauCliBridge, }; use relay_utils::metrics::{GlobalMetrics, StandaloneMetric}; use substrate_relay_helper::finality::SubstrateFinalitySyncPipeline; @@ -67,10 +61,6 @@ pub struct RelayHeaders { #[strum(serialize_all = "kebab_case")] /// Headers relay bridge. pub enum RelayHeadersBridge { - MillauToRialto, - RialtoToMillau, - WestendToMillau, - MillauToRialtoParachain, RococoToBridgeHubWococo, WococoToBridgeHubRococo, KusamaToBridgeHubPolkadot, @@ -110,10 +100,6 @@ trait HeadersRelayer: RelayToRelayHeadersCliBridge { } } -impl HeadersRelayer for MillauToRialtoCliBridge {} -impl HeadersRelayer for RialtoToMillauCliBridge {} -impl HeadersRelayer for WestendToMillauCliBridge {} -impl HeadersRelayer for MillauToRialtoParachainCliBridge {} impl HeadersRelayer for RococoToBridgeHubWococoCliBridge {} impl HeadersRelayer for WococoToBridgeHubRococoCliBridge {} impl HeadersRelayer for KusamaToBridgeHubPolkadotCliBridge {} @@ -125,11 +111,6 @@ impl RelayHeaders { /// Run the command. pub async fn run(self) -> anyhow::Result<()> { match self.bridge { - RelayHeadersBridge::MillauToRialto => MillauToRialtoCliBridge::relay_headers(self), - RelayHeadersBridge::RialtoToMillau => RialtoToMillauCliBridge::relay_headers(self), - RelayHeadersBridge::WestendToMillau => WestendToMillauCliBridge::relay_headers(self), - RelayHeadersBridge::MillauToRialtoParachain => - MillauToRialtoParachainCliBridge::relay_headers(self), RelayHeadersBridge::RococoToBridgeHubWococo => RococoToBridgeHubWococoCliBridge::relay_headers(self), RelayHeadersBridge::WococoToBridgeHubRococo => diff --git a/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/mod.rs b/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/mod.rs index 5a8c084889d75..7075e742e02d8 100644 --- a/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/mod.rs +++ b/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/mod.rs @@ -36,7 +36,6 @@ use structopt::StructOpt; use futures::{FutureExt, TryFutureExt}; use relay_to_parachain::*; -use relay_to_relay::*; use crate::{ bridges::{ @@ -48,14 +47,6 @@ use crate::{ polkadot_bulletin_headers_to_bridge_hub_polkadot::PolkadotBulletinToBridgeHubPolkadotCliBridge, polkadot_parachains_to_polkadot_bulletin::PolkadotToPolkadotBulletinCliBridge, }, - rialto_millau::{ - millau_headers_to_rialto::MillauToRialtoCliBridge, - rialto_headers_to_millau::RialtoToMillauCliBridge, - }, - rialto_parachain_millau::{ - millau_headers_to_rialto_parachain::MillauToRialtoParachainCliBridge, - rialto_parachains_to_millau::RialtoParachainToMillauCliBridge, - }, rococo_westend::{ rococo_parachains_to_bridge_hub_westend::BridgeHubRococoToBridgeHubWestendCliBridge, westend_parachains_to_bridge_hub_rococo::BridgeHubWestendToBridgeHubRococoCliBridge, @@ -203,9 +194,6 @@ where } // All supported chains. -declare_chain_cli_schema!(Millau, millau); -declare_chain_cli_schema!(Rialto, rialto); -declare_chain_cli_schema!(RialtoParachain, rialto_parachain); declare_chain_cli_schema!(Rococo, rococo); declare_chain_cli_schema!(BridgeHubRococo, bridge_hub_rococo); declare_chain_cli_schema!(Wococo, wococo); @@ -217,53 +205,7 @@ declare_chain_cli_schema!(BridgeHubKusama, bridge_hub_kusama); declare_chain_cli_schema!(Polkadot, polkadot); declare_chain_cli_schema!(BridgeHubPolkadot, bridge_hub_polkadot); declare_chain_cli_schema!(PolkadotBulletin, polkadot_bulletin); -// Means to override signers of different layer transactions. -declare_chain_cli_schema!(MillauHeadersToRialto, millau_headers_to_rialto); -declare_chain_cli_schema!(MillauHeadersToRialtoParachain, millau_headers_to_rialto_parachain); -declare_chain_cli_schema!(RialtoHeadersToMillau, rialto_headers_to_millau); -declare_chain_cli_schema!(RialtoParachainsToMillau, rialto_parachains_to_millau); -declare_chain_cli_schema!(RococoHeadersToBridgeHubWococo, rococo_headers_to_bridge_hub_wococo); -declare_chain_cli_schema!( - RococoParachainsToBridgeHubWococo, - rococo_parachains_to_bridge_hub_wococo -); -declare_chain_cli_schema!(WococoHeadersToBridgeHubRococo, wococo_headers_to_bridge_hub_rococo); -declare_chain_cli_schema!( - WococoParachainsToBridgeHubRococo, - wococo_parachains_to_bridge_hub_rococo -); -declare_chain_cli_schema!(RococoHeadersToBridgeHubWestend, rococo_headers_to_bridge_hub_westend); -declare_chain_cli_schema!( - RococoParachainsToBridgeHubWestend, - rococo_parachains_to_bridge_hub_westend -); -declare_chain_cli_schema!(WestendHeadersToBridgeHubRococo, westend_headers_to_bridge_hub_rococo); -declare_chain_cli_schema!( - WestendParachainsToBridgeHubRococo, - westend_parachains_to_bridge_hub_rococo -); -declare_chain_cli_schema!(KusamaHeadersToBridgeHubPolkadot, kusama_headers_to_bridge_hub_polkadot); -declare_chain_cli_schema!( - KusamaParachainsToBridgeHubPolkadot, - kusama_parachains_to_bridge_hub_polkadot -); -declare_chain_cli_schema!(PolkadotHeadersToBridgeHubKusama, polkadot_headers_to_bridge_hub_kusama); -declare_chain_cli_schema!( - PolkadotParachainsToBridgeHubKusama, - polkadot_parachains_to_bridge_hub_kusama -); -declare_chain_cli_schema!( - PolkadotBulletinHeadersToBridgeHubPolkadot, - polkadot_bulletin_headers_to_bridge_hub_polkadot -); -declare_chain_cli_schema!(PolkadotHeadersToPolkadotBulletin, polkadot_headers_to_polkadot_bulletin); -declare_chain_cli_schema!( - PolkadotParachainsToPolkadotBulletin, - polkadot_parachains_to_polkadot_bulletin -); // All supported bridges. -declare_relay_to_relay_bridge_schema!(Millau, Rialto); -declare_relay_to_parachain_bridge_schema!(Millau, RialtoParachain, Rialto); declare_parachain_to_parachain_bridge_schema!(BridgeHubRococo, Rococo, BridgeHubWococo, Wococo); declare_parachain_to_parachain_bridge_schema!(BridgeHubRococo, Rococo, BridgeHubWestend, Westend); declare_parachain_to_parachain_bridge_schema!(BridgeHubKusama, Kusama, BridgeHubPolkadot, Polkadot); @@ -434,58 +376,6 @@ where } } -/// Millau <> Rialto complex relay. -pub struct MillauRialtoFull2WayBridge { - base: ::Base, -} - -#[async_trait] -impl Full2WayBridge for MillauRialtoFull2WayBridge { - type Base = RelayToRelayBridge; - type Left = relay_millau_client::Millau; - type Right = relay_rialto_client::Rialto; - type L2R = MillauToRialtoCliBridge; - type R2L = RialtoToMillauCliBridge; - - fn new(base: Self::Base) -> anyhow::Result { - Ok(Self { base }) - } - - fn base(&self) -> &Self::Base { - &self.base - } - - fn mut_base(&mut self) -> &mut Self::Base { - &mut self.base - } -} - -/// Millau <> RialtoParachain complex relay. -pub struct MillauRialtoParachainFull2WayBridge { - base: ::Base, -} - -#[async_trait] -impl Full2WayBridge for MillauRialtoParachainFull2WayBridge { - type Base = RelayToParachainBridge; - type Left = relay_millau_client::Millau; - type Right = relay_rialto_parachain_client::RialtoParachain; - type L2R = MillauToRialtoParachainCliBridge; - type R2L = RialtoParachainToMillauCliBridge; - - fn new(base: Self::Base) -> anyhow::Result { - Ok(Self { base }) - } - - fn base(&self) -> &Self::Base { - &self.base - } - - fn mut_base(&mut self) -> &mut Self::Base { - &mut self.base - } -} - /// BridgeHubRococo <> BridgeHubWococo complex relay. pub struct BridgeHubRococoBridgeHubWococoFull2WayBridge { base: ::Base, @@ -593,10 +483,6 @@ impl Full2WayBridge for PolkadotBulletinBridgeHubPolkadotFull2WayBridge { /// Complex headers+messages relay. #[derive(Debug, PartialEq, StructOpt)] pub enum RelayHeadersAndMessages { - /// Millau <> Rialto relay. - MillauRialto(MillauRialtoHeadersAndMessages), - /// Millau <> RialtoParachain relay. - MillauRialtoParachain(MillauRialtoParachainHeadersAndMessages), /// BridgeHubRococo <> BridgeHubWococo relay. BridgeHubRococoBridgeHubWococo(BridgeHubRococoBridgeHubWococoHeadersAndMessages), /// BridgeHubKusama <> BridgeHubPolkadot relay. @@ -611,12 +497,6 @@ impl RelayHeadersAndMessages { /// Run the command. pub async fn run(self) -> anyhow::Result<()> { match self { - RelayHeadersAndMessages::MillauRialto(params) => - MillauRialtoFull2WayBridge::new(params.into_bridge().await?)?.run().await, - RelayHeadersAndMessages::MillauRialtoParachain(params) => - MillauRialtoParachainFull2WayBridge::new(params.into_bridge().await?)? - .run() - .await, RelayHeadersAndMessages::BridgeHubRococoBridgeHubWococo(params) => BridgeHubRococoBridgeHubWococoFull2WayBridge::new(params.into_bridge().await?)? .run() @@ -642,130 +522,34 @@ mod tests { use super::*; #[test] - fn should_parse_relay_to_relay_options() { - // when - let res = RelayHeadersAndMessages::from_iter(vec![ - "relay-headers-and-messages", - "millau-rialto", - "--millau-host", - "millau-node-alice", - "--millau-port", - "9944", - "--millau-signer", - "//Charlie", - "--millau-transactions-mortality", - "64", - "--rialto-host", - "rialto-node-alice", - "--rialto-port", - "9944", - "--rialto-signer", - "//Charlie", - "--rialto-transactions-mortality", - "64", - "--lane", - "00000000", - "--lane", - "73776170", - "--prometheus-host", - "0.0.0.0", - ]); - - // then - assert_eq!( - res, - RelayHeadersAndMessages::MillauRialto(MillauRialtoHeadersAndMessages { - shared: HeadersAndMessagesSharedParams { - lane: vec![ - HexLaneId([0x00, 0x00, 0x00, 0x00]), - HexLaneId([0x73, 0x77, 0x61, 0x70]) - ], - only_mandatory_headers: false, - prometheus_params: PrometheusParams { - no_prometheus: false, - prometheus_host: "0.0.0.0".into(), - prometheus_port: 9616, - }, - }, - left: MillauConnectionParams { - millau_host: "millau-node-alice".into(), - millau_port: 9944, - millau_secure: false, - millau_runtime_version: MillauRuntimeVersionParams { - millau_version_mode: RuntimeVersionType::Bundle, - millau_spec_version: None, - millau_transaction_version: None, - }, - }, - left_sign: MillauSigningParams { - millau_signer: Some("//Charlie".into()), - millau_signer_password: None, - millau_signer_file: None, - millau_signer_password_file: None, - millau_transactions_mortality: Some(64), - }, - left_headers_to_right_sign_override: MillauHeadersToRialtoSigningParams { - millau_headers_to_rialto_signer: None, - millau_headers_to_rialto_signer_password: None, - millau_headers_to_rialto_signer_file: None, - millau_headers_to_rialto_signer_password_file: None, - millau_headers_to_rialto_transactions_mortality: None, - }, - right: RialtoConnectionParams { - rialto_host: "rialto-node-alice".into(), - rialto_port: 9944, - rialto_secure: false, - rialto_runtime_version: RialtoRuntimeVersionParams { - rialto_version_mode: RuntimeVersionType::Bundle, - rialto_spec_version: None, - rialto_transaction_version: None, - }, - }, - right_sign: RialtoSigningParams { - rialto_signer: Some("//Charlie".into()), - rialto_signer_password: None, - rialto_signer_file: None, - rialto_signer_password_file: None, - rialto_transactions_mortality: Some(64), - }, - right_headers_to_left_sign_override: RialtoHeadersToMillauSigningParams { - rialto_headers_to_millau_signer: None, - rialto_headers_to_millau_signer_password: None, - rialto_headers_to_millau_signer_file: None, - rialto_headers_to_millau_signer_password_file: None, - rialto_headers_to_millau_transactions_mortality: None, - }, - }), - ); - } - - #[test] - fn should_parse_relay_to_parachain_options() { + fn should_parse_parachain_to_parachain_options() { // when let res = RelayHeadersAndMessages::from_iter(vec![ "relay-headers-and-messages", - "millau-rialto-parachain", - "--millau-host", - "millau-node-alice", - "--millau-port", + "bridge-hub-kusama-bridge-hub-polkadot", + "--bridge-hub-kusama-host", + "bridge-hub-kusama-node-collator1", + "--bridge-hub-kusama-port", "9944", - "--millau-signer", + "--bridge-hub-kusama-signer", "//Iden", - "--rialto-headers-to-millau-signer", - "//Ken", - "--millau-transactions-mortality", + "--bridge-hub-kusama-transactions-mortality", "64", - "--rialto-parachain-host", - "rialto-parachain-collator-charlie", - "--rialto-parachain-port", + "--kusama-host", + "kusama-alice", + "--kusama-port", + "9944", + "--bridge-hub-polkadot-host", + "bridge-hub-polkadot-collator1", + "--bridge-hub-polkadot-port", "9944", - "--rialto-parachain-signer", + "--bridge-hub-polkadot-signer", "//George", - "--rialto-parachain-transactions-mortality", + "--bridge-hub-polkadot-transactions-mortality", "64", - "--rialto-host", - "rialto-node-alice", - "--rialto-port", + "--polkadot-host", + "polkadot-alice", + "--polkadot-port", "9944", "--lane", "00000000", @@ -776,8 +560,8 @@ mod tests { // then assert_eq!( res, - RelayHeadersAndMessages::MillauRialtoParachain( - MillauRialtoParachainHeadersAndMessages { + RelayHeadersAndMessages::BridgeHubKusamaBridgeHubPolkadot( + BridgeHubKusamaBridgeHubPolkadotHeadersAndMessages { shared: HeadersAndMessagesSharedParams { lane: vec![HexLaneId([0x00, 0x00, 0x00, 0x00])], only_mandatory_headers: false, @@ -787,70 +571,59 @@ mod tests { prometheus_port: 9616, }, }, - left: MillauConnectionParams { - millau_host: "millau-node-alice".into(), - millau_port: 9944, - millau_secure: false, - millau_runtime_version: MillauRuntimeVersionParams { - millau_version_mode: RuntimeVersionType::Bundle, - millau_spec_version: None, - millau_transaction_version: None, + left_relay: KusamaConnectionParams { + kusama_host: "kusama-alice".into(), + kusama_port: 9944, + kusama_secure: false, + kusama_runtime_version: KusamaRuntimeVersionParams { + kusama_version_mode: RuntimeVersionType::Bundle, + kusama_spec_version: None, + kusama_transaction_version: None, }, }, - left_sign: MillauSigningParams { - millau_signer: Some("//Iden".into()), - millau_signer_password: None, - millau_signer_file: None, - millau_signer_password_file: None, - millau_transactions_mortality: Some(64), - }, - left_headers_to_right_sign_override: - MillauHeadersToRialtoParachainSigningParams { - millau_headers_to_rialto_parachain_signer: None, - millau_headers_to_rialto_parachain_signer_password: None, - millau_headers_to_rialto_parachain_signer_file: None, - millau_headers_to_rialto_parachain_signer_password_file: None, - millau_headers_to_rialto_parachain_transactions_mortality: None, - }, - right: RialtoParachainConnectionParams { - rialto_parachain_host: "rialto-parachain-collator-charlie".into(), - rialto_parachain_port: 9944, - rialto_parachain_secure: false, - rialto_parachain_runtime_version: RialtoParachainRuntimeVersionParams { - rialto_parachain_version_mode: RuntimeVersionType::Bundle, - rialto_parachain_spec_version: None, - rialto_parachain_transaction_version: None, + left: BridgeHubKusamaConnectionParams { + bridge_hub_kusama_host: "bridge-hub-kusama-node-collator1".into(), + bridge_hub_kusama_port: 9944, + bridge_hub_kusama_secure: false, + bridge_hub_kusama_runtime_version: BridgeHubKusamaRuntimeVersionParams { + bridge_hub_kusama_version_mode: RuntimeVersionType::Bundle, + bridge_hub_kusama_spec_version: None, + bridge_hub_kusama_transaction_version: None, }, }, - right_sign: RialtoParachainSigningParams { - rialto_parachain_signer: Some("//George".into()), - rialto_parachain_signer_password: None, - rialto_parachain_signer_file: None, - rialto_parachain_signer_password_file: None, - rialto_parachain_transactions_mortality: Some(64), + left_sign: BridgeHubKusamaSigningParams { + bridge_hub_kusama_signer: Some("//Iden".into()), + bridge_hub_kusama_signer_password: None, + bridge_hub_kusama_signer_file: None, + bridge_hub_kusama_signer_password_file: None, + bridge_hub_kusama_transactions_mortality: Some(64), }, - right_relay_headers_to_left_sign_override: RialtoHeadersToMillauSigningParams { - rialto_headers_to_millau_signer: Some("//Ken".into()), - rialto_headers_to_millau_signer_password: None, - rialto_headers_to_millau_signer_file: None, - rialto_headers_to_millau_signer_password_file: None, - rialto_headers_to_millau_transactions_mortality: None, + right: BridgeHubPolkadotConnectionParams { + bridge_hub_polkadot_host: "bridge-hub-polkadot-collator1".into(), + bridge_hub_polkadot_port: 9944, + bridge_hub_polkadot_secure: false, + bridge_hub_polkadot_runtime_version: + BridgeHubPolkadotRuntimeVersionParams { + bridge_hub_polkadot_version_mode: RuntimeVersionType::Bundle, + bridge_hub_polkadot_spec_version: None, + bridge_hub_polkadot_transaction_version: None, + }, }, - right_parachains_to_left_sign_override: RialtoParachainsToMillauSigningParams { - rialto_parachains_to_millau_signer: None, - rialto_parachains_to_millau_signer_password: None, - rialto_parachains_to_millau_signer_file: None, - rialto_parachains_to_millau_signer_password_file: None, - rialto_parachains_to_millau_transactions_mortality: None, + right_sign: BridgeHubPolkadotSigningParams { + bridge_hub_polkadot_signer: Some("//George".into()), + bridge_hub_polkadot_signer_password: None, + bridge_hub_polkadot_signer_file: None, + bridge_hub_polkadot_signer_password_file: None, + bridge_hub_polkadot_transactions_mortality: Some(64), }, - right_relay: RialtoConnectionParams { - rialto_host: "rialto-node-alice".into(), - rialto_port: 9944, - rialto_secure: false, - rialto_runtime_version: RialtoRuntimeVersionParams { - rialto_version_mode: RuntimeVersionType::Bundle, - rialto_spec_version: None, - rialto_transaction_version: None, + right_relay: PolkadotConnectionParams { + polkadot_host: "polkadot-alice".into(), + polkadot_port: 9944, + polkadot_secure: false, + polkadot_runtime_version: PolkadotRuntimeVersionParams { + polkadot_version_mode: RuntimeVersionType::Bundle, + polkadot_spec_version: None, + polkadot_transaction_version: None, }, }, } diff --git a/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/parachain_to_parachain.rs b/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/parachain_to_parachain.rs index 1610f648bdcdd..32ba6b3ddadce 100644 --- a/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/parachain_to_parachain.rs +++ b/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/parachain_to_parachain.rs @@ -33,7 +33,6 @@ use substrate_relay_helper::{ on_demand::{ headers::OnDemandHeadersRelay, parachains::OnDemandParachainsRelay, OnDemandRelay, }, - TaggedAccount, TransactionParams, }; /// A base relay between two parachain from different consensus systems. @@ -54,20 +53,6 @@ pub struct ParachainToParachainBridge< pub left_relay: Client<::SourceRelay>, /// Client of the right relay chain. pub right_relay: Client<::SourceRelay>, - - /// Override for right_relay->left headers signer. - pub right_headers_to_left_transaction_params: - TransactionParams::Target>>, - /// Override for right->left parachains signer. - pub right_parachains_to_left_transaction_params: - TransactionParams::Target>>, - - /// Override for left_relay->right headers signer. - pub left_headers_to_right_transaction_params: - TransactionParams::Target>>, - /// Override for left->right parachains signer. - pub left_parachains_to_right_transaction_params: - TransactionParams::Target>>, } macro_rules! declare_parachain_to_parachain_bridge_schema { @@ -86,12 +71,6 @@ macro_rules! declare_parachain_to_parachain_bridge_schema { // default signer, which is always used to sign messages relay transactions on the left chain #[structopt(flatten)] left_sign: [<$left_parachain SigningParams>], - // override for right_relay->left-parachain headers signer - #[structopt(flatten)] - right_relay_headers_to_left_sign_override: [<$right_chain HeadersTo $left_parachain SigningParams>], - // override for right->left parachains signer - #[structopt(flatten)] - right_parachains_to_left_sign_override: [<$right_chain ParachainsTo $left_parachain SigningParams>], #[structopt(flatten)] left_relay: [<$left_chain ConnectionParams>], @@ -101,12 +80,6 @@ macro_rules! declare_parachain_to_parachain_bridge_schema { // default signer, which is always used to sign messages relay transactions on the right chain #[structopt(flatten)] right_sign: [<$right_parachain SigningParams>], - // override for left_relay->right-parachain headers signer - #[structopt(flatten)] - left_relay_headers_to_right_sign_override: [<$left_chain HeadersTo $right_parachain SigningParams>], - // override for left->right parachains signer - #[structopt(flatten)] - left_parachains_to_right_sign_override: [<$left_chain ParachainsTo $right_parachain SigningParams>], #[structopt(flatten)] right_relay: [<$right_chain ConnectionParams>], @@ -143,18 +116,6 @@ macro_rules! declare_parachain_to_parachain_bridge_schema { )?, left_relay: self.left_relay.into_client::().await?, right_relay: self.right_relay.into_client::().await?, - right_headers_to_left_transaction_params: self - .right_relay_headers_to_left_sign_override - .transaction_params_or::(&self.left_sign)?, - left_headers_to_right_transaction_params: self - .left_relay_headers_to_right_sign_override - .transaction_params_or::(&self.right_sign)?, - right_parachains_to_left_transaction_params: self - .right_parachains_to_left_sign_override - .transaction_params_or::(&self.left_sign)?, - left_parachains_to_right_transaction_params: self - .left_parachains_to_right_sign_override - .transaction_params_or::(&self.right_sign)?, }) } } @@ -199,23 +160,6 @@ where Arc>, Arc>, )> { - self.common.left.accounts.push(TaggedAccount::Headers { - id: self.right_headers_to_left_transaction_params.signer.public().into(), - bridged_chain: RightRelay::NAME.to_string(), - }); - self.common.left.accounts.push(TaggedAccount::Parachains { - id: self.right_parachains_to_left_transaction_params.signer.public().into(), - bridged_chain: RightRelay::NAME.to_string(), - }); - self.common.right.accounts.push(TaggedAccount::Headers { - id: self.left_headers_to_right_transaction_params.signer.public().into(), - bridged_chain: Left::NAME.to_string(), - }); - self.common.right.accounts.push(TaggedAccount::Parachains { - id: self.left_parachains_to_right_transaction_params.signer.public().into(), - bridged_chain: LeftRelay::NAME.to_string(), - }); - ::RelayFinality::start_relay_guards( &self.common.right.client, self.common.right.client.can_start_version_guard(), @@ -231,7 +175,7 @@ where OnDemandHeadersRelay::<::RelayFinality>::new( self.left_relay.clone(), self.common.right.client.clone(), - self.left_headers_to_right_transaction_params.clone(), + self.common.right.tx_params.clone(), self.common.shared.only_mandatory_headers, Some(self.common.metrics_params.clone()), ); @@ -239,7 +183,7 @@ where OnDemandHeadersRelay::<::RelayFinality>::new( self.right_relay.clone(), self.common.left.client.clone(), - self.right_headers_to_left_transaction_params.clone(), + self.common.left.tx_params.clone(), self.common.shared.only_mandatory_headers, Some(self.common.metrics_params.clone()), ); @@ -249,7 +193,7 @@ where >::new( self.left_relay.clone(), self.common.right.client.clone(), - self.left_parachains_to_right_transaction_params.clone(), + self.common.right.tx_params.clone(), Arc::new(left_relay_to_right_on_demand_headers), ); let right_to_left_on_demand_parachains = OnDemandParachainsRelay::< @@ -257,7 +201,7 @@ where >::new( self.right_relay.clone(), self.common.left.client.clone(), - self.right_parachains_to_left_transaction_params.clone(), + self.common.left.tx_params.clone(), Arc::new(right_relay_to_left_on_demand_headers), ); diff --git a/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/relay_to_parachain.rs b/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/relay_to_parachain.rs index 98b313cc0960d..fd885b6ea6c6c 100644 --- a/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/relay_to_parachain.rs +++ b/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/relay_to_parachain.rs @@ -36,7 +36,6 @@ use substrate_relay_helper::{ on_demand::{ headers::OnDemandHeadersRelay, parachains::OnDemandParachainsRelay, OnDemandRelay, }, - TaggedAccount, TransactionParams, }; /// A base relay between standalone (relay) chain and a parachain from another consensus system. @@ -54,17 +53,6 @@ pub struct RelayToParachainBridge< Full2WayBridgeCommonParams<::Target, ::Target>, /// Client of the right relay chain. pub right_relay: Client<::SourceRelay>, - - /// Override for right_relay->left headers signer. - pub right_headers_to_left_transaction_params: - TransactionParams::Target>>, - /// Override for right->left parachains signer. - pub right_parachains_to_left_transaction_params: - TransactionParams::Target>>, - - /// Override for left->right headers signer. - pub left_headers_to_right_transaction_params: - TransactionParams::Target>>, } macro_rules! declare_relay_to_parachain_bridge_schema { @@ -83,21 +71,12 @@ macro_rules! declare_relay_to_parachain_bridge_schema { // default signer, which is always used to sign messages relay transactions on the left chain #[structopt(flatten)] left_sign: [<$left_chain SigningParams>], - // override for right_relay->left headers signer - #[structopt(flatten)] - right_relay_headers_to_left_sign_override: [<$right_chain HeadersTo $left_chain SigningParams>], - // override for right->left parachains signer - #[structopt(flatten)] - right_parachains_to_left_sign_override: [<$right_chain ParachainsTo $left_chain SigningParams>], #[structopt(flatten)] right: [<$right_parachain ConnectionParams>], // default signer, which is always used to sign messages relay transactions on the right chain #[structopt(flatten)] right_sign: [<$right_parachain SigningParams>], - // override for left->right headers signer - #[structopt(flatten)] - left_headers_to_right_sign_override: [<$left_chain HeadersTo $right_parachain SigningParams>], #[structopt(flatten)] right_relay: [<$right_chain ConnectionParams>], @@ -130,19 +109,6 @@ macro_rules! declare_relay_to_parachain_bridge_schema { }, )?, right_relay: self.right_relay.into_client::().await?, - right_headers_to_left_transaction_params: self - .right_relay_headers_to_left_sign_override - .transaction_params_or::( - &self.left_sign, - )?, - right_parachains_to_left_transaction_params: self - .right_parachains_to_left_sign_override - .transaction_params_or::( - &self.left_sign, - )?, - left_headers_to_right_transaction_params: self - .left_headers_to_right_sign_override - .transaction_params_or::(&self.right_sign)?, }) } } @@ -185,19 +151,6 @@ where Arc>, Arc>, )> { - self.common.left.accounts.push(TaggedAccount::Headers { - id: self.right_headers_to_left_transaction_params.signer.public().into(), - bridged_chain: RightRelay::NAME.to_string(), - }); - self.common.left.accounts.push(TaggedAccount::Parachains { - id: self.right_parachains_to_left_transaction_params.signer.public().into(), - bridged_chain: RightRelay::NAME.to_string(), - }); - self.common.right.accounts.push(TaggedAccount::Headers { - id: self.left_headers_to_right_transaction_params.signer.public().into(), - bridged_chain: Left::NAME.to_string(), - }); - ::Finality::start_relay_guards( &self.common.right.client, self.common.right.client.can_start_version_guard(), @@ -213,7 +166,7 @@ where OnDemandHeadersRelay::<::Finality>::new( self.common.left.client.clone(), self.common.right.client.clone(), - self.left_headers_to_right_transaction_params.clone(), + self.common.right.tx_params.clone(), self.common.shared.only_mandatory_headers, None, ); @@ -221,7 +174,7 @@ where OnDemandHeadersRelay::<::RelayFinality>::new( self.right_relay.clone(), self.common.left.client.clone(), - self.right_headers_to_left_transaction_params.clone(), + self.common.left.tx_params.clone(), self.common.shared.only_mandatory_headers, Some(self.common.metrics_params.clone()), ); @@ -230,7 +183,7 @@ where >::new( self.right_relay.clone(), self.common.left.client.clone(), - self.right_parachains_to_left_transaction_params.clone(), + self.common.left.tx_params.clone(), Arc::new(right_relay_to_left_on_demand_headers), ); diff --git a/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/relay_to_relay.rs b/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/relay_to_relay.rs index a75263540a55f..11425035de287 100644 --- a/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/relay_to_relay.rs +++ b/bridges/relays/bin-substrate/src/cli/relay_headers_and_messages/relay_to_relay.rs @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +// we don't have any relay/standalone <> relay/standalone chain bridges, but we may need it in a +// future +#![allow(unused_macros)] + use async_trait::async_trait; use std::sync::Arc; @@ -27,7 +31,6 @@ use sp_core::Pair; use substrate_relay_helper::{ finality::SubstrateFinalitySyncPipeline, on_demand::{headers::OnDemandHeadersRelay, OnDemandRelay}, - TaggedAccount, TransactionParams, }; /// A base relay between two standalone (relay) chains. @@ -40,12 +43,6 @@ pub struct RelayToRelayBridge< /// Parameters that are shared by all bridge types. pub common: Full2WayBridgeCommonParams<::Target, ::Target>, - /// Override for right->left headers signer. - pub right_to_left_transaction_params: - TransactionParams::Target>>, - /// Override for left->right headers signer. - pub left_to_right_transaction_params: - TransactionParams::Target>>, } macro_rules! declare_relay_to_relay_bridge_schema { @@ -62,18 +59,12 @@ macro_rules! declare_relay_to_relay_bridge_schema { // default signer, which is always used to sign messages relay transactions on the left chain #[structopt(flatten)] left_sign: [<$left_chain SigningParams>], - // override for right->left headers signer - #[structopt(flatten)] - right_headers_to_left_sign_override: [<$right_chain HeadersTo $left_chain SigningParams>], #[structopt(flatten)] right: [<$right_chain ConnectionParams>], #[structopt(flatten)] // default signer, which is always used to sign messages relay transactions on the right chain right_sign: [<$right_chain SigningParams>], - // override for left->right headers signer - #[structopt(flatten)] - left_headers_to_right_sign_override: [<$left_chain HeadersTo $right_chain SigningParams>], } impl [<$left_chain $right_chain HeadersAndMessages>] { @@ -99,12 +90,8 @@ macro_rules! declare_relay_to_relay_bridge_schema { accounts: vec![], }, )?, - right_to_left_transaction_params: self - .right_headers_to_left_sign_override - .transaction_params_or::(&self.left_sign)?, - left_to_right_transaction_params: self - .left_headers_to_right_sign_override - .transaction_params_or::(&self.right_sign)?, + right_to_left_transaction_params: self.left_sign.transaction_params::(), + left_to_right_transaction_params: self.right_sign.transaction_params::(), }) } } @@ -145,15 +132,6 @@ where Arc>, Arc>, )> { - self.common.right.accounts.push(TaggedAccount::Headers { - id: self.left_to_right_transaction_params.signer.public().into(), - bridged_chain: Self::Left::NAME.to_string(), - }); - self.common.left.accounts.push(TaggedAccount::Headers { - id: self.right_to_left_transaction_params.signer.public().into(), - bridged_chain: Self::Right::NAME.to_string(), - }); - ::Finality::start_relay_guards( &self.common.right.client, self.common.right.client.can_start_version_guard(), @@ -169,7 +147,7 @@ where OnDemandHeadersRelay::<::Finality>::new( self.common.left.client.clone(), self.common.right.client.clone(), - self.left_to_right_transaction_params.clone(), + self.common.right.tx_params.clone(), self.common.shared.only_mandatory_headers, None, ); @@ -177,7 +155,7 @@ where OnDemandHeadersRelay::<::Finality>::new( self.common.right.client.clone(), self.common.left.client.clone(), - self.right_to_left_transaction_params.clone(), + self.common.left.tx_params.clone(), self.common.shared.only_mandatory_headers, None, ); diff --git a/bridges/relays/bin-substrate/src/cli/relay_messages.rs b/bridges/relays/bin-substrate/src/cli/relay_messages.rs index 9880edcda2ca1..7d01f8bcd7df4 100644 --- a/bridges/relays/bin-substrate/src/cli/relay_messages.rs +++ b/bridges/relays/bin-substrate/src/cli/relay_messages.rs @@ -28,14 +28,6 @@ use crate::bridges::{ bridge_hub_polkadot_messages_to_polkadot_bulletin::BridgeHubPolkadotToPolkadotBulletinMessagesCliBridge, polkadot_bulletin_messages_to_bridge_hub_polkadot::PolkadotBulletinToBridgeHubPolkadotMessagesCliBridge, }, - rialto_millau::{ - millau_headers_to_rialto::MillauToRialtoCliBridge, - rialto_headers_to_millau::RialtoToMillauCliBridge, - }, - rialto_parachain_millau::{ - millau_headers_to_rialto_parachain::MillauToRialtoParachainCliBridge, - rialto_parachains_to_millau::RialtoParachainToMillauCliBridge, - }, rococo_westend::{ bridge_hub_rococo_messages_to_bridge_hub_westend::BridgeHubRococoToBridgeHubWestendMessagesCliBridge, bridge_hub_westend_messages_to_bridge_hub_rococo::BridgeHubWestendToBridgeHubRococoMessagesCliBridge, @@ -109,10 +101,6 @@ where } } -impl MessagesRelayer for MillauToRialtoCliBridge {} -impl MessagesRelayer for RialtoToMillauCliBridge {} -impl MessagesRelayer for MillauToRialtoParachainCliBridge {} -impl MessagesRelayer for RialtoParachainToMillauCliBridge {} impl MessagesRelayer for BridgeHubRococoToBridgeHubWococoMessagesCliBridge {} impl MessagesRelayer for BridgeHubWococoToBridgeHubRococoMessagesCliBridge {} impl MessagesRelayer for BridgeHubRococoToBridgeHubWestendMessagesCliBridge {} @@ -126,12 +114,6 @@ impl RelayMessages { /// Run the command. pub async fn run(self) -> anyhow::Result<()> { match self.bridge { - FullBridge::MillauToRialto => MillauToRialtoCliBridge::relay_messages(self), - FullBridge::RialtoToMillau => RialtoToMillauCliBridge::relay_messages(self), - FullBridge::MillauToRialtoParachain => - MillauToRialtoParachainCliBridge::relay_messages(self), - FullBridge::RialtoParachainToMillau => - RialtoParachainToMillauCliBridge::relay_messages(self), FullBridge::BridgeHubRococoToBridgeHubWococo => BridgeHubRococoToBridgeHubWococoMessagesCliBridge::relay_messages(self), FullBridge::BridgeHubWococoToBridgeHubRococo => diff --git a/bridges/relays/bin-substrate/src/cli/relay_parachains.rs b/bridges/relays/bin-substrate/src/cli/relay_parachains.rs index 03d3860f3b224..668632320efa8 100644 --- a/bridges/relays/bin-substrate/src/cli/relay_parachains.rs +++ b/bridges/relays/bin-substrate/src/cli/relay_parachains.rs @@ -20,7 +20,6 @@ use crate::bridges::{ polkadot_parachains_to_bridge_hub_kusama::BridgeHubPolkadotToBridgeHubKusamaCliBridge, }, polkadot_bulletin::polkadot_parachains_to_polkadot_bulletin::PolkadotToPolkadotBulletinCliBridge, - rialto_parachain_millau::rialto_parachains_to_millau::RialtoParachainToMillauCliBridge, rococo_westend::{ rococo_parachains_to_bridge_hub_westend::BridgeHubRococoToBridgeHubWestendCliBridge, westend_parachains_to_bridge_hub_rococo::BridgeHubWestendToBridgeHubRococoCliBridge, @@ -29,7 +28,6 @@ use crate::bridges::{ rococo_parachains_to_bridge_hub_wococo::BridgeHubRococoToBridgeHubWococoCliBridge, wococo_parachains_to_bridge_hub_rococo::BridgeHubWococoToBridgeHubRococoCliBridge, }, - westend_millau::westend_parachains_to_millau::AssetHubWestendToMillauCliBridge, }; use async_std::sync::Mutex; use async_trait::async_trait; @@ -70,8 +68,6 @@ pub struct RelayParachains { #[derive(Debug, EnumString, EnumVariantNames)] #[strum(serialize_all = "kebab_case")] pub enum RelayParachainsBridge { - RialtoToMillau, - WestendToMillau, RococoToBridgeHubWococo, WococoToBridgeHubRococo, KusamaToBridgeHubPolkadot, @@ -122,8 +118,6 @@ where } } -impl ParachainsRelayer for RialtoParachainToMillauCliBridge {} -impl ParachainsRelayer for AssetHubWestendToMillauCliBridge {} impl ParachainsRelayer for BridgeHubRococoToBridgeHubWococoCliBridge {} impl ParachainsRelayer for BridgeHubWococoToBridgeHubRococoCliBridge {} impl ParachainsRelayer for BridgeHubRococoToBridgeHubWestendCliBridge {} @@ -136,10 +130,6 @@ impl RelayParachains { /// Run the command. pub async fn run(self) -> anyhow::Result<()> { match self.bridge { - RelayParachainsBridge::RialtoToMillau => - RialtoParachainToMillauCliBridge::relay_parachains(self), - RelayParachainsBridge::WestendToMillau => - AssetHubWestendToMillauCliBridge::relay_parachains(self), RelayParachainsBridge::RococoToBridgeHubWococo => BridgeHubRococoToBridgeHubWococoCliBridge::relay_parachains(self), RelayParachainsBridge::WococoToBridgeHubRococo => diff --git a/bridges/relays/bin-substrate/src/cli/resubmit_transactions.rs b/bridges/relays/bin-substrate/src/cli/resubmit_transactions.rs deleted file mode 100644 index c5b20e939c1fa..0000000000000 --- a/bridges/relays/bin-substrate/src/cli/resubmit_transactions.rs +++ /dev/null @@ -1,560 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use crate::cli::{chain_schema::*, Balance}; - -use bp_runtime::HeaderIdProvider; -use codec::{Decode, Encode}; -use num_traits::{One, Zero}; -use relay_substrate_client::{ - AccountKeyPairOf, BlockWithJustification, Chain, ChainWithTransactions, Client, - Error as SubstrateError, HeaderIdOf, HeaderOf, SignParam, -}; -use relay_utils::FailedClient; -use sp_core::Bytes; -use sp_runtime::{ - traits::{Hash, Header as HeaderT}, - transaction_validity::TransactionPriority, -}; -use structopt::StructOpt; -use strum::{EnumString, EnumVariantNames, VariantNames}; -use substrate_relay_helper::TransactionParams; - -/// Start resubmit transactions process. -#[derive(StructOpt)] -pub struct ResubmitTransactions { - /// A bridge instance to relay headers for. - #[structopt(possible_values = RelayChain::VARIANTS, case_insensitive = true)] - chain: RelayChain, - #[structopt(flatten)] - target: TargetConnectionParams, - #[structopt(flatten)] - target_sign: TargetSigningParams, - /// Number of blocks we see before considering queued transaction as stalled. - #[structopt(long, default_value = "5")] - stalled_blocks: u32, - /// Tip limit. We'll never submit transaction with larger tip. - #[structopt(long)] - tip_limit: Balance, - /// Tip increase step. We'll be checking updated transaction priority by increasing its tip by - /// this step. - #[structopt(long)] - tip_step: Balance, - /// Priority selection strategy. - #[structopt(subcommand)] - strategy: PrioritySelectionStrategy, -} - -/// Chain, which transactions we're going to track && resubmit. -#[derive(Debug, EnumString, EnumVariantNames)] -#[strum(serialize_all = "kebab_case")] -pub enum RelayChain { - Millau, -} - -/// Strategy to use for priority selection. -#[derive(StructOpt, Debug, PartialEq, Eq, Clone, Copy)] -pub enum PrioritySelectionStrategy { - /// Strategy selects tip that changes transaction priority to be better than priority of - /// the first transaction of previous block. - /// - /// It only makes sense to use this strategy for Millau transactions. Millau has transactions - /// that are close to block limits, so if there are any other queued transactions, 'large' - /// transaction won't fit the block && will be postponed. To avoid this, we change its priority - /// to some large value, making it best transaction => it'll be 'mined' first. - MakeItBestTransaction, - /// Strategy selects tip that changes transaction priority to be better than priority of - /// selected queued transaction. - /// - /// When we first see stalled transaction, we make it better than worst 1/4 of queued - /// transactions. If it is still stalled, we'll make it better than 1/3 of queued transactions, - /// ... - MakeItBetterThanQueuedTransaction, -} - -macro_rules! select_bridge { - ($bridge: expr, $generic: tt) => { - match $bridge { - RelayChain::Millau => { - type Target = relay_millau_client::Millau; - - $generic - }, - } - }; -} - -impl ResubmitTransactions { - /// Run the command. - pub async fn run(self) -> anyhow::Result<()> { - select_bridge!(self.chain, { - let relay_loop_name = format!("ResubmitTransactions{}", Target::NAME); - let client = self.target.into_client::().await?; - let transaction_params = TransactionParams { - signer: self.target_sign.to_keypair::()?, - mortality: self.target_sign.target_transactions_mortality, - }; - - relay_utils::relay_loop((), client) - .run(relay_loop_name, move |_, client, _| { - run_until_connection_lost( - client, - transaction_params.clone(), - Context { - strategy: self.strategy, - best_header: HeaderOf::::new( - Default::default(), - Default::default(), - Default::default(), - Default::default(), - Default::default(), - ), - transaction: None, - resubmitted: 0, - stalled_for: Zero::zero(), - stalled_for_limit: self.stalled_blocks as _, - tip_step: self.tip_step.cast() as _, - tip_limit: self.tip_limit.cast() as _, - }, - ) - }) - .await - .map_err(Into::into) - }) - } -} - -impl PrioritySelectionStrategy { - /// Select target priority. - async fn select_target_priority( - &self, - client: &Client, - context: &Context, - ) -> Result, SubstrateError> { - match *self { - PrioritySelectionStrategy::MakeItBestTransaction => - read_previous_block_best_priority(client, context).await, - PrioritySelectionStrategy::MakeItBetterThanQueuedTransaction => - select_priority_from_queue(client, context).await, - } - } -} - -#[derive(Debug)] -struct Context { - /// Priority selection strategy. - strategy: PrioritySelectionStrategy, - /// Best known block header. - best_header: C::Header, - /// Hash of the (potentially) stalled transaction. - transaction: Option, - /// How many times we have resubmitted this `transaction`? - resubmitted: u32, - /// This transaction is in pool for `stalled_for` wakeup intervals. - stalled_for: C::BlockNumber, - /// When `stalled_for` reaching this limit, transaction is considered stalled. - stalled_for_limit: C::BlockNumber, - /// Tip step interval. - tip_step: C::Balance, - /// Maximal tip. - tip_limit: C::Balance, -} - -impl Context { - /// Return true if transaction has stalled. - fn is_stalled(&self) -> bool { - self.stalled_for >= self.stalled_for_limit - } - - /// Notice resubmitted transaction. - fn notice_resubmitted_transaction(mut self, transaction: C::Hash) -> Self { - self.transaction = Some(transaction); - self.stalled_for = Zero::zero(); - self.resubmitted += 1; - self - } - - /// Notice transaction from the transaction pool. - fn notice_transaction(mut self, transaction: C::Hash) -> Self { - if self.transaction == Some(transaction) { - self.stalled_for += One::one(); - } else { - self.transaction = Some(transaction); - self.stalled_for = One::one(); - self.resubmitted = 0; - } - self - } -} - -/// Run resubmit transactions loop. -async fn run_until_connection_lost( - client: Client, - transaction_params: TransactionParams>, - mut context: Context, -) -> Result<(), FailedClient> { - loop { - async_std::task::sleep(C::AVERAGE_BLOCK_INTERVAL).await; - - let result = run_loop_iteration(client.clone(), transaction_params.clone(), context).await; - context = match result { - Ok(context) => context, - Err(error) => { - log::error!( - target: "bridge", - "Resubmit {} transactions loop has failed with error: {:?}", - C::NAME, - error, - ); - return Err(FailedClient::Target) - }, - }; - } -} - -/// Run single loop iteration. -async fn run_loop_iteration( - client: Client, - transaction_params: TransactionParams>, - mut context: Context, -) -> Result, SubstrateError> { - // correct best header is required for all other actions - context.best_header = client.best_header().await?; - - // check if there's queued transaction, signed by given author - let original_transaction = - match lookup_signer_transaction(&client, &transaction_params.signer).await? { - Some(original_transaction) => original_transaction, - None => { - log::trace!(target: "bridge", "No {} transactions from required signer in the txpool", C::NAME); - return Ok(context) - }, - }; - let original_transaction_hash = C::Hasher::hash(&original_transaction.encode()); - let context = context.notice_transaction(original_transaction_hash); - - // if transaction hasn't been mined for `stalled_blocks`, we'll need to resubmit it - if !context.is_stalled() { - log::trace!( - target: "bridge", - "{} transaction {:?} is not yet stalled ({:?}/{:?})", - C::NAME, - context.transaction, - context.stalled_for, - context.stalled_for_limit, - ); - return Ok(context) - } - - // select priority for updated transaction - let target_priority = match context.strategy.select_target_priority(&client, &context).await? { - Some(target_priority) => target_priority, - None => { - log::trace!(target: "bridge", "Failed to select target priority"); - return Ok(context) - }, - }; - - // update transaction tip - let (is_updated, updated_transaction) = update_transaction_tip( - &client, - &transaction_params, - context.best_header.id(), - original_transaction, - context.tip_step, - context.tip_limit, - target_priority, - ) - .await?; - - if !is_updated { - log::trace!(target: "bridge", "{} transaction tip can not be updated. Reached limit?", C::NAME); - return Ok(context) - } - - let updated_transaction = updated_transaction.encode(); - let updated_transaction_hash = C::Hasher::hash(&updated_transaction); - client.submit_unsigned_extrinsic(Bytes(updated_transaction)).await?; - - log::info!( - target: "bridge", - "Replaced {} transaction {} with {} in txpool", - C::NAME, - original_transaction_hash, - updated_transaction_hash, - ); - - Ok(context.notice_resubmitted_transaction(updated_transaction_hash)) -} - -/// Search transaction pool for transaction, signed by given key pair. -async fn lookup_signer_transaction( - client: &Client, - key_pair: &AccountKeyPairOf, -) -> Result, SubstrateError> { - let pending_transactions = client.pending_extrinsics().await?; - for pending_transaction in pending_transactions { - let pending_transaction = C::SignedTransaction::decode(&mut &pending_transaction.0[..]) - .map_err(SubstrateError::ResponseParseFailed)?; - if !C::is_signed_by(key_pair, &pending_transaction) { - continue - } - - return Ok(Some(pending_transaction)) - } - - Ok(None) -} - -/// Read priority of best signed transaction of previous block. -async fn read_previous_block_best_priority( - client: &Client, - context: &Context, -) -> Result, SubstrateError> { - let best_block = client.get_block(Some(context.best_header.hash())).await?; - let best_transaction = best_block - .extrinsics() - .iter() - .filter_map(|xt| C::SignedTransaction::decode(&mut &xt[..]).ok()) - .find(|xt| C::is_signed(xt)); - match best_transaction { - Some(best_transaction) => Ok(Some( - client - .validate_transaction(*context.best_header.parent_hash(), best_transaction) - .await?? - .priority, - )), - None => Ok(None), - } -} - -/// Select priority of some queued transaction. -async fn select_priority_from_queue( - client: &Client, - context: &Context, -) -> Result, SubstrateError> { - // select transaction from the queue - let queued_transactions = client.pending_extrinsics().await?; - let selected_transaction = match select_transaction_from_queue(queued_transactions, context) { - Some(selected_transaction) => selected_transaction, - None => return Ok(None), - }; - - let selected_transaction = C::SignedTransaction::decode(&mut &selected_transaction[..]) - .map_err(SubstrateError::ResponseParseFailed)?; - let target_priority = client - .validate_transaction(context.best_header.hash(), selected_transaction) - .await?? - .priority; - Ok(Some(target_priority)) -} - -/// Select transaction with target priority from the vec of queued transactions. -fn select_transaction_from_queue( - mut queued_transactions: Vec, - context: &Context, -) -> Option { - if queued_transactions.is_empty() { - return None - } - - // the more times we resubmit transaction (`context.resubmitted`), the closer we move - // to the front of the transaction queue - let total_transactions = queued_transactions.len(); - let resubmitted_factor = context.resubmitted; - let divisor = - 1usize.saturating_add(1usize.checked_shl(resubmitted_factor).unwrap_or(usize::MAX)); - let transactions_to_skip = total_transactions / divisor; - - Some( - queued_transactions - .swap_remove(std::cmp::min(total_transactions - 1, transactions_to_skip)), - ) -} - -/// Try to find appropriate tip for transaction so that its priority is larger than given. -async fn update_transaction_tip( - client: &Client, - transaction_params: &TransactionParams>, - at_block: HeaderIdOf, - tx: C::SignedTransaction, - tip_step: C::Balance, - tip_limit: C::Balance, - target_priority: TransactionPriority, -) -> Result<(bool, C::SignedTransaction), SubstrateError> { - let stx = format!("{tx:?}"); - let mut current_priority = client.validate_transaction(at_block.1, tx.clone()).await??.priority; - let mut unsigned_tx = C::parse_transaction(tx).ok_or_else(|| { - SubstrateError::Custom(format!("Failed to parse {} transaction {stx}", C::NAME,)) - })?; - let old_tip = unsigned_tx.tip; - - let runtime_version = client.simple_runtime_version().await?; - while current_priority < target_priority { - let next_tip = unsigned_tx.tip + tip_step; - if next_tip > tip_limit { - break - } - - log::trace!( - target: "bridge", - "{} transaction priority with tip={:?}: {}. Target priority: {}", - C::NAME, - unsigned_tx.tip, - current_priority, - target_priority, - ); - - unsigned_tx.tip = next_tip; - current_priority = client - .validate_transaction( - at_block.1, - C::sign_transaction( - SignParam { - spec_version: runtime_version.spec_version, - transaction_version: runtime_version.transaction_version, - genesis_hash: *client.genesis_hash(), - signer: transaction_params.signer.clone(), - }, - unsigned_tx.clone(), - )?, - ) - .await?? - .priority; - } - - log::debug!( - target: "bridge", - "{} transaction tip has changed from {:?} to {:?}", - C::NAME, - old_tip, - unsigned_tx.tip, - ); - - Ok(( - old_tip != unsigned_tx.tip, - C::sign_transaction( - SignParam { - spec_version: runtime_version.spec_version, - transaction_version: runtime_version.transaction_version, - genesis_hash: *client.genesis_hash(), - signer: transaction_params.signer.clone(), - }, - unsigned_tx.era(relay_substrate_client::TransactionEra::new( - at_block, - transaction_params.mortality, - )), - )?, - )) -} - -#[cfg(test)] -mod tests { - use super::*; - use bp_rialto::Hash; - use relay_rialto_client::Rialto; - - fn context() -> Context { - Context { - strategy: PrioritySelectionStrategy::MakeItBestTransaction, - best_header: HeaderOf::::new( - Default::default(), - Default::default(), - Default::default(), - Default::default(), - Default::default(), - ), - transaction: None, - resubmitted: 0, - stalled_for: Zero::zero(), - stalled_for_limit: 3, - tip_step: 100, - tip_limit: 1000, - } - } - - #[test] - fn context_works() { - let mut context = context(); - - // when transaction is noticed 2/3 times, it isn't stalled - context = context.notice_transaction(Default::default()); - assert!(!context.is_stalled()); - assert_eq!(context.stalled_for, 1); - assert_eq!(context.resubmitted, 0); - context = context.notice_transaction(Default::default()); - assert!(!context.is_stalled()); - assert_eq!(context.stalled_for, 2); - assert_eq!(context.resubmitted, 0); - - // when transaction is noticed for 3rd time in a row, it is considered stalled - context = context.notice_transaction(Default::default()); - assert!(context.is_stalled()); - assert_eq!(context.stalled_for, 3); - assert_eq!(context.resubmitted, 0); - - // and after we resubmit it, we forget previous transaction - context = context.notice_resubmitted_transaction(Hash::from([1; 32])); - assert_eq!(context.transaction, Some(Hash::from([1; 32]))); - assert_eq!(context.resubmitted, 1); - assert_eq!(context.stalled_for, 0); - } - - #[test] - fn select_transaction_from_queue_works_with_empty_queue() { - assert_eq!(select_transaction_from_queue(vec![], &context()), None); - } - - #[test] - fn select_transaction_from_queue_works() { - let mut context = context(); - let queued_transactions = vec![ - Bytes(vec![1]), - Bytes(vec![2]), - Bytes(vec![3]), - Bytes(vec![4]), - Bytes(vec![5]), - Bytes(vec![6]), - ]; - - // when we resubmit tx for the first time, 1/2 of queue is skipped - assert_eq!( - select_transaction_from_queue(queued_transactions.clone(), &context), - Some(Bytes(vec![4])), - ); - - // when we resubmit tx for the second time, 1/3 of queue is skipped - context = context.notice_resubmitted_transaction(Hash::from([1; 32])); - assert_eq!( - select_transaction_from_queue(queued_transactions.clone(), &context), - Some(Bytes(vec![3])), - ); - - // when we resubmit tx for the third time, 1/5 of queue is skipped - context = context.notice_resubmitted_transaction(Hash::from([2; 32])); - assert_eq!( - select_transaction_from_queue(queued_transactions.clone(), &context), - Some(Bytes(vec![2])), - ); - - // when we resubmit tx for the second time, 1/9 of queue is skipped - context = context.notice_resubmitted_transaction(Hash::from([3; 32])); - assert_eq!( - select_transaction_from_queue(queued_transactions, &context), - Some(Bytes(vec![1])), - ); - } -} diff --git a/bridges/relays/bin-substrate/src/cli/send_message.rs b/bridges/relays/bin-substrate/src/cli/send_message.rs deleted file mode 100644 index 02ef58b371948..0000000000000 --- a/bridges/relays/bin-substrate/src/cli/send_message.rs +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -use crate::{ - bridges::{ - rialto_millau::{ - millau_headers_to_rialto::MillauToRialtoCliBridge, - rialto_headers_to_millau::RialtoToMillauCliBridge, - }, - rialto_parachain_millau::{ - millau_headers_to_rialto_parachain::MillauToRialtoParachainCliBridge, - rialto_parachains_to_millau::RialtoParachainToMillauCliBridge, - }, - }, - cli::{ - bridge::{FullBridge, MessagesCliBridge}, - chain_schema::*, - encode_message::{self, CliEncodeMessage, RawMessage}, - CliChain, - }, -}; -use async_trait::async_trait; -use codec::{Decode, Encode}; -use relay_substrate_client::{ - AccountIdOf, AccountKeyPairOf, Chain, ChainBase, ChainWithTransactions, UnsignedTransaction, -}; -use sp_core::Pair; -use sp_runtime::AccountId32; -use std::fmt::Display; -use structopt::StructOpt; -use strum::VariantNames; - -/// Send bridge message. -#[derive(StructOpt)] -pub struct SendMessage { - /// A bridge instance to encode call for. - #[structopt(possible_values = FullBridge::VARIANTS, case_insensitive = true)] - bridge: FullBridge, - #[structopt(flatten)] - source: SourceConnectionParams, - #[structopt(flatten)] - source_sign: SourceSigningParams, - /// Message type. - #[structopt(subcommand)] - message: crate::cli::encode_message::Message, -} - -#[async_trait] -trait MessageSender: MessagesCliBridge -where - Self::Source: ChainBase + ChainWithTransactions + CliChain + CliEncodeMessage, - ::Balance: Display + From + Into, - ::Call: Sync, - ::SignedTransaction: Sync, - AccountIdOf: From< as Pair>::Public>, - AccountId32: From< as Pair>::Public>, -{ - async fn send_message(data: SendMessage) -> anyhow::Result<()> { - let payload = encode_message::encode_message::(&data.message)?; - - let source_client = data.source.into_client::().await?; - let source_sign = data.source_sign.to_keypair::()?; - - let payload_len = payload.encoded_size(); - let send_message_call = Self::Source::encode_execute_xcm(decode_xcm(payload)?)?; - - source_client - .submit_signed_extrinsic(&source_sign, move |_, transaction_nonce| { - let unsigned = UnsignedTransaction::new(send_message_call, transaction_nonce); - log::info!( - target: "bridge", - "Sending message to {}. Size: {}", - Self::Target::NAME, - payload_len, - ); - Ok(unsigned) - }) - .await?; - - Ok(()) - } -} - -impl MessageSender for MillauToRialtoCliBridge {} -impl MessageSender for RialtoToMillauCliBridge {} -impl MessageSender for MillauToRialtoParachainCliBridge {} -impl MessageSender for RialtoParachainToMillauCliBridge {} - -impl SendMessage { - /// Run the command. - pub async fn run(self) -> anyhow::Result<()> { - match self.bridge { - FullBridge::MillauToRialto => MillauToRialtoCliBridge::send_message(self), - FullBridge::RialtoToMillau => RialtoToMillauCliBridge::send_message(self), - FullBridge::MillauToRialtoParachain => - MillauToRialtoParachainCliBridge::send_message(self), - FullBridge::RialtoParachainToMillau => - RialtoParachainToMillauCliBridge::send_message(self), - // all our (soon to retire_ testnets are above, so if is fine to use `_` - _ => unimplemented!("Sending message from in {:?} is not supported", self.bridge,), - } - .await - } -} - -/// Decode SCALE encoded raw XCM message. -pub(crate) fn decode_xcm(message: RawMessage) -> anyhow::Result> { - Decode::decode(&mut &message[..]) - .map_err(|e| anyhow::format_err!("Failed to decode XCM program: {:?}", e)) -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::cli::{ExplicitOrMaximal, HexBytes}; - - #[test] - fn send_raw_rialto_to_millau() { - // given - let send_message = SendMessage::from_iter(vec![ - "send-message", - "rialto-to-millau", - "--source-port", - "1234", - "--source-signer", - "//Alice", - "raw", - "dead", - ]); - - // then - assert_eq!(send_message.bridge, FullBridge::RialtoToMillau); - assert_eq!(send_message.source.source_port, 1234); - assert_eq!(send_message.source_sign.source_signer, Some("//Alice".into())); - assert_eq!( - send_message.message, - crate::cli::encode_message::Message::Raw { data: HexBytes(vec![0xDE, 0xAD]) } - ); - } - - #[test] - fn send_sized_rialto_to_millau() { - // given - let send_message = SendMessage::from_iter(vec![ - "send-message", - "rialto-to-millau", - "--source-port", - "1234", - "--source-signer", - "//Alice", - "sized", - "max", - ]); - - // then - assert_eq!(send_message.bridge, FullBridge::RialtoToMillau); - assert_eq!(send_message.source.source_port, 1234); - assert_eq!(send_message.source_sign.source_signer, Some("//Alice".into())); - assert_eq!( - send_message.message, - crate::cli::encode_message::Message::Sized { size: ExplicitOrMaximal::Maximal } - ); - } -} diff --git a/bridges/relays/client-millau/Cargo.toml b/bridges/relays/client-millau/Cargo.toml deleted file mode 100644 index ccfeced1c2704..0000000000000 --- a/bridges/relays/client-millau/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "relay-millau-client" -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2021" -license = "GPL-3.0-or-later WITH Classpath-exception-2.0" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.1.5" } -relay-substrate-client = { path = "../client-substrate" } -relay-utils = { path = "../utils" } - -# Supported Chains - -bp-messages = { path = "../../primitives/messages" } -bp-millau = { path = "../../primitives/chain-millau" } -bp-runtime = { path = "../../primitives/runtime" } -millau-runtime = { path = "../../bin/millau/runtime" } - -# Substrate Dependencies - -frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } diff --git a/bridges/relays/client-millau/src/lib.rs b/bridges/relays/client-millau/src/lib.rs deleted file mode 100644 index b3101c980c557..0000000000000 --- a/bridges/relays/client-millau/src/lib.rs +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -//! Types used to connect to the Millau-Substrate chain. - -use bp_messages::MessageNonce; -use bp_millau::MILLAU_SYNCED_HEADERS_GRANDPA_INFO_METHOD; -use bp_runtime::ChainId; -use codec::{Compact, Decode, Encode}; -use relay_substrate_client::{ - BalanceOf, Chain, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, - ChainWithTransactions, ChainWithUtilityPallet, Error as SubstrateError, - FullRuntimeUtilityPallet, NonceOf, SignParam, UnderlyingChainProvider, UnsignedTransaction, -}; -use sp_core::{storage::StorageKey, Pair}; -use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount}; -use sp_session::MembershipProof; -use std::time::Duration; - -/// Millau header id. -pub type HeaderId = relay_utils::HeaderId; - -/// Millau chain definition. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct Millau; - -impl UnderlyingChainProvider for Millau { - type Chain = bp_millau::Millau; -} - -impl ChainWithMessages for Millau { - const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = - bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME; - // TODO (https://github.com/paritytech/parity-bridges-common/issues/1692): change the name - const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> = Some("BridgeRelayers"); - const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = - bp_millau::TO_MILLAU_MESSAGE_DETAILS_METHOD; - const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = - bp_millau::FROM_MILLAU_MESSAGE_DETAILS_METHOD; - const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = - bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; - const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = - bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; -} - -impl Chain for Millau { - const ID: ChainId = bp_runtime::MILLAU_CHAIN_ID; - const NAME: &'static str = "Millau"; - const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = - bp_millau::BEST_FINALIZED_MILLAU_HEADER_METHOD; - const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(5); - - type SignedBlock = millau_runtime::SignedBlock; - type Call = millau_runtime::RuntimeCall; -} - -impl ChainWithGrandpa for Millau { - const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str = - MILLAU_SYNCED_HEADERS_GRANDPA_INFO_METHOD; - - type KeyOwnerProof = MembershipProof; -} - -impl ChainWithBalances for Millau { - fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey { - use frame_support::storage::generator::StorageMap; - StorageKey(frame_system::Account::::storage_map_final_key( - account_id, - )) - } -} - -impl ChainWithTransactions for Millau { - type AccountKeyPair = sp_core::sr25519::Pair; - type SignedTransaction = millau_runtime::UncheckedExtrinsic; - - fn sign_transaction( - param: SignParam, - unsigned: UnsignedTransaction, - ) -> Result { - let raw_payload = SignedPayload::from_raw( - unsigned.call.clone(), - ( - frame_system::CheckNonZeroSender::::new(), - frame_system::CheckSpecVersion::::new(), - frame_system::CheckTxVersion::::new(), - frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from(unsigned.era.frame_era()), - frame_system::CheckNonce::::from(unsigned.nonce), - frame_system::CheckWeight::::new(), - pallet_transaction_payment::ChargeTransactionPayment::::from(unsigned.tip), - millau_runtime::BridgeRejectObsoleteHeadersAndMessages, - millau_runtime::BridgeRefundRialtoParachainMessages::default(), - ), - ( - (), - param.spec_version, - param.transaction_version, - param.genesis_hash, - unsigned.era.signed_payload(param.genesis_hash), - (), - (), - (), - (), - () - ), - ); - let signature = raw_payload.using_encoded(|payload| param.signer.sign(payload)); - let signer: sp_runtime::MultiSigner = param.signer.public().into(); - let (call, extra, _) = raw_payload.deconstruct(); - - Ok(millau_runtime::UncheckedExtrinsic::new_signed( - call.into_decoded()?, - signer.into_account(), - signature.into(), - extra, - )) - } - - fn is_signed(tx: &Self::SignedTransaction) -> bool { - tx.signature.is_some() - } - - fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool { - tx.signature - .as_ref() - .map(|(address, _, _)| { - *address == millau_runtime::Address::from(*signer.public().as_array_ref()) - }) - .unwrap_or(false) - } - - fn parse_transaction(tx: Self::SignedTransaction) -> Option> { - let extra = &tx.signature.as_ref()?.2; - Some( - UnsignedTransaction::new( - tx.function.into(), - Compact::>::decode(&mut &extra.5.encode()[..]).ok()?.into(), - ) - .tip(Compact::>::decode(&mut &extra.7.encode()[..]).ok()?.into()), - ) - } -} - -impl ChainWithUtilityPallet for Millau { - type UtilityPallet = FullRuntimeUtilityPallet; -} - -/// Millau signing params. -pub type SigningParams = sp_core::sr25519::Pair; - -/// Millau header type used in headers sync. -pub type SyncHeader = relay_substrate_client::SyncHeader; - -#[cfg(test)] -mod tests { - use super::*; - use relay_substrate_client::TransactionEra; - - #[test] - fn parse_transaction_works() { - let unsigned = UnsignedTransaction { - call: millau_runtime::RuntimeCall::System(millau_runtime::SystemCall::remark { - remark: b"Hello world!".to_vec(), - }) - .into(), - nonce: 777, - tip: 888, - era: TransactionEra::immortal(), - }; - let signed_transaction = Millau::sign_transaction( - SignParam { - spec_version: 42, - transaction_version: 50000, - genesis_hash: [42u8; 64].into(), - signer: sp_core::sr25519::Pair::from_seed_slice(&[1u8; 32]).unwrap(), - }, - unsigned.clone(), - ) - .unwrap(); - let parsed_transaction = Millau::parse_transaction(signed_transaction).unwrap(); - assert_eq!(parsed_transaction, unsigned); - } -} diff --git a/bridges/relays/client-rialto-parachain/Cargo.toml b/bridges/relays/client-rialto-parachain/Cargo.toml deleted file mode 100644 index fc91e27ee0f82..0000000000000 --- a/bridges/relays/client-rialto-parachain/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -name = "relay-rialto-parachain-client" -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2021" -license = "GPL-3.0-or-later WITH Classpath-exception-2.0" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.1.5" } -scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } -subxt = { version = "0.32.1", default-features = false, features = [] } - -# Bridge dependencies - -bp-bridge-hub-cumulus = { path = "../../primitives/chain-bridge-hub-cumulus" } -bp-header-chain = { path = "../../primitives/header-chain" } -bp-messages = { path = "../../primitives/messages" } -bp-millau = { path = "../../primitives/chain-millau" } -bp-polkadot-core = { path = "../../primitives/polkadot-core" } -bp-rialto-parachain = { path = "../../primitives/chain-rialto-parachain" } -bp-runtime = { path = "../../primitives/runtime" } - -bridge-runtime-common = { path = "../../bin/runtime-common" } -relay-substrate-client = { path = "../client-substrate" } - -# Substrate Dependencies - -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } diff --git a/bridges/relays/client-rialto-parachain/src/codegen_runtime.rs b/bridges/relays/client-rialto-parachain/src/codegen_runtime.rs deleted file mode 100644 index eb19d98d7e487..0000000000000 --- a/bridges/relays/client-rialto-parachain/src/codegen_runtime.rs +++ /dev/null @@ -1,2936 +0,0 @@ -// Copyright 2019-2023 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 . - -//! Autogenerated runtime API -//! THIS FILE WAS AUTOGENERATED USING parity-bridges-common::runtime-codegen -//! EXECUTED COMMAND: target/debug/runtime-codegen --from-node-url http://localhost:20433 - -#[allow(dead_code, unused_imports, non_camel_case_types)] -#[allow(clippy::all)] -pub mod api { - use super::api as root_mod; - pub mod runtime_types { - use super::runtime_types; - pub mod bounded_collections { - use super::runtime_types; - pub mod bounded_vec { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct BoundedVec<_0>(pub ::std::vec::Vec<_0>); - } - pub mod weak_bounded_vec { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct WeakBoundedVec<_0>(pub ::std::vec::Vec<_0>); - } - } - pub mod bp_header_chain { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct StoredHeaderData<_0, _1> { - pub number: _0, - pub state_root: _1, - } - } - pub mod bp_messages { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct DeliveredMessages { - pub begin: ::core::primitive::u64, - pub end: ::core::primitive::u64, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct InboundLaneData<_0> { - pub relayers: ::std::vec::Vec>, - pub last_confirmed_nonce: ::core::primitive::u64, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct LaneId(pub [::core::primitive::u8; 4usize]); - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct MessageKey { - pub lane_id: runtime_types::bp_messages::LaneId, - pub nonce: ::core::primitive::u64, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum MessagesOperatingMode { - #[codec(index = 0)] - Basic(runtime_types::bp_runtime::BasicOperatingMode), - #[codec(index = 1)] - RejectingOutboundMessages, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct OutboundLaneData { - pub oldest_unpruned_nonce: ::core::primitive::u64, - pub latest_received_nonce: ::core::primitive::u64, - pub latest_generated_nonce: ::core::primitive::u64, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum ReceivalResult<_0> { - #[codec(index = 0)] - Dispatched(runtime_types::bp_runtime::messages::MessageDispatchResult<_0>), - #[codec(index = 1)] - InvalidNonce, - #[codec(index = 2)] - TooManyUnrewardedRelayers, - #[codec(index = 3)] - TooManyUnconfirmedMessages, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct ReceivedMessages<_0> { - pub lane: runtime_types::bp_messages::LaneId, - pub receive_results: ::std::vec::Vec<( - ::core::primitive::u64, - runtime_types::bp_messages::ReceivalResult<_0>, - )>, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct UnrewardedRelayer<_0> { - pub relayer: _0, - pub messages: runtime_types::bp_messages::DeliveredMessages, - } - } - pub mod bp_relayers { - use super::runtime_types; - pub mod registration { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct Registration<_0, _1> { - pub valid_till: _0, - pub stake: _1, - } - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum RewardsAccountOwner { - #[codec(index = 0)] - ThisChain, - #[codec(index = 1)] - BridgedChain, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct RewardsAccountParams { - pub lane_id: runtime_types::bp_messages::LaneId, - pub bridged_chain_id: [::core::primitive::u8; 4usize], - pub owner: runtime_types::bp_relayers::RewardsAccountOwner, - } - } - pub mod bp_runtime { - use super::runtime_types; - pub mod messages { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct MessageDispatchResult<_0> { - pub unspent_weight: ::sp_weights::Weight, - pub dispatch_level_result: _0, - } - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum BasicOperatingMode { - #[codec(index = 0)] - Normal, - #[codec(index = 1)] - Halted, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct HeaderId<_0, _1>(pub _1, pub _0); - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum OwnedBridgeModuleError { - #[codec(index = 0)] - Halted, - } - } - pub mod bridge_runtime_common { - use super::runtime_types; - pub mod messages_xcm_extension { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum XcmBlobMessageDispatchResult { - #[codec(index = 0)] - InvalidPayload, - #[codec(index = 1)] - Dispatched, - #[codec(index = 2)] - NotDispatched, - } - } - } - pub mod cumulus_pallet_dmp_queue { - use super::runtime_types; - pub mod pallet { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Call { - #[codec(index = 0)] - service_overweight { - index: ::core::primitive::u64, - weight_limit: ::sp_weights::Weight, - }, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Error { - #[codec(index = 0)] - Unknown, - #[codec(index = 1)] - OverLimit, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Event { - #[codec(index = 0)] - InvalidFormat { message_id: [::core::primitive::u8; 32usize] }, - #[codec(index = 1)] - UnsupportedVersion { message_id: [::core::primitive::u8; 32usize] }, - #[codec(index = 2)] - ExecutedDownward { - message_id: [::core::primitive::u8; 32usize], - outcome: runtime_types::xcm::v3::traits::Outcome, - }, - #[codec(index = 3)] - WeightExhausted { - message_id: [::core::primitive::u8; 32usize], - remaining_weight: ::sp_weights::Weight, - required_weight: ::sp_weights::Weight, - }, - #[codec(index = 4)] - OverweightEnqueued { - message_id: [::core::primitive::u8; 32usize], - overweight_index: ::core::primitive::u64, - required_weight: ::sp_weights::Weight, - }, - #[codec(index = 5)] - OverweightServiced { - overweight_index: ::core::primitive::u64, - weight_used: ::sp_weights::Weight, - }, - #[codec(index = 6)] - MaxMessagesExhausted { message_id: [::core::primitive::u8; 32usize] }, - } - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct ConfigData { - pub max_individual: ::sp_weights::Weight, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct PageIndexData { - pub begin_used: ::core::primitive::u32, - pub end_used: ::core::primitive::u32, - pub overweight_count: ::core::primitive::u64, - } - } - pub mod cumulus_pallet_parachain_system { - use super::runtime_types; - pub mod pallet { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Call { - # [codec (index = 0)] set_validation_data { data : runtime_types :: cumulus_primitives_parachain_inherent :: ParachainInherentData , } , # [codec (index = 1)] sudo_send_upward_message { message : :: std :: vec :: Vec < :: core :: primitive :: u8 > , } , # [codec (index = 2)] authorize_upgrade { code_hash : :: subxt :: utils :: H256 , check_version : :: core :: primitive :: bool , } , # [codec (index = 3)] enact_authorized_upgrade { code : :: std :: vec :: Vec < :: core :: primitive :: u8 > , } , } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Error { - #[codec(index = 0)] - OverlappingUpgrades, - #[codec(index = 1)] - ProhibitedByPolkadot, - #[codec(index = 2)] - TooBig, - #[codec(index = 3)] - ValidationDataNotAvailable, - #[codec(index = 4)] - HostConfigurationNotAvailable, - #[codec(index = 5)] - NotScheduled, - #[codec(index = 6)] - NothingAuthorized, - #[codec(index = 7)] - Unauthorized, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Event { - #[codec(index = 0)] - ValidationFunctionStored, - #[codec(index = 1)] - ValidationFunctionApplied { relay_chain_block_num: ::core::primitive::u32 }, - #[codec(index = 2)] - ValidationFunctionDiscarded, - #[codec(index = 3)] - UpgradeAuthorized { code_hash: ::subxt::utils::H256 }, - #[codec(index = 4)] - DownwardMessagesReceived { count: ::core::primitive::u32 }, - #[codec(index = 5)] - DownwardMessagesProcessed { - weight_used: ::sp_weights::Weight, - dmq_head: ::subxt::utils::H256, - }, - #[codec(index = 6)] - UpwardMessageSent { - message_hash: ::core::option::Option<[::core::primitive::u8; 32usize]>, - }, - } - } - pub mod relay_state_snapshot { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct MessagingStateSnapshot { - pub dmq_mqc_head: ::subxt::utils::H256, - pub relay_dispatch_queue_size: (::core::primitive::u32, ::core::primitive::u32), - pub ingress_channels: ::std::vec::Vec<( - runtime_types::polkadot_parachain::primitives::Id, - runtime_types::polkadot_primitives::v4::AbridgedHrmpChannel, - )>, - pub egress_channels: ::std::vec::Vec<( - runtime_types::polkadot_parachain::primitives::Id, - runtime_types::polkadot_primitives::v4::AbridgedHrmpChannel, - )>, - } - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct CodeUpgradeAuthorization { - pub code_hash: ::subxt::utils::H256, - pub check_version: ::core::primitive::bool, - } - } - pub mod cumulus_pallet_xcm { - use super::runtime_types; - pub mod pallet { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Call {} - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Error {} - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Event { - #[codec(index = 0)] - InvalidFormat([::core::primitive::u8; 32usize]), - #[codec(index = 1)] - UnsupportedVersion([::core::primitive::u8; 32usize]), - #[codec(index = 2)] - ExecutedDownward( - [::core::primitive::u8; 32usize], - runtime_types::xcm::v3::traits::Outcome, - ), - } - } - } - pub mod cumulus_pallet_xcmp_queue { - use super::runtime_types; - pub mod pallet { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Call { - #[codec(index = 0)] - service_overweight { - index: ::core::primitive::u64, - weight_limit: ::sp_weights::Weight, - }, - #[codec(index = 1)] - suspend_xcm_execution, - #[codec(index = 2)] - resume_xcm_execution, - #[codec(index = 3)] - update_suspend_threshold { new: ::core::primitive::u32 }, - #[codec(index = 4)] - update_drop_threshold { new: ::core::primitive::u32 }, - #[codec(index = 5)] - update_resume_threshold { new: ::core::primitive::u32 }, - #[codec(index = 6)] - update_threshold_weight { new: ::sp_weights::Weight }, - #[codec(index = 7)] - update_weight_restrict_decay { new: ::sp_weights::Weight }, - #[codec(index = 8)] - update_xcmp_max_individual_weight { new: ::sp_weights::Weight }, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Error { - #[codec(index = 0)] - FailedToSend, - #[codec(index = 1)] - BadXcmOrigin, - #[codec(index = 2)] - BadXcm, - #[codec(index = 3)] - BadOverweightIndex, - #[codec(index = 4)] - WeightOverLimit, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Event { - #[codec(index = 0)] - Success { - message_hash: ::core::option::Option<[::core::primitive::u8; 32usize]>, - weight: ::sp_weights::Weight, - }, - #[codec(index = 1)] - Fail { - message_hash: ::core::option::Option<[::core::primitive::u8; 32usize]>, - error: runtime_types::xcm::v3::traits::Error, - weight: ::sp_weights::Weight, - }, - #[codec(index = 2)] - BadVersion { - message_hash: ::core::option::Option<[::core::primitive::u8; 32usize]>, - }, - #[codec(index = 3)] - BadFormat { - message_hash: ::core::option::Option<[::core::primitive::u8; 32usize]>, - }, - #[codec(index = 4)] - XcmpMessageSent { - message_hash: ::core::option::Option<[::core::primitive::u8; 32usize]>, - }, - #[codec(index = 5)] - OverweightEnqueued { - sender: runtime_types::polkadot_parachain::primitives::Id, - sent_at: ::core::primitive::u32, - index: ::core::primitive::u64, - required: ::sp_weights::Weight, - }, - #[codec(index = 6)] - OverweightServiced { index: ::core::primitive::u64, used: ::sp_weights::Weight }, - } - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct InboundChannelDetails { - pub sender: runtime_types::polkadot_parachain::primitives::Id, - pub state: runtime_types::cumulus_pallet_xcmp_queue::InboundState, - pub message_metadata: ::std::vec::Vec<( - ::core::primitive::u32, - runtime_types::polkadot_parachain::primitives::XcmpMessageFormat, - )>, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum InboundState { - #[codec(index = 0)] - Ok, - #[codec(index = 1)] - Suspended, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct OutboundChannelDetails { - pub recipient: runtime_types::polkadot_parachain::primitives::Id, - pub state: runtime_types::cumulus_pallet_xcmp_queue::OutboundState, - pub signals_exist: ::core::primitive::bool, - pub first_index: ::core::primitive::u16, - pub last_index: ::core::primitive::u16, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum OutboundState { - #[codec(index = 0)] - Ok, - #[codec(index = 1)] - Suspended, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct QueueConfigData { - pub suspend_threshold: ::core::primitive::u32, - pub drop_threshold: ::core::primitive::u32, - pub resume_threshold: ::core::primitive::u32, - pub threshold_weight: ::sp_weights::Weight, - pub weight_restrict_decay: ::sp_weights::Weight, - pub xcmp_max_individual_weight: ::sp_weights::Weight, - } - } - pub mod cumulus_primitives_parachain_inherent { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct MessageQueueChain(pub ::subxt::utils::H256); - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct ParachainInherentData { - pub validation_data: - runtime_types::polkadot_primitives::v4::PersistedValidationData< - ::subxt::utils::H256, - ::core::primitive::u32, - >, - pub relay_chain_state: runtime_types::sp_trie::storage_proof::StorageProof, - pub downward_messages: ::std::vec::Vec< - runtime_types::polkadot_core_primitives::InboundDownwardMessage< - ::core::primitive::u32, - >, - >, - pub horizontal_messages: ::subxt::utils::KeyedVec< - runtime_types::polkadot_parachain::primitives::Id, - ::std::vec::Vec< - runtime_types::polkadot_core_primitives::InboundHrmpMessage< - ::core::primitive::u32, - >, - >, - >, - } - } - pub mod finality_grandpa { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct Commit<_0, _1, _2, _3> { - pub target_hash: _0, - pub target_number: _1, - pub precommits: ::std::vec::Vec< - runtime_types::finality_grandpa::SignedPrecommit<_0, _1, _2, _3>, - >, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct Precommit<_0, _1> { - pub target_hash: _0, - pub target_number: _1, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct SignedPrecommit<_0, _1, _2, _3> { - pub precommit: runtime_types::finality_grandpa::Precommit<_0, _1>, - pub signature: _2, - pub id: _3, - } - } - pub mod frame_support { - use super::runtime_types; - pub mod dispatch { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum DispatchClass { - #[codec(index = 0)] - Normal, - #[codec(index = 1)] - Operational, - #[codec(index = 2)] - Mandatory, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct DispatchInfo { - pub weight: ::sp_weights::Weight, - pub class: runtime_types::frame_support::dispatch::DispatchClass, - pub pays_fee: runtime_types::frame_support::dispatch::Pays, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Pays { - #[codec(index = 0)] - Yes, - #[codec(index = 1)] - No, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct PerDispatchClass<_0> { - pub normal: _0, - pub operational: _0, - pub mandatory: _0, - } - } - pub mod traits { - use super::runtime_types; - pub mod tokens { - use super::runtime_types; - pub mod misc { - use super::runtime_types; - #[derive( - :: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq, - )] - pub enum BalanceStatus { - #[codec(index = 0)] - Free, - #[codec(index = 1)] - Reserved, - } - } - } - } - } - pub mod frame_system { - use super::runtime_types; - pub mod extensions { - use super::runtime_types; - pub mod check_genesis { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct CheckGenesis; - } - pub mod check_mortality { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct CheckMortality(pub ::sp_runtime::generic::Era); - } - pub mod check_non_zero_sender { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct CheckNonZeroSender; - } - pub mod check_nonce { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct CheckNonce(#[codec(compact)] pub ::core::primitive::u32); - } - pub mod check_spec_version { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct CheckSpecVersion; - } - pub mod check_tx_version { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct CheckTxVersion; - } - pub mod check_weight { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct CheckWeight; - } - } - pub mod limits { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct BlockLength { - pub max: runtime_types::frame_support::dispatch::PerDispatchClass< - ::core::primitive::u32, - >, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct BlockWeights { - pub base_block: ::sp_weights::Weight, - pub max_block: ::sp_weights::Weight, - pub per_class: runtime_types::frame_support::dispatch::PerDispatchClass< - runtime_types::frame_system::limits::WeightsPerClass, - >, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct WeightsPerClass { - pub base_extrinsic: ::sp_weights::Weight, - pub max_extrinsic: ::core::option::Option<::sp_weights::Weight>, - pub max_total: ::core::option::Option<::sp_weights::Weight>, - pub reserved: ::core::option::Option<::sp_weights::Weight>, - } - } - pub mod pallet { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Call { - #[codec(index = 0)] - remark { remark: ::std::vec::Vec<::core::primitive::u8> }, - #[codec(index = 1)] - set_heap_pages { pages: ::core::primitive::u64 }, - #[codec(index = 2)] - set_code { code: ::std::vec::Vec<::core::primitive::u8> }, - #[codec(index = 3)] - set_code_without_checks { code: ::std::vec::Vec<::core::primitive::u8> }, - #[codec(index = 4)] - set_storage { - items: ::std::vec::Vec<( - ::std::vec::Vec<::core::primitive::u8>, - ::std::vec::Vec<::core::primitive::u8>, - )>, - }, - #[codec(index = 5)] - kill_storage { keys: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>> }, - #[codec(index = 6)] - kill_prefix { - prefix: ::std::vec::Vec<::core::primitive::u8>, - subkeys: ::core::primitive::u32, - }, - #[codec(index = 7)] - remark_with_event { remark: ::std::vec::Vec<::core::primitive::u8> }, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Error { - #[codec(index = 0)] - InvalidSpecName, - #[codec(index = 1)] - SpecVersionNeedsToIncrease, - #[codec(index = 2)] - FailedToExtractRuntimeVersion, - #[codec(index = 3)] - NonDefaultComposite, - #[codec(index = 4)] - NonZeroRefCount, - #[codec(index = 5)] - CallFiltered, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Event { - #[codec(index = 0)] - ExtrinsicSuccess { - dispatch_info: runtime_types::frame_support::dispatch::DispatchInfo, - }, - #[codec(index = 1)] - ExtrinsicFailed { - dispatch_error: runtime_types::sp_runtime::DispatchError, - dispatch_info: runtime_types::frame_support::dispatch::DispatchInfo, - }, - #[codec(index = 2)] - CodeUpdated, - #[codec(index = 3)] - NewAccount { account: ::sp_core::crypto::AccountId32 }, - #[codec(index = 4)] - KilledAccount { account: ::sp_core::crypto::AccountId32 }, - #[codec(index = 5)] - Remarked { sender: ::sp_core::crypto::AccountId32, hash: ::subxt::utils::H256 }, - } - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct AccountInfo<_0, _1> { - pub nonce: _0, - pub consumers: _0, - pub providers: _0, - pub sufficients: _0, - pub data: _1, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct EventRecord<_0, _1> { - pub phase: runtime_types::frame_system::Phase, - pub event: _0, - pub topics: ::std::vec::Vec<_1>, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct LastRuntimeUpgradeInfo { - #[codec(compact)] - pub spec_version: ::core::primitive::u32, - pub spec_name: ::std::string::String, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Phase { - #[codec(index = 0)] - ApplyExtrinsic(::core::primitive::u32), - #[codec(index = 1)] - Finalization, - #[codec(index = 2)] - Initialization, - } - } - pub mod pallet_balances { - use super::runtime_types; - pub mod pallet { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Call { - #[codec(index = 0)] - transfer_allow_death { - dest: ::subxt::utils::MultiAddress<::sp_core::crypto::AccountId32, ()>, - #[codec(compact)] - value: ::core::primitive::u128, - }, - #[codec(index = 1)] - set_balance_deprecated { - who: ::subxt::utils::MultiAddress<::sp_core::crypto::AccountId32, ()>, - #[codec(compact)] - new_free: ::core::primitive::u128, - #[codec(compact)] - old_reserved: ::core::primitive::u128, - }, - #[codec(index = 2)] - force_transfer { - source: ::subxt::utils::MultiAddress<::sp_core::crypto::AccountId32, ()>, - dest: ::subxt::utils::MultiAddress<::sp_core::crypto::AccountId32, ()>, - #[codec(compact)] - value: ::core::primitive::u128, - }, - #[codec(index = 3)] - transfer_keep_alive { - dest: ::subxt::utils::MultiAddress<::sp_core::crypto::AccountId32, ()>, - #[codec(compact)] - value: ::core::primitive::u128, - }, - #[codec(index = 4)] - transfer_all { - dest: ::subxt::utils::MultiAddress<::sp_core::crypto::AccountId32, ()>, - keep_alive: ::core::primitive::bool, - }, - #[codec(index = 5)] - force_unreserve { - who: ::subxt::utils::MultiAddress<::sp_core::crypto::AccountId32, ()>, - amount: ::core::primitive::u128, - }, - #[codec(index = 6)] - upgrade_accounts { who: ::std::vec::Vec<::sp_core::crypto::AccountId32> }, - #[codec(index = 7)] - transfer { - dest: ::subxt::utils::MultiAddress<::sp_core::crypto::AccountId32, ()>, - #[codec(compact)] - value: ::core::primitive::u128, - }, - #[codec(index = 8)] - force_set_balance { - who: ::subxt::utils::MultiAddress<::sp_core::crypto::AccountId32, ()>, - #[codec(compact)] - new_free: ::core::primitive::u128, - }, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Error { - #[codec(index = 0)] - VestingBalance, - #[codec(index = 1)] - LiquidityRestrictions, - #[codec(index = 2)] - InsufficientBalance, - #[codec(index = 3)] - ExistentialDeposit, - #[codec(index = 4)] - Expendability, - #[codec(index = 5)] - ExistingVestingSchedule, - #[codec(index = 6)] - DeadAccount, - #[codec(index = 7)] - TooManyReserves, - #[codec(index = 8)] - TooManyHolds, - #[codec(index = 9)] - TooManyFreezes, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Event { - #[codec(index = 0)] - Endowed { - account: ::sp_core::crypto::AccountId32, - free_balance: ::core::primitive::u128, - }, - #[codec(index = 1)] - DustLost { - account: ::sp_core::crypto::AccountId32, - amount: ::core::primitive::u128, - }, - #[codec(index = 2)] - Transfer { - from: ::sp_core::crypto::AccountId32, - to: ::sp_core::crypto::AccountId32, - amount: ::core::primitive::u128, - }, - #[codec(index = 3)] - BalanceSet { - who: ::sp_core::crypto::AccountId32, - free: ::core::primitive::u128, - }, - #[codec(index = 4)] - Reserved { - who: ::sp_core::crypto::AccountId32, - amount: ::core::primitive::u128, - }, - #[codec(index = 5)] - Unreserved { - who: ::sp_core::crypto::AccountId32, - amount: ::core::primitive::u128, - }, - #[codec(index = 6)] - ReserveRepatriated { - from: ::sp_core::crypto::AccountId32, - to: ::sp_core::crypto::AccountId32, - amount: ::core::primitive::u128, - destination_status: - runtime_types::frame_support::traits::tokens::misc::BalanceStatus, - }, - #[codec(index = 7)] - Deposit { who: ::sp_core::crypto::AccountId32, amount: ::core::primitive::u128 }, - #[codec(index = 8)] - Withdraw { - who: ::sp_core::crypto::AccountId32, - amount: ::core::primitive::u128, - }, - #[codec(index = 9)] - Slashed { who: ::sp_core::crypto::AccountId32, amount: ::core::primitive::u128 }, - #[codec(index = 10)] - Minted { who: ::sp_core::crypto::AccountId32, amount: ::core::primitive::u128 }, - #[codec(index = 11)] - Burned { who: ::sp_core::crypto::AccountId32, amount: ::core::primitive::u128 }, - #[codec(index = 12)] - Suspended { - who: ::sp_core::crypto::AccountId32, - amount: ::core::primitive::u128, - }, - #[codec(index = 13)] - Restored { - who: ::sp_core::crypto::AccountId32, - amount: ::core::primitive::u128, - }, - #[codec(index = 14)] - Upgraded { who: ::sp_core::crypto::AccountId32 }, - #[codec(index = 15)] - Issued { amount: ::core::primitive::u128 }, - #[codec(index = 16)] - Rescinded { amount: ::core::primitive::u128 }, - #[codec(index = 17)] - Locked { who: ::sp_core::crypto::AccountId32, amount: ::core::primitive::u128 }, - #[codec(index = 18)] - Unlocked { - who: ::sp_core::crypto::AccountId32, - amount: ::core::primitive::u128, - }, - } - } - pub mod types { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct AccountData<_0> { - pub free: _0, - pub reserved: _0, - pub frozen: _0, - pub flags: runtime_types::pallet_balances::types::ExtraFlags, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct BalanceLock<_0> { - pub id: [::core::primitive::u8; 8usize], - pub amount: _0, - pub reasons: runtime_types::pallet_balances::types::Reasons, - } - #[derive( - :: codec :: Decode, - :: codec :: Encode, - :: subxt :: ext :: codec :: CompactAs, - Clone, - Debug, - PartialEq, - )] - pub struct ExtraFlags(pub ::core::primitive::u128); - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct IdAmount<_0, _1> { - pub id: _0, - pub amount: _1, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Reasons { - #[codec(index = 0)] - Fee, - #[codec(index = 1)] - Misc, - #[codec(index = 2)] - All, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct ReserveData<_0, _1> { - pub id: _0, - pub amount: _1, - } - } - } - pub mod pallet_bridge_grandpa { - use super::runtime_types; - pub mod pallet { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Call { - #[codec(index = 0)] - submit_finality_proof { - finality_target: ::std::boxed::Box< - ::sp_runtime::generic::Header< - ::core::primitive::u64, - ::bp_millau::BlakeTwoAndKeccak256, - >, - >, - justification: ::bp_header_chain::justification::GrandpaJustification< - ::sp_runtime::generic::Header< - ::core::primitive::u64, - ::bp_millau::BlakeTwoAndKeccak256, - >, - >, - }, - #[codec(index = 1)] - initialize { - init_data: ::bp_header_chain::InitializationData< - ::sp_runtime::generic::Header< - ::core::primitive::u64, - ::bp_millau::BlakeTwoAndKeccak256, - >, - >, - }, - #[codec(index = 2)] - set_owner { new_owner: ::core::option::Option<::sp_core::crypto::AccountId32> }, - #[codec(index = 3)] - set_operating_mode { - operating_mode: runtime_types::bp_runtime::BasicOperatingMode, - }, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Error { - #[codec(index = 0)] - InvalidJustification, - #[codec(index = 1)] - InvalidAuthoritySet, - #[codec(index = 2)] - OldHeader, - #[codec(index = 3)] - UnsupportedScheduledChange, - #[codec(index = 4)] - NotInitialized, - #[codec(index = 5)] - AlreadyInitialized, - #[codec(index = 6)] - TooManyAuthoritiesInSet, - #[codec(index = 7)] - BridgeModule(runtime_types::bp_runtime::OwnedBridgeModuleError), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Event { - #[codec(index = 0)] - UpdatedBestFinalizedHeader { - number: ::core::primitive::u64, - hash: ::bp_millau::MillauHash, - }, - } - } - pub mod storage_types { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct StoredAuthoritySet { - pub authorities: runtime_types::bounded_collections::bounded_vec::BoundedVec<( - runtime_types::sp_consensus_grandpa::app::Public, - ::core::primitive::u64, - )>, - pub set_id: ::core::primitive::u64, - } - } - } - pub mod pallet_bridge_messages { - use super::runtime_types; - pub mod pallet { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Call { - # [codec (index = 0)] set_owner { new_owner : :: core :: option :: Option < :: sp_core :: crypto :: AccountId32 > , } , # [codec (index = 1)] set_operating_mode { operating_mode : runtime_types :: bp_messages :: MessagesOperatingMode , } , # [codec (index = 2)] receive_messages_proof { relayer_id_at_bridged_chain : :: sp_core :: crypto :: AccountId32 , proof : :: bridge_runtime_common :: messages :: target :: FromBridgedChainMessagesProof < :: bp_millau :: MillauHash > , messages_count : :: core :: primitive :: u32 , dispatch_weight : :: sp_weights :: Weight , } , # [codec (index = 3)] receive_messages_delivery_proof { proof : :: bridge_runtime_common :: messages :: source :: FromBridgedChainMessagesDeliveryProof < :: bp_millau :: MillauHash > , relayers_state : :: bp_messages :: UnrewardedRelayersState , } , } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Error { - #[codec(index = 0)] - NotOperatingNormally, - #[codec(index = 1)] - InactiveOutboundLane, - #[codec(index = 2)] - MessageIsTooLarge, - #[codec(index = 3)] - MessageRejectedByChainVerifier, - #[codec(index = 4)] - MessageRejectedByLaneVerifier, - #[codec(index = 5)] - FailedToWithdrawMessageFee, - #[codec(index = 6)] - TooManyMessagesInTheProof, - #[codec(index = 7)] - InvalidMessagesProof, - #[codec(index = 8)] - InvalidMessagesDeliveryProof, - #[codec(index = 9)] - InvalidUnrewardedRelayers, - #[codec(index = 10)] - InvalidUnrewardedRelayersState, - #[codec(index = 11)] - InsufficientDispatchWeight, - #[codec(index = 12)] - MessageIsNotYetSent, - #[codec(index = 13)] - TryingToConfirmMoreMessagesThanExpected, - #[codec(index = 14)] - BridgeModule(runtime_types::bp_runtime::OwnedBridgeModuleError), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Event { - # [codec (index = 0)] MessageAccepted { lane_id : runtime_types :: bp_messages :: LaneId , nonce : :: core :: primitive :: u64 , } , # [codec (index = 1)] MessagesReceived (:: std :: vec :: Vec < runtime_types :: bp_messages :: ReceivedMessages < runtime_types :: bridge_runtime_common :: messages_xcm_extension :: XcmBlobMessageDispatchResult > > ,) , # [codec (index = 2)] MessagesDelivered { lane_id : runtime_types :: bp_messages :: LaneId , messages : runtime_types :: bp_messages :: DeliveredMessages , } , } - } - } - pub mod pallet_bridge_relayers { - use super::runtime_types; - pub mod pallet { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Call { - #[codec(index = 0)] - claim_rewards { - rewards_account_params: runtime_types::bp_relayers::RewardsAccountParams, - }, - #[codec(index = 1)] - register { valid_till: ::core::primitive::u32 }, - #[codec(index = 2)] - deregister, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Error { - #[codec(index = 0)] - NoRewardForRelayer, - #[codec(index = 1)] - FailedToPayReward, - #[codec(index = 2)] - InvalidRegistrationLease, - #[codec(index = 3)] - CannotReduceRegistrationLease, - #[codec(index = 4)] - FailedToReserve, - #[codec(index = 5)] - FailedToUnreserve, - #[codec(index = 6)] - NotRegistered, - #[codec(index = 7)] - RegistrationIsStillActive, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Event { - #[codec(index = 0)] - RewardPaid { - relayer: ::sp_core::crypto::AccountId32, - rewards_account_params: runtime_types::bp_relayers::RewardsAccountParams, - reward: ::core::primitive::u128, - }, - #[codec(index = 1)] - RegistrationUpdated { - relayer: ::sp_core::crypto::AccountId32, - registration: runtime_types::bp_relayers::registration::Registration< - ::core::primitive::u32, - ::core::primitive::u128, - >, - }, - #[codec(index = 2)] - Deregistered { relayer: ::sp_core::crypto::AccountId32 }, - #[codec(index = 3)] - SlashedAndDeregistered { - relayer: ::sp_core::crypto::AccountId32, - registration: runtime_types::bp_relayers::registration::Registration< - ::core::primitive::u32, - ::core::primitive::u128, - >, - }, - } - } - } - pub mod pallet_sudo { - use super::runtime_types; - pub mod pallet { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Call { - #[codec(index = 0)] - sudo { - call: - ::std::boxed::Box, - }, - #[codec(index = 1)] - sudo_unchecked_weight { - call: - ::std::boxed::Box, - weight: ::sp_weights::Weight, - }, - #[codec(index = 2)] - set_key { - new: ::subxt::utils::MultiAddress<::sp_core::crypto::AccountId32, ()>, - }, - #[codec(index = 3)] - sudo_as { - who: ::subxt::utils::MultiAddress<::sp_core::crypto::AccountId32, ()>, - call: - ::std::boxed::Box, - }, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Error { - #[codec(index = 0)] - RequireSudo, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Event { - #[codec(index = 0)] - Sudid { - sudo_result: - ::core::result::Result<(), runtime_types::sp_runtime::DispatchError>, - }, - #[codec(index = 1)] - KeyChanged { - old_sudoer: ::core::option::Option<::sp_core::crypto::AccountId32>, - }, - #[codec(index = 2)] - SudoAsDone { - sudo_result: - ::core::result::Result<(), runtime_types::sp_runtime::DispatchError>, - }, - } - } - } - pub mod pallet_timestamp { - use super::runtime_types; - pub mod pallet { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Call { - #[codec(index = 0)] - set { - #[codec(compact)] - now: ::core::primitive::u64, - }, - } - } - } - pub mod pallet_transaction_payment { - use super::runtime_types; - pub mod pallet { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Event { - #[codec(index = 0)] - TransactionFeePaid { - who: ::sp_core::crypto::AccountId32, - actual_fee: ::core::primitive::u128, - tip: ::core::primitive::u128, - }, - } - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct ChargeTransactionPayment(#[codec(compact)] pub ::core::primitive::u128); - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Releases { - #[codec(index = 0)] - V1Ancient, - #[codec(index = 1)] - V2, - } - } - pub mod pallet_xcm { - use super::runtime_types; - pub mod pallet { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Call { - #[codec(index = 0)] - send { - dest: ::std::boxed::Box, - message: ::std::boxed::Box, - }, - #[codec(index = 1)] - teleport_assets { - dest: ::std::boxed::Box, - beneficiary: ::std::boxed::Box, - assets: ::std::boxed::Box, - fee_asset_item: ::core::primitive::u32, - }, - #[codec(index = 2)] - reserve_transfer_assets { - dest: ::std::boxed::Box, - beneficiary: ::std::boxed::Box, - assets: ::std::boxed::Box, - fee_asset_item: ::core::primitive::u32, - }, - #[codec(index = 3)] - execute { - message: ::std::boxed::Box, - max_weight: ::sp_weights::Weight, - }, - #[codec(index = 4)] - force_xcm_version { - location: - ::std::boxed::Box, - xcm_version: ::core::primitive::u32, - }, - #[codec(index = 5)] - force_default_xcm_version { - maybe_xcm_version: ::core::option::Option<::core::primitive::u32>, - }, - #[codec(index = 6)] - force_subscribe_version_notify { - location: ::std::boxed::Box, - }, - #[codec(index = 7)] - force_unsubscribe_version_notify { - location: ::std::boxed::Box, - }, - #[codec(index = 8)] - limited_reserve_transfer_assets { - dest: ::std::boxed::Box, - beneficiary: ::std::boxed::Box, - assets: ::std::boxed::Box, - fee_asset_item: ::core::primitive::u32, - weight_limit: runtime_types::xcm::v3::WeightLimit, - }, - #[codec(index = 9)] - limited_teleport_assets { - dest: ::std::boxed::Box, - beneficiary: ::std::boxed::Box, - assets: ::std::boxed::Box, - fee_asset_item: ::core::primitive::u32, - weight_limit: runtime_types::xcm::v3::WeightLimit, - }, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Error { - #[codec(index = 0)] - Unreachable, - #[codec(index = 1)] - SendFailure, - #[codec(index = 2)] - Filtered, - #[codec(index = 3)] - UnweighableMessage, - #[codec(index = 4)] - DestinationNotInvertible, - #[codec(index = 5)] - Empty, - #[codec(index = 6)] - CannotReanchor, - #[codec(index = 7)] - TooManyAssets, - #[codec(index = 8)] - InvalidOrigin, - #[codec(index = 9)] - BadVersion, - #[codec(index = 10)] - BadLocation, - #[codec(index = 11)] - NoSubscription, - #[codec(index = 12)] - AlreadySubscribed, - #[codec(index = 13)] - InvalidAsset, - #[codec(index = 14)] - LowBalance, - #[codec(index = 15)] - TooManyLocks, - #[codec(index = 16)] - AccountNotSovereign, - #[codec(index = 17)] - FeesNotMet, - #[codec(index = 18)] - LockNotFound, - #[codec(index = 19)] - InUse, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Event { - #[codec(index = 0)] - Attempted(runtime_types::xcm::v3::traits::Outcome), - #[codec(index = 1)] - Sent( - runtime_types::xcm::v3::multilocation::MultiLocation, - runtime_types::xcm::v3::multilocation::MultiLocation, - runtime_types::xcm::v3::Xcm, - ), - #[codec(index = 2)] - UnexpectedResponse( - runtime_types::xcm::v3::multilocation::MultiLocation, - ::core::primitive::u64, - ), - #[codec(index = 3)] - ResponseReady(::core::primitive::u64, runtime_types::xcm::v3::Response), - #[codec(index = 4)] - Notified(::core::primitive::u64, ::core::primitive::u8, ::core::primitive::u8), - #[codec(index = 5)] - NotifyOverweight( - ::core::primitive::u64, - ::core::primitive::u8, - ::core::primitive::u8, - ::sp_weights::Weight, - ::sp_weights::Weight, - ), - #[codec(index = 6)] - NotifyDispatchError( - ::core::primitive::u64, - ::core::primitive::u8, - ::core::primitive::u8, - ), - #[codec(index = 7)] - NotifyDecodeFailed( - ::core::primitive::u64, - ::core::primitive::u8, - ::core::primitive::u8, - ), - #[codec(index = 8)] - InvalidResponder( - runtime_types::xcm::v3::multilocation::MultiLocation, - ::core::primitive::u64, - ::core::option::Option< - runtime_types::xcm::v3::multilocation::MultiLocation, - >, - ), - #[codec(index = 9)] - InvalidResponderVersion( - runtime_types::xcm::v3::multilocation::MultiLocation, - ::core::primitive::u64, - ), - #[codec(index = 10)] - ResponseTaken(::core::primitive::u64), - #[codec(index = 11)] - AssetsTrapped( - ::subxt::utils::H256, - runtime_types::xcm::v3::multilocation::MultiLocation, - runtime_types::xcm::VersionedMultiAssets, - ), - #[codec(index = 12)] - VersionChangeNotified( - runtime_types::xcm::v3::multilocation::MultiLocation, - ::core::primitive::u32, - runtime_types::xcm::v3::multiasset::MultiAssets, - ), - #[codec(index = 13)] - SupportedVersionChanged( - runtime_types::xcm::v3::multilocation::MultiLocation, - ::core::primitive::u32, - ), - #[codec(index = 14)] - NotifyTargetSendFail( - runtime_types::xcm::v3::multilocation::MultiLocation, - ::core::primitive::u64, - runtime_types::xcm::v3::traits::Error, - ), - #[codec(index = 15)] - NotifyTargetMigrationFail( - runtime_types::xcm::VersionedMultiLocation, - ::core::primitive::u64, - ), - #[codec(index = 16)] - InvalidQuerierVersion( - runtime_types::xcm::v3::multilocation::MultiLocation, - ::core::primitive::u64, - ), - #[codec(index = 17)] - InvalidQuerier( - runtime_types::xcm::v3::multilocation::MultiLocation, - ::core::primitive::u64, - runtime_types::xcm::v3::multilocation::MultiLocation, - ::core::option::Option< - runtime_types::xcm::v3::multilocation::MultiLocation, - >, - ), - #[codec(index = 18)] - VersionNotifyStarted( - runtime_types::xcm::v3::multilocation::MultiLocation, - runtime_types::xcm::v3::multiasset::MultiAssets, - ), - #[codec(index = 19)] - VersionNotifyRequested( - runtime_types::xcm::v3::multilocation::MultiLocation, - runtime_types::xcm::v3::multiasset::MultiAssets, - ), - #[codec(index = 20)] - VersionNotifyUnrequested( - runtime_types::xcm::v3::multilocation::MultiLocation, - runtime_types::xcm::v3::multiasset::MultiAssets, - ), - #[codec(index = 21)] - FeesPaid( - runtime_types::xcm::v3::multilocation::MultiLocation, - runtime_types::xcm::v3::multiasset::MultiAssets, - ), - #[codec(index = 22)] - AssetsClaimed( - ::subxt::utils::H256, - runtime_types::xcm::v3::multilocation::MultiLocation, - runtime_types::xcm::VersionedMultiAssets, - ), - } - } - } - pub mod polkadot_core_primitives { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct InboundDownwardMessage<_0> { - pub sent_at: _0, - pub msg: ::std::vec::Vec<::core::primitive::u8>, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct InboundHrmpMessage<_0> { - pub sent_at: _0, - pub data: ::std::vec::Vec<::core::primitive::u8>, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct OutboundHrmpMessage<_0> { - pub recipient: _0, - pub data: ::std::vec::Vec<::core::primitive::u8>, - } - } - pub mod polkadot_parachain { - use super::runtime_types; - pub mod primitives { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct HeadData(pub ::std::vec::Vec<::core::primitive::u8>); - #[derive( - :: codec :: Decode, - :: codec :: Encode, - :: subxt :: ext :: codec :: CompactAs, - Clone, - Debug, - PartialEq, - )] - pub struct Id(pub ::core::primitive::u32); - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum XcmpMessageFormat { - #[codec(index = 0)] - ConcatenatedVersionedXcm, - #[codec(index = 1)] - ConcatenatedEncodedBlob, - #[codec(index = 2)] - Signals, - } - } - } - pub mod polkadot_primitives { - use super::runtime_types; - pub mod v4 { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct AbridgedHostConfiguration { - pub max_code_size: ::core::primitive::u32, - pub max_head_data_size: ::core::primitive::u32, - pub max_upward_queue_count: ::core::primitive::u32, - pub max_upward_queue_size: ::core::primitive::u32, - pub max_upward_message_size: ::core::primitive::u32, - pub max_upward_message_num_per_candidate: ::core::primitive::u32, - pub hrmp_max_message_num_per_candidate: ::core::primitive::u32, - pub validation_upgrade_cooldown: ::core::primitive::u32, - pub validation_upgrade_delay: ::core::primitive::u32, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct AbridgedHrmpChannel { - pub max_capacity: ::core::primitive::u32, - pub max_total_size: ::core::primitive::u32, - pub max_message_size: ::core::primitive::u32, - pub msg_count: ::core::primitive::u32, - pub total_size: ::core::primitive::u32, - pub mqc_head: ::core::option::Option<::subxt::utils::H256>, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct PersistedValidationData<_0, _1> { - pub parent_head: runtime_types::polkadot_parachain::primitives::HeadData, - pub relay_parent_number: _1, - pub relay_parent_storage_root: _0, - pub max_pov_size: _1, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum UpgradeRestriction { - #[codec(index = 0)] - Present, - } - } - } - pub mod rialto_parachain_runtime { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct BridgeRejectObsoleteHeadersAndMessages; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct DummyBridgeRefundMillauMessages; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct Runtime; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum RuntimeCall { - #[codec(index = 0)] - System(runtime_types::frame_system::pallet::Call), - #[codec(index = 1)] - Timestamp(runtime_types::pallet_timestamp::pallet::Call), - #[codec(index = 2)] - Sudo(runtime_types::pallet_sudo::pallet::Call), - #[codec(index = 20)] - ParachainSystem(runtime_types::cumulus_pallet_parachain_system::pallet::Call), - #[codec(index = 30)] - Balances(runtime_types::pallet_balances::pallet::Call), - #[codec(index = 50)] - XcmpQueue(runtime_types::cumulus_pallet_xcmp_queue::pallet::Call), - #[codec(index = 51)] - PolkadotXcm(runtime_types::pallet_xcm::pallet::Call), - #[codec(index = 52)] - CumulusXcm(runtime_types::cumulus_pallet_xcm::pallet::Call), - #[codec(index = 53)] - DmpQueue(runtime_types::cumulus_pallet_dmp_queue::pallet::Call), - #[codec(index = 54)] - BridgeRelayers(runtime_types::pallet_bridge_relayers::pallet::Call), - #[codec(index = 55)] - BridgeMillauGrandpa(runtime_types::pallet_bridge_grandpa::pallet::Call), - #[codec(index = 56)] - BridgeMillauMessages(runtime_types::pallet_bridge_messages::pallet::Call), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum RuntimeEvent { - #[codec(index = 0)] - System(runtime_types::frame_system::pallet::Event), - #[codec(index = 2)] - Sudo(runtime_types::pallet_sudo::pallet::Event), - #[codec(index = 3)] - TransactionPayment(runtime_types::pallet_transaction_payment::pallet::Event), - #[codec(index = 20)] - ParachainSystem(runtime_types::cumulus_pallet_parachain_system::pallet::Event), - #[codec(index = 30)] - Balances(runtime_types::pallet_balances::pallet::Event), - #[codec(index = 50)] - XcmpQueue(runtime_types::cumulus_pallet_xcmp_queue::pallet::Event), - #[codec(index = 51)] - PolkadotXcm(runtime_types::pallet_xcm::pallet::Event), - #[codec(index = 52)] - CumulusXcm(runtime_types::cumulus_pallet_xcm::pallet::Event), - #[codec(index = 53)] - DmpQueue(runtime_types::cumulus_pallet_dmp_queue::pallet::Event), - #[codec(index = 54)] - BridgeRelayers(runtime_types::pallet_bridge_relayers::pallet::Event), - #[codec(index = 55)] - BridgeMillauGrandpa(runtime_types::pallet_bridge_grandpa::pallet::Event), - #[codec(index = 56)] - BridgeMillauMessages(runtime_types::pallet_bridge_messages::pallet::Event), - } - } - pub mod sp_arithmetic { - use super::runtime_types; - pub mod fixed_point { - use super::runtime_types; - #[derive( - :: codec :: Decode, - :: codec :: Encode, - :: subxt :: ext :: codec :: CompactAs, - Clone, - Debug, - PartialEq, - )] - pub struct FixedU128(pub ::core::primitive::u128); - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum ArithmeticError { - #[codec(index = 0)] - Underflow, - #[codec(index = 1)] - Overflow, - #[codec(index = 2)] - DivisionByZero, - } - } - pub mod sp_consensus_grandpa { - use super::runtime_types; - pub mod app { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct Public(pub runtime_types::sp_core::ed25519::Public); - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct Signature(pub runtime_types::sp_core::ed25519::Signature); - } - } - pub mod sp_core { - use super::runtime_types; - pub mod ecdsa { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct Signature(pub [::core::primitive::u8; 65usize]); - } - pub mod ed25519 { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct Public(pub [::core::primitive::u8; 32usize]); - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct Signature(pub [::core::primitive::u8; 64usize]); - } - pub mod sr25519 { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct Signature(pub [::core::primitive::u8; 64usize]); - } - } - pub mod sp_runtime { - use super::runtime_types; - pub mod generic { - use super::runtime_types; - pub mod digest { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum DigestItem { - #[codec(index = 6)] - PreRuntime( - [::core::primitive::u8; 4usize], - ::std::vec::Vec<::core::primitive::u8>, - ), - #[codec(index = 4)] - Consensus( - [::core::primitive::u8; 4usize], - ::std::vec::Vec<::core::primitive::u8>, - ), - #[codec(index = 5)] - Seal( - [::core::primitive::u8; 4usize], - ::std::vec::Vec<::core::primitive::u8>, - ), - #[codec(index = 0)] - Other(::std::vec::Vec<::core::primitive::u8>), - #[codec(index = 8)] - RuntimeEnvironmentUpdated, - } - } - pub mod unchecked_extrinsic { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct UncheckedExtrinsic<_0, _1, _2, _3>( - pub ::std::vec::Vec<::core::primitive::u8>, - #[codec(skip)] pub ::core::marker::PhantomData<(_1, _0, _2, _3)>, - ); - } - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum DispatchError { - #[codec(index = 0)] - Other, - #[codec(index = 1)] - CannotLookup, - #[codec(index = 2)] - BadOrigin, - #[codec(index = 3)] - Module(runtime_types::sp_runtime::ModuleError), - #[codec(index = 4)] - ConsumerRemaining, - #[codec(index = 5)] - NoProviders, - #[codec(index = 6)] - TooManyConsumers, - #[codec(index = 7)] - Token(runtime_types::sp_runtime::TokenError), - #[codec(index = 8)] - Arithmetic(runtime_types::sp_arithmetic::ArithmeticError), - #[codec(index = 9)] - Transactional(runtime_types::sp_runtime::TransactionalError), - #[codec(index = 10)] - Exhausted, - #[codec(index = 11)] - Corruption, - #[codec(index = 12)] - Unavailable, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct ModuleError { - pub index: ::core::primitive::u8, - pub error: [::core::primitive::u8; 4usize], - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum MultiSignature { - #[codec(index = 0)] - Ed25519(runtime_types::sp_core::ed25519::Signature), - #[codec(index = 1)] - Sr25519(runtime_types::sp_core::sr25519::Signature), - #[codec(index = 2)] - Ecdsa(runtime_types::sp_core::ecdsa::Signature), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum TokenError { - #[codec(index = 0)] - FundsUnavailable, - #[codec(index = 1)] - OnlyProvider, - #[codec(index = 2)] - BelowMinimum, - #[codec(index = 3)] - CannotCreate, - #[codec(index = 4)] - UnknownAsset, - #[codec(index = 5)] - Frozen, - #[codec(index = 6)] - Unsupported, - #[codec(index = 7)] - CannotCreateHold, - #[codec(index = 8)] - NotExpendable, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum TransactionalError { - #[codec(index = 0)] - LimitReached, - #[codec(index = 1)] - NoLayer, - } - } - pub mod sp_trie { - use super::runtime_types; - pub mod storage_proof { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct StorageProof { - pub trie_nodes: ::std::vec::Vec<::std::vec::Vec<::core::primitive::u8>>, - } - } - } - pub mod sp_version { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct RuntimeVersion { - pub spec_name: ::std::string::String, - pub impl_name: ::std::string::String, - pub authoring_version: ::core::primitive::u32, - pub spec_version: ::core::primitive::u32, - pub impl_version: ::core::primitive::u32, - pub apis: - ::std::vec::Vec<([::core::primitive::u8; 8usize], ::core::primitive::u32)>, - pub transaction_version: ::core::primitive::u32, - pub state_version: ::core::primitive::u8, - } - } - pub mod sp_weights { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct RuntimeDbWeight { - pub read: ::core::primitive::u64, - pub write: ::core::primitive::u64, - } - } - pub mod xcm { - use super::runtime_types; - pub mod double_encoded { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct DoubleEncoded { - pub encoded: ::std::vec::Vec<::core::primitive::u8>, - } - } - pub mod v2 { - use super::runtime_types; - pub mod junction { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Junction { - #[codec(index = 0)] - Parachain(#[codec(compact)] ::core::primitive::u32), - #[codec(index = 1)] - AccountId32 { - network: runtime_types::xcm::v2::NetworkId, - id: [::core::primitive::u8; 32usize], - }, - #[codec(index = 2)] - AccountIndex64 { - network: runtime_types::xcm::v2::NetworkId, - #[codec(compact)] - index: ::core::primitive::u64, - }, - #[codec(index = 3)] - AccountKey20 { - network: runtime_types::xcm::v2::NetworkId, - key: [::core::primitive::u8; 20usize], - }, - #[codec(index = 4)] - PalletInstance(::core::primitive::u8), - #[codec(index = 5)] - GeneralIndex(#[codec(compact)] ::core::primitive::u128), - #[codec(index = 6)] - GeneralKey( - runtime_types::bounded_collections::weak_bounded_vec::WeakBoundedVec< - ::core::primitive::u8, - >, - ), - #[codec(index = 7)] - OnlyChild, - #[codec(index = 8)] - Plurality { - id: runtime_types::xcm::v2::BodyId, - part: runtime_types::xcm::v2::BodyPart, - }, - } - } - pub mod multiasset { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum AssetId { - #[codec(index = 0)] - Concrete(runtime_types::xcm::v2::multilocation::MultiLocation), - #[codec(index = 1)] - Abstract(::std::vec::Vec<::core::primitive::u8>), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum AssetInstance { - #[codec(index = 0)] - Undefined, - #[codec(index = 1)] - Index(#[codec(compact)] ::core::primitive::u128), - #[codec(index = 2)] - Array4([::core::primitive::u8; 4usize]), - #[codec(index = 3)] - Array8([::core::primitive::u8; 8usize]), - #[codec(index = 4)] - Array16([::core::primitive::u8; 16usize]), - #[codec(index = 5)] - Array32([::core::primitive::u8; 32usize]), - #[codec(index = 6)] - Blob(::std::vec::Vec<::core::primitive::u8>), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Fungibility { - #[codec(index = 0)] - Fungible(#[codec(compact)] ::core::primitive::u128), - #[codec(index = 1)] - NonFungible(runtime_types::xcm::v2::multiasset::AssetInstance), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct MultiAsset { - pub id: runtime_types::xcm::v2::multiasset::AssetId, - pub fun: runtime_types::xcm::v2::multiasset::Fungibility, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum MultiAssetFilter { - #[codec(index = 0)] - Definite(runtime_types::xcm::v2::multiasset::MultiAssets), - #[codec(index = 1)] - Wild(runtime_types::xcm::v2::multiasset::WildMultiAsset), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct MultiAssets( - pub ::std::vec::Vec, - ); - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum WildFungibility { - #[codec(index = 0)] - Fungible, - #[codec(index = 1)] - NonFungible, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum WildMultiAsset { - #[codec(index = 0)] - All, - #[codec(index = 1)] - AllOf { - id: runtime_types::xcm::v2::multiasset::AssetId, - fun: runtime_types::xcm::v2::multiasset::WildFungibility, - }, - } - } - pub mod multilocation { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Junctions { - #[codec(index = 0)] - Here, - #[codec(index = 1)] - X1(runtime_types::xcm::v2::junction::Junction), - #[codec(index = 2)] - X2( - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - ), - #[codec(index = 3)] - X3( - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - ), - #[codec(index = 4)] - X4( - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - ), - #[codec(index = 5)] - X5( - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - ), - #[codec(index = 6)] - X6( - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - ), - #[codec(index = 7)] - X7( - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - ), - #[codec(index = 8)] - X8( - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - runtime_types::xcm::v2::junction::Junction, - ), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct MultiLocation { - pub parents: ::core::primitive::u8, - pub interior: runtime_types::xcm::v2::multilocation::Junctions, - } - } - pub mod traits { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Error { - #[codec(index = 0)] - Overflow, - #[codec(index = 1)] - Unimplemented, - #[codec(index = 2)] - UntrustedReserveLocation, - #[codec(index = 3)] - UntrustedTeleportLocation, - #[codec(index = 4)] - MultiLocationFull, - #[codec(index = 5)] - MultiLocationNotInvertible, - #[codec(index = 6)] - BadOrigin, - #[codec(index = 7)] - InvalidLocation, - #[codec(index = 8)] - AssetNotFound, - #[codec(index = 9)] - FailedToTransactAsset, - #[codec(index = 10)] - NotWithdrawable, - #[codec(index = 11)] - LocationCannotHold, - #[codec(index = 12)] - ExceedsMaxMessageSize, - #[codec(index = 13)] - DestinationUnsupported, - #[codec(index = 14)] - Transport, - #[codec(index = 15)] - Unroutable, - #[codec(index = 16)] - UnknownClaim, - #[codec(index = 17)] - FailedToDecode, - #[codec(index = 18)] - MaxWeightInvalid, - #[codec(index = 19)] - NotHoldingFees, - #[codec(index = 20)] - TooExpensive, - #[codec(index = 21)] - Trap(::core::primitive::u64), - #[codec(index = 22)] - UnhandledXcmVersion, - #[codec(index = 23)] - WeightLimitReached(::core::primitive::u64), - #[codec(index = 24)] - Barrier, - #[codec(index = 25)] - WeightNotComputable, - } - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum BodyId { - #[codec(index = 0)] - Unit, - #[codec(index = 1)] - Named( - runtime_types::bounded_collections::weak_bounded_vec::WeakBoundedVec< - ::core::primitive::u8, - >, - ), - #[codec(index = 2)] - Index(#[codec(compact)] ::core::primitive::u32), - #[codec(index = 3)] - Executive, - #[codec(index = 4)] - Technical, - #[codec(index = 5)] - Legislative, - #[codec(index = 6)] - Judicial, - #[codec(index = 7)] - Defense, - #[codec(index = 8)] - Administration, - #[codec(index = 9)] - Treasury, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum BodyPart { - #[codec(index = 0)] - Voice, - #[codec(index = 1)] - Members { - #[codec(compact)] - count: ::core::primitive::u32, - }, - #[codec(index = 2)] - Fraction { - #[codec(compact)] - nom: ::core::primitive::u32, - #[codec(compact)] - denom: ::core::primitive::u32, - }, - #[codec(index = 3)] - AtLeastProportion { - #[codec(compact)] - nom: ::core::primitive::u32, - #[codec(compact)] - denom: ::core::primitive::u32, - }, - #[codec(index = 4)] - MoreThanProportion { - #[codec(compact)] - nom: ::core::primitive::u32, - #[codec(compact)] - denom: ::core::primitive::u32, - }, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Instruction { - #[codec(index = 0)] - WithdrawAsset(runtime_types::xcm::v2::multiasset::MultiAssets), - #[codec(index = 1)] - ReserveAssetDeposited(runtime_types::xcm::v2::multiasset::MultiAssets), - #[codec(index = 2)] - ReceiveTeleportedAsset(runtime_types::xcm::v2::multiasset::MultiAssets), - #[codec(index = 3)] - QueryResponse { - #[codec(compact)] - query_id: ::core::primitive::u64, - response: runtime_types::xcm::v2::Response, - #[codec(compact)] - max_weight: ::core::primitive::u64, - }, - #[codec(index = 4)] - TransferAsset { - assets: runtime_types::xcm::v2::multiasset::MultiAssets, - beneficiary: runtime_types::xcm::v2::multilocation::MultiLocation, - }, - #[codec(index = 5)] - TransferReserveAsset { - assets: runtime_types::xcm::v2::multiasset::MultiAssets, - dest: runtime_types::xcm::v2::multilocation::MultiLocation, - xcm: runtime_types::xcm::v2::Xcm, - }, - #[codec(index = 6)] - Transact { - origin_type: runtime_types::xcm::v2::OriginKind, - #[codec(compact)] - require_weight_at_most: ::core::primitive::u64, - call: runtime_types::xcm::double_encoded::DoubleEncoded, - }, - #[codec(index = 7)] - HrmpNewChannelOpenRequest { - #[codec(compact)] - sender: ::core::primitive::u32, - #[codec(compact)] - max_message_size: ::core::primitive::u32, - #[codec(compact)] - max_capacity: ::core::primitive::u32, - }, - #[codec(index = 8)] - HrmpChannelAccepted { - #[codec(compact)] - recipient: ::core::primitive::u32, - }, - #[codec(index = 9)] - HrmpChannelClosing { - #[codec(compact)] - initiator: ::core::primitive::u32, - #[codec(compact)] - sender: ::core::primitive::u32, - #[codec(compact)] - recipient: ::core::primitive::u32, - }, - #[codec(index = 10)] - ClearOrigin, - #[codec(index = 11)] - DescendOrigin(runtime_types::xcm::v2::multilocation::Junctions), - #[codec(index = 12)] - ReportError { - #[codec(compact)] - query_id: ::core::primitive::u64, - dest: runtime_types::xcm::v2::multilocation::MultiLocation, - #[codec(compact)] - max_response_weight: ::core::primitive::u64, - }, - #[codec(index = 13)] - DepositAsset { - assets: runtime_types::xcm::v2::multiasset::MultiAssetFilter, - #[codec(compact)] - max_assets: ::core::primitive::u32, - beneficiary: runtime_types::xcm::v2::multilocation::MultiLocation, - }, - #[codec(index = 14)] - DepositReserveAsset { - assets: runtime_types::xcm::v2::multiasset::MultiAssetFilter, - #[codec(compact)] - max_assets: ::core::primitive::u32, - dest: runtime_types::xcm::v2::multilocation::MultiLocation, - xcm: runtime_types::xcm::v2::Xcm, - }, - #[codec(index = 15)] - ExchangeAsset { - give: runtime_types::xcm::v2::multiasset::MultiAssetFilter, - receive: runtime_types::xcm::v2::multiasset::MultiAssets, - }, - #[codec(index = 16)] - InitiateReserveWithdraw { - assets: runtime_types::xcm::v2::multiasset::MultiAssetFilter, - reserve: runtime_types::xcm::v2::multilocation::MultiLocation, - xcm: runtime_types::xcm::v2::Xcm, - }, - #[codec(index = 17)] - InitiateTeleport { - assets: runtime_types::xcm::v2::multiasset::MultiAssetFilter, - dest: runtime_types::xcm::v2::multilocation::MultiLocation, - xcm: runtime_types::xcm::v2::Xcm, - }, - #[codec(index = 18)] - QueryHolding { - #[codec(compact)] - query_id: ::core::primitive::u64, - dest: runtime_types::xcm::v2::multilocation::MultiLocation, - assets: runtime_types::xcm::v2::multiasset::MultiAssetFilter, - #[codec(compact)] - max_response_weight: ::core::primitive::u64, - }, - #[codec(index = 19)] - BuyExecution { - fees: runtime_types::xcm::v2::multiasset::MultiAsset, - weight_limit: runtime_types::xcm::v2::WeightLimit, - }, - #[codec(index = 20)] - RefundSurplus, - #[codec(index = 21)] - SetErrorHandler(runtime_types::xcm::v2::Xcm), - #[codec(index = 22)] - SetAppendix(runtime_types::xcm::v2::Xcm), - #[codec(index = 23)] - ClearError, - #[codec(index = 24)] - ClaimAsset { - assets: runtime_types::xcm::v2::multiasset::MultiAssets, - ticket: runtime_types::xcm::v2::multilocation::MultiLocation, - }, - #[codec(index = 25)] - Trap(#[codec(compact)] ::core::primitive::u64), - #[codec(index = 26)] - SubscribeVersion { - #[codec(compact)] - query_id: ::core::primitive::u64, - #[codec(compact)] - max_response_weight: ::core::primitive::u64, - }, - #[codec(index = 27)] - UnsubscribeVersion, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum NetworkId { - #[codec(index = 0)] - Any, - #[codec(index = 1)] - Named( - runtime_types::bounded_collections::weak_bounded_vec::WeakBoundedVec< - ::core::primitive::u8, - >, - ), - #[codec(index = 2)] - Polkadot, - #[codec(index = 3)] - Kusama, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum OriginKind { - #[codec(index = 0)] - Native, - #[codec(index = 1)] - SovereignAccount, - #[codec(index = 2)] - Superuser, - #[codec(index = 3)] - Xcm, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Response { - #[codec(index = 0)] - Null, - #[codec(index = 1)] - Assets(runtime_types::xcm::v2::multiasset::MultiAssets), - #[codec(index = 2)] - ExecutionResult( - ::core::option::Option<( - ::core::primitive::u32, - runtime_types::xcm::v2::traits::Error, - )>, - ), - #[codec(index = 3)] - Version(::core::primitive::u32), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum WeightLimit { - #[codec(index = 0)] - Unlimited, - #[codec(index = 1)] - Limited(#[codec(compact)] ::core::primitive::u64), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct Xcm(pub ::std::vec::Vec); - } - pub mod v3 { - use super::runtime_types; - pub mod junction { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum BodyId { - #[codec(index = 0)] - Unit, - #[codec(index = 1)] - Moniker([::core::primitive::u8; 4usize]), - #[codec(index = 2)] - Index(#[codec(compact)] ::core::primitive::u32), - #[codec(index = 3)] - Executive, - #[codec(index = 4)] - Technical, - #[codec(index = 5)] - Legislative, - #[codec(index = 6)] - Judicial, - #[codec(index = 7)] - Defense, - #[codec(index = 8)] - Administration, - #[codec(index = 9)] - Treasury, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum BodyPart { - #[codec(index = 0)] - Voice, - #[codec(index = 1)] - Members { - #[codec(compact)] - count: ::core::primitive::u32, - }, - #[codec(index = 2)] - Fraction { - #[codec(compact)] - nom: ::core::primitive::u32, - #[codec(compact)] - denom: ::core::primitive::u32, - }, - #[codec(index = 3)] - AtLeastProportion { - #[codec(compact)] - nom: ::core::primitive::u32, - #[codec(compact)] - denom: ::core::primitive::u32, - }, - #[codec(index = 4)] - MoreThanProportion { - #[codec(compact)] - nom: ::core::primitive::u32, - #[codec(compact)] - denom: ::core::primitive::u32, - }, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Junction { - #[codec(index = 0)] - Parachain(#[codec(compact)] ::core::primitive::u32), - #[codec(index = 1)] - AccountId32 { - network: - ::core::option::Option, - id: [::core::primitive::u8; 32usize], - }, - #[codec(index = 2)] - AccountIndex64 { - network: - ::core::option::Option, - #[codec(compact)] - index: ::core::primitive::u64, - }, - #[codec(index = 3)] - AccountKey20 { - network: - ::core::option::Option, - key: [::core::primitive::u8; 20usize], - }, - #[codec(index = 4)] - PalletInstance(::core::primitive::u8), - #[codec(index = 5)] - GeneralIndex(#[codec(compact)] ::core::primitive::u128), - #[codec(index = 6)] - GeneralKey { - length: ::core::primitive::u8, - data: [::core::primitive::u8; 32usize], - }, - #[codec(index = 7)] - OnlyChild, - #[codec(index = 8)] - Plurality { - id: runtime_types::xcm::v3::junction::BodyId, - part: runtime_types::xcm::v3::junction::BodyPart, - }, - #[codec(index = 9)] - GlobalConsensus(runtime_types::xcm::v3::junction::NetworkId), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum NetworkId { - #[codec(index = 0)] - ByGenesis([::core::primitive::u8; 32usize]), - #[codec(index = 1)] - ByFork { - block_number: ::core::primitive::u64, - block_hash: [::core::primitive::u8; 32usize], - }, - #[codec(index = 2)] - Polkadot, - #[codec(index = 3)] - Kusama, - #[codec(index = 4)] - Westend, - #[codec(index = 5)] - Rococo, - #[codec(index = 6)] - Wococo, - #[codec(index = 7)] - Ethereum { - #[codec(compact)] - chain_id: ::core::primitive::u64, - }, - #[codec(index = 8)] - BitcoinCore, - #[codec(index = 9)] - BitcoinCash, - } - } - pub mod junctions { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Junctions { - #[codec(index = 0)] - Here, - #[codec(index = 1)] - X1(runtime_types::xcm::v3::junction::Junction), - #[codec(index = 2)] - X2( - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - ), - #[codec(index = 3)] - X3( - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - ), - #[codec(index = 4)] - X4( - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - ), - #[codec(index = 5)] - X5( - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - ), - #[codec(index = 6)] - X6( - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - ), - #[codec(index = 7)] - X7( - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - ), - #[codec(index = 8)] - X8( - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - runtime_types::xcm::v3::junction::Junction, - ), - } - } - pub mod multiasset { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum AssetId { - #[codec(index = 0)] - Concrete(runtime_types::xcm::v3::multilocation::MultiLocation), - #[codec(index = 1)] - Abstract([::core::primitive::u8; 32usize]), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum AssetInstance { - #[codec(index = 0)] - Undefined, - #[codec(index = 1)] - Index(#[codec(compact)] ::core::primitive::u128), - #[codec(index = 2)] - Array4([::core::primitive::u8; 4usize]), - #[codec(index = 3)] - Array8([::core::primitive::u8; 8usize]), - #[codec(index = 4)] - Array16([::core::primitive::u8; 16usize]), - #[codec(index = 5)] - Array32([::core::primitive::u8; 32usize]), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Fungibility { - #[codec(index = 0)] - Fungible(#[codec(compact)] ::core::primitive::u128), - #[codec(index = 1)] - NonFungible(runtime_types::xcm::v3::multiasset::AssetInstance), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct MultiAsset { - pub id: runtime_types::xcm::v3::multiasset::AssetId, - pub fun: runtime_types::xcm::v3::multiasset::Fungibility, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum MultiAssetFilter { - #[codec(index = 0)] - Definite(runtime_types::xcm::v3::multiasset::MultiAssets), - #[codec(index = 1)] - Wild(runtime_types::xcm::v3::multiasset::WildMultiAsset), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct MultiAssets( - pub ::std::vec::Vec, - ); - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum WildFungibility { - #[codec(index = 0)] - Fungible, - #[codec(index = 1)] - NonFungible, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum WildMultiAsset { - #[codec(index = 0)] - All, - #[codec(index = 1)] - AllOf { - id: runtime_types::xcm::v3::multiasset::AssetId, - fun: runtime_types::xcm::v3::multiasset::WildFungibility, - }, - #[codec(index = 2)] - AllCounted(#[codec(compact)] ::core::primitive::u32), - #[codec(index = 3)] - AllOfCounted { - id: runtime_types::xcm::v3::multiasset::AssetId, - fun: runtime_types::xcm::v3::multiasset::WildFungibility, - #[codec(compact)] - count: ::core::primitive::u32, - }, - } - } - pub mod multilocation { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct MultiLocation { - pub parents: ::core::primitive::u8, - pub interior: runtime_types::xcm::v3::junctions::Junctions, - } - } - pub mod traits { - use super::runtime_types; - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Error { - #[codec(index = 0)] - Overflow, - #[codec(index = 1)] - Unimplemented, - #[codec(index = 2)] - UntrustedReserveLocation, - #[codec(index = 3)] - UntrustedTeleportLocation, - #[codec(index = 4)] - LocationFull, - #[codec(index = 5)] - LocationNotInvertible, - #[codec(index = 6)] - BadOrigin, - #[codec(index = 7)] - InvalidLocation, - #[codec(index = 8)] - AssetNotFound, - #[codec(index = 9)] - FailedToTransactAsset, - #[codec(index = 10)] - NotWithdrawable, - #[codec(index = 11)] - LocationCannotHold, - #[codec(index = 12)] - ExceedsMaxMessageSize, - #[codec(index = 13)] - DestinationUnsupported, - #[codec(index = 14)] - Transport, - #[codec(index = 15)] - Unroutable, - #[codec(index = 16)] - UnknownClaim, - #[codec(index = 17)] - FailedToDecode, - #[codec(index = 18)] - MaxWeightInvalid, - #[codec(index = 19)] - NotHoldingFees, - #[codec(index = 20)] - TooExpensive, - #[codec(index = 21)] - Trap(::core::primitive::u64), - #[codec(index = 22)] - ExpectationFalse, - #[codec(index = 23)] - PalletNotFound, - #[codec(index = 24)] - NameMismatch, - #[codec(index = 25)] - VersionIncompatible, - #[codec(index = 26)] - HoldingWouldOverflow, - #[codec(index = 27)] - ExportError, - #[codec(index = 28)] - ReanchorFailed, - #[codec(index = 29)] - NoDeal, - #[codec(index = 30)] - FeesNotMet, - #[codec(index = 31)] - LockError, - #[codec(index = 32)] - NoPermission, - #[codec(index = 33)] - Unanchored, - #[codec(index = 34)] - NotDepositable, - #[codec(index = 35)] - UnhandledXcmVersion, - #[codec(index = 36)] - WeightLimitReached(::sp_weights::Weight), - #[codec(index = 37)] - Barrier, - #[codec(index = 38)] - WeightNotComputable, - #[codec(index = 39)] - ExceedsStackLimit, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Outcome { - #[codec(index = 0)] - Complete(::sp_weights::Weight), - #[codec(index = 1)] - Incomplete(::sp_weights::Weight, runtime_types::xcm::v3::traits::Error), - #[codec(index = 2)] - Error(runtime_types::xcm::v3::traits::Error), - } - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Instruction { - #[codec(index = 0)] - WithdrawAsset(runtime_types::xcm::v3::multiasset::MultiAssets), - #[codec(index = 1)] - ReserveAssetDeposited(runtime_types::xcm::v3::multiasset::MultiAssets), - #[codec(index = 2)] - ReceiveTeleportedAsset(runtime_types::xcm::v3::multiasset::MultiAssets), - #[codec(index = 3)] - QueryResponse { - #[codec(compact)] - query_id: ::core::primitive::u64, - response: runtime_types::xcm::v3::Response, - max_weight: ::sp_weights::Weight, - querier: ::core::option::Option< - runtime_types::xcm::v3::multilocation::MultiLocation, - >, - }, - #[codec(index = 4)] - TransferAsset { - assets: runtime_types::xcm::v3::multiasset::MultiAssets, - beneficiary: runtime_types::xcm::v3::multilocation::MultiLocation, - }, - #[codec(index = 5)] - TransferReserveAsset { - assets: runtime_types::xcm::v3::multiasset::MultiAssets, - dest: runtime_types::xcm::v3::multilocation::MultiLocation, - xcm: runtime_types::xcm::v3::Xcm, - }, - #[codec(index = 6)] - Transact { - origin_kind: runtime_types::xcm::v2::OriginKind, - require_weight_at_most: ::sp_weights::Weight, - call: runtime_types::xcm::double_encoded::DoubleEncoded, - }, - #[codec(index = 7)] - HrmpNewChannelOpenRequest { - #[codec(compact)] - sender: ::core::primitive::u32, - #[codec(compact)] - max_message_size: ::core::primitive::u32, - #[codec(compact)] - max_capacity: ::core::primitive::u32, - }, - #[codec(index = 8)] - HrmpChannelAccepted { - #[codec(compact)] - recipient: ::core::primitive::u32, - }, - #[codec(index = 9)] - HrmpChannelClosing { - #[codec(compact)] - initiator: ::core::primitive::u32, - #[codec(compact)] - sender: ::core::primitive::u32, - #[codec(compact)] - recipient: ::core::primitive::u32, - }, - #[codec(index = 10)] - ClearOrigin, - #[codec(index = 11)] - DescendOrigin(runtime_types::xcm::v3::junctions::Junctions), - #[codec(index = 12)] - ReportError(runtime_types::xcm::v3::QueryResponseInfo), - #[codec(index = 13)] - DepositAsset { - assets: runtime_types::xcm::v3::multiasset::MultiAssetFilter, - beneficiary: runtime_types::xcm::v3::multilocation::MultiLocation, - }, - #[codec(index = 14)] - DepositReserveAsset { - assets: runtime_types::xcm::v3::multiasset::MultiAssetFilter, - dest: runtime_types::xcm::v3::multilocation::MultiLocation, - xcm: runtime_types::xcm::v3::Xcm, - }, - #[codec(index = 15)] - ExchangeAsset { - give: runtime_types::xcm::v3::multiasset::MultiAssetFilter, - want: runtime_types::xcm::v3::multiasset::MultiAssets, - maximal: ::core::primitive::bool, - }, - #[codec(index = 16)] - InitiateReserveWithdraw { - assets: runtime_types::xcm::v3::multiasset::MultiAssetFilter, - reserve: runtime_types::xcm::v3::multilocation::MultiLocation, - xcm: runtime_types::xcm::v3::Xcm, - }, - #[codec(index = 17)] - InitiateTeleport { - assets: runtime_types::xcm::v3::multiasset::MultiAssetFilter, - dest: runtime_types::xcm::v3::multilocation::MultiLocation, - xcm: runtime_types::xcm::v3::Xcm, - }, - #[codec(index = 18)] - ReportHolding { - response_info: runtime_types::xcm::v3::QueryResponseInfo, - assets: runtime_types::xcm::v3::multiasset::MultiAssetFilter, - }, - #[codec(index = 19)] - BuyExecution { - fees: runtime_types::xcm::v3::multiasset::MultiAsset, - weight_limit: runtime_types::xcm::v3::WeightLimit, - }, - #[codec(index = 20)] - RefundSurplus, - #[codec(index = 21)] - SetErrorHandler(runtime_types::xcm::v3::Xcm), - #[codec(index = 22)] - SetAppendix(runtime_types::xcm::v3::Xcm), - #[codec(index = 23)] - ClearError, - #[codec(index = 24)] - ClaimAsset { - assets: runtime_types::xcm::v3::multiasset::MultiAssets, - ticket: runtime_types::xcm::v3::multilocation::MultiLocation, - }, - #[codec(index = 25)] - Trap(#[codec(compact)] ::core::primitive::u64), - #[codec(index = 26)] - SubscribeVersion { - #[codec(compact)] - query_id: ::core::primitive::u64, - max_response_weight: ::sp_weights::Weight, - }, - #[codec(index = 27)] - UnsubscribeVersion, - #[codec(index = 28)] - BurnAsset(runtime_types::xcm::v3::multiasset::MultiAssets), - #[codec(index = 29)] - ExpectAsset(runtime_types::xcm::v3::multiasset::MultiAssets), - #[codec(index = 30)] - ExpectOrigin( - ::core::option::Option< - runtime_types::xcm::v3::multilocation::MultiLocation, - >, - ), - #[codec(index = 31)] - ExpectError( - ::core::option::Option<( - ::core::primitive::u32, - runtime_types::xcm::v3::traits::Error, - )>, - ), - #[codec(index = 32)] - ExpectTransactStatus(runtime_types::xcm::v3::MaybeErrorCode), - #[codec(index = 33)] - QueryPallet { - module_name: ::std::vec::Vec<::core::primitive::u8>, - response_info: runtime_types::xcm::v3::QueryResponseInfo, - }, - #[codec(index = 34)] - ExpectPallet { - #[codec(compact)] - index: ::core::primitive::u32, - name: ::std::vec::Vec<::core::primitive::u8>, - module_name: ::std::vec::Vec<::core::primitive::u8>, - #[codec(compact)] - crate_major: ::core::primitive::u32, - #[codec(compact)] - min_crate_minor: ::core::primitive::u32, - }, - #[codec(index = 35)] - ReportTransactStatus(runtime_types::xcm::v3::QueryResponseInfo), - #[codec(index = 36)] - ClearTransactStatus, - #[codec(index = 37)] - UniversalOrigin(runtime_types::xcm::v3::junction::Junction), - #[codec(index = 38)] - ExportMessage { - network: runtime_types::xcm::v3::junction::NetworkId, - destination: runtime_types::xcm::v3::junctions::Junctions, - xcm: runtime_types::xcm::v3::Xcm, - }, - #[codec(index = 39)] - LockAsset { - asset: runtime_types::xcm::v3::multiasset::MultiAsset, - unlocker: runtime_types::xcm::v3::multilocation::MultiLocation, - }, - #[codec(index = 40)] - UnlockAsset { - asset: runtime_types::xcm::v3::multiasset::MultiAsset, - target: runtime_types::xcm::v3::multilocation::MultiLocation, - }, - #[codec(index = 41)] - NoteUnlockable { - asset: runtime_types::xcm::v3::multiasset::MultiAsset, - owner: runtime_types::xcm::v3::multilocation::MultiLocation, - }, - #[codec(index = 42)] - RequestUnlock { - asset: runtime_types::xcm::v3::multiasset::MultiAsset, - locker: runtime_types::xcm::v3::multilocation::MultiLocation, - }, - #[codec(index = 43)] - SetFeesMode { jit_withdraw: ::core::primitive::bool }, - #[codec(index = 44)] - SetTopic([::core::primitive::u8; 32usize]), - #[codec(index = 45)] - ClearTopic, - #[codec(index = 46)] - AliasOrigin(runtime_types::xcm::v3::multilocation::MultiLocation), - #[codec(index = 47)] - UnpaidExecution { - weight_limit: runtime_types::xcm::v3::WeightLimit, - check_origin: ::core::option::Option< - runtime_types::xcm::v3::multilocation::MultiLocation, - >, - }, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum MaybeErrorCode { - #[codec(index = 0)] - Success, - #[codec(index = 1)] - Error( - runtime_types::bounded_collections::bounded_vec::BoundedVec< - ::core::primitive::u8, - >, - ), - #[codec(index = 2)] - TruncatedError( - runtime_types::bounded_collections::bounded_vec::BoundedVec< - ::core::primitive::u8, - >, - ), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct PalletInfo { - #[codec(compact)] - pub index: ::core::primitive::u32, - pub name: runtime_types::bounded_collections::bounded_vec::BoundedVec< - ::core::primitive::u8, - >, - pub module_name: runtime_types::bounded_collections::bounded_vec::BoundedVec< - ::core::primitive::u8, - >, - #[codec(compact)] - pub major: ::core::primitive::u32, - #[codec(compact)] - pub minor: ::core::primitive::u32, - #[codec(compact)] - pub patch: ::core::primitive::u32, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct QueryResponseInfo { - pub destination: runtime_types::xcm::v3::multilocation::MultiLocation, - #[codec(compact)] - pub query_id: ::core::primitive::u64, - pub max_weight: ::sp_weights::Weight, - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum Response { - #[codec(index = 0)] - Null, - #[codec(index = 1)] - Assets(runtime_types::xcm::v3::multiasset::MultiAssets), - #[codec(index = 2)] - ExecutionResult( - ::core::option::Option<( - ::core::primitive::u32, - runtime_types::xcm::v3::traits::Error, - )>, - ), - #[codec(index = 3)] - Version(::core::primitive::u32), - #[codec(index = 4)] - PalletsInfo( - runtime_types::bounded_collections::bounded_vec::BoundedVec< - runtime_types::xcm::v3::PalletInfo, - >, - ), - #[codec(index = 5)] - DispatchResult(runtime_types::xcm::v3::MaybeErrorCode), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum WeightLimit { - #[codec(index = 0)] - Unlimited, - #[codec(index = 1)] - Limited(::sp_weights::Weight), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub struct Xcm(pub ::std::vec::Vec); - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum VersionedMultiAssets { - #[codec(index = 1)] - V2(runtime_types::xcm::v2::multiasset::MultiAssets), - #[codec(index = 3)] - V3(runtime_types::xcm::v3::multiasset::MultiAssets), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum VersionedMultiLocation { - #[codec(index = 1)] - V2(runtime_types::xcm::v2::multilocation::MultiLocation), - #[codec(index = 3)] - V3(runtime_types::xcm::v3::multilocation::MultiLocation), - } - #[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)] - pub enum VersionedXcm { - #[codec(index = 2)] - V2(runtime_types::xcm::v2::Xcm), - #[codec(index = 3)] - V3(runtime_types::xcm::v3::Xcm), - } - } - } -} diff --git a/bridges/relays/client-rialto-parachain/src/lib.rs b/bridges/relays/client-rialto-parachain/src/lib.rs deleted file mode 100644 index b6617b90f137e..0000000000000 --- a/bridges/relays/client-rialto-parachain/src/lib.rs +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -//! Types used to connect to the Rialto-Substrate chain. - -pub mod codegen_runtime; - -use bp_messages::MessageNonce; -use bp_polkadot_core::SuffixedCommonSignedExtensionExt; -use bp_runtime::ChainId; -use codec::Encode; -use relay_substrate_client::{ - Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, Error as SubstrateError, - SignParam, UnderlyingChainProvider, UnsignedTransaction, -}; -use sp_core::{storage::StorageKey, Pair}; -use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount, MultiAddress}; -use std::time::Duration; - -pub use codegen_runtime::api::runtime_types; - -pub type RuntimeCall = runtime_types::rialto_parachain_runtime::RuntimeCall; -pub type SudoCall = runtime_types::pallet_sudo::pallet::Call; -pub type BridgeGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call; -pub type BridgeMessagesCall = runtime_types::pallet_bridge_messages::pallet::Call; - -/// The address format for describing accounts. -pub type Address = MultiAddress; - -/// Rialto parachain definition -#[derive(Debug, Clone, Copy)] -pub struct RialtoParachain; - -impl UnderlyingChainProvider for RialtoParachain { - type Chain = bp_rialto_parachain::RialtoParachain; -} - -impl Chain for RialtoParachain { - const ID: ChainId = bp_runtime::RIALTO_PARACHAIN_CHAIN_ID; - const NAME: &'static str = "RialtoParachain"; - const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = - bp_rialto_parachain::BEST_FINALIZED_RIALTO_PARACHAIN_HEADER_METHOD; - const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(5); - - type SignedBlock = bp_polkadot_core::SignedBlock; - type Call = RuntimeCall; -} - -impl ChainWithBalances for RialtoParachain { - fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey { - bp_polkadot_core::AccountInfoStorageMapKeyProvider::final_key(account_id) - } -} - -impl ChainWithMessages for RialtoParachain { - const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = - bp_rialto_parachain::WITH_RIALTO_PARACHAIN_MESSAGES_PALLET_NAME; - // TODO (https://github.com/paritytech/parity-bridges-common/issues/1692): change the name - const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> = Some("BridgeRelayers"); - const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = - bp_rialto_parachain::TO_RIALTO_PARACHAIN_MESSAGE_DETAILS_METHOD; - const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = - bp_rialto_parachain::FROM_RIALTO_PARACHAIN_MESSAGE_DETAILS_METHOD; - const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = - bp_rialto_parachain::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; - const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = - bp_rialto_parachain::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; -} - -impl ChainWithTransactions for RialtoParachain { - type AccountKeyPair = sp_core::sr25519::Pair; - type SignedTransaction = - bp_polkadot_core::UncheckedExtrinsic; - - fn sign_transaction( - param: SignParam, - unsigned: UnsignedTransaction, - ) -> Result { - let raw_payload = SignedPayload::new( - unsigned.call, - bp_rialto_parachain::SignedExtension::from_params( - param.spec_version, - param.transaction_version, - unsigned.era, - param.genesis_hash, - unsigned.nonce, - unsigned.tip, - (((), ()), ((), ())), - ), - )?; - - let signature = raw_payload.using_encoded(|payload| param.signer.sign(payload)); - let signer: sp_runtime::MultiSigner = param.signer.public().into(); - let (call, extra, _) = raw_payload.deconstruct(); - - Ok(Self::SignedTransaction::new_signed( - call, - signer.into_account().into(), - signature.into(), - extra, - )) - } - - fn is_signed(tx: &Self::SignedTransaction) -> bool { - tx.signature.is_some() - } - - fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool { - tx.signature - .as_ref() - .map(|(address, _, _)| *address == Address::Id(signer.public().into())) - .unwrap_or(false) - } - - fn parse_transaction(tx: Self::SignedTransaction) -> Option> { - let extra = &tx.signature.as_ref()?.2; - Some(UnsignedTransaction::new(tx.function, extra.nonce()).tip(extra.tip())) - } -} - -/// RialtoParachain signing params. -pub type SigningParams = sp_core::sr25519::Pair; - -/// RialtoParachain header type used in headers sync. -pub type SyncHeader = relay_substrate_client::SyncHeader; diff --git a/bridges/relays/client-rialto/Cargo.toml b/bridges/relays/client-rialto/Cargo.toml deleted file mode 100644 index 7a1b378c9ac9c..0000000000000 --- a/bridges/relays/client-rialto/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "relay-rialto-client" -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2021" -license = "GPL-3.0-or-later WITH Classpath-exception-2.0" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.1.5" } -relay-substrate-client = { path = "../client-substrate" } -relay-utils = { path = "../utils" } - -# Bridge dependencies - -bp-messages = { path = "../../primitives/messages" } -bp-rialto = { path = "../../primitives/chain-rialto" } -bp-runtime = { path = "../../primitives/runtime" } -rialto-runtime = { path = "../../bin/rialto/runtime" } - -# Substrate Dependencies - -frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -sp-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } diff --git a/bridges/relays/client-rialto/src/lib.rs b/bridges/relays/client-rialto/src/lib.rs deleted file mode 100644 index 2aa5bd638cc87..0000000000000 --- a/bridges/relays/client-rialto/src/lib.rs +++ /dev/null @@ -1,191 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Parity Bridges Common. - -// Parity Bridges Common is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Bridges Common is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Bridges Common. If not, see . - -//! Types used to connect to the Rialto-Substrate chain. - -use bp_messages::MessageNonce; -use bp_rialto::RIALTO_SYNCED_HEADERS_GRANDPA_INFO_METHOD; -use bp_runtime::ChainId; -use codec::{Compact, Decode, Encode}; -use relay_substrate_client::{ - BalanceOf, Chain, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, - ChainWithTransactions, Error as SubstrateError, NonceOf, RelayChain, SignParam, - UnderlyingChainProvider, UnsignedTransaction, -}; -use sp_core::{storage::StorageKey, Pair}; -use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount}; -use sp_session::MembershipProof; -use std::time::Duration; - -/// Rialto header id. -pub type HeaderId = relay_utils::HeaderId; - -/// Rialto chain definition -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct Rialto; - -impl UnderlyingChainProvider for Rialto { - type Chain = bp_rialto::Rialto; -} - -impl Chain for Rialto { - const ID: ChainId = bp_runtime::RIALTO_CHAIN_ID; - const NAME: &'static str = "Rialto"; - const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = - bp_rialto::BEST_FINALIZED_RIALTO_HEADER_METHOD; - const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(5); - - type SignedBlock = rialto_runtime::SignedBlock; - type Call = rialto_runtime::RuntimeCall; -} - -impl ChainWithGrandpa for Rialto { - const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str = - RIALTO_SYNCED_HEADERS_GRANDPA_INFO_METHOD; - - type KeyOwnerProof = MembershipProof; -} - -impl RelayChain for Rialto { - const PARAS_PALLET_NAME: &'static str = bp_rialto::PARAS_PALLET_NAME; -} - -impl ChainWithMessages for Rialto { - const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = - bp_rialto::WITH_RIALTO_MESSAGES_PALLET_NAME; - // TODO (https://github.com/paritytech/parity-bridges-common/issues/1692): change the name - const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> = Some("BridgeRelayers"); - const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = - bp_rialto::TO_RIALTO_MESSAGE_DETAILS_METHOD; - const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = - bp_rialto::FROM_RIALTO_MESSAGE_DETAILS_METHOD; - const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = - bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; - const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = - bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; -} - -impl ChainWithBalances for Rialto { - fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey { - use frame_support::storage::generator::StorageMap; - StorageKey(frame_system::Account::::storage_map_final_key( - account_id, - )) - } -} - -impl ChainWithTransactions for Rialto { - type AccountKeyPair = sp_core::sr25519::Pair; - type SignedTransaction = rialto_runtime::UncheckedExtrinsic; - - fn sign_transaction( - param: SignParam, - unsigned: UnsignedTransaction, - ) -> Result { - let raw_payload = SignedPayload::from_raw( - unsigned.call.clone(), - ( - frame_system::CheckNonZeroSender::::new(), - frame_system::CheckSpecVersion::::new(), - frame_system::CheckTxVersion::::new(), - frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from(unsigned.era.frame_era()), - frame_system::CheckNonce::::from(unsigned.nonce), - frame_system::CheckWeight::::new(), - pallet_transaction_payment::ChargeTransactionPayment::::from(unsigned.tip), - ), - ( - (), - param.spec_version, - param.transaction_version, - param.genesis_hash, - unsigned.era.signed_payload(param.genesis_hash), - (), - (), - (), - ), - ); - let signature = raw_payload.using_encoded(|payload| param.signer.sign(payload)); - let signer: sp_runtime::MultiSigner = param.signer.public().into(); - let (call, extra, _) = raw_payload.deconstruct(); - - Ok(rialto_runtime::UncheckedExtrinsic::new_signed( - call.into_decoded()?, - signer.into_account().into(), - signature.into(), - extra, - )) - } - - fn is_signed(tx: &Self::SignedTransaction) -> bool { - tx.signature.is_some() - } - - fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool { - tx.signature - .as_ref() - .map(|(address, _, _)| *address == rialto_runtime::Address::Id(signer.public().into())) - .unwrap_or(false) - } - - fn parse_transaction(tx: Self::SignedTransaction) -> Option> { - let extra = &tx.signature.as_ref()?.2; - Some( - UnsignedTransaction::new( - tx.function.into(), - Compact::>::decode(&mut &extra.5.encode()[..]).ok()?.into(), - ) - .tip(Compact::>::decode(&mut &extra.7.encode()[..]).ok()?.into()), - ) - } -} - -/// Rialto signing params. -pub type SigningParams = sp_core::sr25519::Pair; - -/// Rialto header type used in headers sync. -pub type SyncHeader = relay_substrate_client::SyncHeader; - -#[cfg(test)] -mod tests { - use super::*; - use relay_substrate_client::TransactionEra; - - #[test] - fn parse_transaction_works() { - let unsigned = UnsignedTransaction { - call: rialto_runtime::RuntimeCall::System(rialto_runtime::SystemCall::remark { - remark: b"Hello world!".to_vec(), - }) - .into(), - nonce: 777, - tip: 888, - era: TransactionEra::immortal(), - }; - let signed_transaction = Rialto::sign_transaction( - SignParam { - spec_version: 42, - transaction_version: 50000, - genesis_hash: [42u8; 32].into(), - signer: sp_core::sr25519::Pair::from_seed_slice(&[1u8; 32]).unwrap(), - }, - unsigned.clone(), - ) - .unwrap(); - let parsed_transaction = Rialto::parse_transaction(signed_transaction).unwrap(); - assert_eq!(parsed_transaction, unsigned); - } -} diff --git a/bridges/relays/finality/README.md b/bridges/relays/finality/README.md index 444056e756303..0a8d6a4c8b128 100644 --- a/bridges/relays/finality/README.md +++ b/bridges/relays/finality/README.md @@ -38,21 +38,21 @@ with mandatory headers are fee-free, the cost of running such relay is zero (in ## Finality Relay Metrics Finality relay provides several metrics. Metrics names depend on names of source and target chains. The list below -shows metrics names for Rialto (source chain) to Millau (target chain) finality relay. For other chains, simply -change chain names. So the metrics are: +shows metrics names for Rococo (source chain) to BridgeHubWestend (target chain) finality relay. For other +chains, simply change chain names. So the metrics are: -- `Rialto_to_Millau_Sync_best_source_block_number` - returns best finalized source chain (Rialto) block number, known +- `Rococo_to_BridgeHubWestend_Sync_best_source_block_number` - returns best finalized source chain (Rococo) block number, known to the relay. If relay is running in [on-demand mode](../bin-substrate/src/cli/relay_headers_and_messages/), the number may not match (it may be far behind) the actual best finalized number; -- `Rialto_to_Millau_Sync_best_source_at_target_block_number` - returns best finalized source chain (Rialto) block +- `Rococo_to_BridgeHubWestend_Sync_best_source_at_target_block_number` - returns best finalized source chain (Rococo) block number that is known to the bridge GRANDPA pallet at the target chain. -- `Rialto_to_Millau_Sync_is_source_and_source_at_target_using_different_forks` - if this metrics is set to `1`, then +- `Rococo_to_BridgeHubWestend_Sync_is_source_and_source_at_target_using_different_forks` - if this metrics is set to `1`, then the best source chain header, known to the target chain doesn't match the same-number-header at the source chain. It means that the GRANDPA validators set has crafted the duplicate justification and it has been submitted to the target chain. Normally (if majority of validators are honest and if you're running finality relay without large breaks) this shall not happen and the metric will have `0` value. -If relay operates properly, you should see that the `Rialto_to_Millau_Sync_best_source_at_target_block_number` -tries to reach the `Rialto_to_Millau_Sync_best_source_block_number`. And the latter one always increases. +If relay operates properly, you should see that the `Rococo_to_BridgeHubWestend_Sync_best_source_at_target_block_number` +tries to reach the `Rococo_to_BridgeHubWestend_Sync_best_source_block_number`. And the latter one always increases. diff --git a/bridges/relays/lib-substrate-relay/Cargo.toml b/bridges/relays/lib-substrate-relay/Cargo.toml index 6fe3c02cbca82..8a490a9d2756d 100644 --- a/bridges/relays/lib-substrate-relay/Cargo.toml +++ b/bridges/relays/lib-substrate-relay/Cargo.toml @@ -50,12 +50,9 @@ sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", bra sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } [dev-dependencies] -bp-rialto = { path = "../../primitives/chain-rialto" } -bp-rialto-parachain = { path = "../../primitives/chain-rialto-parachain" } bp-rococo = { path = "../../primitives/chain-rococo" } bp-wococo = { path = "../../primitives/chain-wococo" } pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -relay-rialto-client = { path = "../client-rialto" } relay-rococo-client = { path = "../client-rococo" } -relay-wococo-client = { path = "../client-wococo" } -rialto-runtime = { path = "../../bin/rialto/runtime" } +relay-bridge-hub-rococo-client = { path = "../client-bridge-hub-rococo" } +relay-bridge-hub-wococo-client = { path = "../client-bridge-hub-wococo" } diff --git a/bridges/relays/lib-substrate-relay/src/lib.rs b/bridges/relays/lib-substrate-relay/src/lib.rs index 50a89e90e2dcd..6e62038665133 100644 --- a/bridges/relays/lib-substrate-relay/src/lib.rs +++ b/bridges/relays/lib-substrate-relay/src/lib.rs @@ -45,21 +45,8 @@ pub struct TransactionParams { /// Tagged relay account, which balance may be exposed as metrics by the relay. #[derive(Clone, Debug)] pub enum TaggedAccount { - /// Account, used to sign headers relay transactions from given bridged chain. - Headers { - /// Account id. - id: AccountId, - /// Name of the bridged chain, which headers are relayed. - bridged_chain: String, - }, - /// Account, used to sign parachains relay transactions from given bridged relay chain. - Parachains { - /// Account id. - id: AccountId, - /// Name of the bridged relay chain with parachain heads. - bridged_chain: String, - }, - /// Account, used to sign message relay transactions from given bridged chain. + /// Account, used to sign message (also headers and parachains) relay transactions from given + /// bridged chain. Messages { /// Account id. id: AccountId, @@ -72,8 +59,6 @@ impl TaggedAccount { /// Returns reference to the account id. pub fn id(&self) -> &AccountId { match *self { - TaggedAccount::Headers { ref id, .. } => id, - TaggedAccount::Parachains { ref id, .. } => id, TaggedAccount::Messages { ref id, .. } => id, } } @@ -81,10 +66,6 @@ impl TaggedAccount { /// Returns stringified account tag. pub fn tag(&self) -> String { match *self { - TaggedAccount::Headers { ref bridged_chain, .. } => format!("{bridged_chain}Headers"), - TaggedAccount::Parachains { ref bridged_chain, .. } => { - format!("{bridged_chain}Parachains") - }, TaggedAccount::Messages { ref bridged_chain, .. } => { format!("{bridged_chain}Messages") }, diff --git a/bridges/relays/lib-substrate-relay/src/messages_lane.rs b/bridges/relays/lib-substrate-relay/src/messages_lane.rs index 413f3d2c51ef5..41f04c8f986ee 100644 --- a/bridges/relays/lib-substrate-relay/src/messages_lane.rs +++ b/bridges/relays/lib-substrate-relay/src/messages_lane.rs @@ -187,8 +187,6 @@ where { // 2/3 is reserved for proofs and tx overhead let max_messages_size_in_single_batch = P::TargetChain::max_extrinsic_size() / 3; - // we don't know exact weights of the Polkadot runtime. So to guess weights we'll be using - // weights from Rialto and then simply dividing it by x2. let limits = match params.limits { Some(limits) => limits, None => diff --git a/bridges/relays/lib-substrate-relay/src/messages_source.rs b/bridges/relays/lib-substrate-relay/src/messages_source.rs index 4c49d76bdf357..ed7a2d5924fb7 100644 --- a/bridges/relays/lib-substrate-relay/src/messages_source.rs +++ b/bridges/relays/lib-substrate-relay/src/messages_source.rs @@ -555,9 +555,8 @@ fn split_msgs_to_refine( mod tests { use super::*; use bp_runtime::Chain as ChainBase; - use relay_rialto_client::Rialto; - use relay_rococo_client::Rococo; - use relay_wococo_client::Wococo; + use relay_bridge_hub_rococo_client::BridgeHubRococo; + use relay_bridge_hub_wococo_client::BridgeHubWococo; fn message_details_from_rpc( nonces: RangeInclusive, @@ -574,16 +573,20 @@ mod tests { #[test] fn validate_out_msgs_details_succeeds_if_no_messages_are_missing() { - assert!( - validate_out_msgs_details::(&message_details_from_rpc(1..=3), 1..=3,).is_ok() - ); + assert!(validate_out_msgs_details::( + &message_details_from_rpc(1..=3), + 1..=3, + ) + .is_ok()); } #[test] fn validate_out_msgs_details_succeeds_if_head_messages_are_missing() { - assert!( - validate_out_msgs_details::(&message_details_from_rpc(2..=3), 1..=3,).is_ok() + assert!(validate_out_msgs_details::( + &message_details_from_rpc(2..=3), + 1..=3, ) + .is_ok()) } #[test] @@ -591,7 +594,7 @@ mod tests { let mut message_details_from_rpc = message_details_from_rpc(1..=3); message_details_from_rpc.remove(1); assert!(matches!( - validate_out_msgs_details::(&message_details_from_rpc, 1..=3,), + validate_out_msgs_details::(&message_details_from_rpc, 1..=3,), Err(SubstrateError::Custom(_)) )); } @@ -599,7 +602,7 @@ mod tests { #[test] fn validate_out_msgs_details_map_fails_if_tail_messages_are_missing() { assert!(matches!( - validate_out_msgs_details::(&message_details_from_rpc(1..=2), 1..=3,), + validate_out_msgs_details::(&message_details_from_rpc(1..=2), 1..=3,), Err(SubstrateError::Custom(_)) )); } @@ -607,7 +610,7 @@ mod tests { #[test] fn validate_out_msgs_details_fails_if_all_messages_are_missing() { assert!(matches!( - validate_out_msgs_details::(&[], 1..=3), + validate_out_msgs_details::(&[], 1..=3), Err(SubstrateError::Custom(_)) )); } @@ -615,7 +618,7 @@ mod tests { #[test] fn validate_out_msgs_details_fails_if_more_messages_than_nonces() { assert!(matches!( - validate_out_msgs_details::(&message_details_from_rpc(1..=5), 2..=5,), + validate_out_msgs_details::(&message_details_from_rpc(1..=5), 2..=5,), Err(SubstrateError::Custom(_)) )); } @@ -641,8 +644,10 @@ mod tests { msgs_to_refine.push((payload, out_msg_details)); } - let maybe_batches = - split_msgs_to_refine::(LaneId([0, 0, 0, 0]), msgs_to_refine); + let maybe_batches = split_msgs_to_refine::( + Default::default(), + msgs_to_refine, + ); match expected_batches { Ok(expected_batches) => { let batches = maybe_batches.unwrap(); @@ -664,7 +669,7 @@ mod tests { #[test] fn test_split_msgs_to_refine() { - let max_extrinsic_size = Rococo::max_extrinsic_size() as usize; + let max_extrinsic_size = BridgeHubRococo::max_extrinsic_size() as usize; // Check that an error is returned when one of the messages is too big. check_split_msgs_to_refine(vec![max_extrinsic_size], Err(())); diff --git a/bridges/relays/parachains/README.md b/bridges/relays/parachains/README.md index fc5ad03fb340d..bacd28594d807 100644 --- a/bridges/relays/parachains/README.md +++ b/bridges/relays/parachains/README.md @@ -35,15 +35,15 @@ transaction. Every parachain in Polkadot is identified by the 32-bit number. All metrics, exposed by the parachains finality relay have the `parachain` label, which is set to the parachain id. And the metrics are prefixed with the prefix, that depends on the name of the source relay and target chains. The list below shows metrics names for -Rialto (source relay chain) to Millau (target chain) parachains finality relay. For other chains, simply +Rococo (source relay chain) to BridgeHubWestend (target chain) parachains finality relay. For other chains, simply change chain names. So the metrics are: -- `Rialto_to_Millau_Parachains_best_parachain_block_number_at_source` - returns best known parachain block - number, registered in the `paras` pallet at the source relay chain (Rialto in our example); +- `Rococo_to_BridgeHubWestend_Parachains_best_parachain_block_number_at_source` - returns best known parachain block + number, registered in the `paras` pallet at the source relay chain (Rococo in our example); -- `Rialto_to_Millau_Parachains_best_parachain_block_number_at_target` - returns best known parachain block - number, registered in the bridge parachains pallet at the target chain (Millau in our example). +- `Rococo_to_BridgeHubWestend_Parachains_best_parachain_block_number_at_target` - returns best known parachain block + number, registered in the bridge parachains pallet at the target chain (BridgeHubWestend in our example). -If relay operates properly, you should see that the `Rialto_to_Millau_Parachains_best_parachain_block_number_at_target` -tries to reach the `Rialto_to_Millau_Parachains_best_parachain_block_number_at_source`. And the latter one +If relay operates properly, you should see that the `Rococo_to_BridgeHubWestend_Parachains_best_parachain_block_number_at_target` +tries to reach the `Rococo_to_BridgeHubWestend_Parachains_best_parachain_block_number_at_source`. And the latter one always increases.