diff --git a/Cargo.lock b/Cargo.lock index e58b25b608..1540551f44 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1635,6 +1635,16 @@ dependencies = [ "vec_map", ] +[[package]] +name = "client-legacy" +version = "0.1.0" +dependencies = [ + "bp-messages", + "parity-scale-codec", + "scale-info", + "sp-runtime", +] + [[package]] name = "colorchoice" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index 8a071c38a7..409824aaed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ members = [ "relay-clients/client-bridge-hub-rococo", "relay-clients/client-bridge-hub-westend", "relay-clients/client-kusama", + "relay-clients/client-legacy", "relay-clients/client-polkadot", "relay-clients/client-polkadot-bulletin", "relay-clients/client-rococo", diff --git a/relay-clients/client-legacy/Cargo.toml b/relay-clients/client-legacy/Cargo.toml new file mode 100644 index 0000000000..9f25248232 --- /dev/null +++ b/relay-clients/client-legacy/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "relay-legacy-client" +version = "0.1.0" +authors.workspace = true +edition.workspace = true +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" +repository.workspace = true + +[lints] +workspace = true + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.6.1", features = ["derive"] } +scale-info = { version = "2.11.3", default-features = false, features = ["derive"] } + +# Bridge dependencies +bp-messages = { git = "https://github.com/paritytech/polkadot-sdk", branch = "bko-bridges-v2-compact-proofs" } + +# Substrate Dependencies +sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "bko-bridges-v2-compact-proofs" } diff --git a/relay-clients/client-legacy/src/lib.rs b/relay-clients/client-legacy/src/lib.rs new file mode 100644 index 0000000000..e5a5f5a262 --- /dev/null +++ b/relay-clients/client-legacy/src/lib.rs @@ -0,0 +1,77 @@ +// 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 ensure compatibility with older versions of various types from `polkadot-sdk`. +//! +//! E.g. When a runtime is changed and uses different or newer types for the same struct, we can add +//! the older versions here and use them with `tools/runtime-codegen` for `TypeSubstitute`. + +/// Types compatible with versions before the "compact proofs" feature. +pub mod non_compact_proofs { + pub mod bridge_runtime_common { + pub mod messages { + use bp_messages::{LaneId, MessageNonce}; + use codec::{Decode, Encode}; + use scale_info::TypeInfo; + use sp_runtime::RuntimeDebug; + + /// Raw storage proof type (just raw trie nodes). + pub type RawStorageProof = Vec>; + + pub mod source { + use super::*; + + /// Messages delivery proof from bridged chain: + /// + /// - hash of finalized header; + /// - storage proof of inbound lane state; + /// - lane id. + #[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)] + pub struct FromBridgedChainMessagesDeliveryProof { + /// Hash of the bridge header the proof is for. + pub bridged_header_hash: BridgedHeaderHash, + /// Storage trie proof generated for [`Self::bridged_header_hash`]. + pub storage_proof: RawStorageProof, + /// Lane id of which messages were delivered and the proof is for. + pub lane: LaneId, + } + } + pub mod target { + use super::*; + + /// Messages proof from bridged chain: + /// + /// - hash of finalized header; + /// - storage proof of messages and (optionally) outbound lane state; + /// - lane id; + /// - nonces (inclusive range) of messages which are included in this proof. + #[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)] + pub struct FromBridgedChainMessagesProof { + /// Hash of the finalized bridged header the proof is for. + pub bridged_header_hash: BridgedHeaderHash, + /// A storage trie proof of messages being delivered. + pub storage_proof: RawStorageProof, + /// Messages in this proof are sent over this lane. + pub lane: LaneId, + /// Nonce of the first message being delivered. + pub nonces_start: MessageNonce, + /// Nonce of the last message being delivered. + pub nonces_end: MessageNonce, + } + } + } + } +} diff --git a/tools/runtime-codegen/src/main.rs b/tools/runtime-codegen/src/main.rs index 87ce08d79a..04b20c28d1 100644 --- a/tools/runtime-codegen/src/main.rs +++ b/tools/runtime-codegen/src/main.rs @@ -140,6 +140,14 @@ fn main() -> color_eyre::Result<()> { TypeSubstitute::simple("bp_header_chain::InitializationData"), TypeSubstitute::simple("bp_polkadot_core::parachains::ParaId"), TypeSubstitute::simple("bp_polkadot_core::parachains::ParaHeadsProof"), + TypeSubstitute::custom( + "bridge_runtime_common::messages::target::FromBridgedChainMessagesProof", + "::relay_legacy_client::non_compact_proofs::bridge_runtime_common::messages::target::FromBridgedChainMessagesProof", + ), + TypeSubstitute::custom( + "bridge_runtime_common::messages::source::FromBridgedChainMessagesDeliveryProof", + "::relay_legacy_client::non_compact_proofs::bridge_runtime_common::messages::source::FromBridgedChainMessagesDeliveryProof", + ), TypeSubstitute::simple( "bp_messages::target_chain::FromBridgedChainMessagesProof", ),