Change Runtime APIs best_finalized() signature

Change Runtime APIs best_finalized() signature to return Option<HeaderId>

Signed-off-by: Serban Iorga <serban@parity.io>
This commit is contained in:
Serban Iorga
2022-07-28 15:18:40 +03:00
committed by Bastian Köcher
parent f13211344b
commit 7969459d07
14 changed files with 39 additions and 43 deletions
+10 -11
View File
@@ -40,6 +40,7 @@ use crate::{
};
use beefy_primitives::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion, ValidatorSet};
use bp_runtime::{HeaderId, HeaderIdProvider};
use bridge_runtime_common::messages::{
source::estimate_message_dispatch_and_delivery_fee, MessageBridge,
};
@@ -56,9 +57,7 @@ use sp_mmr_primitives::{
};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{
Block as BlockT, Header as HeaderT, IdentityLookup, Keccak256, NumberFor, OpaqueKeys,
},
traits::{Block as BlockT, IdentityLookup, Keccak256, NumberFor, OpaqueKeys},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedPointNumber, FixedU128, Perquintill,
};
@@ -818,19 +817,19 @@ impl_runtime_apis! {
}
impl bp_rialto::RialtoFinalityApi<Block> for Runtime {
fn best_finalized() -> Option<(bp_rialto::BlockNumber, bp_rialto::Hash)> {
BridgeRialtoGrandpa::best_finalized().map(|header| (header.number, header.hash()))
fn best_finalized() -> Option<HeaderId<bp_rialto::Hash, bp_rialto::BlockNumber>> {
BridgeRialtoGrandpa::best_finalized().map(|header| header.id())
}
}
impl bp_westend::WestendFinalityApi<Block> for Runtime {
fn best_finalized() -> Option<(bp_westend::BlockNumber, bp_westend::Hash)> {
BridgeWestendGrandpa::best_finalized().map(|header| (header.number, header.hash()))
fn best_finalized() -> Option<HeaderId<bp_westend::Hash, bp_westend::BlockNumber>> {
BridgeWestendGrandpa::best_finalized().map(|header| header.id())
}
}
impl bp_westend::WestmintFinalityApi<Block> for Runtime {
fn best_finalized() -> Option<(bp_westend::BlockNumber, bp_westend::Hash)> {
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;
@@ -839,12 +838,12 @@ impl_runtime_apis! {
WithWestendParachainsInstance,
>::best_parachain_head(WESTMINT_PARACHAIN_ID.into())?;
let head = bp_westend::Header::decode(&mut &encoded_head.0[..]).ok()?;
Some((*head.number(), head.hash()))
Some(head.id())
}
}
impl bp_rialto_parachain::RialtoParachainFinalityApi<Block> for Runtime {
fn best_finalized() -> Option<(bp_rialto::BlockNumber, bp_rialto::Hash)> {
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::<
@@ -852,7 +851,7 @@ impl_runtime_apis! {
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.number(), head.hash()))
Some(head.id())
}
}