Skip to content

Commit

Permalink
feat(protocol): return verification timestamp in getLastVerifiedBlock (
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik and adaki2004 authored Aug 1, 2024
1 parent 2936312 commit 1998288
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion packages/protocol/contracts/L1/libs/LibUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -137,6 +137,7 @@ library LibUtils {

blockHash_ = transition.blockHash;
stateRoot_ = transition.stateRoot;
verifiedAt_ = transition.timestamp;
}
}

Expand Down

0 comments on commit 1998288

Please sign in to comment.