@@ -51,7 +51,7 @@ type DriverSetup struct {
5151 EndpointProvider dial.L2EndpointProvider
5252 ChannelConfig ChannelConfig
5353 PlasmaDA * plasma.DAClient
54- NearDA * opnear.DAClient
54+ NearDA opnear.CLIConfig
5555}
5656
5757// BatchSubmitter encapsulates a service responsible for submitting L2 tx
@@ -439,10 +439,24 @@ func (l *BatchSubmitter) blobTxCandidate(data txData) (*txmgr.TxCandidate, error
439439 }, nil
440440}
441441
442- func (l * BatchSubmitter ) submitBlobToNearDA (data []byte ) ([]byte , error ) {
442+ func (l * BatchSubmitter ) submitBlobToNearDA (data []byte ) (frameRef []byte , err error ) {
443+ defer func () {
444+ if rErr := recover (); rErr != nil {
445+ err = fmt .Errorf ("critical error from submitBlobToNearDA: %v" , rErr )
446+ }
447+ }()
448+
449+ // create a Near DA Client before submitting blob
450+ daClient , err := opnear .NewDAClient (l .NearDA .DaAccount , l .NearDA .DaContract , l .NearDA .DaKey , l .NearDA .DaNetwork , l .NearDA .DaNamespaceId )
451+ if err != nil {
452+ l .Log .Error ("new near da client" , "err" , err )
453+ return nil , err
454+ }
455+ defer daClient .FreeDAClient ()
456+
443457 l .Log .Debug ("submitBlobToNearDA" , "data" , hex .EncodeToString (data ), "size" , len (data ))
444458 // frameRef is the blob commitment, which is provided as [transaction_id ++ commitment]
445- frameRef , err := l . NearDA .Submit (data )
459+ frameRef , err = daClient .Submit (data )
446460 if err != nil {
447461 l .Log .Warn ("failed to submit blob to near da" , "err" , err )
448462 return nil , err
@@ -451,7 +465,7 @@ func (l *BatchSubmitter) submitBlobToNearDA(data []byte) ([]byte, error) {
451465 // finality is achieved which is 3 blocks (around 2-3 seconds) its not possible for a reorg to happen
452466 // check the submitted blob after finality
453467 time .Sleep (10 * time .Second )
454- blobData , err := l . NearDA .Get (frameRef , 0 )
468+ blobData , err := daClient .Get (frameRef , 0 )
455469 if err != nil {
456470 log .Error ("failed to get blob from near da, maybe chain reorg" , "id" , hex .EncodeToString (data ), "err" , err )
457471 return nil , err
0 commit comments