Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
cache-all-crates: true

- name: Cargo check
run: cargo check
run: cargo check --workspace

check-benchmarking:
name: Cargo check (benchmarking)
Expand All @@ -70,10 +70,13 @@ jobs:
cache-on-failure: true
cache-all-crates: true

- name: Cargo check (benchmarking)
run: >
cd node &&
cargo check --features=runtime-benchmarks
- name: Cargo check (Rococo) (benchmarking)
run: |
cargo check --workspace --features=rococo,runtime-benchmarks

#- name: Cargo check (Polkadot) (benchmarking)
# run: |
# cargo check --workspace --features=polkadot,runtime-benchmarks

test:
name: Test
Expand All @@ -93,6 +96,17 @@ jobs:
cache-on-failure: true
cache-all-crates: true

# TODO: enable `--all-features`.
- name: Run tests
run: cargo test --workspace
run: |
cargo test --workspace
cargo test --workspace --features=runtime-benchmarks

- name: Run (Rococo) runtime tests
run: |
cargo test -p polkadot-bulletin-chain-runtime --features=rococo
cargo test -p polkadot-bulletin-chain-runtime --features=rococo,runtime-benchmarks

#- name: Run (Polkadot) runtime tests
# run: |
# cargo test -p polkadot-bulletin-chain-runtime --features=polkadot
# cargo test -p polkadot-bulletin-chain-runtime --features=polkadot,runtime-benchmarks
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
- name: Install Rust
run: |
rustup update stable --no-self-update
rustup target add wasm32-unknown-unknown
rustup target add wasm32v1-none

- name: Install linux dependencies
if: (matrix.os == '' || startsWith(matrix.os, 'ubuntu'))
Expand Down
8 changes: 5 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ repository = "https://github.com/zdave-parity/polkadot-bulletin-chain.git"

[workspace.dependencies]
array-bytes = { version = "6.1" }
cfg-if = { version = "1.0" }
clap = { version = "4.2.5" }
codec = { package = "parity-scale-codec", version = "3.7.5", default-features = false }
futures = { version = "0.3.21" }
Expand All @@ -15,8 +16,8 @@ scale-info = { version = "2.11.6", default-features = false }
serde = { version = "1.0.126" }
serde_json = { version = "1.0.132", default-features = false }
static_assertions = { version = "1.1" }
try-runtime-cli = { version = "0.42" }
tracing = { version = "0.1.41", default-features = false }
try-runtime-cli = { version = "0.42" }

[workspace]
resolver = "2"
Expand All @@ -29,4 +30,6 @@ members = [
"runtime",
]
[profile.release]
# Polkadot runtime requires unwinding.
opt-level = 3
panic = "unwind"
11 changes: 8 additions & 3 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ try-runtime-cli = { optional = true, workspace = true }
substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" }

[features]
default = []
default = [
# TODO: temporary let's activate rococo by default
"rococo",
]
# Dependencies that are only required if runtime benchmarking should be built.
runtime-benchmarks = [
"frame-benchmarking-cli/runtime-benchmarks",
Expand All @@ -83,7 +86,9 @@ try-runtime = [
"frame-system/try-runtime",
"polkadot-bulletin-chain-runtime/try-runtime",
"sp-runtime/try-runtime",
"try-runtime-cli?/try-runtime",
"try-runtime-cli/try-runtime",
]
# To bridge with Rococo Bridge Hub instead of Polkadot Bridge Hub
# To bridge with Rococo Bridge Hub
rococo = ["polkadot-bulletin-chain-runtime/rococo"]
# To bridge with PeoplePolkadot
polkadot = ["polkadot-bulletin-chain-runtime/polkadot"]
1 change: 0 additions & 1 deletion pallets/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ codec = { workspace = true }
scale-info = { features = ["derive"], workspace = true }

polkadot-sdk-frame = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", default-features = false, features = [
"experimental",
"runtime",
] }

Expand Down
1 change: 0 additions & 1 deletion pallets/relayer-set/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ log = { workspace = true, default-features = true }
scale-info = { features = ["derive"], workspace = true }

polkadot-sdk-frame = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", default-features = false, features = [
"experimental",
"runtime",
] }

Expand Down
1 change: 0 additions & 1 deletion pallets/transaction-storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ log = { workspace = true, default-features = true }
scale-info = { features = ["derive"], workspace = true }

polkadot-sdk-frame = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", default-features = false, features = [
"experimental",
"runtime",
] }
sp-transaction-storage-proof = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", default-features = false }
Expand Down
1 change: 0 additions & 1 deletion pallets/validator-set/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ log = { workspace = true, default-features = true }
scale-info = { features = ["derive"], workspace = true }

