I'm using subxt
with the aim to handle bursts of transactions concurrently through a single account. I understand the nonce must be incremented, however I'm unsure of the exact lifecycle of a tx and at what stage the next nonce is expected.
I have tested with a simple atomic counter that I manually increment, however it seems if increment and submit too fast the tx's never make it into the block.
Do I need to ensure that tx A (nonce 21)
has made it into the block before tx B (nonce 22)
can be submitted?
I'm wondering if there are any typical strategies to handle this, whether some sort of queue is required, or I if can achieve this with a simple counter.
Example
let mut signer = PairSigner::new(pair);
if let Some(nonce) = nonce {
signer.set_nonce(nonce.inc_next());
}
let api = ClientBuilder::new()
.set_url(env.rpc.url.clone())
.build()
.await
.to()?
.to_runtime_api::<RuntimeApi<DefaultConfig, PolkadotExtrinsicParams<DefaultConfig>>>();
let submitted = api
.tx()
.system()
.remark(self.0.as_bytes().to_vec())
.sign_and_submit_then_watch_default(&signer)
.await
.to()?;
let tx = submitted.wait_for_in_block().await?;
let events = tx.wait_for_success().await.to()?;
let hash = events.block_hash();
let header = api
.client
.rpc()
.header(Some(hash))
.await
.to()?
.ok_or_else(|| Error::Generic("extrinsic header is None".into()))?;
Ok(header.number)
Era::Immortal
and they become invalid before making it into the block. Could you post your code please?Era::Immortal
as seen here. Also added a code example