Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
hujw77 committed Apr 19, 2024
1 parent 0d4a84c commit 652d4d2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
11 changes: 7 additions & 4 deletions src/ORMP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ contract ORMP is ReentrancyGuard, Channel {
event MessageAssigned(
bytes32 indexed msgHash, address indexed oracle, address indexed relayer, uint256 oracleFee, uint256 relayerFee
);
event HashImported(address indexed oracle, bytes32 indexed lookupKey, bytes32 indexed hash);
event HashImported(address indexed oracle, uint256 chainId, address channel, uint256 msgIndex, bytes32 hash);

/// oracle => lookupKey => hash
mapping(address => mapping(bytes32 => bytes32)) public hashLookup;
Expand Down Expand Up @@ -73,11 +73,14 @@ contract ORMP is ReentrancyGuard, Channel {
/// @dev Import hash by any oracle address.
/// @notice Hash is an abstract of the proof system, it can be a block hash or a message root hash,
/// specifically provided by oracles.
/// @param lookupKey The key for loop up hash.
/// @param chainId The source chain id.
/// @param channel The message channel.
/// @param msgIndex The source chain message index.
/// @param hash_ The hash to import.
function importHash(bytes32 lookupKey, bytes32 hash_) external {
function importHash(uint256 chainId, address channel, uint256 msgIndex, bytes32 hash_) external {
bytes32 lookupKey = keccak256(abi.encode(chainId, channel, msgIndex));
hashLookup[msg.sender][lookupKey] = hash_;
emit HashImported(msg.sender, lookupKey, hash_);
emit HashImported(msg.sender, chainId, channel, msgIndex, hash_);
}

function _handleFee(
Expand Down
8 changes: 2 additions & 6 deletions src/eco/Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,11 @@ contract Oracle is Verifier {
external
onlyOwner
{
IORMP(PROTOCOL).importHash(_lookupkey(chainId, channel, msgIndex), msgHash);
IORMP(PROTOCOL).importHash(chainId, channel, msgIndex, msgHash);
}

function hashOf(uint256 chainId, address channel, uint256 msgIndex) public view override returns (bytes32) {
return IORMP(PROTOCOL).hashLookup(address(this), _lookupkey(chainId, channel, msgIndex));
}

function _lookupkey(uint256 chainId, address channel, uint256 msgIndex) internal pure returns (bytes32) {
return keccak256(abi.encode(chainId, channel, msgIndex));
return IORMP(PROTOCOL).hashLookup(address(this), keccak256(abi.encode(chainId, channel, msgIndex)));
}

function changeOwner(address newOwner) external onlyOwner {
Expand Down
4 changes: 2 additions & 2 deletions src/eco/Relayer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ contract Relayer {
return sourceToken + payloadToken;
}

function relay(Message calldata message, bytes calldata proof) external onlyApproved {
IORMP(PROTOCOL).recv(message, proof);
function relay(Message calldata message) external onlyApproved {
IORMP(PROTOCOL).recv(message, "");
}
}
6 changes: 4 additions & 2 deletions src/interfaces/IORMP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ interface IORMP {
/// @dev Import hash by any oracle address.
/// @notice Hash is an abstract of the proof system, it can be a block hash or a message root hash,
/// specifically provided by oracles.
/// @param lookupKey The key for loop up hash.
/// @param chainId The source chain id.
/// @param channel The message channel.
/// @param msgIndex The source chain message index.
/// @param hash_ The hash to import.
function importHash(bytes32 lookupKey, bytes32 hash_) external;
function importHash(uint256 chainId, address channel, uint256 msgIndex, bytes32 hash_) external;

/// @dev Fetch hash.
/// @param oracle The oracle address.
Expand Down
2 changes: 1 addition & 1 deletion test/eco/Relayer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ contract RelayerTest is Test {
gasLimit: 0,
encoded: ""
});
relayer.relay(message, "");
relayer.relay(message);
}

function recv(Message calldata message, bytes calldata proof) external returns (bool) {}
Expand Down

0 comments on commit 652d4d2

Please sign in to comment.