Skip to content

Commit

Permalink
fix deltaTimeStamp and TimestampLimit for eth_call (0xPolygonHermez#3529
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tclemos authored Apr 4, 2024
1 parent 26ec1b5 commit c04b2c2
Show file tree
Hide file tree
Showing 4 changed files with 412 additions and 6 deletions.
12 changes: 6 additions & 6 deletions state/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,7 @@ 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))
transactions := s.BuildChangeL2Block(uint32(0), uint32(0))

batchL2Data, err := EncodeUnsignedTransaction(*tx, s.cfg.ChainID, &nonce, forkID)
if err != nil {
Expand All @@ -535,22 +534,23 @@ func (s *State) internalProcessUnsignedTransactionV2(ctx context.Context, tx *ty

// v2 fields
L1InfoRoot: l2Block.BlockInfoRoot().Bytes(),
TimestampLimit: uint64(time.Now().Unix()),
TimestampLimit: l2Block.Time(),
SkipFirstChangeL2Block: cFalse,
SkipWriteBlockInfoRoot: cTrue,
}
if noZKEVMCounters {
processBatchRequestV2.NoCounters = cTrue
}

log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.From]: %v", processBatchRequestV2.From)
log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldBatchNum]: %v", processBatchRequestV2.OldBatchNum)
log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldStateRoot]: %v", hex.EncodeToHex(processBatchRequestV2.OldStateRoot))
log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldAccInputHash]: %v", hex.EncodeToHex(processBatchRequestV2.OldAccInputHash))

log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.Coinbase]: %v", processBatchRequestV2.Coinbase)
log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ForkId]: %v", processBatchRequestV2.ForkId)
log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ChainId]: %v", processBatchRequestV2.ChainId)
log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.UpdateMerkleTree]: %v", processBatchRequestV2.UpdateMerkleTree)
log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ChainId]: %v", processBatchRequestV2.ChainId)
log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ForkId]: %v", processBatchRequestV2.ForkId)
log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.From]: %v", processBatchRequestV2.From)
log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ContextId]: %v", processBatchRequestV2.ContextId)

log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.L1InfoRoot]: %v", hex.EncodeToHex(processBatchRequestV2.L1InfoRoot))
Expand Down
15 changes: 15 additions & 0 deletions test/contracts/auto/CounterAndBlock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

contract CounterAndBlock {
uint public count;

function increment() external {
count += 1;
}

function getCount() public view returns (uint, uint) {
return (count, block.timestamp);
}
}
287 changes: 287 additions & 0 deletions test/contracts/bin/CounterAndBlock/CounterAndBlock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c04b2c2

Please sign in to comment.