diff --git a/state/transaction.go b/state/transaction.go index 1223273d89..42a7281974 100644 --- a/state/transaction.go +++ b/state/transaction.go @@ -372,6 +372,17 @@ func (s *State) internalProcessUnsignedTransactionV1(ctx context.Context, tx *ty } nonce := loadedNonce.Uint64() + var oldStateRoot common.Hash + previousL2BlockNumber := uint64(0) + if l2Block.NumberU64() > 0 { + previousL2BlockNumber = l2Block.NumberU64() - 1 + } + previousL2Block, err := s.GetL2BlockByNumber(ctx, previousL2BlockNumber, dbTx) + if err != nil { + return nil, err + } + oldStateRoot = previousL2Block.Root() + batchL2Data, err := EncodeUnsignedTransaction(*tx, s.cfg.ChainID, &nonce, forkID) if err != nil { log.Errorf("error encoding unsigned transaction ", err) @@ -382,7 +393,7 @@ func (s *State) internalProcessUnsignedTransactionV1(ctx context.Context, tx *ty processBatchRequestV1 := &executor.ProcessBatchRequest{ From: senderAddress.String(), OldBatchNum: batch.BatchNumber, - OldStateRoot: l2Block.Root().Bytes(), + OldStateRoot: oldStateRoot.Bytes(), OldAccInputHash: batch.AccInputHash.Bytes(), ForkId: forkID, Coinbase: l2Block.Coinbase().String(),