Skip to content

Commit

Permalink
Statemine primitives (#1625)
Browse files Browse the repository at this point in the history
* Statemine primitives

* ref issue in TODO

* fix TODO
  • Loading branch information
svyatonik authored and bkchr committed Apr 10, 2024
1 parent 2c0b6b7 commit 3e00c5c
Show file tree
Hide file tree
Showing 21 changed files with 305 additions and 77 deletions.
7 changes: 0 additions & 7 deletions bridges/primitives/chain-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ use bp_runtime::decl_bridge_finality_runtime_apis;
/// Kusama Chain
pub type Kusama = PolkadotLike;

/// The target length of a session (how often authorities change) on Kusama 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 = time_units::HOURS;

/// Name of the With-Kusama GRANDPA pallet instance that is deployed at bridged chains.
pub const WITH_KUSAMA_GRANDPA_PALLET_NAME: &str = "BridgeKusamaGrandpa";

Expand Down
2 changes: 0 additions & 2 deletions bridges/primitives/chain-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ edition = "2021"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"

[dependencies]
smallvec = "1.7"

# Bridge Dependencies

bp-polkadot-core = { path = "../polkadot-core", default-features = false }
Expand Down
7 changes: 0 additions & 7 deletions bridges/primitives/chain-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ use bp_runtime::decl_bridge_finality_runtime_apis;
/// Polkadot Chain
pub type Polkadot = PolkadotLike;

/// The target length of a session (how often authorities change) on Polkadot 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 * time_units::HOURS;

/// Name of the With-Polkadot GRANDPA pallet instance that is deployed at bridged chains.
pub const WITH_POLKADOT_GRANDPA_PALLET_NAME: &str = "BridgePolkadotGrandpa";

Expand Down
7 changes: 0 additions & 7 deletions bridges/primitives/chain-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ use bp_runtime::decl_bridge_finality_runtime_apis;
/// Rococo Chain
pub type Rococo = PolkadotLike;

/// The target length of a session (how often authorities change) on Rococo 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 = time_units::HOURS;

/// Name of the With-Rococo GRANDPA pallet instance that is deployed at bridged chains.
pub const WITH_ROCOCO_GRANDPA_PALLET_NAME: &str = "BridgeRococoGrandpa";

Expand Down
24 changes: 24 additions & 0 deletions bridges/primitives/chain-statemine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "bp-statemine"
description = "Primitives of Statemine runtime."
version = "0.1.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"

[dependencies]

# Bridge Dependencies

bp-polkadot-core = { path = "../polkadot-core", default-features = false }

# Substrate Based Dependencies

sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }

[features]
default = ["std"]
std = [
"bp-polkadot-core/std",
"sp-version/std",
]
38 changes: 38 additions & 0 deletions bridges/primitives/chain-statemine/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.

// Parity Bridges Common is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Parity Bridges Common is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.

#![cfg_attr(not(feature = "std"), no_std)]
// RuntimeApi generated functions
#![allow(clippy::too_many_arguments)]

pub use bp_polkadot_core::*;

use sp_version::RuntimeVersion;

/// Statemine Chain.
pub type Statemine = PolkadotLike;

/// Known Statemine runtime version.
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: sp_version::create_runtime_str!("statemine"),
impl_name: sp_version::create_runtime_str!("statemine"),
authoring_version: 1,
spec_version: 9300,
impl_version: 0,
apis: sp_version::create_apis_vec![[]],
transaction_version: 8,
state_version: 1,
};
6 changes: 0 additions & 6 deletions bridges/primitives/chain-westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ 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, features = ["derive"] }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }

# Bridge Dependencies

Expand All @@ -18,15 +16,11 @@ bp-runtime = { path = "../runtime", default-features = false }
# Substrate Based Dependencies

sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }

[features]
default = ["std"]
std = [
"bp-polkadot-core/std",
"bp-runtime/std",
"codec/std",
"scale-info/std",
"sp-api/std",
"sp-runtime/std",
]
29 changes: 0 additions & 29 deletions bridges/primitives/chain-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,12 @@
// RuntimeApi generated functions
#![allow(clippy::too_many_arguments)]

use scale_info::TypeInfo;

pub use bp_polkadot_core::*;
use bp_runtime::decl_bridge_finality_runtime_apis;

/// Westend Chain
pub type Westend = PolkadotLike;

/// Westend Runtime `Call` enum.
///
/// We are not currently submitting any Westend transactions => it is empty.
#[derive(codec::Encode, codec::Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
pub enum Call {}

impl sp_runtime::traits::Dispatchable for Call {
type RuntimeOrigin = ();
type Config = ();
type Info = ();
type PostInfo = ();

fn dispatch(
self,
_origin: Self::RuntimeOrigin,
) -> sp_runtime::DispatchResultWithInfo<Self::PostInfo> {
unimplemented!("The Call is not expected to be dispatched.")
}
}

/// Name of the parachains pallet at the Westend runtime.
pub const PARAS_PALLET_NAME: &str = "Paras";

Expand All @@ -54,13 +32,6 @@ pub const WITH_WESTEND_GRANDPA_PALLET_NAME: &str = "BridgeWestendGrandpa";
/// Name of the With-Westend parachains bridge pallet instance that is deployed at bridged chains.
pub const WITH_WESTEND_BRIDGE_PARAS_PALLET_NAME: &str = "BridgeWestendParachains";

