Skip to content

Commit

Permalink
fix deltaTimeStamp for unsigned txs execution for specific block
Browse files Browse the repository at this point in the history
  • Loading branch information
tclemos committed Feb 17, 2024
1 parent c575f6b commit eb77e04
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions state/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,23 @@ func (s *State) internalProcessUnsignedTransactionV2(ctx context.Context, tx *ty
}
nonce := loadedNonce.Uint64()

deltaTimestamp := uint32(uint64(time.Now().Unix()) - l2Block.Time())
transactions := s.BuildChangeL2Block(deltaTimestamp, uint32(0))
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()

l1InfoTree, err := s.GetL1InfoRootLeafByL1InfoRoot(ctx, l2Block.BlockInfoRoot(), nil)
if err != nil {
return nil, err
}
deltaTimestamp := uint32(l2Block.Time() - previousL2Block.Time())
transactions := s.BuildChangeL2Block(deltaTimestamp, l1InfoTree.L1InfoTreeIndex)

batchL2Data, err := EncodeUnsignedTransaction(*tx, s.cfg.ChainID, &nonce, forkID)
if err != nil {
Expand All @@ -505,7 +520,7 @@ func (s *State) internalProcessUnsignedTransactionV2(ctx context.Context, tx *ty
processBatchRequestV2 := &executor.ProcessBatchRequestV2{
From: senderAddress.String(),
OldBatchNum: batch.BatchNumber,
OldStateRoot: l2Block.Root().Bytes(),
OldStateRoot: oldStateRoot.Bytes(),
OldAccInputHash: batch.AccInputHash.Bytes(),
Coinbase: batch.Coinbase.String(),
ForkId: forkID,
Expand Down

0 comments on commit eb77e04

Please sign in to comment.