Skip to content
This repository has been archived by the owner on Apr 12, 2021. It is now read-only.

Add nonReentrant to relayMessage() #172

Merged
merged 5 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ abstract contract OVM_BaseCrossDomainMessenger is iOVM_BaseCrossDomainMessenger,
address _target,
bytes memory _message,
uint32 _gasLimit
) nonReentrant
)
maurelian marked this conversation as resolved.
Show resolved Hide resolved
override
public
nonReentrant
{
bytes memory xDomainCalldata = _getXDomainCalldata(
_target,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol";
import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol";
import { Lib_AddressManager } from "../../libraries/resolver/Lib_AddressManager.sol";
import { Lib_SecureMerkleTrie } from "../../libraries/trie/Lib_SecureMerkleTrie.sol";
import { Lib_ReentrancyGuard } from "../../libraries/utils/Lib_ReentrancyGuard.sol";

/* Interface Imports */
import { iOVM_L1CrossDomainMessenger } from "../../iOVM/bridge/iOVM_L1CrossDomainMessenger.sol";
Expand All @@ -18,6 +19,7 @@ import { OVM_BaseCrossDomainMessenger } from "./OVM_BaseCrossDomainMessenger.sol

/**
* @title OVM_L1CrossDomainMessenger
* @dev This contract lives on L1. It sends messages to L2, and relays them from L2
maurelian marked this conversation as resolved.
Show resolved Hide resolved
*/
contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCrossDomainMessenger, Lib_AddressResolver {

Expand Down Expand Up @@ -81,6 +83,7 @@ contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCros
)
override
public
nonReentrant
onlyRelayer()
{
bytes memory xDomainCalldata = _getXDomainCalldata(
Expand Down Expand Up @@ -140,6 +143,7 @@ contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCros
)
override
public
nonReentrant
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, this code path speaks directly to the rollup contracts (OVM_CanonicalTransactionChain.enqueue specifically) so it should not be re-enterable based on the behavior of that target, so it should not be needed.

I'd recommend removing it, because the L1 SSTORE is gonna be expensive. If you think that it's worth keeping, we can, but we should also add it to sendMessage, since the functions serve similar purposes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OVM_BaseCrossDomainMessenger.sendMessage() already has the nonReentrant modifier on it. You can see above that I moved it down a couple lines to improve the style. But looking at both sendMessage and replayMessage more closely, I agree that it looks pretty safe to remove them.

{
bytes memory xDomainCalldata = _getXDomainCalldata(
_target,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pragma experimental ABIEncoderV2;

/* Library Imports */
import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol";
import { Lib_ReentrancyGuard } from "../../libraries/utils/Lib_ReentrancyGuard.sol";

/* Interface Imports */
import { iOVM_L2CrossDomainMessenger } from "../../iOVM/bridge/iOVM_L2CrossDomainMessenger.sol";
Expand All @@ -17,6 +18,7 @@ import { OVM_BaseCrossDomainMessenger } from "./OVM_BaseCrossDomainMessenger.sol
/**
* @title OVM_L2CrossDomainMessenger
* @dev L2 CONTRACT (COMPILED)
* This contract lives on L2. It sends messages to L1, and relays them from L1
maurelian marked this conversation as resolved.
Show resolved Hide resolved
*/
contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, OVM_BaseCrossDomainMessenger, Lib_AddressResolver {

Expand Down Expand Up @@ -50,6 +52,7 @@ contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, OVM_BaseCros
uint256 _messageNonce
)
override
nonReentrant
public
{
require(
Expand Down