diff --git a/src/ORMP.sol b/src/ORMP.sol index 9fa7932..836efb1 100644 --- a/src/ORMP.sol +++ b/src/ORMP.sol @@ -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; @@ -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( diff --git a/src/eco/Oracle.sol b/src/eco/Oracle.sol index e042194..92c6bc9 100644 --- a/src/eco/Oracle.sol +++ b/src/eco/Oracle.sol @@ -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 { diff --git a/src/eco/Relayer.sol b/src/eco/Relayer.sol index 56fa2a5..fa47c3c 100644 --- a/src/eco/Relayer.sol +++ b/src/eco/Relayer.sol @@ -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, ""); } } diff --git a/src/interfaces/IORMP.sol b/src/interfaces/IORMP.sol index 654bb91..e3a65ba 100644 --- a/src/interfaces/IORMP.sol +++ b/src/interfaces/IORMP.sol @@ -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. diff --git a/test/eco/Relayer.t.sol b/test/eco/Relayer.t.sol index 0cb0d0d..b132c41 100644 --- a/test/eco/Relayer.t.sol +++ b/test/eco/Relayer.t.sol @@ -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) {}