@@ -4,6 +4,7 @@ use strata_db::{
44 traits:: SequencerDatabase ,
55 types:: { BlobEntry , BlobL1Status , L1TxStatus } ,
66} ;
7+ use strata_primitives:: buf:: Buf32 ;
78use strata_state:: da_blob:: { BlobDest , BlobIntent } ;
89use strata_status:: StatusTx ;
910use strata_storage:: ops:: inscription:: { Context , InscriptionDataOps } ;
@@ -18,6 +19,9 @@ use crate::{
1819 writer:: { builder:: InscriptionError , signer:: create_and_sign_blob_inscriptions} ,
1920} ;
2021
22+ const SIGN_MAX_RETRIES : u8 = 3 ;
23+ const BASE_SIGN_DELAY : u64 = 3 ; // Seconds
24+
2125/// A handle to the Inscription task.
2226pub struct InscriptionHandle {
2327 ops : Arc < InscriptionDataOps > ,
@@ -130,8 +134,10 @@ fn get_next_blobidx_to_watch(insc_ops: &InscriptionDataOps) -> anyhow::Result<u6
130134}
131135
132136/// Watches for inscription transactions status in bitcoin. Note that this watches for each
133- /// inscription until it is confirmed
134- /// Watches for inscription transactions status in the Bitcoin blockchain.
137+ /// inscription until it is confirmed.
138+ /// Watches for inscription transactions status in the Bitcoin blockchain. The current design is to
139+ /// watch for inscriptions serially i.e. next inscription is not processed unless the current one is
140+ /// confirmed to bitcoin.
135141///
136142/// # Note
137143///
@@ -159,7 +165,7 @@ pub async fn watcher_task(
159165 // entry
160166 BlobL1Status :: Unsigned | BlobL1Status :: NeedsResign => {
161167 debug ! ( ?blobentry. status, %curr_blobidx, "Processing unsigned blobentry" ) ;
162- match create_and_sign_blob_inscriptions (
168+ match create_and_sign_blob_inscriptions_with_retries (
163169 & blobentry,
164170 & broadcast_handle,
165171 bitcoin_client. clone ( ) ,
@@ -233,6 +239,33 @@ pub async fn watcher_task(
233239 }
234240}
235241
242+ async fn create_and_sign_blob_inscriptions_with_retries (
243+ blobentry : & BlobEntry ,
244+ broadcast_handle : & L1BroadcastHandle ,
245+ client : Arc < impl Reader + Wallet + Signer > ,
246+ config : & WriterConfig ,
247+ ) -> Result < ( Buf32 , Buf32 ) , InscriptionError > {
248+ let mut retries = 0 ;
249+ let mut delay = BASE_SIGN_DELAY ;
250+ while retries <= SIGN_MAX_RETRIES {
251+ match create_and_sign_blob_inscriptions ( blobentry, broadcast_handle, client. clone ( ) , config)
252+ . await
253+ {
254+ Ok ( d) => return Ok ( d) ,
255+ Err ( err) => {
256+ warn ! ( %err, commit_txid = %blobentry. commit_txid, "Error creating and signing blob, retrying" ) ;
257+ }
258+ }
259+ retries += 1 ;
260+ tokio:: time:: sleep ( Duration :: new ( delay, 0 ) ) . await ;
261+ delay <<= 1 ;
262+ }
263+ error ! ( commit_txid = %blobentry. commit_txid, "Max retries exceeded while creating and signing blob" ) ;
264+ Err ( InscriptionError :: Other ( anyhow:: anyhow!(
265+ "Max retries exceeded while creating and signing blob"
266+ ) ) )
267+ }
268+
236269async fn update_l1_status (
237270 blobentry : & BlobEntry ,
238271 new_status : & BlobL1Status ,
0 commit comments