Skip to content

Commit

Permalink
feat(protocol): allow L2 contracts to read L2's parent block timestamp (
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik committed Mar 13, 2024
1 parent fc9f19f commit 9b79359
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/protocol/contracts/L2/TaikoL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ contract TaikoL2 is CrossChainOwned {
/// @notice The last synced L1 block height.
uint64 public lastSyncedBlock;

/// @notice The parent block's timestamp.
uint64 public parentTimestamp;

/// @notice The current block's timestamp.
uint64 private __currentBlockTimestamp;

uint256[47] private __gap;

/// @notice Emitted when the latest L1 block details are anchored to L2.
Expand Down Expand Up @@ -95,6 +101,7 @@ contract TaikoL2 is CrossChainOwned {

gasExcess = _gasExcess;
(publicInputHash,) = _calcPublicInputHash(block.number);
__currentBlockTimestamp = uint64(block.timestamp);
}

/// @notice Anchors the latest L1 block details to L2 for cross-layer
Expand Down Expand Up @@ -154,6 +161,9 @@ contract TaikoL2 is CrossChainOwned {
l2Hashes[parentId] = blockhash(parentId);
publicInputHash = publicInputHashNew;

parentTimestamp = __currentBlockTimestamp;
__currentBlockTimestamp = uint64(block.timestamp);

emit Anchored(blockhash(parentId), gasExcess);
}

Expand Down

0 comments on commit 9b79359

Please sign in to comment.