mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 23:21:02 +00:00
63 lines
2.5 KiB
Rust
63 lines
2.5 KiB
Rust
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
|
// This file is part of Parity Bridges Common.
|
|
|
|
// Parity Bridges Common is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
|
|
// Parity Bridges Common is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//! Westend-to-Millau headers sync entrypoint.
|
|
|
|
use crate::finality_pipeline::{SubstrateFinalitySyncPipeline, SubstrateFinalityToSubstrate};
|
|
|
|
use bp_header_chain::justification::GrandpaJustification;
|
|
use codec::Encode;
|
|
use relay_millau_client::{Millau, SigningParams as MillauSigningParams};
|
|
use relay_substrate_client::{Chain, TransactionSignScheme};
|
|
use relay_utils::metrics::MetricsParams;
|
|
use relay_westend_client::{SyncHeader as WestendSyncHeader, Westend};
|
|
use sp_core::{Bytes, Pair};
|
|
|
|
/// Westend-to-Millau finality sync pipeline.
|
|
pub(crate) type WestendFinalityToMillau = SubstrateFinalityToSubstrate<Westend, Millau, MillauSigningParams>;
|
|
|
|
impl SubstrateFinalitySyncPipeline for WestendFinalityToMillau {
|
|
const BEST_FINALIZED_SOURCE_HEADER_ID_AT_TARGET: &'static str = bp_westend::BEST_FINALIZED_WESTEND_HEADER_METHOD;
|
|
|
|
type TargetChain = Millau;
|
|
|
|
fn customize_metrics(params: MetricsParams) -> anyhow::Result<MetricsParams> {
|
|
crate::chains::add_polkadot_kusama_price_metrics::<Self>(Some(finality_relay::metrics_prefix::<Self>()), params)
|
|
}
|
|
|
|
fn transactions_author(&self) -> bp_millau::AccountId {
|
|
(*self.target_sign.public().as_array_ref()).into()
|
|
}
|
|
|
|
fn make_submit_finality_proof_transaction(
|
|
&self,
|
|
transaction_nonce: <Millau as Chain>::Index,
|
|
header: WestendSyncHeader,
|
|
proof: GrandpaJustification<bp_westend::Header>,
|
|
) -> Bytes {
|
|
let call = millau_runtime::BridgeGrandpaWestendCall::<
|
|
millau_runtime::Runtime,
|
|
millau_runtime::WestendGrandpaInstance,
|
|
>::submit_finality_proof(header.into_inner(), proof)
|
|
.into();
|
|
|
|
let genesis_hash = *self.target_client.genesis_hash();
|
|
let transaction = Millau::sign_transaction(genesis_hash, &self.target_sign, transaction_nonce, call);
|
|
|
|
Bytes(transaction.encode())
|
|
}
|
|
}
|