Skip to main content

Optimism_ChildMessenger

Optimism_ChildMessenger#

Sends cross chain messages from Optimism L2 to Ethereum L1 network.

This contract is ownable via the onlyFromCrossDomainAccount. modifier, restricting ownership to the cross-domain parent messenger contract that lives on L1.

Functions#

constructor(address _parentMessenger) (public)

Construct the Optimism_ChildMessenger contract.

Parameters:#

  • _parentMessenger: The address of the L1 parent messenger. Acts as the "owner" of this contract.
setOracleSpoke(address newOracleSpoke) (public)

Changes the stored address of the Oracle spoke, deployed on L2.

The caller of this function must be the parent messenger, over the canonical bridge.

Parameters:#

  • newOracleSpoke: address of the new oracle spoke, deployed on L2.
setParentMessenger(address newParentMessenger) (public)

Changes the stored address of the parent messenger, deployed on L1.

The caller of this function must be the parent messenger, over the canonical bridge.

Parameters:#

  • newParentMessenger: address of the new parent messenger, deployed on L1.
setDefaultGasLimit(uint32 newDefaultGasLimit) (public)

Changes the default gas limit that is sent along with transactions to Ethereum.

The caller of this function must be the parent messenger, over the canonical bridge.

Parameters:#

  • newDefaultGasLimit: the new L1 gas limit to be set.
sendMessageToParent(bytes data) (public)

Sends a message to the parent messenger via the canonical message bridge.

The caller must be the OracleSpoke on L2. No other contract is permissioned to call this function. The L1 target, the parent messenger, must implement processMessageFromChild to consume the message.

Parameters:#

  • data: data message sent to the L1 messenger. Should be an encoded function call or packed data.
processMessageFromCrossChainParent(bytes data, address target) (public)

Process a received message from the parent messenger via the canonical message bridge.

The caller must be the the parent messenger, sent over the canonical message bridge.

Parameters:#

  • data: data message sent from the L1 messenger. Should be an encoded function call or packed data.
  • target: desired recipient of data. Target must implement the processMessageFromParent function. Having this as a param enables the L1 Messenger to send messages to arbitrary addresses on the L2. This is primarily used to send messages to the OracleSpoke and GovernorSpoke on L2.
_preEntranceCheck() (internal)
_preEntranceSet() (internal)
_postEntranceReset() (internal)
_startReentrantGuardDisabled() (internal)
_endReentrantGuardDisabled() (internal)
getCrossDomainMessenger() → contract ICrossDomainMessenger (internal)

Gets the messenger, usually from storage. This function is exposed in case a child contract needs to override.

sendCrossDomainMessage(address _crossDomainTarget, uint32 _gasLimit, bytes _message) (internal)

q Sends a message to an account on another domain

Parameters:#

  • _crossDomainTarget: The intended recipient on the destination domain
  • _message: The data to send to the target (usually calldata to a function with onlyFromCrossDomainAccount())
  • _gasLimit: The gasLimit for the receipt of the message on the target domain.

Events#

SetOracleSpoke(address newOracleSpoke)
SetParentMessenger(address newParentMessenger)
SetDefaultGasLimit(uint32 newDefaultGasLimit)
MessageSentToParent(bytes data, address parentAddress, address oracleSpoke, uint32 gasLimit)
MessageReceivedFromParent(bytes data, address targetSpoke, address parentAddress)

Modifiers#

nonReentrant()

Prevents a contract from calling itself, directly or indirectly. Calling a nonReentrant function from another nonReentrant function is not supported. It is possible to prevent this from happening by making the nonReentrant function external, and making it call a private function that does the actual state modification.

nonReentrantView()

Designed to prevent a view-only method from being re-entered during a call to a nonReentrant() state-changing method.

onlyFromCrossDomainAccount(address _sourceDomainAccount)

Enforces that the modified function is only callable by a specific cross-domain account.

Parameters:

  • _sourceDomainAccount: The only account on the originating domain which is authenticated to call this function.