Function: sendMessage(byte[3] _destination_chain, byte[32] _destination, byte[32][] _contents)
This function is used to send a cross-chain message to another blockchain. It charges a toll and emits a MessageSent
event. This event will be monitored by the bridge system, which will relay the message to the destination chain.
Inputs
_destination_chain
Control: Arbitrary.
Constraints: Valid
supportedChains
mapping.Impact: Chain ID of the destination chain.
_destination
Control: Arbitrary.
Constraints: None.
Impact: Target address of the destination chain.
_contents
Control: Arbitrary.
Constraints: None.
Impact: Content of the message being sent, including token address, amount, and recipient address.
Branches and code coverage
Intended branches
Check message toll is paid.
Check destination chain is supported.
Increment the nonce.
Send the toll to the miner.
Emit a
MessageSent
event.
Negative behavior
Revert if message toll is not paid.
Revert if destination chain is not supported.
Function call analysis
block.coinbase.call()
What happens if it reverts, reenters or does other unusual control flow? If miner is the contact address, the reentrance risk exists, which can result in a nonsequential
ethNonce
occurrence ofMessageSent
.