Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions tx-submitter/services/rollup.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,9 +852,9 @@ func (r *Rollup) finalize() error {
// gas bump
gas = r.BumpGas(gas)

nonce := r.getNextNonce()
if nonce == 0 {
return fmt.Errorf("failed to get next nonce")
nonce, err := r.getNextNonce()
if err != nil {
return fmt.Errorf("failed to get next nonce: %w", err)
}

tx := ethtypes.NewTx(&ethtypes.DynamicFeeTx{
Expand Down Expand Up @@ -1026,9 +1026,9 @@ func (r *Rollup) rollup() error {
gas = r.BumpGas(gas)

// Get next nonce
nonce := r.getNextNonce()
if nonce == 0 {
return fmt.Errorf("failed to get next nonce")
nonce, err := r.getNextNonce()
if err != nil {
return fmt.Errorf("failed to get next nonce: %w", err)
}

// Create and sign transaction (commitState is always type-2, never blob)
Expand Down Expand Up @@ -1063,20 +1063,19 @@ func (r *Rollup) rollup() error {
return nil
}

func (r *Rollup) getNextNonce() uint64 {
func (r *Rollup) getNextNonce() (uint64, error) {
nonce, err := r.L1Client.PendingNonceAt(context.Background(), r.WalletAddr())
if err != nil {
log.Error("Failed to get nonce", "error", err)
return 0
return 0, fmt.Errorf("failed to get pending nonce: %w", err)
}
if r.pendingTxs.Len() == 0 {
return nonce
return nonce, nil
}
pn := r.pendingTxs.GetNonce()
if pn+1 > nonce {
return pn + 1
return pn + 1, nil
}
return nonce
return nonce, nil
}

func (r *Rollup) createRollupTx(batch *eth.RPCRollupBatch, nonce, gas uint64, tip, gasFeeCap, blobFee *big.Int, calldata []byte, head *ethtypes.Header) (*ethtypes.Transaction, error) {
Expand Down
Loading