Mailbox
Hyperlane's generalized message passing (GMP) interface is implemented as a smart contract called the Mailbox. This contract encodes and decodes message headers, ensures global message uniqueness, and prevents replay attacks.
Message Headers
The Mailbox prepends message bodies with a header containing the following fields:
version
: The version of the Mailbox contractnonce
: A unique identifier for each message sent from a given Mailboxorigin
: The domain of the origin chainsender
: The address of the sender on the origin chaindestination
: The domain of the destination chainrecipient
: The address of the recipient on the destination chain
See the Message
library for more information on the message encoding.
Uniqueness
The nonce
is a monotonically increasing integer for each message sent from a given Mailbox. It is incremented each time a message is dispatched to serve as a separator for otherwise identical messages.
- Solidity
function delivered(bytes32 messageId) external view returns (bool);
The messageId
is a globally unique message identifier, returned from the dispatch
call, computed as the keccak256
hash of the message (with headers).
Replay Protection
The Mailbox maintains a mapping of already delivered messageId
values to prevent replay attacks. If a message is received with a messageId
that has already been delivered, the message is rejected.
- Solidity
function defaultIsm() external view returns (IInterchainSecurityModule);