mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 19:51:02 +00:00
Fix transactions mortality (#1196)
* added lost stall timeout fix * use best_block.parent() to start mortal tx era * fmt * Revert "revert messages transactions mortality" This reverts commit 77776357dafdfa80dcb3ec307d76fcfd0d5195bb.
This commit is contained in:
committed by
Bastian Köcher
parent
e675b13042
commit
cc6320c3f9
@@ -34,7 +34,7 @@ use jsonrpsee_ws_client::{
|
|||||||
},
|
},
|
||||||
WsClient as RpcClient, WsClientBuilder as RpcClientBuilder,
|
WsClient as RpcClient, WsClientBuilder as RpcClientBuilder,
|
||||||
};
|
};
|
||||||
use num_traits::{Bounded, Zero};
|
use num_traits::{Bounded, CheckedSub, One, Zero};
|
||||||
use pallet_balances::AccountData;
|
use pallet_balances::AccountData;
|
||||||
use pallet_transaction_payment::InclusionFee;
|
use pallet_transaction_payment::InclusionFee;
|
||||||
use relay_utils::{relay_loop::RECONNECT_DELAY, HeaderId};
|
use relay_utils::{relay_loop::RECONNECT_DELAY, HeaderId};
|
||||||
@@ -349,7 +349,17 @@ impl<C: Chain> Client<C> {
|
|||||||
let _guard = self.submit_signed_extrinsic_lock.lock().await;
|
let _guard = self.submit_signed_extrinsic_lock.lock().await;
|
||||||
let transaction_nonce = self.next_account_index(extrinsic_signer).await?;
|
let transaction_nonce = self.next_account_index(extrinsic_signer).await?;
|
||||||
let best_header = self.best_header().await?;
|
let best_header = self.best_header().await?;
|
||||||
let best_header_id = HeaderId(*best_header.number(), best_header.hash());
|
|
||||||
|
// By using parent of best block here, we are protecing again best-block reorganizations.
|
||||||
|
// E.g. transaction my have been submitted when the best block was `A[num=100]`. Then it has
|
||||||
|
// been changed to `B[num=100]`. Hash of `A` has been included into transaction signature
|
||||||
|
// payload. So when signature will be checked, the check will fail and transaction will be
|
||||||
|
// dropped from the pool.
|
||||||
|
let best_header_id = match best_header.number().checked_sub(&One::one()) {
|
||||||
|
Some(parent_block_number) => HeaderId(parent_block_number, *best_header.parent_hash()),
|
||||||
|
None => HeaderId(*best_header.number(), best_header.hash()),
|
||||||
|
};
|
||||||
|
|
||||||
self.jsonrpsee_execute(move |client| async move {
|
self.jsonrpsee_execute(move |client| async move {
|
||||||
let extrinsic = prepare_extrinsic(best_header_id, transaction_nonce);
|
let extrinsic = prepare_extrinsic(best_header_id, transaction_nonce);
|
||||||
let tx_hash = Substrate::<C>::author_submit_extrinsic(&*client, extrinsic).await?;
|
let tx_hash = Substrate::<C>::author_submit_extrinsic(&*client, extrinsic).await?;
|
||||||
|
|||||||
@@ -220,7 +220,11 @@ async fn background_task<P: SubstrateFinalitySyncPipeline>(
|
|||||||
P::TargetChain::AVERAGE_BLOCK_INTERVAL,
|
P::TargetChain::AVERAGE_BLOCK_INTERVAL,
|
||||||
),
|
),
|
||||||
recent_finality_proofs_limit: RECENT_FINALITY_PROOFS_LIMIT,
|
recent_finality_proofs_limit: RECENT_FINALITY_PROOFS_LIMIT,
|
||||||
stall_timeout: STALL_TIMEOUT,
|
stall_timeout: relay_substrate_client::transaction_stall_timeout(
|
||||||
|
target_transactions_mortality,
|
||||||
|
TargetChain::AVERAGE_BLOCK_INTERVAL,
|
||||||
|
STALL_TIMEOUT,
|
||||||
|
),
|
||||||
only_mandatory_headers,
|
only_mandatory_headers,
|
||||||
},
|
},
|
||||||
MetricsParams::disabled(),
|
MetricsParams::disabled(),
|
||||||
|
|||||||
Reference in New Issue
Block a user