@@ -216,7 +216,7 @@ func (s *Sender) SendTransaction(contextID string, target *common.Address, data
216216 return common.Hash {}, fmt .Errorf ("failed to get fee data, err: %w" , err )
217217 }
218218
219- signedTx , err := s .createTx (feeData , target , data , sidecar , nil )
219+ signedTx , err := s .createTx (feeData , target , data , sidecar , s . transactionSigner . GetNonce () )
220220 if err != nil {
221221 s .metrics .sendTransactionFailureSendTx .WithLabelValues (s .service , s .name ).Inc ()
222222 log .Error ("failed to create signed tx (non-resubmit case)" , "from" , s .transactionSigner .GetAddr ().String (), "nonce" , s .transactionSigner .GetNonce (), "err" , err )
@@ -247,19 +247,13 @@ func (s *Sender) SendTransaction(contextID string, target *common.Address, data
247247 return common.Hash {}, fmt .Errorf ("failed to send transaction, err: %w" , err )
248248 }
249249
250+ s .transactionSigner .SetNonce (signedTx .Nonce () + 1 )
251+
250252 return signedTx .Hash (), nil
251253}
252254
253- func (s * Sender ) createTx (feeData * FeeData , target * common.Address , data []byte , sidecar * gethTypes.BlobTxSidecar , overrideNonce * uint64 ) (* gethTypes.Transaction , error ) {
254- var (
255- nonce = s .transactionSigner .GetNonce ()
256- txData gethTypes.TxData
257- )
258-
259- // this is a resubmit call, override the nonce
260- if overrideNonce != nil {
261- nonce = * overrideNonce
262- }
255+ func (s * Sender ) createTx (feeData * FeeData , target * common.Address , data []byte , sidecar * gethTypes.BlobTxSidecar , nonce uint64 ) (* gethTypes.Transaction , error ) {
256+ var txData gethTypes.TxData
263257
264258 switch s .config .TxType {
265259 case LegacyTxType :
@@ -312,11 +306,6 @@ func (s *Sender) createTx(feeData *FeeData, target *common.Address, data []byte,
312306 return nil , err
313307 }
314308
315- // update nonce when it is not from resubmit
316- if overrideNonce == nil {
317- s .transactionSigner .SetNonce (nonce + 1 )
318- }
319-
320309 if feeData .gasTipCap != nil {
321310 s .metrics .currentGasTipCap .WithLabelValues (s .service , s .name ).Set (float64 (feeData .gasTipCap .Uint64 ()))
322311 }
@@ -492,7 +481,7 @@ func (s *Sender) createReplacingTransaction(tx *gethTypes.Transaction, baseFee,
492481
493482 nonce := tx .Nonce ()
494483 s .metrics .resubmitTransactionTotal .WithLabelValues (s .service , s .name ).Inc ()
495- signedTx , err := s .createTx (& feeData , tx .To (), tx .Data (), tx .BlobTxSidecar (), & nonce )
484+ signedTx , err := s .createTx (& feeData , tx .To (), tx .Data (), tx .BlobTxSidecar (), nonce )
496485 if err != nil {
497486 log .Error ("failed to create signed tx (resubmit case)" , "from" , s .transactionSigner .GetAddr ().String (), "nonce" , nonce , "err" , err )
498487 return nil , err
0 commit comments