Skip to content

Commit

Permalink
refactor(evm): normalizes interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
allemanfredi committed Jan 25, 2024
1 parent 1183fb1 commit b2d2324
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
13 changes: 9 additions & 4 deletions packages/evm/contracts/interfaces/IBlockHashOracleAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ pragma solidity ^0.8.17;

import { IOracleAdapter } from "./IOracleAdapter.sol";

/**
* @title IBlockHashOracleAdapter
*/
interface IBlockHashOracleAdapter is IOracleAdapter {
/// @dev Proves and stores valid ancestral block hashes for a given chain ID.
/// @param chainId The ID of the chain to prove block hashes for.
/// @param blockHeaders The RLP encoded block headers to prove the hashes for.
/// @notice Block headers should be ordered by descending block number and should start with a known block header.
/**
* @dev Proves and stores valid ancestral block hashes for a given chain ID.
* @param chainId - The ID of the chain to prove block hashes for.
* @param blockHeaders - The RLP encoded block headers to prove the hashes for.
* @notice Block headers should be ordered by descending block number and should start with a known block header.
*/
function proveAncestralBlockHashes(uint256 chainId, bytes[] memory blockHeaders) external;
}
3 changes: 3 additions & 0 deletions packages/evm/contracts/interfaces/IHeaderStorage.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.17;

/**
* @title IHeaderStorage
*/
interface IHeaderStorage {
error HeaderOutOfRange(address emitter, uint256 blockNumber);

Expand Down
19 changes: 12 additions & 7 deletions packages/evm/contracts/interfaces/IOracleAdapter.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.17;

/**
* @title IOracleAdapter
*/
interface IOracleAdapter {
event HashStored(uint256 indexed id, bytes32 indexed hashes);

error InvalidBlockHeaderLength(uint256 length);
error InvalidBlockHeaderRLP();
error ConflictingBlockHeader(uint256 blockNumber, bytes32 reportedBlockHash, bytes32 storedBlockHash);

/// @dev Returns the hash for a given ID, as reported by the oracle.
/// @param domain Identifier for the domain to query.
/// @param id Identifier for the ID to query.
/// @return hash Bytes32 hash reported by the oracle for the given ID on the given domain.
/// @notice MUST return bytes32(0) if the oracle has not yet reported a hash for the given ID.
event HashStored(uint256 indexed id, bytes32 indexed hashes);

/**
* @dev Returns the hash for a given ID, as reported by the oracle.
* @param domain - Identifier for the domain to query.
* @param id - Identifier for the ID to query.
* @return hash Bytes32 hash reported by the oracle for the given ID on the given domain.
* @notice MUST return bytes32(0) if the oracle has not yet reported a hash for the given ID.
*/
function getHashFromOracle(uint256 domain, uint256 id) external view returns (bytes32 hash);
}
3 changes: 3 additions & 0 deletions packages/evm/contracts/interfaces/IYaho.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { Message } from "./IMessage.sol";
import { IReporter } from "./IReporter.sol";
import { IOracleAdapter } from "./IOracleAdapter.sol";

/**
* @title IYaho
*/
interface IYaho is IMessageHashCalculator, IMessageIdCalculator {
error NoMessagesGiven();
error NoMessageIdsGiven();
Expand Down

0 comments on commit b2d2324

Please sign in to comment.