Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(protocol): allow L2 contracts to read L2's parent block timestamp #16425

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading