Skip to content

Commit d76568e

Browse files
authored
Merge pull request #3 from Moonsong-Labs/betanet-stagenet
Add Betanet <-> Stagenet bridge commands
2 parents 1d20b9b + 4c5a311 commit d76568e

26 files changed

+11168
-9
lines changed

Cargo.lock

Lines changed: 62 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ members = [
1818
"relay-clients/client-polkadot-bulletin",
1919
"relay-clients/client-rococo",
2020
"relay-clients/client-westend",
21+
"relay-clients/client-moonbase",
2122
"chains/chain-bridge-hub-polkadot",
2223
"chains/chain-bridge-hub-kusama",
24+
"chains/chain-moonbase",
2325
"chains/chain-polkadot",
2426
"chains/chain-kusama",
2527
"substrate-relay",
@@ -81,6 +83,7 @@ bp-parachains = { git = "https://github.com/paritytech/polkadot-sdk", branch = "
8183
bp-polkadot = { path = "./chains/chain-polkadot" }
8284
bp-polkadot-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
8385
bp-kusama = { path = "./chains/chain-kusama" }
86+
bp-moonbase = { path = "./chains/chain-moonbase" }
8487
bp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
8588
bridge-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
8689
relay-substrate-client = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
@@ -128,6 +131,7 @@ relay-polkadot-client = { path = "./relay-clients/client-polkadot" }
128131
relay-polkadot-bulletin-client = { path = "./relay-clients/client-polkadot-bulletin" }
129132
relay-rococo-client = { path = "./relay-clients/client-rococo" }
130133
relay-westend-client = { path = "./relay-clients/client-westend" }
134+
relay-moonbase-client = { path = "./relay-clients/client-moonbase" }
131135
substrate-relay-helper = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
132136
bp-test-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
133137
hex-literal = "0.4"

chains/chain-moonbase/Cargo.toml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[package]
2+
name = "bp-moonbase"
3+
description = "Primitives of Moonbase parachain runtime."
4+
version = "0.6.0"
5+
authors.workspace = true
6+
edition.workspace = true
7+
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
8+
repository.workspace = true
9+
10+
[lints]
11+
workspace = true
12+
13+
[dependencies]
14+
15+
libsecp256k1 = { version = "0.7", default-features = false, features = ["hmac"] }
16+
sha3 = { version = "0.10", default-features = false }
17+
impl-serde = { version = "0.4.0", default-features = false }
18+
log = { workspace = true }
19+
codec = { workspace = true }
20+
scale-info = { workspace = true }
21+
serde = { workspace = true, features = ["derive"] }
22+
23+
# Bridge Dependencies
24+
25+
bp-bridge-hub-cumulus = { workspace = true }
26+
bp-messages = { workspace = true }
27+
bp-runtime = { workspace = true }
28+
29+
# Substrate Based Dependencies
30+
31+
frame-support = { workspace = true }
32+
sp-api = { workspace = true }
33+
sp-runtime = { workspace = true }
34+
sp-std = { workspace = true }
35+
sp-core = { workspace = true }
36+
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master"}
37+
38+
[features]
39+
default = ["std"]
40+
std = [
41+
"bp-bridge-hub-cumulus/std",
42+
"bp-messages/std",
43+
"bp-runtime/std",
44+
"frame-support/std",
45+
"sp-api/std",
46+
"sp-runtime/std",
47+
"sp-std/std",
48+
"sp-core/std",
49+
"sp-io/std"
50+
]
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// Copyright 2025 Moonbeam foundation
2+
// This file is part of Moonbeam.
3+
4+
// Moonbeam is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// Moonbeam is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.
16+
17+
//! # Betanet bridge primitives
18+
19+
use bp_messages::{ChainWithMessages, MessageNonce};
20+
use bp_runtime::{Chain, ChainId, Parachain};
21+
use frame_support::{dispatch::DispatchClass, weights::Weight};
22+
use sp_runtime::StateVersion;
23+
24+
pub use crate::{
25+
AccountId, AccountInfoStorageMapKeyProvider, Balance, BlockLength, BlockNumber, BlockWeights,
26+
Hash, Hasher, Header, Nonce, Signature, UncheckedExtrinsic, MAX_BRIDGE_HUB_HEADER_SIZE,
27+
MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
28+
};
29+
30+
/// Identifier of Betanet parachain.
31+
pub const PARACHAIN_ID: u32 = 888;
32+
33+
/// Name of the messages pallet instance that is deployed at bridged chains.
34+
pub const WITH_BRIDGE_MESSAGES_PALLET_NAME: &str = "BridgeMessages";
35+
36+
/// Betanet parachain.
37+
pub struct Betanet;
38+
39+
impl Chain for Betanet {
40+
const ID: ChainId = *b"mnbb";
41+
42+
type BlockNumber = BlockNumber;
43+
type Hash = Hash;
44+
type Hasher = Hasher;
45+
type Header = Header;
46+
47+
type AccountId = AccountId;
48+
type Balance = Balance;
49+
type Nonce = Nonce;
50+
type Signature = Signature;
51+
52+
const STATE_VERSION: StateVersion = StateVersion::V1;
53+
54+
fn max_extrinsic_size() -> u32 {
55+
*BlockLength::get().max.get(DispatchClass::Normal)
56+
}
57+
58+
fn max_extrinsic_weight() -> Weight {
59+
BlockWeights::get()
60+
.get(DispatchClass::Normal)
61+
.max_extrinsic
62+
.unwrap_or(Weight::MAX)
63+
}
64+
}
65+
66+
impl Parachain for Betanet {
67+
const PARACHAIN_ID: u32 = PARACHAIN_ID;
68+
const MAX_HEADER_SIZE: u32 = MAX_BRIDGE_HUB_HEADER_SIZE;
69+
}
70+
71+
impl ChainWithMessages for Betanet {
72+
const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = WITH_BRIDGE_MESSAGES_PALLET_NAME;
73+
74+
const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
75+
MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
76+
const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
77+
MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
78+
}

chains/chain-moonbase/src/lib.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2025 Moonbeam foundation
2+
// This file is part of Moonbeam.
3+
4+
// Moonbeam is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// Moonbeam is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.
16+
17+
//! # Betanet bridge primitives
18+
19+
#![cfg_attr(not(feature = "std"), no_std)]
20+
21+
pub use bp_bridge_hub_cumulus::{
22+
BlockLength, BlockWeights, Hasher, Nonce, SignedBlock, AVERAGE_BLOCK_INTERVAL,
23+
MAX_BRIDGE_HUB_HEADER_SIZE, MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
24+
MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
25+
};
26+
use bp_runtime::{decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis};
27+
// TODO: Temporary, remove once moonbeam has been updated to stable2503
28+
mod temporary;
29+
pub use temporary::{
30+
AccountId, AccountInfoStorageMapKeyProvider, Balance, BlockNumber, Hash, Header, Signature,
31+
UncheckedExtrinsic,
32+
};
33+
34+
pub mod betanet;
35+
pub mod stagenet;
36+
37+
/// Bridge lane identifier.
38+
pub type LaneId = bp_messages::HashedLaneId;
39+
40+
decl_bridge_finality_runtime_apis!(moonbase_westend);
41+
decl_bridge_messages_runtime_apis!(moonbase_westend, LaneId);

0 commit comments

Comments
 (0)