L1Block.sol 2.72 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 9 10 11 12
/// @custom:proxied
/// @custom:predeploy 0x4200000000000000000000000000000000000015
/// @title L1Block
/// @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.
13
contract L1Block is Semver {
14
    /// @notice Address of the special depositor account.
15 16
    address public constant DEPOSITOR_ACCOUNT = 0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAd0001;

17
    /// @notice The latest L1 block number known by the L2 system.
18 19
    uint64 public number;

20
    /// @notice The latest L1 timestamp known by the L2 system.
21 22
    uint64 public timestamp;

23
    /// @notice The latest L1 basefee.
24 25
    uint256 public basefee;

26
    /// @notice The latest L1 blockhash.
27 28
    bytes32 public hash;

29
    /// @notice The number of L2 blocks in the same epoch.
30 31
    uint64 public sequenceNumber;

32
    /// @notice The versioned hash to authenticate the batcher by.
33 34
    bytes32 public batcherHash;

35
    /// @notice The overhead value applied to the L1 portion of the transaction fee.
36 37
    uint256 public l1FeeOverhead;

38
    /// @notice The scalar value applied to the L1 portion of the transaction fee.
39 40
    uint256 public l1FeeScalar;

41 42 43
    /// @custom:semver 1.0.1
    /// @notice Constructs the L1Block contract.
    constructor() Semver(1, 0, 1) {}
44

45 46 47 48 49 50 51 52 53
    /// @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.
    /// @param _batcherHash    Versioned hash to authenticate batcher by.
    /// @param _l1FeeOverhead  L1 fee overhead.
    /// @param _l1FeeScalar    L1 fee scalar.
54 55 56 57 58
    function setL1BlockValues(
        uint64 _number,
        uint64 _timestamp,
        uint256 _basefee,
        bytes32 _hash,
59 60 61 62
        uint64 _sequenceNumber,
        bytes32 _batcherHash,
        uint256 _l1FeeOverhead,
        uint256 _l1FeeScalar
63
    ) external {
64 65 66 67
        require(
            msg.sender == DEPOSITOR_ACCOUNT,
            "L1Block: only the depositor account can set L1 block values"
        );
68 69 70 71 72 73

        number = _number;
        timestamp = _timestamp;
        basefee = _basefee;
        hash = _hash;
        sequenceNumber = _sequenceNumber;
74 75 76
        batcherHash = _batcherHash;
        l1FeeOverhead = _l1FeeOverhead;
        l1FeeScalar = _l1FeeScalar;
77 78
    }
}