Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
hujw77 committed Jul 31, 2023
1 parent e680621 commit dc40852
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 16 deletions.
8 changes: 2 additions & 6 deletions src/Channel.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@

pragma solidity 0.8.17;

import "./Common.sol";
import "./imt/IncrementalMerkleTree.sol";
import "./interfaces/IEndpoint.sol";
import "./interfaces/IUserConfig.sol";
import "./interfaces/IVerifier.sol";

interface IEndpoint {
function recv(Message calldata message) external returns (bool dispatchResult);
}
import "./imt/IncrementalMerkleTree.sol";

/// @title Channel
/// @notice A channel is a logical connection over cross-chain network.
Expand Down
6 changes: 3 additions & 3 deletions src/Endpoint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
pragma solidity 0.8.17;

import "./Common.sol";
import "./call/ExcessivelySafeCall.sol";
import "./interfaces/IUserConfig.sol";
import "./interfaces/IOracle.sol";
import "./interfaces/IChannel.sol";
import "./interfaces/IRelayer.sol";
import "./interfaces/IOracle.sol";
import "./interfaces/IUserConfig.sol";
import "./call/ExcessivelySafeCall.sol";
import "./security/ReentrancyGuard.sol";

/// @title Endpoint
Expand Down
9 changes: 8 additions & 1 deletion src/Verifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,24 @@

pragma solidity 0.8.17;

import "./imt/IncrementalMerkleTree.sol";
import "./interfaces/IVerifier.sol";
import "./imt/IncrementalMerkleTree.sol";

abstract contract Verifier is IVerifier {
/// @notice Message proof.
/// @param messageIndex Leaf index of the message hash in incremental merkle tree.
/// @param messageProof Merkle proof of the message hash.
struct Proof {
uint256 messageIndex;
bytes32[32] messageProof;
}

/// @notice Fetch message root oracle.
/// @param chainId The destination chain id.
/// @return Message root in destination chain.
function merkleRoot(uint256 chainId) public view virtual returns (bytes32);

/// @inheritdoc IVerifier
function verifyMessageProof(uint256 fromChainId, bytes32 msgHash, bytes calldata proof)
external
view
Expand Down
2 changes: 1 addition & 1 deletion src/eco/Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

pragma solidity 0.8.17;

import "../interfaces/IFeedOracle.sol";
import "../Verifier.sol";
import "../interfaces/IFeedOracle.sol";

contract Oracle is Verifier {
event Assigned(bytes32 indexed msgHash);
Expand Down
6 changes: 1 addition & 5 deletions src/eco/Relayer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@

pragma solidity 0.8.17;

import "../Common.sol";

interface IChannel {
function recvMessage(Message calldata message, bytes calldata proof) external;
}
import "../interfaces/IChannel.sol";

contract Relayer {
event Assigned(bytes32 indexed msgHash, uint256 fee);
Expand Down
3 changes: 3 additions & 0 deletions src/interfaces/IChannel.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@

pragma solidity 0.8.17;

import "../Common.sol";

interface IChannel {
function sendMessage(address from, uint256 toChainId, address to, bytes calldata encoded)
external
returns (bytes32);
function recvMessage(Message calldata message, bytes calldata proof) external;
}
2 changes: 2 additions & 0 deletions src/interfaces/IEndpoint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ interface IEndpoint {
/// @param message Failed message info.
/// @return dispatchResult Result of the message dispatch.
function retryFailedMessage(Message calldata message) external returns (bool dispatchResult);

function recv(Message calldata message) external returns (bool dispatchResult);
}
7 changes: 7 additions & 0 deletions src/interfaces/IVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
pragma solidity 0.8.17;

interface IVerifier {
/// @notice Verify message proof
/// @dev Message proof provided by relayer. Oracle should provide message root of
/// source chain, and verify the merkle proof of the message hash.
/// @param fromChainId Source chain id.
/// @param msgHash Hash of the message.
/// @param proof Merkle proof of the message
/// @return Result of the message verify.
function verifyMessageProof(uint256 fromChainId, bytes32 msgHash, bytes calldata proof)
external
view
Expand Down

0 comments on commit dc40852

Please sign in to comment.