Skip to content

Commit e42b256

Browse files
authored
only store header state root (pallet-bridge-grandpa) (paritytech#1699)
1 parent e53f3f3 commit e42b256

File tree

16 files changed

+113
-193
lines changed

16 files changed

+113
-193
lines changed

bin/millau/runtime/src/lib.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,8 @@ parameter_types! {
413413
}
414414

415415
parameter_types! {
416-
/// Maximal size of SCALE-encoded Rialto header.
417-
pub const MaxRialtoHeaderSize: u32 = bp_rialto::MAX_HEADER_SIZE;
418-
419416
/// Maximal number of authorities at Westend.
420417
pub const MaxAuthoritiesAtWestend: u32 = bp_westend::MAX_AUTHORITIES_COUNT;
421-
/// Maximal size of SCALE-encoded Westend header.
422-
pub const MaxWestendHeaderSize: u32 = bp_westend::MAX_HEADER_SIZE;
423418
}
424419

425420
pub type RialtoGrandpaInstance = ();
@@ -432,7 +427,6 @@ impl pallet_bridge_grandpa::Config for Runtime {
432427
type MaxRequests = ConstU32<50>;
433428
type HeadersToKeep = HeadersToKeep;
434429
type MaxBridgedAuthorities = MaxAuthoritiesAtRialto;
435-
type MaxBridgedHeaderSize = MaxRialtoHeaderSize;
436430

437431
type WeightInfo = pallet_bridge_grandpa::weights::BridgeWeight<Runtime>;
438432
}
@@ -443,7 +437,6 @@ impl pallet_bridge_grandpa::Config<WestendGrandpaInstance> for Runtime {
443437
type MaxRequests = ConstU32<50>;
444438
type HeadersToKeep = HeadersToKeep;
445439
type MaxBridgedAuthorities = MaxAuthoritiesAtWestend;
446-
type MaxBridgedHeaderSize = MaxWestendHeaderSize;
447440

448441
type WeightInfo = pallet_bridge_grandpa::weights::BridgeWeight<Runtime>;
449442
}
@@ -871,13 +864,13 @@ impl_runtime_apis! {
871864

872865
impl bp_rialto::RialtoFinalityApi<Block> for Runtime {
873866
fn best_finalized() -> Option<HeaderId<bp_rialto::Hash, bp_rialto::BlockNumber>> {
874-
BridgeRialtoGrandpa::best_finalized().map(|header| header.id())
867+
BridgeRialtoGrandpa::best_finalized()
875868
}
876869
}
877870

878871
impl bp_westend::WestendFinalityApi<Block> for Runtime {
879872
fn best_finalized() -> Option<HeaderId<bp_westend::Hash, bp_westend::BlockNumber>> {
880-
BridgeWestendGrandpa::best_finalized().map(|header| header.id())
873+
BridgeWestendGrandpa::best_finalized()
881874
}
882875
}
883876

bin/rialto-parachain/runtime/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use sp_version::NativeVersion;
4545
use sp_version::RuntimeVersion;
4646

4747
// A few exports that help ease life for downstream crates.
48-
use bp_runtime::{HeaderId, HeaderIdProvider};
48+
use bp_runtime::HeaderId;
4949
pub use frame_support::{
5050
construct_runtime,
5151
dispatch::DispatchClass,
@@ -525,8 +525,6 @@ parameter_types! {
525525

526526
/// Maximal number of authorities at Millau.
527527
pub const MaxAuthoritiesAtMillau: u32 = bp_millau::MAX_AUTHORITIES_COUNT;
528-
/// Maximal size of SCALE-encoded Millau header.
529-
pub const MaxMillauHeaderSize: u32 = bp_millau::MAX_HEADER_SIZE;
530528
}
531529

532530
pub type MillauGrandpaInstance = ();
@@ -539,7 +537,6 @@ impl pallet_bridge_grandpa::Config for Runtime {
539537
type MaxRequests = ConstU32<50>;
540538
type HeadersToKeep = HeadersToKeep;
541539
type MaxBridgedAuthorities = MaxAuthoritiesAtMillau;
542-
type MaxBridgedHeaderSize = MaxMillauHeaderSize;
543540
type WeightInfo = pallet_bridge_grandpa::weights::BridgeWeight<Runtime>;
544541
}
545542

@@ -728,7 +725,7 @@ impl_runtime_apis! {
728725

729726
impl bp_millau::MillauFinalityApi<Block> for Runtime {
730727
fn best_finalized() -> Option<HeaderId<bp_millau::Hash, bp_millau::BlockNumber>> {
731-
BridgeMillauGrandpa::best_finalized().map(|header| header.id())
728+
BridgeMillauGrandpa::best_finalized()
732729
}
733730
}
734731

bin/rialto/runtime/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub mod parachains;
3333
pub mod xcm_config;
3434

3535
use beefy_primitives::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion, ValidatorSet};
36-
use bp_runtime::{HeaderId, HeaderIdProvider};
36+
use bp_runtime::HeaderId;
3737
use pallet_grandpa::{
3838
fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList,
3939
};
@@ -410,8 +410,6 @@ parameter_types! {
410410

411411
/// Maximal number of authorities at Millau.
412412
pub const MaxAuthoritiesAtMillau: u32 = bp_millau::MAX_AUTHORITIES_COUNT;
413-
/// Maximal size of SCALE-encoded Millau header.
414-
pub const MaxMillauHeaderSize: u32 = bp_millau::MAX_HEADER_SIZE;
415413
}
416414

417415
pub type MillauGrandpaInstance = ();
@@ -424,7 +422,6 @@ impl pallet_bridge_grandpa::Config for Runtime {
424422
type MaxRequests = ConstU32<50>;
425423
type HeadersToKeep = HeadersToKeep;
426424
type MaxBridgedAuthorities = MaxAuthoritiesAtMillau;
427-
type MaxBridgedHeaderSize = MaxMillauHeaderSize;
428425
type WeightInfo = pallet_bridge_grandpa::weights::BridgeWeight<Runtime>;
429426
}
430427

@@ -721,7 +718,7 @@ impl_runtime_apis! {
721718

722719
impl bp_millau::MillauFinalityApi<Block> for Runtime {
723720
fn best_finalized() -> Option<HeaderId<bp_millau::Hash, bp_millau::BlockNumber>> {
724-
BridgeMillauGrandpa::best_finalized().map(|header| header.id())
721+
BridgeMillauGrandpa::best_finalized()
725722
}
726723
}
727724

bin/runtime-common/src/messages.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,6 @@ mod tests {
705705
use crate::messages_generation::{
706706
encode_all_messages, encode_lane_data, prepare_messages_storage_proof,
707707
};
708-
use bp_runtime::HeaderOf;
709708
use codec::{Decode, Encode};
710709
use frame_support::weights::Weight;
711710
use sp_core::H256;
@@ -881,17 +880,17 @@ mod tests {
881880
struct BridgedHeaderChain;
882881

883882
impl HeaderChain<BridgedUnderlyingChain> for BridgedHeaderChain {
884-
fn finalized_header(
883+
fn finalized_header_state_root(
885884
_hash: HashOf<BridgedChain>,
886-
) -> Option<HeaderOf<BridgedUnderlyingChain>> {
887-
TEST_BRIDGED_HEADER.with(|h| h.borrow().clone())
885+
) -> Option<HashOf<BridgedChain>> {
886+
TEST_BRIDGED_HEADER.with(|h| h.borrow().clone()).map(|h| *h.state_root())
888887
}
889888
}
890889

891890
struct ThisHeaderChain;
892891

893892
impl HeaderChain<ThisUnderlyingChain> for ThisHeaderChain {
894-
fn finalized_header(_hash: HashOf<ThisChain>) -> Option<HeaderOf<ThisUnderlyingChain>> {
893+
fn finalized_header_state_root(_hash: HashOf<ThisChain>) -> Option<HashOf<ThisChain>> {
895894
unreachable!()
896895
}
897896
}

modules/grandpa/src/extension.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<
4040

4141
let best_finalized = crate::BestFinalized::<T, I>::get();
4242
let best_finalized_number = match best_finalized {
43-
Some((best_finalized_number, _)) => best_finalized_number,
43+
Some(best_finalized_id) => best_finalized_id.number(),
4444
None => return InvalidTransaction::Call.into(),
4545
};
4646

@@ -66,6 +66,7 @@ mod tests {
6666
mock::{run_test, test_header, RuntimeCall, TestNumber, TestRuntime},
6767
BestFinalized,
6868
};
69+
use bp_runtime::HeaderId;
6970
use bp_test_utils::make_default_justification;
7071

7172
fn validate_block_submit(num: TestNumber) -> bool {
@@ -81,7 +82,7 @@ mod tests {
8182

8283
fn sync_to_header_10() {
8384
let header10_hash = sp_core::H256::default();
84-
BestFinalized::<TestRuntime, ()>::put((10, header10_hash));
85+
BestFinalized::<TestRuntime, ()>::put(HeaderId(10, header10_hash));
8586
}
8687

8788
#[test]

0 commit comments

Comments
 (0)