/// The target length of a session (how often authorities change) on Westend 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 = 10 * time_units::MINUTES;

/// Maximal number of GRANDPA authorities at Westend.
///
/// Corresponds to the `MaxAuthorities` constant value from the Westend runtime configuration.
Expand Down
7 changes: 0 additions & 7 deletions bridges/primitives/chain-wococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ use bp_runtime::decl_bridge_finality_runtime_apis;
/// Wococo Chain
pub type Wococo = PolkadotLike;

/// The target length of a session (how often authorities change) on Wococo 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 = time_units::MINUTES;

/// Name of the With-Wococo GRANDPA pallet instance that is deployed at bridged chains.
pub const WITH_WOCOCO_GRANDPA_PALLET_NAME: &str = "BridgeWococoGrandpa";

Expand Down
2 changes: 2 additions & 0 deletions bridges/relays/bin-substrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ 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" }
bp-statemine = { path = "../../primitives/chain-statemine" }
bp-westend = { path = "../../primitives/chain-westend" }
bridge-runtime-common = { path = "../../bin/runtime-common" }
messages-relay = { path = "../messages" }
Expand All @@ -36,6 +37,7 @@ 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-statemine-client = { path = "../client-statemine" }
relay-substrate-client = { path = "../client-substrate" }
relay-utils = { path = "../utils" }
relay-westend-client = { path = "../client-westend" }
Expand Down
1 change: 0 additions & 1 deletion bridges/relays/bin-substrate/src/chains/millau.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ impl CliChain for Millau {
const RUNTIME_VERSION: Option<RuntimeVersion> = Some(millau_runtime::VERSION);

type KeyPair = sp_core::sr25519::Pair;
type MessagePayload = Vec<u8>;

fn ss58_format() -> u16 {
millau_runtime::SS58Prefix::get() as u16
Expand Down
1 change: 1 addition & 0 deletions bridges/relays/bin-substrate/src/chains/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub mod westend_parachains_to_millau;
mod millau;
mod rialto;
mod rialto_parachain;
mod statemine;
mod westend;

#[cfg(test)]
Expand Down
1 change: 0 additions & 1 deletion bridges/relays/bin-substrate/src/chains/rialto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ impl CliChain for Rialto {
const RUNTIME_VERSION: Option<RuntimeVersion> = Some(rialto_runtime::VERSION);

type KeyPair = sp_core::sr25519::Pair;
type MessagePayload = Vec<u8>;

fn ss58_format() -> u16 {
rialto_runtime::SS58Prefix::get() as u16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ impl CliChain for RialtoParachain {
const RUNTIME_VERSION: Option<RuntimeVersion> = Some(rialto_parachain_runtime::VERSION);

type KeyPair = sp_core::sr25519::Pair;
type MessagePayload = Vec<u8>;

fn ss58_format() -> u16 {
rialto_parachain_runtime::SS58Prefix::get() as u16
Expand Down
34 changes: 34 additions & 0 deletions bridges/relays/bin-substrate/src/chains/statemine.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.

// Parity Bridges Common is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Parity Bridges Common is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.

//! Statemine chain specification for CLI.

use crate::cli::CliChain;
use relay_statemine_client::Statemine;
use sp_version::RuntimeVersion;

impl CliChain for Statemine {
const RUNTIME_VERSION: Option<RuntimeVersion> = Some(bp_statemine::VERSION);

type KeyPair = sp_core::sr25519::Pair;

fn ss58_format() -> u16 {
sp_core::crypto::Ss58AddressFormat::from(
sp_core::crypto::Ss58AddressFormatRegistry::KusamaAccount,
)
.into()
}
}
2 changes: 0 additions & 2 deletions bridges/relays/bin-substrate/src/chains/westend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ impl CliChain for Westend {
const RUNTIME_VERSION: Option<RuntimeVersion> = None;

type KeyPair = sp_core::sr25519::Pair;
type MessagePayload = Vec<u8>;

fn ss58_format() -> u16 {
sp_core::crypto::Ss58AddressFormat::from(
Expand All @@ -38,7 +37,6 @@ impl CliChain for Westmint {
const RUNTIME_VERSION: Option<RuntimeVersion> = None;

type KeyPair = sp_core::sr25519::Pair;
type MessagePayload = Vec<u8>;

fn ss58_format() -> u16 {
sp_core::crypto::Ss58AddressFormat::from(
Expand Down
5 changes: 0 additions & 5 deletions bridges/relays/bin-substrate/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,6 @@ pub trait CliChain: relay_substrate_client::Chain {
/// In case of chains supporting multiple cryptos, pick one used by the CLI.
type KeyPair: sp_core::crypto::Pair;

/// Bridge Message Payload type.
///
/// TODO [#854] This should be removed in favor of target-specifc types.
type MessagePayload;

/// Numeric value of SS58 format.
fn ss58_format() -> u16;
}
Expand Down
24 changes: 24 additions & 0 deletions bridges/relays/client-statemine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "relay-statemine-client"
version = "0.1.0"
authors = ["Parity Technologies <[email protected]>"]
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" }
scale-info = { version = "2.1.1", features = ["derive"] }

# Bridge dependencies

bp-polkadot-core = { path = "../../primitives/polkadot-core" }
bp-statemine = { path = "../../primitives/chain-statemine" }

# Substrate Dependencies

frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
Loading

0 comments on commit 3e00c5c

Please sign in to comment.