// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import {IBondVault} from "./Interfaces.sol"; import {QuorumLib} from "./QuorumLib.sol"; contract Checkpoints { IBondVault public immutable bondVault; uint256 public immutable l2ChainId; uint256 internal lHeight; bytes32 internal lBlockHash; bytes32 internal lStateRoot; uint256 internal lAt; bool public hasCheckpoint; event Checkpoint(uint256 indexed height, bytes32 blockHash, bytes32 stateRoot); constructor(address bondVault_, uint256 l2ChainId_) { bondVault = IBondVault(bondVault_); l2ChainId = l2ChainId_; } function submit(uint256 height, bytes32 blockHash, bytes32 stateRoot, bytes[] calldata sigs) external { if (hasCheckpoint) require(height > lHeight, "height not increasing"); bytes32 d = QuorumLib.checkpointDigest(l2ChainId, height, blockHash, stateRoot); QuorumLib.requireQuorum(bondVault, d, sigs); hasCheckpoint = true; lHeight = height; lBlockHash = blockHash; lStateRoot = stateRoot; lAt = block.timestamp; emit Checkpoint(height, blockHash, stateRoot); } function latest() external view returns (uint256 height, bytes32 blockHash, bytes32 stateRoot, uint256 at) { return (lHeight, lBlockHash, lStateRoot, lAt); } }