The home for Hyperlane core contracts, sdk packages, and other infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hyperlane-monorepo/solidity/contracts/isms/hook/AbstractHookISM.sol

60 lines
2.1 KiB

// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.8.0;
/*@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@ HYPERLANE @@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@*/
// ============ Internal Imports ============
import {IInterchainSecurityModule} from "../../interfaces/IInterchainSecurityModule.sol";
import {Message} from "../../libs/Message.sol";
import {TypeCasts} from "../../libs/TypeCasts.sol";
// ============ External Imports ============
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
/**
* @title ArbtractNativeISM
* @notice Uses the native bridges to verify interchain messages.
* @dev In the future, the hook might be moved inside the Mailbox which doesn't require storage mappings for senders.
* for more details see https://github.com/hyperlane-xyz/hyperlane-monorepo/issues/2381
*/
abstract contract AbstractHookISM is IInterchainSecurityModule, Initializable {
// ============ Public Storage ============
// Maps messageId to whether or not the sender attested to that message ID on the origin chain
// @dev anyone can send an untrusted messageId, so need to check for that while verifying
mapping(bytes32 => mapping(bytes32 => bool)) public verifiedMessageIds;
// ============ Events ============
event ReceivedMessage(bytes32 indexed sender, bytes32 indexed messageId);
// ============ External Functions ============
/**
* @notice Verify a message was received by ISM.
* @param _message Message to verify.
*/
function verify(
bytes calldata, /*_metadata*/
bytes calldata _message
) external view returns (bool) {
bytes32 _messageId = Message.id(_message);
bytes32 _messageSender = Message.sender(_message);
return verifiedMessageIds[_messageId][_messageSender];
}
}