Commit 69ee689f authored by smartcontracts's avatar smartcontracts Committed by GitHub

fix(ctb): remove DefaultValues (#2961)

Unnecessary library, only being used in a single place now and it can
just be an internal constant. I see no strong reason for this library to
continue to exist.
parent 33aef763
---
'@eth-optimism/contracts-bedrock': patch
---
Remove unnecessary DefaultValues library
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
/**
* @title DefaultValues
*/
library 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;
}
......@@ -7,7 +7,6 @@ import { L2OutputOracle_Initializer } from "./L2OutputOracle.t.sol";
/* Libraries */
import { AddressAliasHelper } from "../vendor/AddressAliasHelper.sol";
import { DefaultValues } from "../libraries/DefaultValues.sol";
import { PredeployAddresses } from "../libraries/PredeployAddresses.sol";
import { CrossDomainUtils } from "../libraries/CrossDomainUtils.sol";
import { WithdrawalVerifier } from "../libraries/WithdrawalVerifier.sol";
......
......@@ -10,7 +10,6 @@ import { L2OutputOracle } from "../L1/L2OutputOracle.sol";
import { L2CrossDomainMessenger } from "../L2/L2CrossDomainMessenger.sol";
import { L1CrossDomainMessenger } from "../L1/L1CrossDomainMessenger.sol";
import { CrossDomainHashing } from "../libraries/CrossDomainHashing.sol";
import { DefaultValues } from "../libraries/DefaultValues.sol";
contract L2CrossDomainMessenger_Test is Messenger_Initializer {
// Receiver address for testing
......
......@@ -11,7 +11,6 @@ import {
ReentrancyGuardUpgradeable
} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import { ExcessivelySafeCall } from "excessively-safe-call/src/ExcessivelySafeCall.sol";
import { DefaultValues } from "../libraries/DefaultValues.sol";
import { CrossDomainHashing } from "../libraries/CrossDomainHashing.sol";
/**
......@@ -83,6 +82,13 @@ abstract contract CrossDomainMessenger is
*/
uint256 internal constant RELAY_GAS_BUFFER = RELAY_GAS_REQUIRED - 5000;
/**
* @notice Initial value for the xDomainMsgSender variable. We set this to a non-zero value
* because performing an SSTORE on a non-zero value is significantly cheaper than on a
* zero value.
*/
address internal constant DEFAULT_XDOMAIN_SENDER = 0x000000000000000000000000000000000000dEaD;
/**
* @notice Mapping of message hashes to boolean receipt values. Note that a message will only
* be present in this mapping if it failed to be relayed on this chain at least once.
......@@ -152,10 +158,7 @@ abstract contract CrossDomainMessenger is
* @return Address of the sender of the currently executing message on the other chain.
*/
function xDomainMessageSender() external view returns (address) {
require(
xDomainMsgSender != DefaultValues.DEFAULT_XDOMAIN_SENDER,
"xDomainMessageSender is not set"
);
require(xDomainMsgSender != DEFAULT_XDOMAIN_SENDER, "xDomainMessageSender is not set");
return xDomainMsgSender;
}
......@@ -287,7 +290,7 @@ abstract contract CrossDomainMessenger is
0,
_message
);
xDomainMsgSender = DefaultValues.DEFAULT_XDOMAIN_SENDER;
xDomainMsgSender = DEFAULT_XDOMAIN_SENDER;
if (success == true) {
successfulMessages[versionedHash] = true;
......@@ -312,7 +315,7 @@ abstract contract CrossDomainMessenger is
function _initialize(address _otherMessenger, address[] memory _blockedSystemAddresses)
internal
{
xDomainMsgSender = DefaultValues.DEFAULT_XDOMAIN_SENDER;
xDomainMsgSender = DEFAULT_XDOMAIN_SENDER;
otherMessenger = _otherMessenger;
for (uint256 i = 0; i < _blockedSystemAddresses.length; i++) {
......
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