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
5385d3f3
Commit
5385d3f3
authored
Jun 02, 2022
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
contracts: Fix OZ-N-04 Hardcoded values
parent
332ebdae
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
11 deletions
+49
-11
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+4
-4
OptimismPortal.sol
packages/contracts-bedrock/contracts/L1/OptimismPortal.sol
+12
-2
L2ToL1MessagePasser.sol
...es/contracts-bedrock/contracts/L2/L2ToL1MessagePasser.sol
+14
-1
CrossDomainMessenger.sol
...acts-bedrock/contracts/universal/CrossDomainMessenger.sol
+9
-3
StandardBridge.sol
.../contracts-bedrock/contracts/universal/StandardBridge.sol
+10
-1
No files found.
packages/contracts-bedrock/.gas-snapshot
View file @
5385d3f3
...
@@ -26,13 +26,13 @@ L1BlockNumberTest:test_receive() (gas: 25436)
...
@@ -26,13 +26,13 @@ L1BlockNumberTest:test_receive() (gas: 25436)
L1CrossDomainMessenger_Test:testCannot_L1MessengerPause() (gas: 10909)
L1CrossDomainMessenger_Test:testCannot_L1MessengerPause() (gas: 10909)
L1CrossDomainMessenger_Test:test_L1MessengerMessageVersion() (gas: 8366)
L1CrossDomainMessenger_Test:test_L1MessengerMessageVersion() (gas: 8366)
L1CrossDomainMessenger_Test:test_L1MessengerPause() (gas: 31882)
L1CrossDomainMessenger_Test:test_L1MessengerPause() (gas: 31882)
L1CrossDomainMessenger_Test:test_L1MessengerRelayMessageSucceeds() (gas: 61
175
)
L1CrossDomainMessenger_Test:test_L1MessengerRelayMessageSucceeds() (gas: 61
239
)
L1CrossDomainMessenger_Test:test_L1MessengerRelayMessageToSystemContract() (gas: 44859)
L1CrossDomainMessenger_Test:test_L1MessengerRelayMessageToSystemContract() (gas: 44859)
L1CrossDomainMessenger_Test:test_L1MessengerRelayShouldRevertIfPaused() (gas: 41631)
L1CrossDomainMessenger_Test:test_L1MessengerRelayShouldRevertIfPaused() (gas: 41631)
L1CrossDomainMessenger_Test:test_L1MessengerSendMessage() (gas: 172148)
L1CrossDomainMessenger_Test:test_L1MessengerSendMessage() (gas: 172148)
L1CrossDomainMessenger_Test:test_L1MessengerTwiceSendMessage() (gas: 1254131)
L1CrossDomainMessenger_Test:test_L1MessengerTwiceSendMessage() (gas: 1254131)
L1CrossDomainMessenger_Test:test_L1MessengerXDomainSenderReverts() (gas: 10566)
L1CrossDomainMessenger_Test:test_L1MessengerXDomainSenderReverts() (gas: 10566)
L1CrossDomainMessenger_Test:test_L1MessengerxDomainMessageSenderResets() (gas: 58
471
)
L1CrossDomainMessenger_Test:test_L1MessengerxDomainMessageSenderResets() (gas: 58
535
)
L1StandardBridge_Test:test_depositERC20() (gas: 452873)
L1StandardBridge_Test:test_depositERC20() (gas: 452873)
L1StandardBridge_Test:test_depositERC20To() (gas: 454650)
L1StandardBridge_Test:test_depositERC20To() (gas: 454650)
L1StandardBridge_Test:test_depositETH() (gas: 247054)
L1StandardBridge_Test:test_depositETH() (gas: 247054)
...
@@ -49,13 +49,13 @@ L1StandardBridge_Test:test_receive() (gas: 391794)
...
@@ -49,13 +49,13 @@ L1StandardBridge_Test:test_receive() (gas: 391794)
L2CrossDomainMessenger_Test:testCannot_L2MessengerPause() (gas: 10843)
L2CrossDomainMessenger_Test:testCannot_L2MessengerPause() (gas: 10843)
L2CrossDomainMessenger_Test:test_L2MessengerMessageVersion() (gas: 8410)
L2CrossDomainMessenger_Test:test_L2MessengerMessageVersion() (gas: 8410)
L2CrossDomainMessenger_Test:test_L2MessengerPause() (gas: 31837)
L2CrossDomainMessenger_Test:test_L2MessengerPause() (gas: 31837)
L2CrossDomainMessenger_Test:test_L2MessengerRelayMessageSucceeds() (gas: 57
474
)
L2CrossDomainMessenger_Test:test_L2MessengerRelayMessageSucceeds() (gas: 57
538
)
L2CrossDomainMessenger_Test:test_L2MessengerRelayMessageToSystemContract() (gas: 24567)
L2CrossDomainMessenger_Test:test_L2MessengerRelayMessageToSystemContract() (gas: 24567)
L2CrossDomainMessenger_Test:test_L2MessengerRelayShouldRevertIfPaused() (gas: 41599)
L2CrossDomainMessenger_Test:test_L2MessengerRelayShouldRevertIfPaused() (gas: 41599)
L2CrossDomainMessenger_Test:test_L2MessengerSendMessage() (gas: 119659)
L2CrossDomainMessenger_Test:test_L2MessengerSendMessage() (gas: 119659)
L2CrossDomainMessenger_Test:test_L2MessengerTwiceSendMessage() (gas: 133096)
L2CrossDomainMessenger_Test:test_L2MessengerTwiceSendMessage() (gas: 133096)
L2CrossDomainMessenger_Test:test_L2MessengerXDomainSenderReverts() (gas: 10588)
L2CrossDomainMessenger_Test:test_L2MessengerXDomainSenderReverts() (gas: 10588)
L2CrossDomainMessenger_Test:test_L2MessengerxDomainMessageSenderResets() (gas: 54
795
)
L2CrossDomainMessenger_Test:test_L2MessengerxDomainMessageSenderResets() (gas: 54
859
)
L2OutputOracleTest:testCannot_appendCurrentTimestamp() (gas: 18627)
L2OutputOracleTest:testCannot_appendCurrentTimestamp() (gas: 18627)
L2OutputOracleTest:testCannot_appendEmptyOutput() (gas: 16756)
L2OutputOracleTest:testCannot_appendEmptyOutput() (gas: 16756)
L2OutputOracleTest:testCannot_appendFutureTimestamp() (gas: 18708)
L2OutputOracleTest:testCannot_appendFutureTimestamp() (gas: 18708)
...
...
packages/contracts-bedrock/contracts/L1/OptimismPortal.sol
View file @
5385d3f3
...
@@ -67,6 +67,16 @@ contract OptimismPortal is ResourceMetering {
...
@@ -67,6 +67,16 @@ contract OptimismPortal is ResourceMetering {
*/
*/
address public l2Sender = DEFAULT_L2_SENDER;
address public l2Sender = DEFAULT_L2_SENDER;
/**
* @notice The L2 gas limit set when eth is deposited using the receive() function.
*/
uint64 internal constant RECEIVE_DEFAULT_GAS_LIMIT = 100_000;
/**
* @notice Additional gas reserved for clean up after finalizing a transaction withdrawal.
*/
uint256 internal constant FINALIZE_GAS_BUFFER = 20_000;
/**
/**
* @notice A list of withdrawal hashes which have been successfully finalized.
* @notice A list of withdrawal hashes which have been successfully finalized.
*/
*/
...
@@ -87,7 +97,7 @@ contract OptimismPortal is ResourceMetering {
...
@@ -87,7 +97,7 @@ contract OptimismPortal is ResourceMetering {
* function for EOAs. Contracts should call the depositTransaction() function directly.
* function for EOAs. Contracts should call the depositTransaction() function directly.
*/
*/
receive() external payable {
receive() external payable {
depositTransaction(msg.sender, msg.value,
100000
, false, bytes(""));
depositTransaction(msg.sender, msg.value,
RECEIVE_DEFAULT_GAS_LIMIT
, false, bytes(""));
}
}
/**
/**
...
@@ -221,7 +231,7 @@ contract OptimismPortal is ResourceMetering {
...
@@ -221,7 +231,7 @@ contract OptimismPortal is ResourceMetering {
// target contract is at least the gas limit specified by the user. We can do this by
// target contract is at least the gas limit specified by the user. We can do this by
// enforcing that, at this point in time, we still have gaslimit + buffer gas available.
// enforcing that, at this point in time, we still have gaslimit + buffer gas available.
require(
require(
gasleft() >= _gasLimit +
20000
,
gasleft() >= _gasLimit +
FINALIZE_GAS_BUFFER
,
"OptimismPortal: insufficient gas to finalize withdrawal"
"OptimismPortal: insufficient gas to finalize withdrawal"
);
);
...
...
packages/contracts-bedrock/contracts/L2/L2ToL1MessagePasser.sol
View file @
5385d3f3
...
@@ -39,6 +39,19 @@ contract L2ToL1MessagePasser {
...
@@ -39,6 +39,19 @@ contract L2ToL1MessagePasser {
*/
*/
event WithdrawerBalanceBurnt(uint256 indexed amount);
event WithdrawerBalanceBurnt(uint256 indexed amount);
/*************
* Constants *
*************/
/**
* @notice The L1 gas limit set when eth is withdrawn using the receive() function.
*/
uint256 internal constant RECEIVE_DEFAULT_GAS_LIMIT = 100_000;
/*************
* Variables *
*************/
/**
/**
* @notice Includes the message hashes for all withdrawals
* @notice Includes the message hashes for all withdrawals
*/
*/
...
@@ -53,7 +66,7 @@ contract L2ToL1MessagePasser {
...
@@ -53,7 +66,7 @@ contract L2ToL1MessagePasser {
* @notice Allows users to withdraw ETH by sending directly to this contract.
* @notice Allows users to withdraw ETH by sending directly to this contract.
*/
*/
receive() external payable {
receive() external payable {
initiateWithdrawal(msg.sender,
100000
, bytes(""));
initiateWithdrawal(msg.sender,
RECEIVE_DEFAULT_GAS_LIMIT
, bytes(""));
}
}
/**
/**
...
...
packages/contracts-bedrock/contracts/universal/CrossDomainMessenger.sol
View file @
5385d3f3
...
@@ -54,7 +54,10 @@ abstract contract CrossDomainMessenger is
...
@@ -54,7 +54,10 @@ abstract contract CrossDomainMessenger is
uint32 public constant MIN_GAS_DYNAMIC_OVERHEAD = 1;
uint32 public constant MIN_GAS_DYNAMIC_OVERHEAD = 1;
uint32 public constant MIN_GAS_CONSTANT_OVERHEAD = 100000;
uint32 public constant MIN_GAS_CONSTANT_OVERHEAD = 100_000;
uint256 internal constant RELAY_GAS_REQUIRED = 45_000;
uint256 internal constant RELAY_GAS_BUFFER = RELAY_GAS_REQUIRED - 5000;
/*************
/*************
* Variables *
* Variables *
...
@@ -209,12 +212,15 @@ abstract contract CrossDomainMessenger is
...
@@ -209,12 +212,15 @@ abstract contract CrossDomainMessenger is
require(successfulMessages[versionedHash] == false, "Message has already been relayed.");
require(successfulMessages[versionedHash] == false, "Message has already been relayed.");
// TODO: Make sure this will always give us enough gas.
// TODO: Make sure this will always give us enough gas.
require(gasleft() >= _minGasLimit + 45000, "Insufficient gas to relay message.");
require(
gasleft() >= _minGasLimit + RELAY_GAS_REQUIRED,
"Insufficient gas to relay message."
);
xDomainMsgSender = _sender;
xDomainMsgSender = _sender;
(bool success, ) = ExcessivelySafeCall.excessivelySafeCall(
(bool success, ) = ExcessivelySafeCall.excessivelySafeCall(
_target,
_target,
gasleft() -
40000
,
gasleft() -
RELAY_GAS_BUFFER
,
_value,
_value,
0,
0,
_message
_message
...
...
packages/contracts-bedrock/contracts/universal/StandardBridge.sol
View file @
5385d3f3
...
@@ -68,6 +68,15 @@ abstract contract StandardBridge {
...
@@ -68,6 +68,15 @@ abstract contract StandardBridge {
bytes _data
bytes _data
);
);
/*************
* Constants *
*************/
/**
* @notice The L2 gas limit set when eth is depoisited using the receive() function.
*/
uint32 internal constant RECEIVE_DEFAULT_GAS_LIMIT = 200_000;
/*************
/*************
* Variables *
* Variables *
*************/
*************/
...
@@ -129,7 +138,7 @@ abstract contract StandardBridge {
...
@@ -129,7 +138,7 @@ abstract contract StandardBridge {
* to L2 through the standard bridge.
* to L2 through the standard bridge.
*/
*/
receive() external payable onlyEOA {
receive() external payable onlyEOA {
_initiateBridgeETH(msg.sender, msg.sender, msg.value,
200_000
, bytes(""));
_initiateBridgeETH(msg.sender, msg.sender, msg.value,
RECEIVE_DEFAULT_GAS_LIMIT
, bytes(""));
}
}
/**
/**
...
...
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