Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
deploy
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
deploy
Commits
b8715ecc
Commit
b8715ecc
authored
Apr 18, 2025
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update contract for withdrawal
parent
a837d358
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
22 deletions
+4
-22
OptimismPortal.sol
layer2/contracts-bedrock/src/L1/OptimismPortal.sol
+4
-22
No files found.
layer2/contracts-bedrock/src/L1/OptimismPortal.sol
View file @
b8715ecc
...
...
@@ -430,7 +430,6 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
// revert GasEstimation();
// }
}
event Println(uint256 line);
/// @notice withdrawal for a user.
...
...
@@ -447,20 +446,10 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
external
whenNotPaused
{
emit Println(1);
if (_param.user == address(this)) revert BadTarget();
emit Println(2);
bytes32 outputRoot = l2Oracle.getL2Output(_l2OutputIndex).outputRoot;
emit Println(3);
require(_param.user!=address(this), "BadTarget()");
Types.OutputProposal memory proposal = l2Oracle.getL2Output(_l2OutputIndex);
bytes32 outputRoot = proposal.outputRoot;
bytes32 withdrawalHash = Hashing.hashExChainWithdrawal(_param);
emit Println(4);
ProvenWithdrawal memory provenWithdrawal = provenWithdrawals[withdrawalHash];
require(
provenWithdrawal.timestamp == 0
|| l2Oracle.getL2Output(provenWithdrawal.l2OutputIndex).outputRoot != provenWithdrawal.outputRoot,
"OptimismPortal: withdrawal hash has already been proven"
);
emit Println(5);
// Verify that the hash of this withdrawal was stored in the L2toL1MessagePasser contract
// on L2. If this is true, under the assumption that the SecureMerkleTrie does not have
...
...
@@ -475,7 +464,6 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
}),
"OptimismPortal: invalid withdrawal inclusion proof"
);
emit Println(6);
// Designate the withdrawalHash as proven by storing the `outputRoot`, `timestamp`, and
// `l2BlockNumber` in the `provenWithdrawals` mapping. A `withdrawalHash` can only be
...
...
@@ -485,30 +473,24 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
timestamp: uint128(block.timestamp),
l2OutputIndex: uint128(_l2OutputIndex)
});
emit Println(7);
// Check that this withdrawal has not already been finalized, this is replay protection.
require(finalizedWithdrawals[withdrawalHash] == false, "OptimismPortal: withdrawal has already been finalized");
emit Println(8);
// Mark the withdrawal as finalized so it can't be replayed.
finalizedWithdrawals[withdrawalHash] = true;
emit Println(9);
// Set the l2Sender so contracts know who triggered this withdrawal on L2.
// This acts as a reentrancy guard.
l2Sender = msg.sender;
bool success;
emit Println(10);
(address token,) = gasPayingToken();
if (token == Constants.ETHER) {
emit Println(11);
success = SafeCall.send(_param.user, _param.value);
} else {
// Cannot call the token contract directly from the portal. This would allow an attacker
// to call approve from a withdrawal and drain the balance of the portal.
emit Println(12);
if (_param.user == token) revert BadTarget();
require(_param.user != token, "BadTarget() user queal token address");
// Only transfer value when a non zero value is specified. This saves gas in the case of
// using the standard bridge or arbitrary message passing.
...
...
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