L1Block.sol 2.1 KB
Newer Older
1
// SPDX-License-Identifier: MIT
2
pragma solidity 0.8.15;
3

4 5
import { Semver } from "../universal/Semver.sol";

6
/**
7 8
 * @custom:proxied
 * @custom:predeploy 0x4200000000000000000000000000000000000015
9
 * @title L1Block
10 11 12 13
 * @notice The L1Block predeploy gives users access to information about the last known L1 block.
 *         Values within this contract are updated once per epoch (every L1 block) and can only be
 *         set by the "depositor" account, a special system address. Depositor account transactions
 *         are created by the protocol whenever we move to a new epoch.
14
 */
15
contract L1Block is Semver {
16
    /**
17
     * @notice Address of the special depositor account.
18 19 20 21
     */
    address public constant DEPOSITOR_ACCOUNT = 0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAd0001;

    /**
22
     * @notice The latest L1 block number known by the L2 system.
23 24 25 26
     */
    uint64 public number;

    /**
27
     * @notice The latest L1 timestamp known by the L2 system.
28 29 30 31
     */
    uint64 public timestamp;

    /**
32
     * @notice The latest L1 basefee.
33 34 35 36
     */
    uint256 public basefee;

    /**
37
     * @notice The latest L1 blockhash.
38 39 40 41
     */
    bytes32 public hash;

    /**
42
     * @notice The number of L2 blocks in the same epoch.
43 44 45
     */
    uint64 public sequenceNumber;

46 47 48 49 50
    /**
     * @custom:semver 0.0.1
     */
    constructor() Semver(0, 0, 1) {}

51
    /**
52 53 54 55 56 57 58
     * @notice Updates the L1 block values.
     *
     * @param _number         L1 blocknumber.
     * @param _timestamp      L1 timestamp.
     * @param _basefee        L1 basefee.
     * @param _hash           L1 blockhash.
     * @param _sequenceNumber Number of L2 blocks since epoch start.
59 60 61 62 63 64 65 66
     */
    function setL1BlockValues(
        uint64 _number,
        uint64 _timestamp,
        uint256 _basefee,
        bytes32 _hash,
        uint64 _sequenceNumber
    ) external {
67 68 69 70
        require(
            msg.sender == DEPOSITOR_ACCOUNT,
            "L1Block: only the depositor account can set L1 block values"
        );
71 72 73 74 75 76 77 78

        number = _number;
        timestamp = _timestamp;
        basefee = _basefee;
        hash = _hash;
        sequenceNumber = _sequenceNumber;
    }
}