Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
08bc4633
Unverified
Commit
08bc4633
authored
Dec 09, 2022
by
mergify[bot]
Committed by
GitHub
Dec 09, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4339 from ethereum-optimism/sc/ctb-default-sender-constants
maint(ctb): move default sender to constants
parents
a2f57bd2
82768d54
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
18 deletions
+13
-18
OptimismPortal.sol
packages/contracts-bedrock/contracts/L1/OptimismPortal.sol
+3
-8
Constants.sol
packages/contracts-bedrock/contracts/libraries/Constants.sol
+7
-0
CrossDomainMessenger.sol
...acts-bedrock/contracts/universal/CrossDomainMessenger.sol
+3
-10
No files found.
packages/contracts-bedrock/contracts/L1/OptimismPortal.sol
View file @
08bc4633
...
...
@@ -38,11 +38,6 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
*/
uint256 internal constant DEPOSIT_VERSION = 0;
/**
* @notice Value used to reset the l2Sender, this is more efficient than setting it to zero.
*/
address internal constant DEFAULT_L2_SENDER = 0x000000000000000000000000000000000000dEaD;
/**
* @notice The L2 gas limit set when eth is deposited using the receive() function.
*/
...
...
@@ -131,7 +126,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
* @notice Initializer;
*/
function initialize() public initializer {
l2Sender = DEFAULT_L2_SENDER;
l2Sender =
Constants.
DEFAULT_L2_SENDER;
__ResourceMetering_init();
}
...
...
@@ -239,7 +234,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
function finalizeWithdrawalTransaction(Types.WithdrawalTransaction memory _tx) external {
// Prevent nested withdrawals within withdrawals.
require(
l2Sender == DEFAULT_L2_SENDER,
l2Sender ==
Constants.
DEFAULT_L2_SENDER,
"OptimismPortal: can only trigger one withdrawal per transaction"
);
...
...
@@ -315,7 +310,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
);
// Reset the l2Sender back to the default value.
l2Sender = DEFAULT_L2_SENDER;
l2Sender =
Constants.
DEFAULT_L2_SENDER;
// All withdrawals are immediately finalized. Replayability can
// be achieved through contracts built on top of this contract
...
...
packages/contracts-bedrock/contracts/libraries/Constants.sol
View file @
08bc4633
...
...
@@ -17,4 +17,11 @@ library Constants {
* never have any code on any EVM chain.
*/
address internal constant ESTIMATION_ADDRESS = address(1);
/**
* @notice Value used for the L2 sender storage slot in both the OptimismPortal and the
* CrossDomainMessenger contracts before an actual sender is set. This value is
* non-zero to reduce the gas cost of message passing transactions.
*/
address internal constant DEFAULT_L2_SENDER = 0x000000000000000000000000000000000000dEaD;
}
packages/contracts-bedrock/contracts/universal/CrossDomainMessenger.sol
View file @
08bc4633
...
...
@@ -81,13 +81,6 @@ 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 Address of the paired CrossDomainMessenger contract on the other chain.
*/
...
...
@@ -322,7 +315,7 @@ abstract contract CrossDomainMessenger is
xDomainMsgSender = _sender;
bool success = SafeCall.call(_target, gasleft() - RELAY_GAS_BUFFER, _value, _message);
xDomainMsgSender =
DEFAULT_XDOMAIN
_SENDER;
xDomainMsgSender =
Constants.DEFAULT_L2
_SENDER;
if (success == true) {
successfulMessages[versionedHash] = true;
...
...
@@ -351,7 +344,7 @@ abstract contract CrossDomainMessenger is
*/
function xDomainMessageSender() external view returns (address) {
require(
xDomainMsgSender !=
DEFAULT_XDOMAIN
_SENDER,
xDomainMsgSender !=
Constants.DEFAULT_L2
_SENDER,
"CrossDomainMessenger: xDomainMessageSender is not set"
);
...
...
@@ -399,7 +392,7 @@ abstract contract CrossDomainMessenger is
*/
// solhint-disable-next-line func-name-mixedcase
function __CrossDomainMessenger_init() internal onlyInitializing {
xDomainMsgSender =
DEFAULT_XDOMAIN
_SENDER;
xDomainMsgSender =
Constants.DEFAULT_L2
_SENDER;
__Context_init_unchained();
__Ownable_init_unchained();
__Pausable_init_unchained();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment