Polygon_ParentMessenger
Polygon_ParentMessenger
#
Sends cross chain messages from Ethereum to Polygon network.
This contract extends the FxBaseRootTunnel
contract and therefore is 1-to-1 mapped with the
FxBaseChildTunnel
extended by the Polygon_ChildMessenger
contract deployed on Polygon. This mapping ensures that
the internal _processMessageFromChild
function is only callable indirectly by the Polygon_ChildMessenger
.
#
Functionsconstructor(address _checkpointManager, address _fxRoot, uint256 _childChainId) (public)
Construct the Optimism_ParentMessenger contract.
#
Parameters:- _checkpointManager: The address of the Polygon checkpoint manager deployed on Mainnet. Required to construct new FxBaseRootTunnel that can connect to native Polygon data tunnel.
- _fxRoot: Polygon system contract deployed on Mainnet, required to construct new FxBaseRootTunnel that can send messages via native Polygon data tunnel.
- _childChainId: The chain id of the Optimism L2 network this messenger should connect to.
sendMessageToChild(bytes data) (public)
Sends a message to the child messenger via the canonical message bridge.
The caller must be the either the OracleHub or the GovernorHub. This is to send either a price or initiate a governance action to the OracleSpoke or GovernorSpoke on the child chain. The recipient of this message is the child messenger. The messenger must implement _processMessageFromRoot which then forwards the data to the target either the OracleSpoke or the governorSpoke depending on the caller.
#
Parameters:- data: data message sent to the child messenger. Should be an encoded function call or packed data.
_processMessageFromChild(bytes data) (internal)
Process a received message from the child messenger via the canonical message bridge.
This internal method will be called inside FxBaseRootTunnel.receiveMessage(bytes memory inputData)
,
which must be called by an EOA to finalize the relay of the message from Polygon to Ethereum.
The inputData
is a proof of transaction that is derived from the transaction hash of the transaction on the
child chain that originated the cross-chain price request via _sendMessageToRoot.
This call will revert if setFxChild
has not been called. Fx Child should be set to Polygon_ChildMessenger.
#
Parameters:- data: ABI encoded params with which to call function on OracleHub or GovernorHub.
_preEntranceCheck() (internal)
_preEntranceSet() (internal)
_postEntranceReset() (internal)
setChildMessenger(address newChildMessenger) (public)
Changes the stored address of the child messenger, deployed on L2.
The caller of this function must be the owner. This should be set to the DVM governor.
#
Parameters:- newChildMessenger: address of the new child messenger, deployed on L2.
setOracleHub(address newOracleHub) (public)
Changes the stored address of the Oracle hub, deployed on L1.
The caller of this function must be the owner. This should be set to the DVM governor.
#
Parameters:- newOracleHub: address of the new oracle hub, deployed on L1 Ethereum.
setGovernorHub(address newGovernorHub) (public)
Changes the stored address of the Governor hub, deployed on L1.
The caller of this function must be the owner. This should be set to the DVM governor.
#
Parameters:- newGovernorHub: address of the new governor hub, deployed on L1 Ethereum.
setOracleSpoke(address newOracleSpoke) (public)
Changes the stored address of the oracle spoke, deployed on L2.
The caller of this function must be the owner. This should be set to the DVM governor.
#
Parameters:- newOracleSpoke: address of the new oracle spoke, deployed on L2.
setGovernorSpoke(address newGovernorSpoke) (public)
Changes the stored address of the governor spoke, deployed on L2.
The caller of this function must be the owner. This should be set to the DVM governor.
#
Parameters:- newGovernorSpoke: address of the new governor spoke, deployed on L2.
getL1CallValue() โ uint256 (external)
Returns the amount of ETH required for a caller to pass as msg.value when calling sendMessageToChild
.
owner() โ address (public)
Returns the address of the current owner.
renounceOwnership() (public)
Leaves the contract without owner. It will not be possible to call
onlyOwner
functions anymore. Can only be called by the current owner.
NOTE: Renouncing ownership will leave the contract without an owner,
thereby removing any functionality that is only available to the owner.
transferOwnership(address newOwner) (public)
Transfers ownership of the contract to a new account (newOwner
).
Can only be called by the current owner.
_transferOwnership(address newOwner) (internal)
Transfers ownership of the contract to a new account (newOwner
).
Internal function without access restriction.
_msgSender() โ address (internal)
_msgData() โ bytes (internal)
setFxChildTunnel(address _fxChildTunnel) (public)
_sendMessageToChild(bytes message) (internal)
Send bytes message to Child Tunnel
#
Parameters:- message: bytes message that will be sent to Child Tunnel some message examples - abi.encode(tokenId); abi.encode(tokenId, tokenMetadata); abi.encode(messageType, messageData);
_validateAndExtractMessage(bytes inputData) โ bytes (internal)
receiveMessage(bytes inputData) (public)
receive message from L2 to L1, validated by proof
This function verifies if the transaction actually happened on child chain
#
Parameters:- inputData: RLP encoded data of the reference tx containing following list of fields 0 - headerNumber - Checkpoint header block number containing the reference tx 1 - blockProof - Proof that the block header (in the child chain) is a leaf in the submitted merkle root 2 - blockNumber - Block number containing the reference tx on child chain 3 - blockTime - Reference tx block time 4 - txRoot - Transactions root of block 5 - receiptRoot - Receipts root of block 6 - receipt - Receipt of the reference transaction 7 - receiptProof - Merkle proof of the reference receipt 8 - branchMask - 32 bits denoting the path of receipt in merkle tree 9 - receiptLogIndex - Log Index to read from the receipt
#
EventsMessageSentToChild(bytes data, address targetSpoke)
MessageReceivedFromChild(address targetHub, bytes dataToSendToTarget)
SetChildMessenger(address childMessenger)
SetOracleHub(address oracleHub)
SetGovernorHub(address governorHub)
SetOracleSpoke(address oracleSpoke)
SetGovernorSpoke(address governorSpoke)
OwnershipTransferred(address previousOwner, address newOwner)
#
ModifiersnonReentrant()
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.
onlyHubContract()
onlyOwner()
Throws if called by any account other than the owner.