Skip to content

Commit d2cfa78

Browse files
committed
fix deltaTimeStamp for unsigned txs execution for specific block
1 parent eb77e04 commit d2cfa78

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

state/transaction.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,17 @@ func (s *State) internalProcessUnsignedTransactionV1(ctx context.Context, tx *ty
372372
}
373373
nonce := loadedNonce.Uint64()
374374

375+
var oldStateRoot common.Hash
376+
previousL2BlockNumber := uint64(0)
377+
if l2Block.NumberU64() > 0 {
378+
previousL2BlockNumber = l2Block.NumberU64() - 1
379+
}
380+
previousL2Block, err := s.GetL2BlockByNumber(ctx, previousL2BlockNumber, dbTx)
381+
if err != nil {
382+
return nil, err
383+
}
384+
oldStateRoot = previousL2Block.Root()
385+
375386
batchL2Data, err := EncodeUnsignedTransaction(*tx, s.cfg.ChainID, &nonce, forkID)
376387
if err != nil {
377388
log.Errorf("error encoding unsigned transaction ", err)
@@ -382,7 +393,7 @@ func (s *State) internalProcessUnsignedTransactionV1(ctx context.Context, tx *ty
382393
processBatchRequestV1 := &executor.ProcessBatchRequest{
383394
From: senderAddress.String(),
384395
OldBatchNum: batch.BatchNumber,
385-
OldStateRoot: l2Block.Root().Bytes(),
396+
OldStateRoot: oldStateRoot.Bytes(),
386397
OldAccInputHash: batch.AccInputHash.Bytes(),
387398
ForkId: forkID,
388399
Coinbase: l2Block.Coinbase().String(),

0 commit comments

Comments
 (0)