mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 20:21:03 +00:00
Message transactions mortality (#1191)
* transactions mortality in message and complex relays * logging + enable in test deployments * spellcheck * fmt
This commit is contained in:
committed by
Bastian Köcher
parent
e23266c7e6
commit
1ef41a59be
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Polkadot-to-Kusama messages sync entrypoint.
|
||||
|
||||
use std::{ops::RangeInclusive, time::Duration};
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
use codec::Encode;
|
||||
use sp_core::{Bytes, Pair};
|
||||
@@ -41,6 +41,7 @@ use substrate_relay_helper::{
|
||||
},
|
||||
messages_source::SubstrateMessagesSource,
|
||||
messages_target::SubstrateMessagesTarget,
|
||||
STALL_TIMEOUT,
|
||||
};
|
||||
|
||||
/// Polkadot-to-Kusama message lane.
|
||||
@@ -90,6 +91,7 @@ impl SubstrateMessageLane for PolkadotMessagesToKusama {
|
||||
|
||||
fn make_messages_receiving_proof_transaction(
|
||||
&self,
|
||||
best_block_id: PolkadotHeaderId,
|
||||
transaction_nonce: bp_runtime::IndexOf<Polkadot>,
|
||||
_generated_at_block: KusamaHeaderId,
|
||||
proof: <Self::MessageLane as MessageLane>::MessagesReceivingProof,
|
||||
@@ -105,7 +107,10 @@ impl SubstrateMessageLane for PolkadotMessagesToKusama {
|
||||
let transaction = Polkadot::sign_transaction(
|
||||
genesis_hash,
|
||||
&self.message_lane.source_sign,
|
||||
relay_substrate_client::TransactionEra::immortal(),
|
||||
relay_substrate_client::TransactionEra::new(
|
||||
best_block_id,
|
||||
self.message_lane.source_transactions_mortality,
|
||||
),
|
||||
UnsignedTransaction::new(call, transaction_nonce),
|
||||
);
|
||||
log::trace!(
|
||||
@@ -124,6 +129,7 @@ impl SubstrateMessageLane for PolkadotMessagesToKusama {
|
||||
|
||||
fn make_messages_delivery_transaction(
|
||||
&self,
|
||||
best_block_id: KusamaHeaderId,
|
||||
transaction_nonce: bp_runtime::IndexOf<Kusama>,
|
||||
_generated_at_header: PolkadotHeaderId,
|
||||
_nonces: RangeInclusive<MessageNonce>,
|
||||
@@ -145,7 +151,10 @@ impl SubstrateMessageLane for PolkadotMessagesToKusama {
|
||||
let transaction = Kusama::sign_transaction(
|
||||
genesis_hash,
|
||||
&self.message_lane.target_sign,
|
||||
relay_substrate_client::TransactionEra::immortal(),
|
||||
relay_substrate_client::TransactionEra::new(
|
||||
best_block_id,
|
||||
self.message_lane.target_transactions_mortality,
|
||||
),
|
||||
UnsignedTransaction::new(call, transaction_nonce),
|
||||
);
|
||||
log::trace!(
|
||||
@@ -169,7 +178,13 @@ type KusamaTargetClient = SubstrateMessagesTarget<PolkadotMessagesToKusama>;
|
||||
pub async fn run(
|
||||
params: MessagesRelayParams<Polkadot, PolkadotSigningParams, Kusama, KusamaSigningParams>,
|
||||
) -> anyhow::Result<()> {
|
||||
let stall_timeout = Duration::from_secs(5 * 60);
|
||||
let stall_timeout = relay_substrate_client::bidirectional_transaction_stall_timeout(
|
||||
params.source_transactions_mortality,
|
||||
params.target_transactions_mortality,
|
||||
Polkadot::AVERAGE_BLOCK_INTERVAL,
|
||||
Kusama::AVERAGE_BLOCK_INTERVAL,
|
||||
STALL_TIMEOUT,
|
||||
);
|
||||
let relayer_id_at_polkadot = (*params.source_sign.public().as_array_ref()).into();
|
||||
|
||||
let lane_id = params.lane_id;
|
||||
@@ -178,8 +193,10 @@ pub async fn run(
|
||||
message_lane: SubstrateMessageLaneToSubstrate {
|
||||
source_client: source_client.clone(),
|
||||
source_sign: params.source_sign,
|
||||
source_transactions_mortality: params.source_transactions_mortality,
|
||||
target_client: params.target_client.clone(),
|
||||
target_sign: params.target_sign,
|
||||
target_transactions_mortality: params.target_transactions_mortality,
|
||||
relayer_id_at_source: relayer_id_at_polkadot,
|
||||
},
|
||||
};
|
||||
@@ -205,12 +222,17 @@ pub async fn run(
|
||||
Max messages in single transaction: {}\n\t\
|
||||
Max messages size in single transaction: {}\n\t\
|
||||
Max messages weight in single transaction: {}\n\t\
|
||||
Relayer mode: {:?}",
|
||||
Relayer mode: {:?}\n\t\
|
||||
Tx mortality: {:?}/{:?}\n\t\
|
||||
Stall timeout: {:?}",
|
||||
lane.message_lane.relayer_id_at_source,
|
||||
max_messages_in_single_batch,
|
||||
max_messages_size_in_single_batch,
|
||||
max_messages_weight_in_single_batch,
|
||||
params.relayer_mode,
|
||||
params.source_transactions_mortality,
|
||||
params.target_transactions_mortality,
|
||||
stall_timeout,
|
||||
);
|
||||
|
||||
let (metrics_params, metrics_values) = add_standalone_metrics(
|
||||
|
||||
Reference in New Issue
Block a user