@@ -566,8 +566,8 @@ func (e *Executor) applyBlock(ctx context.Context, header types.Header, data *ty
566566
567567 // Execute transactions
568568 ctx = context .WithValue (ctx , types .HeaderContextKey , header )
569- newAppHash , _ , err := e . exec . ExecuteTxs ( ctx , rawTxs , header . Height (),
570- header . Time (), currentState . AppHash )
569+
570+ newAppHash , err := e . executeTxsWithRetry ( ctx , rawTxs , header , currentState )
571571 if err != nil {
572572 e .sendCriticalError (fmt .Errorf ("failed to execute transactions: %w" , err ))
573573 return types.State {}, fmt .Errorf ("failed to execute transactions: %w" , err )
@@ -592,6 +592,35 @@ func (e *Executor) signHeader(header types.Header) (types.Signature, error) {
592592 return e .signer .Sign (bz )
593593}
594594
595+ // executeTxsWithRetry executes transactions with retry logic
596+ func (s * Executor ) executeTxsWithRetry (ctx context.Context , rawTxs [][]byte , header types.Header , currentState types.State ) ([]byte , error ) {
597+ for attempt := 1 ; attempt <= common .MaxRetriesBeforeHalt ; attempt ++ {
598+ newAppHash , _ , err := s .exec .ExecuteTxs (ctx , rawTxs , header .Height (), header .Time (), currentState .AppHash )
599+ if err != nil {
600+ if attempt == common .MaxRetriesBeforeHalt {
601+ return nil , fmt .Errorf ("failed to execute transactions: %w" , err )
602+ }
603+
604+ s .logger .Error ().Err (err ).
605+ Int ("attempt" , attempt ).
606+ Int ("max_attempts" , common .MaxRetriesBeforeHalt ).
607+ Uint64 ("height" , header .Height ()).
608+ Msg ("failed to execute transactions, retrying" )
609+
610+ select {
611+ case <- time .After (common .MaxRetriesTimeout ):
612+ continue
613+ case <- s .ctx .Done ():
614+ return nil , fmt .Errorf ("context cancelled during retry: %w" , s .ctx .Err ())
615+ }
616+ }
617+
618+ return newAppHash , nil
619+ }
620+
621+ return nil , nil
622+ }
623+
595624// validateBlock validates the created block
596625func (e * Executor ) validateBlock (lastState types.State , header * types.SignedHeader , data * types.Data ) error {
597626 // Set custom verifier for aggregator node signature
0 commit comments