diff --git a/common/version/version.go b/common/version/version.go index 1e467875b..b3edea871 100644 --- a/common/version/version.go +++ b/common/version/version.go @@ -5,7 +5,7 @@ import ( "runtime/debug" ) -var tag = "v4.4.81" +var tag = "v4.4.82" var commit = func() string { if info, ok := debug.ReadBuildInfo(); ok { diff --git a/rollup/internal/controller/sender/sender.go b/rollup/internal/controller/sender/sender.go index a36be1912..daf4e7b54 100644 --- a/rollup/internal/controller/sender/sender.go +++ b/rollup/internal/controller/sender/sender.go @@ -216,7 +216,7 @@ func (s *Sender) SendTransaction(contextID string, target *common.Address, data return common.Hash{}, fmt.Errorf("failed to get fee data, err: %w", err) } - signedTx, err := s.createTx(feeData, target, data, sidecar, nil) + signedTx, err := s.createTx(feeData, target, data, sidecar, s.transactionSigner.GetNonce()) if err != nil { s.metrics.sendTransactionFailureSendTx.WithLabelValues(s.service, s.name).Inc() 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 return common.Hash{}, fmt.Errorf("failed to send transaction, err: %w", err) } + s.transactionSigner.SetNonce(signedTx.Nonce() + 1) + return signedTx.Hash(), nil } -func (s *Sender) createTx(feeData *FeeData, target *common.Address, data []byte, sidecar *gethTypes.BlobTxSidecar, overrideNonce *uint64) (*gethTypes.Transaction, error) { - var ( - nonce = s.transactionSigner.GetNonce() - txData gethTypes.TxData - ) - - // this is a resubmit call, override the nonce - if overrideNonce != nil { - nonce = *overrideNonce - } +func (s *Sender) createTx(feeData *FeeData, target *common.Address, data []byte, sidecar *gethTypes.BlobTxSidecar, nonce uint64) (*gethTypes.Transaction, error) { + var txData gethTypes.TxData switch s.config.TxType { case LegacyTxType: @@ -312,11 +306,6 @@ func (s *Sender) createTx(feeData *FeeData, target *common.Address, data []byte, return nil, err } - // update nonce when it is not from resubmit - if overrideNonce == nil { - s.transactionSigner.SetNonce(nonce + 1) - } - if feeData.gasTipCap != nil { s.metrics.currentGasTipCap.WithLabelValues(s.service, s.name).Set(float64(feeData.gasTipCap.Uint64())) } @@ -492,7 +481,7 @@ func (s *Sender) createReplacingTransaction(tx *gethTypes.Transaction, baseFee, nonce := tx.Nonce() s.metrics.resubmitTransactionTotal.WithLabelValues(s.service, s.name).Inc() - signedTx, err := s.createTx(&feeData, tx.To(), tx.Data(), tx.BlobTxSidecar(), &nonce) + signedTx, err := s.createTx(&feeData, tx.To(), tx.Data(), tx.BlobTxSidecar(), nonce) if err != nil { log.Error("failed to create signed tx (resubmit case)", "from", s.transactionSigner.GetAddr().String(), "nonce", nonce, "err", err) return nil, err diff --git a/rollup/internal/controller/sender/sender_test.go b/rollup/internal/controller/sender/sender_test.go index 83fb04537..1af81b299 100644 --- a/rollup/internal/controller/sender/sender_test.go +++ b/rollup/internal/controller/sender/sender_test.go @@ -282,7 +282,7 @@ func testResubmitZeroGasPriceTransaction(t *testing.T) { gasFeeCap: big.NewInt(0), gasLimit: 50000, } - tx, err := s.createTx(feeData, &common.Address{}, nil, nil, nil) + tx, err := s.createTx(feeData, &common.Address{}, nil, nil, s.transactionSigner.GetNonce()) assert.NoError(t, err) assert.NotNil(t, tx) err = s.client.SendTransaction(s.ctx, tx) @@ -373,7 +373,7 @@ func testResubmitNonZeroGasPriceTransaction(t *testing.T) { sidecar, err = makeSidecar(txBlob[i]) assert.NoError(t, err) } - tx, err := s.createTx(feeData, &common.Address{}, nil, sidecar, nil) + tx, err := s.createTx(feeData, &common.Address{}, nil, sidecar, s.transactionSigner.GetNonce()) assert.NoError(t, err) assert.NotNil(t, tx) err = s.client.SendTransaction(s.ctx, tx) @@ -420,7 +420,7 @@ func testResubmitUnderpricedTransaction(t *testing.T) { gasFeeCap: big.NewInt(1000000000), gasLimit: 50000, } - tx, err := s.createTx(feeData, &common.Address{}, nil, nil, nil) + tx, err := s.createTx(feeData, &common.Address{}, nil, nil, s.transactionSigner.GetNonce()) assert.NoError(t, err) assert.NotNil(t, tx) err = s.client.SendTransaction(s.ctx, tx)