github.com/ethereum-optimism/optimism@v1.7.2/packages/contracts-bedrock/src/cannon/interfaces/IPreimageOracle.sol (about)

     1  // SPDX-License-Identifier: MIT
     2  pragma solidity 0.8.15;
     3  
     4  /// @title IPreimageOracle
     5  /// @notice Interface for a preimage oracle.
     6  interface IPreimageOracle {
     7      /// @notice Reads a preimage from the oracle.
     8      /// @param _key The key of the preimage to read.
     9      /// @param _offset The offset of the preimage to read.
    10      /// @return dat_ The preimage data.
    11      /// @return datLen_ The length of the preimage data.
    12      function readPreimage(bytes32 _key, uint256 _offset) external view returns (bytes32 dat_, uint256 datLen_);
    13  
    14      /// @notice Loads of local data part into the preimage oracle.
    15      /// @param _ident The identifier of the local data.
    16      /// @param _localContext The local key context for the preimage oracle. Optionally, can be set as a constant
    17      ///                      if the caller only requires one set of local keys.
    18      /// @param _word The local data word.
    19      /// @param _size The number of bytes in `_word` to load.
    20      /// @param _partOffset The offset of the local data part to write to the oracle.
    21      /// @dev The local data parts are loaded into the preimage oracle under the context
    22      ///      of the caller - no other account can write to the caller's context
    23      ///      specific data.
    24      ///
    25      ///      There are 5 local data identifiers:
    26      ///      ┌────────────┬────────────────────────┐
    27      ///      │ Identifier │      Data              │
    28      ///      ├────────────┼────────────────────────┤
    29      ///      │          1 │ L1 Head Hash (bytes32) │
    30      ///      │          2 │ Output Root (bytes32)  │
    31      ///      │          3 │ Root Claim (bytes32)   │
    32      ///      │          4 │ L2 Block Number (u64)  │
    33      ///      │          5 │ Chain ID (u64)         │
    34      ///      └────────────┴────────────────────────┘
    35      function loadLocalData(
    36          uint256 _ident,
    37          bytes32 _localContext,
    38          bytes32 _word,
    39          uint256 _size,
    40          uint256 _partOffset
    41      )
    42          external
    43          returns (bytes32 key_);
    44  
    45      /// @notice Prepares a preimage to be read by keccak256 key, starting at the given offset and up to 32 bytes
    46      ///         (clipped at preimage length, if out of data).
    47      /// @param _partOffset The offset of the preimage to read.
    48      /// @param _preimage The preimage data.
    49      function loadKeccak256PreimagePart(uint256 _partOffset, bytes calldata _preimage) external;
    50  
    51      /// @notice Prepares a preimage to be read by sha256 key, starting at the given offset and up to 32 bytes
    52      ///         (clipped at preimage length, if out of data).
    53      /// @param _partOffset The offset of the preimage to read.
    54      /// @param _preimage The preimage data.
    55      function loadSha256PreimagePart(uint256 _partOffset, bytes calldata _preimage) external;
    56  
    57      /// @notice Verifies that `p(_z) = _y` given `_commitment` that corresponds to the polynomial `p(x)` and a KZG
    58      //          proof. The value `y` is the pre-image, and the preimage key is `5 ++ keccak256(_commitment ++ z)[1:]`.
    59      /// @param _z Big endian point value. Part of the preimage key.
    60      /// @param _y Big endian point value. The preimage for the key.
    61      /// @param _commitment The commitment to the polynomial. 48 bytes, part of the preimage key.
    62      /// @param _proof The KZG proof, part of the preimage key.
    63      /// @param _partOffset The offset of the preimage to store.
    64      function loadBlobPreimagePart(
    65          uint256 _z,
    66          uint256 _y,
    67          bytes calldata _commitment,
    68          bytes calldata _proof,
    69          uint256 _partOffset
    70      )
    71          external;
    72  
    73      /// @notice Prepares a precompile result to be read by a precompile key for the specified offset.
    74      ///         The precompile result data is a concatenation of the precompile call status byte and its return data.
    75      ///         The preimage key is `6 ++ keccak256(precompile ++ input)[1:]`.
    76      /// @param _partOffset The offset of the precompile result being loaded.
    77      /// @param _precompile The precompile address
    78      /// @param _input The input to the precompile call.
    79      function loadPrecompilePreimagePart(uint256 _partOffset, address _precompile, bytes calldata _input) external;
    80  }