From 21bcfbc0b7355e920a56e4348b7b51c64f746a87 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Wed, 13 Mar 2024 16:11:46 +0800 Subject: [PATCH] Taiko L2 offers parentTimestamp --- packages/protocol/contracts/L2/TaikoL2.sol | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/protocol/contracts/L2/TaikoL2.sol b/packages/protocol/contracts/L2/TaikoL2.sol index 99f5f7e362..4dd7c2085b 100644 --- a/packages/protocol/contracts/L2/TaikoL2.sol +++ b/packages/protocol/contracts/L2/TaikoL2.sol @@ -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. @@ -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 @@ -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); }