Commit 436c48fd authored by Davis Shaver's avatar Davis Shaver Committed by Kelvin Fichter

chore(contracts): defaults lib w/ xdomain msg sender

parent 8148d2fb
---
'@eth-optimism/contracts': patch
---
Added default values library for contracts
...@@ -7,6 +7,7 @@ import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolve ...@@ -7,6 +7,7 @@ import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolve
import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol";
import { Lib_AddressManager } from "../../libraries/resolver/Lib_AddressManager.sol"; import { Lib_AddressManager } from "../../libraries/resolver/Lib_AddressManager.sol";
import { Lib_SecureMerkleTrie } from "../../libraries/trie/Lib_SecureMerkleTrie.sol"; import { Lib_SecureMerkleTrie } from "../../libraries/trie/Lib_SecureMerkleTrie.sol";
import { Lib_DefaultValues } from "../../libraries/constants/Lib_DefaultValues.sol";
import { Lib_PredeployAddresses } from "../../libraries/constants/Lib_PredeployAddresses.sol"; import { Lib_PredeployAddresses } from "../../libraries/constants/Lib_PredeployAddresses.sol";
import { Lib_CrossDomainUtils } from "../../libraries/bridge/Lib_CrossDomainUtils.sol"; import { Lib_CrossDomainUtils } from "../../libraries/bridge/Lib_CrossDomainUtils.sol";
...@@ -51,14 +52,6 @@ contract OVM_L1CrossDomainMessenger is ...@@ -51,14 +52,6 @@ contract OVM_L1CrossDomainMessenger is
bytes32 indexed _xDomainCalldataHash bytes32 indexed _xDomainCalldataHash
); );
/*************
* Constants *
*************/
// The default x-domain message sender being set to a non-zero value makes
// deployment a bit more expensive, but in exchange the refund on every call to
// `relayMessage` by the L1 and L2 messengers will be higher.
address internal constant DEFAULT_XDOMAIN_SENDER = 0x000000000000000000000000000000000000dEaD;
/********************** /**********************
* Contract Variables * * Contract Variables *
...@@ -68,7 +61,7 @@ contract OVM_L1CrossDomainMessenger is ...@@ -68,7 +61,7 @@ contract OVM_L1CrossDomainMessenger is
mapping (bytes32 => bool) public relayedMessages; mapping (bytes32 => bool) public relayedMessages;
mapping (bytes32 => bool) public successfulMessages; mapping (bytes32 => bool) public successfulMessages;
address internal xDomainMsgSender = DEFAULT_XDOMAIN_SENDER; address internal xDomainMsgSender = Lib_DefaultValues.DEFAULT_XDOMAIN_SENDER;
/*************** /***************
* Constructor * * Constructor *
...@@ -121,7 +114,7 @@ contract OVM_L1CrossDomainMessenger is ...@@ -121,7 +114,7 @@ contract OVM_L1CrossDomainMessenger is
"L1CrossDomainMessenger already intialized." "L1CrossDomainMessenger already intialized."
); );
libAddressManager = Lib_AddressManager(_libAddressManager); libAddressManager = Lib_AddressManager(_libAddressManager);
xDomainMsgSender = DEFAULT_XDOMAIN_SENDER; xDomainMsgSender = Lib_DefaultValues.DEFAULT_XDOMAIN_SENDER;
// Initialize upgradable OZ contracts // Initialize upgradable OZ contracts
__Context_init_unchained(); // Context is a dependency for both Ownable and Pausable __Context_init_unchained(); // Context is a dependency for both Ownable and Pausable
...@@ -176,7 +169,7 @@ contract OVM_L1CrossDomainMessenger is ...@@ -176,7 +169,7 @@ contract OVM_L1CrossDomainMessenger is
address address
) )
{ {
require(xDomainMsgSender != DEFAULT_XDOMAIN_SENDER, "xDomainMessageSender is not set"); require(xDomainMsgSender != Lib_DefaultValues.DEFAULT_XDOMAIN_SENDER, "xDomainMessageSender is not set");
return xDomainMsgSender; return xDomainMsgSender;
} }
...@@ -266,7 +259,7 @@ contract OVM_L1CrossDomainMessenger is ...@@ -266,7 +259,7 @@ contract OVM_L1CrossDomainMessenger is
xDomainMsgSender = _sender; xDomainMsgSender = _sender;
(bool success, ) = _target.call(_message); (bool success, ) = _target.call(_message);
xDomainMsgSender = DEFAULT_XDOMAIN_SENDER; xDomainMsgSender = Lib_DefaultValues.DEFAULT_XDOMAIN_SENDER;
// Mark the message as received if the call was successful. Ensures that a message can be // Mark the message as received if the call was successful. Ensures that a message can be
// relayed multiple times in the case that the call reverted. // relayed multiple times in the case that the call reverted.
......
...@@ -4,6 +4,7 @@ pragma experimental ABIEncoderV2; ...@@ -4,6 +4,7 @@ pragma experimental ABIEncoderV2;
/* Library Imports */ /* Library Imports */
import { Lib_CrossDomainUtils } from "../../libraries/bridge/Lib_CrossDomainUtils.sol"; import { Lib_CrossDomainUtils } from "../../libraries/bridge/Lib_CrossDomainUtils.sol";
import { Lib_DefaultValues } from "../../libraries/constants/Lib_DefaultValues.sol";
import { Lib_PredeployAddresses } from "../../libraries/constants/Lib_PredeployAddresses.sol"; import { Lib_PredeployAddresses } from "../../libraries/constants/Lib_PredeployAddresses.sol";
/* Interface Imports */ /* Interface Imports */
...@@ -29,15 +30,6 @@ contract OVM_L2CrossDomainMessenger is ...@@ -29,15 +30,6 @@ contract OVM_L2CrossDomainMessenger is
ReentrancyGuard ReentrancyGuard
{ {
/*************
* Constants *
*************/
// The default x-domain message sender being set to a non-zero value makes
// deployment a bit more expensive, but in exchange the refund on every call to
// `relayMessage` by the L1 and L2 messengers will be higher.
address internal constant DEFAULT_XDOMAIN_SENDER = 0x000000000000000000000000000000000000dEaD;
/************* /*************
* Variables * * Variables *
*************/ *************/
...@@ -46,7 +38,7 @@ contract OVM_L2CrossDomainMessenger is ...@@ -46,7 +38,7 @@ contract OVM_L2CrossDomainMessenger is
mapping (bytes32 => bool) public successfulMessages; mapping (bytes32 => bool) public successfulMessages;
mapping (bytes32 => bool) public sentMessages; mapping (bytes32 => bool) public sentMessages;
uint256 public messageNonce; uint256 public messageNonce;
address internal xDomainMsgSender = DEFAULT_XDOMAIN_SENDER; address internal xDomainMsgSender = Lib_DefaultValues.DEFAULT_XDOMAIN_SENDER;
address public l1CrossDomainMessenger; address public l1CrossDomainMessenger;
/*************** /***************
...@@ -73,7 +65,7 @@ contract OVM_L2CrossDomainMessenger is ...@@ -73,7 +65,7 @@ contract OVM_L2CrossDomainMessenger is
address address
) )
{ {
require(xDomainMsgSender != DEFAULT_XDOMAIN_SENDER, "xDomainMessageSender is not set"); require(xDomainMsgSender != Lib_DefaultValues.DEFAULT_XDOMAIN_SENDER, "xDomainMessageSender is not set");
return xDomainMsgSender; return xDomainMsgSender;
} }
...@@ -150,7 +142,7 @@ contract OVM_L2CrossDomainMessenger is ...@@ -150,7 +142,7 @@ contract OVM_L2CrossDomainMessenger is
xDomainMsgSender = _sender; xDomainMsgSender = _sender;
(bool success, ) = _target.call(_message); (bool success, ) = _target.call(_message);
xDomainMsgSender = DEFAULT_XDOMAIN_SENDER; xDomainMsgSender = Lib_DefaultValues.DEFAULT_XDOMAIN_SENDER;
// Mark the message as received if the call was successful. Ensures that a message can be // Mark the message as received if the call was successful. Ensures that a message can be
// relayed multiple times in the case that the call reverted. // relayed multiple times in the case that the call reverted.
......
// SPDX-License-Identifier: MIT
pragma solidity >0.5.0 <0.8.0;
/**
* @title Lib_DefaultValues
*/
library Lib_DefaultValues {
// The default x-domain message sender being set to a non-zero value makes
// deployment a bit more expensive, but in exchange the refund on every call to
// `relayMessage` by the L1 and L2 messengers will be higher.
address internal constant DEFAULT_XDOMAIN_SENDER = 0x000000000000000000000000000000000000dEaD;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment