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
f14c715f
Commit
f14c715f
authored
Apr 18, 2025
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug for withdrawal.
parent
3870897b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
27 deletions
+9
-27
config.sh
packages/contracts-bedrock/scripts/getting-started/config.sh
+2
-2
OptimismPortal.sol
packages/contracts-bedrock/src/L1/OptimismPortal.sol
+5
-23
proposer.sh
proposer.sh
+2
-2
No files found.
packages/contracts-bedrock/scripts/getting-started/config.sh
View file @
f14c715f
...
@@ -153,8 +153,8 @@ cat << EOL >> tmp_config.json
...
@@ -153,8 +153,8 @@ cat << EOL >> tmp_config.json
"daResolveWindow": 100,
"daResolveWindow": 100,
"daBondSize": 1000,
"daBondSize": 1000,
"daResolverRefundPercentage": 50,
"daResolverRefundPercentage": 50,
"useCustomGasToken":
fals
e,
"useCustomGasToken":
tru
e,
"customGasTokenAddress": "0x
88395111AB1586a4030dAC62a183542762929bbC
"
"customGasTokenAddress": "0x
9c4bd341cf7134a53b1f34cfa9f3dea4fde61c9c
"
}
}
EOL
EOL
...
...
packages/contracts-bedrock/src/L1/OptimismPortal.sol
View file @
f14c715f
...
@@ -214,7 +214,7 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
...
@@ -214,7 +214,7 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
}
}
/// @notice Returns the gas paying token and its decimals.
/// @notice Returns the gas paying token and its decimals.
function gasPayingToken()
internal
view returns (address addr_, uint8 decimals_) {
function gasPayingToken()
public
view returns (address addr_, uint8 decimals_) {
(addr_, decimals_) = systemConfig.gasPayingToken();
(addr_, decimals_) = systemConfig.gasPayingToken();
}
}
...
@@ -430,7 +430,6 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
...
@@ -430,7 +430,6 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
// revert GasEstimation();
// revert GasEstimation();
// }
// }
}
}
event Println(uint256 line);
/// @notice withdrawal for a user.
/// @notice withdrawal for a user.
...
@@ -447,20 +446,10 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
...
@@ -447,20 +446,10 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
external
external
whenNotPaused
whenNotPaused
{
{
emit Println(1);
require(_param.user!=address(this), "BadTarget()");
if (_param.user == address(this)) revert BadTarget();
Types.OutputProposal memory proposal = l2Oracle.getL2Output(_l2OutputIndex);
emit Println(2);
bytes32 outputRoot = proposal.outputRoot;
bytes32 outputRoot = l2Oracle.getL2Output(_l2OutputIndex).outputRoot;
emit Println(3);
bytes32 withdrawalHash = Hashing.hashExChainWithdrawal(_param);
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
// 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
// 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 {
...
@@ -475,7 +464,6 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
}),
}),
"OptimismPortal: invalid withdrawal inclusion proof"
"OptimismPortal: invalid withdrawal inclusion proof"
);
);
emit Println(6);
// Designate the withdrawalHash as proven by storing the `outputRoot`, `timestamp`, and
// Designate the withdrawalHash as proven by storing the `outputRoot`, `timestamp`, and
// `l2BlockNumber` in the `provenWithdrawals` mapping. A `withdrawalHash` can only be
// `l2BlockNumber` in the `provenWithdrawals` mapping. A `withdrawalHash` can only be
...
@@ -485,30 +473,24 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
...
@@ -485,30 +473,24 @@ contract OptimismPortal is Initializable, ResourceMetering, ISemver {
timestamp: uint128(block.timestamp),
timestamp: uint128(block.timestamp),
l2OutputIndex: uint128(_l2OutputIndex)
l2OutputIndex: uint128(_l2OutputIndex)
});
});
emit Println(7);
// Check that this withdrawal has not already been finalized, this is replay protection.
// Check that this withdrawal has not already been finalized, this is replay protection.
require(finalizedWithdrawals[withdrawalHash] == false, "OptimismPortal: withdrawal has already been finalized");
require(finalizedWithdrawals[withdrawalHash] == false, "OptimismPortal: withdrawal has already been finalized");
emit Println(8);
// Mark the withdrawal as finalized so it can't be replayed.
// Mark the withdrawal as finalized so it can't be replayed.
finalizedWithdrawals[withdrawalHash] = true;
finalizedWithdrawals[withdrawalHash] = true;
emit Println(9);
// Set the l2Sender so contracts know who triggered this withdrawal on L2.
// Set the l2Sender so contracts know who triggered this withdrawal on L2.
// This acts as a reentrancy guard.
// This acts as a reentrancy guard.
l2Sender = msg.sender;
l2Sender = msg.sender;
bool success;
bool success;
emit Println(10);
(address token,) = gasPayingToken();
(address token,) = gasPayingToken();
if (token == Constants.ETHER) {
if (token == Constants.ETHER) {
emit Println(11);
success = SafeCall.send(_param.user, _param.value);
success = SafeCall.send(_param.user, _param.value);
} else {
} else {
// Cannot call the token contract directly from the portal. This would allow an attacker
// 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.
// to call approve from a withdrawal and drain the balance of the portal.
emit Println(12);
require(_param.user != token, "BadTarget() user queal token address");
if (_param.user == token) revert BadTarget();
// Only transfer value when a non zero value is specified. This saves gas in the case of
// 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.
// using the standard bridge or arbitrary message passing.
...
...
proposer.sh
View file @
f14c715f
...
@@ -2,11 +2,11 @@
...
@@ -2,11 +2,11 @@
source
.envrc
source
.envrc
./bin/op-proposer
\
./bin/op-proposer
\
--data-dir
=
./
data
/proposer
\
--data-dir
=
./
node
/proposer
\
--poll-interval
=
12s
\
--poll-interval
=
12s
\
--rpc
.port
=
8560
\
--rpc
.port
=
8560
\
--rollup-rpc
=
http://127.0.0.1:9545
\
--rollup-rpc
=
http://127.0.0.1:9545
\
--l2oo-address
=
$(
cat
./deployer/artifact.json |
grep
"L2OutputOracleProxy"
|
grep
-Eo
"0x[a-fA-F0-9]+"
)
\
--l2oo-address
=
$(
cat
./deployer/artifact.json |
grep
"L2OutputOracleProxy"
|
grep
-Eo
"0x[a-fA-F0-9]+"
)
\
--portal-address
=
$(
cat
./deployer/artifact.json |
grep
-w
"OptimismPortal"
|
grep
-Eo
"0x[a-fA-F0-9]+"
)
\
--portal-address
=
$(
cat
./deployer/artifact.json |
grep
-w
"OptimismPortal
Proxy
"
|
grep
-Eo
"0x[a-fA-F0-9]+"
)
\
--private-key
=
$GS_PROPOSER_PRIVATE_KEY
\
--private-key
=
$GS_PROPOSER_PRIVATE_KEY
\
--l1-eth-rpc
=
$L1_RPC_URL
--l1-eth-rpc
=
$L1_RPC_URL
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