mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 22:45:40 +00:00
Add Bridge Header Sync to Rococo Runtime (#2983)
* Add bridges code to workspace * Add Rococo and Wococo bridge instances to Rococo runtime * Add Rococo and Wococo runtime APIs * Add GenesisConfig parameters for bridge pallet * Update Rococo spec_version used by bridge relayer * Add scripts for running Rococo and Wococo dev nodes * Add scripts for running Rococo<>Wococo header sync * Apply patch for build artifact location * Remove bridges crates from workspace * Downgrade async related dependencies * Change bridge pallet owner to be `root_key` * Bump number of `MaxRequests` allowed * Revert changes in `bridges` subtree folder * Use correct account for Sudo * Add comment explaining duplicate bridge pallets * Remove WeightInfo comment. Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
This commit is contained in:
@@ -68,6 +68,11 @@ xcm-executor = { package = "xcm-executor", path = "../../xcm/xcm-executor", defa
|
||||
xcm-builder = { package = "xcm-builder", path = "../../xcm/xcm-builder", default-features = false }
|
||||
pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false }
|
||||
|
||||
# Bridge Dependencies
|
||||
bp-rococo = { path = "../../bridges/primitives/chain-rococo", default-features = false }
|
||||
bp-wococo = { path = "../../bridges/primitives/chain-wococo", default-features = false }
|
||||
pallet-bridge-grandpa = { path = "../../bridges/modules/grandpa", default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
substrate-wasm-builder = "3.0.0"
|
||||
|
||||
@@ -77,6 +82,8 @@ no_std = []
|
||||
std = [
|
||||
"authority-discovery-primitives/std",
|
||||
"babe-primitives/std",
|
||||
"bp-rococo/std",
|
||||
"bp-wococo/std",
|
||||
"parity-scale-codec/std",
|
||||
"frame-executive/std",
|
||||
"pallet-authority-discovery/std",
|
||||
@@ -84,6 +91,7 @@ std = [
|
||||
"pallet-babe/std",
|
||||
"beefy-primitives/std",
|
||||
"pallet-balances/std",
|
||||
"pallet-bridge-grandpa/std",
|
||||
"pallet-collective/std",
|
||||
"pallet-beefy/std",
|
||||
"pallet-grandpa/std",
|
||||
|
||||
@@ -236,6 +236,12 @@ construct_runtime! {
|
||||
Beefy: pallet_beefy::{Pallet, Config<T>, Storage},
|
||||
MmrLeaf: mmr_common::{Pallet, Storage},
|
||||
|
||||
// It might seem strange that we add both sides of the bridge to the same runtime. We do this because this
|
||||
// runtime as shared by both the Rococo and Wococo chains. When running as Rococo we only use
|
||||
// `BridgeWococoGrandpa`, and vice versa.
|
||||
BridgeRococoGrandpa: pallet_bridge_grandpa::{Pallet, Call, Storage, Config<T>} = 40,
|
||||
BridgeWococoGrandpa: pallet_bridge_grandpa::<Instance1>::{Pallet, Call, Storage, Config<T>} = 41,
|
||||
|
||||
// Validator Manager pallet.
|
||||
ValidatorManager: validator_manager::{Pallet, Call, Storage, Event<T>},
|
||||
|
||||
@@ -794,6 +800,38 @@ impl mmr_common::Config for Runtime {
|
||||
type ParachainHeads = Paras;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
// This is a pretty unscientific cap.
|
||||
//
|
||||
// Note that once this is hit the pallet will essentially throttle incoming requests down to one
|
||||
// call per block.
|
||||
pub const MaxRequests: u32 = 4 * HOURS as u32;
|
||||
|
||||
// Number of headers to keep.
|
||||
//
|
||||
// Assuming the worst case of every header being finalized, we will keep headers at least for a
|
||||
// week.
|
||||
pub const HeadersToKeep: u32 = 7 * DAYS as u32;
|
||||
}
|
||||
|
||||
pub type RococoGrandpaInstance = ();
|
||||
impl pallet_bridge_grandpa::Config for Runtime {
|
||||
type BridgedChain = bp_rococo::Rococo;
|
||||
type MaxRequests = MaxRequests;
|
||||
type HeadersToKeep = HeadersToKeep;
|
||||
|
||||
type WeightInfo = pallet_bridge_grandpa::weights::RialtoWeight<Runtime>;
|
||||
}
|
||||
|
||||
pub type WococoGrandpaInstance = pallet_bridge_grandpa::Instance1;
|
||||
impl pallet_bridge_grandpa::Config<WococoGrandpaInstance> for Runtime {
|
||||
type BridgedChain = bp_wococo::Wococo;
|
||||
type MaxRequests = MaxRequests;
|
||||
type HeadersToKeep = HeadersToKeep;
|
||||
|
||||
type WeightInfo = pallet_bridge_grandpa::weights::RialtoWeight<Runtime>;
|
||||
}
|
||||
|
||||
impl Randomness<Hash, BlockNumber> for ParentHashRandomness {
|
||||
fn random(subject: &[u8]) -> (Hash, BlockNumber) {
|
||||
(
|
||||
@@ -1222,6 +1260,28 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl bp_rococo::RococoFinalityApi<Block> for Runtime {
|
||||
fn best_finalized() -> (bp_rococo::BlockNumber, bp_rococo::Hash) {
|
||||
let header = BridgeRococoGrandpa::best_finalized();
|
||||
(header.number, header.hash())
|
||||
}
|
||||
|
||||
fn is_known_header(hash: bp_rococo::Hash) -> bool {
|
||||
BridgeRococoGrandpa::is_known_header(hash)
|
||||
}
|
||||
}
|
||||
|
||||
impl bp_wococo::WococoFinalityApi<Block> for Runtime {
|
||||
fn best_finalized() -> (bp_wococo::BlockNumber, bp_wococo::Hash) {
|
||||
let header = BridgeWococoGrandpa::best_finalized();
|
||||
(header.number, header.hash())
|
||||
}
|
||||
|
||||
fn is_known_header(hash: bp_wococo::Hash) -> bool {
|
||||
BridgeWococoGrandpa::is_known_header(hash)
|
||||
}
|
||||
}
|
||||
|
||||
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
|
||||
fn account_nonce(account: AccountId) -> Nonce {
|
||||
System::account_nonce(account)
|
||||
|
||||
Reference in New Issue
Block a user