From 19982889f7f4c073d182a6076633c5e2c892c73a Mon Sep 17 00:00:00 2001 From: Daniel Wang <99078276+dantaik@users.noreply.github.com> Date: Thu, 1 Aug 2024 14:00:02 +0800 Subject: [PATCH] feat(protocol): return verification timestamp in getLastVerifiedBlock (#17868) Co-authored-by: D <51912515+adaki2004@users.noreply.github.com> --- packages/protocol/contracts/L1/TaikoL1.sol | 10 ++++++---- packages/protocol/contracts/L1/libs/LibUtils.sol | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/protocol/contracts/L1/TaikoL1.sol b/packages/protocol/contracts/L1/TaikoL1.sol index 1f4a39f1bb..43ad057fbe 100644 --- a/packages/protocol/contracts/L1/TaikoL1.sol +++ b/packages/protocol/contracts/L1/TaikoL1.sol @@ -228,26 +228,28 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents { /// @return blockId_ The last verified block's ID. /// @return blockHash_ The last verified block's blockHash. /// @return stateRoot_ The last verified block's stateRoot. + /// @return verifiedAt_ The timestamp this block is verified at. function getLastVerifiedBlock() external view - returns (uint64 blockId_, bytes32 blockHash_, bytes32 stateRoot_) + returns (uint64 blockId_, bytes32 blockHash_, bytes32 stateRoot_, uint64 verifiedAt_) { blockId_ = state.slotB.lastVerifiedBlockId; - (blockHash_, stateRoot_) = LibUtils.getBlockInfo(state, getConfig(), blockId_); + (blockHash_, stateRoot_, verifiedAt_) = LibUtils.getBlockInfo(state, getConfig(), blockId_); } /// @notice Returns information about the last synchronized block. /// @return blockId_ The last verified block's ID. /// @return blockHash_ The last verified block's blockHash. /// @return stateRoot_ The last verified block's stateRoot. + /// @return verifiedAt_ The timestamp this block is verified at. function getLastSyncedBlock() external view - returns (uint64 blockId_, bytes32 blockHash_, bytes32 stateRoot_) + returns (uint64 blockId_, bytes32 blockHash_, bytes32 stateRoot_, uint64 verifiedAt_) { blockId_ = state.slotA.lastSyncedBlockId; - (blockHash_, stateRoot_) = LibUtils.getBlockInfo(state, getConfig(), blockId_); + (blockHash_, stateRoot_, verifiedAt_) = LibUtils.getBlockInfo(state, getConfig(), blockId_); } /// @notice Gets the state variables of the TaikoL1 contract. diff --git a/packages/protocol/contracts/L1/libs/LibUtils.sol b/packages/protocol/contracts/L1/libs/LibUtils.sol index 0eadc38434..3f7fa3c36e 100644 --- a/packages/protocol/contracts/L1/libs/LibUtils.sol +++ b/packages/protocol/contracts/L1/libs/LibUtils.sol @@ -127,7 +127,7 @@ library LibUtils { ) internal view - returns (bytes32 blockHash_, bytes32 stateRoot_) + returns (bytes32 blockHash_, bytes32 stateRoot_, uint64 verifiedAt_) { (TaikoData.Block storage blk, uint64 slot) = getBlock(_state, _config, _blockId); @@ -137,6 +137,7 @@ library LibUtils { blockHash_ = transition.blockHash; stateRoot_ = transition.stateRoot; + verifiedAt_ = transition.timestamp; } }