polkadot-sdk-frame = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", default-features = false, features = [
"experimental",
"runtime",
] }
sp-staking = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", default-features = false }
Expand Down
10 changes: 8 additions & 2 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repository = "https://github.com/paritytech/polkadot-bulletin-chain/"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
cfg-if = { workspace = true }
codec = { workspace = true, features = ["derive"] }
log = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
Expand Down Expand Up @@ -80,11 +81,12 @@ xcm = { default-features = false, git = "https://github.com/paritytech/polkadot-
xcm-builder = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", package = "staging-xcm-builder" }
xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", package = "staging-xcm-executor" }

# TODO: just to pass `--features runtime-benchmarks`
# TODO: just to pass `--features runtime-benchmarks` or `--features try-runtime`
pallet-xcm = { optional = true, default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" }
pallet-staking = { optional = true, default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" }
sp-staking = { optional = true, default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" }
parachains-common = { optional = true, default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" }
pallet-revive = { optional = true, default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602" }

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "db5e645422ccf952018a3c466a33fef477858602", optional = true }
Expand Down Expand Up @@ -163,6 +165,7 @@ std = [
"xcm/std",

"pallet-bridge-relayers/std",
"pallet-revive?/std",
"pallet-staking?/std",
"pallet-xcm?/std",
"parachains-common?/std",
Expand Down Expand Up @@ -202,6 +205,7 @@ runtime-benchmarks = [
"xcm-executor/runtime-benchmarks",
"xcm/runtime-benchmarks",

"pallet-revive?/runtime-benchmarks",
"pallet-staking/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
Expand All @@ -227,7 +231,8 @@ try-runtime = [

"pallet-bridge-relayers/try-runtime",
"pallet-relayer-set/try-runtime",
"pallet-staking?/try-runtime",
"pallet-revive/try-runtime",
"pallet-staking/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-transaction-storage/try-runtime",
"pallet-validator-set/try-runtime",
Expand All @@ -237,3 +242,4 @@ try-runtime = [
"sp-runtime/try-runtime",
]
rococo = []
polkadot = []
15 changes: 7 additions & 8 deletions runtime/src/bridge_config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! With Polkadot Bridge Hub bridge configuration.
#![cfg(feature = "rococo")]

//! With Rococo Bridge Hub bridge configuration.

use crate::{
xcm_config::{decode_bridge_message, XcmConfig},
Expand All @@ -25,7 +27,6 @@ use xcm_executor::XcmExecutor;
pub const XCM_LANE: LegacyLaneId = LegacyLaneId([0, 0, 0, 0]);

parameter_types! {
// TODO: (change to Polkadot - or make this `pub storage` for supporting Rococo and Polkadot)
pub RococoGlobalConsensusNetwork: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);
pub BridgedNetwork: NetworkId = RococoGlobalConsensusNetwork::get();
pub RococoGlobalConsensusNetworkLocation: Location = Location::new(
Expand All @@ -41,8 +42,6 @@ parameter_types! {
/// A name of parachains pallet at Pokadot.
pub const AtRococoParasPalletName: &'static str = bp_rococo::PARAS_PALLET_NAME;

// /// Chain identifier of Polkadot Bridge Hub.
// pub const BridgeHubPolkadotChainId: ChainId = bp_runtime::BRIDGE_HUB_POLKADOT_CHAIN_ID;
/// A number of Polkadot Bridge Hub head digests that we keep in the storage.
pub const BridgeHubRococoHeadsToKeep: u32 = 1024;
/// A maximal size of Polkadot Bridge Hub head digest.
Expand Down Expand Up @@ -244,8 +243,8 @@ where
.map_err(drop)
.and_then(|payload| decode_bridge_message(payload).map(|(_, xcm)| xcm).map_err(drop))
.and_then(|xcm| xcm.try_into().map_err(drop))
// TODO: FAIL-CI Weight::MAX maybe change for something else, hard-coded or Weight::MAX/4...
// TODO: (real weights) https://github.com/paritytech/polkadot-bulletin-chain/issues/22
// TODO: FAIL-CI Weight::MAX maybe change for something else, hard-coded or
// Weight::MAX/4... TODO: (real weights) https://github.com/paritytech/polkadot-bulletin-chain/issues/22
.and_then(|xcm| XcmExecutor::<XcmConfig>::prepare(xcm, Weight::MAX).map_err(drop))
.map(|weighed_xcm| weighed_xcm.weight_of())
.unwrap_or(Weight::zero())
Expand Down Expand Up @@ -305,8 +304,8 @@ where
}
}

/// Export XCM messages to be relayed to the Polkadot Bridge Hub chain.
pub type ToBridgeHubRococoHaulBlobExporter = HaulBlobExporter<
/// Export XCM messages to be relayed to the Rococo Bridge Hub chain.
pub type ToBridgeHaulBlobExporter = HaulBlobExporter<
XcmBlobHauler<Runtime, WithBridgeHubRococoMessagesInstance>,
RococoGlobalConsensusNetworkLocation,
AlwaysV5,
Expand Down
50 changes: 42 additions & 8 deletions runtime/src/genesis_config_presets.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
use crate::{
bridge_config::XCM_LANE, opaque::SessionKeys, AccountId, BabeConfig, BridgeRococoGrandpaConfig,
BridgeRococoMessagesConfig, BridgeRococoParachainsConfig, RelayerSetConfig,
RuntimeGenesisConfig, SessionConfig, Signature, SudoConfig, ValidatorSetConfig,
BABE_GENESIS_EPOCH_CONFIG,
opaque::SessionKeys, AccountId, BabeConfig, RelayerSetConfig, RuntimeGenesisConfig,
SessionConfig, Signature, SudoConfig, ValidatorSetConfig, BABE_GENESIS_EPOCH_CONFIG,
};

#[cfg(feature = "polkadot")]
use crate::{
bridge_config::XCM_LANE, BridgePolkadotGrandpaConfig, BridgePolkadotMessagesConfig,
BridgePolkadotParachainsConfig,
};
#[cfg(feature = "rococo")]
use crate::{
bridge_config::XCM_LANE, BridgeRococoGrandpaConfig, BridgeRococoMessagesConfig,
BridgeRococoParachainsConfig,
};

use scale_info::prelude::format;
use sp_consensus_babe::AuthorityId as BabeId;
use sp_consensus_grandpa::AuthorityId as GrandpaId;
Expand Down Expand Up @@ -45,6 +55,7 @@ fn session_keys(babe: BabeId, grandpa: GrandpaId) -> SessionKeys {
/// Configure initial storage state for FRAME modules.
fn testnet_genesis(
initial_authorities: Vec<(AccountId, BabeId, GrandpaId)>,
bridges_pallet_owner: Option<AccountId>,
root_key: AccountId,
) -> serde_json::Value {
let config = RuntimeGenesisConfig {
Expand Down Expand Up @@ -74,16 +85,35 @@ fn testnet_genesis(
// would want to use separate keys for the relayers.
initial_relayers: initial_authorities.into_iter().map(|x| x.0).collect::<Vec<_>>(),
},
#[cfg(feature = "rococo")]
bridge_rococo_grandpa: BridgeRococoGrandpaConfig {
owner: Some(root_key.clone()),
owner: bridges_pallet_owner.clone(),
..Default::default()
},
#[cfg(feature = "rococo")]
bridge_rococo_parachains: BridgeRococoParachainsConfig {
owner: Some(root_key.clone()),
owner: bridges_pallet_owner.clone(),
..Default::default()
},
#[cfg(feature = "rococo")]
bridge_rococo_messages: BridgeRococoMessagesConfig {
owner: Some(root_key),
owner: bridges_pallet_owner,
opened_lanes: vec![XCM_LANE],
..Default::default()
},
#[cfg(feature = "polkadot")]
bridge_polkadot_grandpa: BridgePolkadotGrandpaConfig {
owner: bridges_pallet_owner.clone(),
..Default::default()
},
#[cfg(feature = "polkadot")]
bridge_polkadot_parachains: BridgePolkadotParachainsConfig {
owner: bridges_pallet_owner.clone(),
..Default::default()
},
#[cfg(feature = "polkadot")]
bridge_polkadot_messages: BridgePolkadotMessagesConfig {
owner: bridges_pallet_owner,
opened_lanes: vec![XCM_LANE],
..Default::default()
},
Expand All @@ -99,6 +129,8 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
sp_genesis_builder::DEV_RUNTIME_PRESET => testnet_genesis(
// Initial PoA authorities
vec![authority_keys_from_seed("Alice")],
// Bridges pallet owner
Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
// Sudo account
get_account_id_from_seed::<sr25519::Public>("Alice"),
),
Expand All @@ -110,14 +142,16 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
authority_keys_from_seed("Bob"),
authority_keys_from_seed("Bob//stash"),
],
// Bridges pallet owner
Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
// Sudo account
get_account_id_from_seed::<sr25519::Public>("Alice"),
),
_ => return None,
};
Some(
serde_json::to_string(&patch)
.expect("serialization to json is expected to work. qed.")
.expect("serialization to JSON is expected to work. qed.")
.into_bytes(),
)
}
Expand Down
Loading