Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only store header state root (pallet-bridge-parachains) #1701

Merged
merged 12 commits into from
Dec 12, 2022
8 changes: 8 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions bin/millau/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ scale-info = { version = "2.1.1", default-features = false, features = ["derive"

bp-messages = { path = "../../../primitives/messages", default-features = false }
bp-millau = { path = "../../../primitives/chain-millau", default-features = false }
bp-parachains = { path = "../../../primitives/parachains", default-features = false }
bp-polkadot-core = { path = "../../../primitives/polkadot-core", default-features = false }
bp-relayers = { path = "../../../primitives/relayers", default-features = false }
bp-rialto = { path = "../../../primitives/chain-rialto", default-features = false }
Expand Down Expand Up @@ -84,6 +85,7 @@ std = [
"beefy-primitives/std",
"bp-messages/std",
"bp-millau/std",
"bp-parachains/std",
"bp-polkadot-core/std",
"bp-relayers/std",
"bp-rialto/std",
Expand Down
34 changes: 13 additions & 21 deletions bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ pub mod rialto_parachain_messages;
pub mod xcm_config;

use beefy_primitives::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion, ValidatorSet};
use bp_runtime::{HeaderId, HeaderIdProvider};
use codec::Decode;
use bp_parachains::SingleParaStoredHeaderDataBuilder;
use bp_runtime::HeaderId;
use pallet_grandpa::{
fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList,
};
Expand Down Expand Up @@ -520,8 +520,8 @@ impl pallet_bridge_messages::Config<WithRialtoParachainMessagesInstance> for Run
parameter_types! {
pub const RialtoParasPalletName: &'static str = bp_rialto::PARAS_PALLET_NAME;
pub const WestendParasPalletName: &'static str = bp_westend::PARAS_PALLET_NAME;
pub const MaxRialtoParaHeadSize: u32 = bp_rialto::MAX_NESTED_PARACHAIN_HEAD_SIZE;
pub const MaxWestendParaHeadSize: u32 = bp_westend::MAX_NESTED_PARACHAIN_HEAD_SIZE;
pub const MaxRialtoParaHeadDataSize: u32 = bp_rialto::MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE;
pub const MaxWestendParaHeadDataSize: u32 = bp_westend::MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE;
}

/// Instance of the with-Rialto parachains pallet.
Expand All @@ -532,9 +532,10 @@ impl pallet_bridge_parachains::Config<WithRialtoParachainsInstance> for Runtime
type WeightInfo = pallet_bridge_parachains::weights::BridgeWeight<Runtime>;
type BridgesGrandpaPalletInstance = RialtoGrandpaInstance;
type ParasPalletName = RialtoParasPalletName;
type TrackedParachains = frame_support::traits::Everything;
type ParaStoredHeaderDataBuilder =
SingleParaStoredHeaderDataBuilder<bp_rialto_parachain::RialtoParachain>;
type HeadsToKeep = HeadersToKeep;
type MaxParaHeadSize = MaxRialtoParaHeadSize;
type MaxParaHeadDataSize = MaxRialtoParaHeadDataSize;
}

/// Instance of the with-Westend parachains pallet.
Expand All @@ -545,9 +546,9 @@ impl pallet_bridge_parachains::Config<WithWestendParachainsInstance> for Runtime
type WeightInfo = pallet_bridge_parachains::weights::BridgeWeight<Runtime>;
type BridgesGrandpaPalletInstance = WestendGrandpaInstance;
type ParasPalletName = WestendParasPalletName;
type TrackedParachains = frame_support::traits::Everything;
type ParaStoredHeaderDataBuilder = SingleParaStoredHeaderDataBuilder<bp_westend::Westmint>;
type HeadsToKeep = HeadersToKeep;
type MaxParaHeadSize = MaxWestendParaHeadSize;
type MaxParaHeadDataSize = MaxWestendParaHeadDataSize;
}

impl pallet_utility::Config for Runtime {
Expand Down Expand Up @@ -886,28 +887,19 @@ impl_runtime_apis! {

impl bp_westend::WestmintFinalityApi<Block> for Runtime {
fn best_finalized() -> Option<HeaderId<bp_westend::Hash, bp_westend::BlockNumber>> {
// the parachains finality pallet is never decoding parachain heads, so it is
// only done in the integration code
use bp_westend::WESTMINT_PARACHAIN_ID;
let encoded_head = pallet_bridge_parachains::Pallet::<
pallet_bridge_parachains::Pallet::<
Runtime,
WithWestendParachainsInstance,
>::best_parachain_head(WESTMINT_PARACHAIN_ID.into())?;
let head = bp_westend::Header::decode(&mut &encoded_head.0[..]).ok()?;
Some(head.id())
>::best_parachain_head_id::<bp_westend::Westmint>().unwrap_or(None)
}
}

impl bp_rialto_parachain::RialtoParachainFinalityApi<Block> for Runtime {
fn best_finalized() -> Option<HeaderId<bp_rialto::Hash, bp_rialto::BlockNumber>> {
// the parachains finality pallet is never decoding parachain heads, so it is
// only done in the integration code
let encoded_head = pallet_bridge_parachains::Pallet::<
pallet_bridge_parachains::Pallet::<
Runtime,
WithRialtoParachainsInstance,
>::best_parachain_head(bp_rialto_parachain::RIALTO_PARACHAIN_ID.into())?;
let head = bp_rialto_parachain::Header::decode(&mut &encoded_head.0[..]).ok()?;
Some(head.id())
>::best_parachain_head_id::<bp_rialto_parachain::RialtoParachain>().unwrap_or(None)
}
}

Expand Down
1 change: 1 addition & 0 deletions modules/parachains/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master",
[dev-dependencies]
bp-header-chain = { path = "../../primitives/header-chain" }
bp-test-utils = { path = "../../primitives/test-utils" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }

[features]
Expand Down
Loading