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
8c4d4417
Commit
8c4d4417
authored
Mar 23, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
contracts-bedrock: more fixes
parent
f28d13bb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
13 deletions
+69
-13
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+10
-9
SystemConfig.t.sol
packages/contracts-bedrock/contracts/test/SystemConfig.t.sol
+14
-0
017-SystemConfigImpl.ts
packages/contracts-bedrock/deploy/017-SystemConfigImpl.ts
+13
-3
019-SystemDictatorInit.ts
packages/contracts-bedrock/deploy/019-SystemDictatorInit.ts
+1
-1
guaranteed-gas-market.md
specs/guaranteed-gas-market.md
+31
-0
No files found.
packages/contracts-bedrock/.gas-snapshot
View file @
8c4d4417
...
@@ -267,9 +267,9 @@ OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutp
...
@@ -267,9 +267,9 @@ OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutp
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutputTimestampIsNotFinalized_reverts() (gas: 207497)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutputTimestampIsNotFinalized_reverts() (gas: 207497)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalNotProven_reverts() (gas: 41753)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalNotProven_reverts() (gas: 41753)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalProofNotOldEnough_reverts() (gas: 199441)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalProofNotOldEnough_reverts() (gas: 199441)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onInsufficientGas_reverts() (gas: 2057
95
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onInsufficientGas_reverts() (gas: 2057
87
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onRecentWithdrawal_reverts() (gas: 180206)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onRecentWithdrawal_reverts() (gas: 180206)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onReentrancy_reverts() (gas: 2438
12
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onReentrancy_reverts() (gas: 2438
04
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onReplay_reverts() (gas: 245528)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onReplay_reverts() (gas: 245528)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_paused_reverts() (gas: 53576)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_paused_reverts() (gas: 53576)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_provenWithdrawalHash_succeeds() (gas: 234941)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_provenWithdrawalHash_succeeds() (gas: 234941)
...
@@ -418,14 +418,15 @@ SequencerFeeVault_Test:test_withdraw_succeeds() (gas: 163228)
...
@@ -418,14 +418,15 @@ SequencerFeeVault_Test:test_withdraw_succeeds() (gas: 163228)
SetPrevBaseFee_Test:test_setPrevBaseFee_succeeds() (gas: 11515)
SetPrevBaseFee_Test:test_setPrevBaseFee_succeeds() (gas: 11515)
StandardBridge_Stateless_Test:test_isCorrectTokenPair_succeeds() (gas: 49936)
StandardBridge_Stateless_Test:test_isCorrectTokenPair_succeeds() (gas: 49936)
StandardBridge_Stateless_Test:test_isOptimismMintableERC20_succeeds() (gas: 33072)
StandardBridge_Stateless_Test:test_isOptimismMintableERC20_succeeds() (gas: 33072)
SystemConfig_Initialize_TestFail:test_initialize_lowGasLimit_reverts() (gas: 14
7845
)
SystemConfig_Initialize_TestFail:test_initialize_lowGasLimit_reverts() (gas: 14
8894
)
SystemConfig_Setters_TestFail:test_setBatcherHash_notOwner_reverts() (gas: 10546)
SystemConfig_Setters_TestFail:test_setBatcherHash_notOwner_reverts() (gas: 10546)
SystemConfig_Setters_TestFail:test_setGasConfig_notOwner_reverts() (gas: 10
599
)
SystemConfig_Setters_TestFail:test_setGasConfig_notOwner_reverts() (gas: 10
622
)
SystemConfig_Setters_TestFail:test_setGasLimit_notOwner_reverts() (gas: 10615)
SystemConfig_Setters_TestFail:test_setGasLimit_notOwner_reverts() (gas: 10615)
SystemConfig_Setters_TestFail:test_setResourceConfig_badMinMax_reverts() (gas: 12951)
SystemConfig_Setters_TestFail:test_setResourceConfig_badMinMax_reverts() (gas: 13002)
SystemConfig_Setters_TestFail:test_setResourceConfig_lowGasLimit_reverts() (gas: 16030)
SystemConfig_Setters_TestFail:test_setResourceConfig_badPrecision_reverts() (gas: 15592)
SystemConfig_Setters_TestFail:test_setResourceConfig_notOwner_reverts() (gas: 11578)
SystemConfig_Setters_TestFail:test_setResourceConfig_lowGasLimit_reverts() (gas: 16082)
SystemConfig_Setters_TestFail:test_setResourceConfig_zeroDenominator_reverts() (gas: 12999)
SystemConfig_Setters_TestFail:test_setResourceConfig_notOwner_reverts() (gas: 11610)
SystemConfig_Setters_TestFail:test_setUnsafeBlockSigner_notOwner_reverts() (gas: 10661)
SystemConfig_Setters_TestFail:test_setResourceConfig_zeroDenominator_reverts() (gas: 13039)
SystemConfig_Setters_TestFail:test_setUnsafeBlockSigner_notOwner_reverts() (gas: 10639)
TransferOnionTest:test_constructor_succeeds() (gas: 564855)
TransferOnionTest:test_constructor_succeeds() (gas: 564855)
TransferOnionTest:test_unwrap_succeeds() (gas: 724958)
TransferOnionTest:test_unwrap_succeeds() (gas: 724958)
\ No newline at end of file
packages/contracts-bedrock/contracts/test/SystemConfig.t.sol
View file @
8c4d4417
...
@@ -134,6 +134,20 @@ contract SystemConfig_Setters_TestFail is SystemConfig_Init {
...
@@ -134,6 +134,20 @@ contract SystemConfig_Setters_TestFail is SystemConfig_Init {
vm.expectRevert("SystemConfig: gas limit too low");
vm.expectRevert("SystemConfig: gas limit too low");
sysConf.setResourceConfig(config);
sysConf.setResourceConfig(config);
}
}
function test_setResourceConfig_badPrecision_reverts() external {
SystemConfig.ResourceConfig memory config = SystemConfig.ResourceConfig({
maxResourceLimit: 20_000_000,
elasticityMultiplier: 11,
baseFeeMaxChangeDenominator: 8,
systemTxMaxGas: 1_000_000,
minimumBaseFee: 1 gwei,
maximumBaseFee: 2 gwei
});
vm.prank(sysConf.owner());
vm.expectRevert("SystemConfig: precision loss with target resource limit");
sysConf.setResourceConfig(config);
}
}
}
contract SystemConfig_Setters_Test is SystemConfig_Init {
contract SystemConfig_Setters_Test is SystemConfig_Init {
...
...
packages/contracts-bedrock/deploy/017-SystemConfigImpl.ts
View file @
8c4d4417
import
assert
from
'
assert
'
import
{
DeployFunction
}
from
'
hardhat-deploy/dist/types
'
import
{
DeployFunction
}
from
'
hardhat-deploy/dist/types
'
import
'
@eth-optimism/hardhat-deploy-config
'
import
'
@eth-optimism/hardhat-deploy-config
'
import
{
ethers
}
from
'
ethers
'
import
{
ethers
}
from
'
ethers
'
import
{
assertContractVariable
,
deploy
}
from
'
../src/deploy-utils
'
import
{
assertContractVariable
,
deploy
}
from
'
../src/deploy-utils
'
const
uint128Max
=
ethers
.
BigNumber
.
from
(
'
0xffffffffffffffffffffffffffffffff
'
)
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
batcherHash
=
hre
.
ethers
.
utils
const
batcherHash
=
hre
.
ethers
.
utils
.
hexZeroPad
(
hre
.
deployConfig
.
batchSenderAddress
,
32
)
.
hexZeroPad
(
hre
.
deployConfig
.
batchSenderAddress
,
32
)
...
@@ -25,9 +29,7 @@ const deployFn: DeployFunction = async (hre) => {
...
@@ -25,9 +29,7 @@ const deployFn: DeployFunction = async (hre) => {
baseFeeMaxChangeDenominator
:
8
,
baseFeeMaxChangeDenominator
:
8
,
systemTxMaxGas
:
1
_000_000
,
systemTxMaxGas
:
1
_000_000
,
minimumBaseFee
:
ethers
.
utils
.
parseUnits
(
'
1
'
,
'
gwei
'
),
minimumBaseFee
:
ethers
.
utils
.
parseUnits
(
'
1
'
,
'
gwei
'
),
maximumBaseFee
:
ethers
.
BigNumber
.
from
(
maximumBaseFee
:
uint128Max
,
'
0xffffffffffffffffffffffffffffffff
'
),
},
},
],
],
postDeployAction
:
async
(
contract
)
=>
{
postDeployAction
:
async
(
contract
)
=>
{
...
@@ -52,6 +54,14 @@ const deployFn: DeployFunction = async (hre) => {
...
@@ -52,6 +54,14 @@ const deployFn: DeployFunction = async (hre) => {
'
unsafeBlockSigner
'
,
'
unsafeBlockSigner
'
,
hre
.
deployConfig
.
p2pSequencerAddress
hre
.
deployConfig
.
p2pSequencerAddress
)
)
const
config
=
await
contract
.
resourceConfig
()
assert
(
config
.
maxResourceLimit
===
20
_000_000
)
assert
(
config
.
elasticityMultiplier
===
10
)
assert
(
config
.
baseFeeMaxChangeDenominator
===
8
)
assert
(
config
.
systemTxMaxGas
===
1
_000_000
)
assert
(
ethers
.
utils
.
parseUnits
(
'
1
'
,
'
gwei
'
).
eq
(
config
.
minimumBaseFee
))
assert
(
config
.
maximumBaseFee
.
eq
(
uint128Max
))
},
},
})
})
}
}
...
...
packages/contracts-bedrock/deploy/019-SystemDictatorInit.ts
View file @
8c4d4417
...
@@ -104,7 +104,7 @@ const deployFn: DeployFunction = async (hre) => {
...
@@ -104,7 +104,7 @@ const deployFn: DeployFunction = async (hre) => {
maxResourceLimit
:
20
_000_000
,
maxResourceLimit
:
20
_000_000
,
elasticityMultiplier
:
10
,
elasticityMultiplier
:
10
,
baseFeeMaxChangeDenominator
:
8
,
baseFeeMaxChangeDenominator
:
8
,
minimumBaseFee
:
1000000000
,
minimumBaseFee
:
ethers
.
utils
.
parseUnits
(
'
1
'
,
'
gwei
'
)
,
systemTxMaxGas
:
1
_000_000
,
systemTxMaxGas
:
1
_000_000
,
maximumBaseFee
:
BigNumber
.
from
(
maximumBaseFee
:
BigNumber
.
from
(
'
0xffffffffffffffffffffffffffffffff
'
'
0xffffffffffffffffffffffffffffffff
'
...
...
specs/guaranteed-gas-market.md
View file @
8c4d4417
...
@@ -5,8 +5,10 @@
...
@@ -5,8 +5,10 @@
**Table of Contents**
**Table of Contents**
-
[
Gas Stipend
](
#gas-stipend
)
-
[
Gas Stipend
](
#gas-stipend
)
-
[
Default Values
](
#default-values
)
-
[
Limiting Guaranteed Gas
](
#limiting-guaranteed-gas
)
-
[
Limiting Guaranteed Gas
](
#limiting-guaranteed-gas
)
-
[
Rationale for burning L1 Gas
](
#rationale-for-burning-l1-gas
)
-
[
Rationale for burning L1 Gas
](
#rationale-for-burning-l1-gas
)
-
[
On Preventing Griefing Attacks
](
#on-preventing-griefing-attacks
)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
...
@@ -36,6 +38,18 @@ the L2 gas, where `gas spent` is the amount of L1 gas spent processing the depos
...
@@ -36,6 +38,18 @@ the L2 gas, where `gas spent` is the amount of L1 gas spent processing the depos
of this credit is greater than the ETH value of the requested guaranteed gas
of this credit is greater than the ETH value of the requested guaranteed gas
(
`requested guaranteed gas * L2 gas price`
), no L1 gas is burnt.
(
`requested guaranteed gas * L2 gas price`
), no L1 gas is burnt.
## Default Values
| Variable | Value |
| ------------------------------- | ----------------- |
| Max Resource Limit | 20,000,000 |
| Elasticity Multiplier | 10 |
| Base Fee Max Change Denominator | 8 |
| Minimum Base Fee | 1 gwei |
| Maximum Base Fee | type(uint128).max |
| System Tx Max Gas | 1,000,000 |
## Limiting Guaranteed Gas
## Limiting Guaranteed Gas
The total amount of guaranteed gas that can be bought in a single L1 block must be limited to
The total amount of guaranteed gas that can be bought in a single L1 block must be limited to
...
@@ -123,3 +137,20 @@ The payable version (Option 2) will likely have discount applied to it (or conve
...
@@ -123,3 +137,20 @@ The payable version (Option 2) will likely have discount applied to it (or conve
premium applied to it).
premium applied to it).
For the initial release of bedrock, only #1 is supported.
For the initial release of bedrock, only #1 is supported.
## On Preventing Griefing Attacks
The cost of purchasing all of the deposit gas in every block must be expensive
enough to prevent attackers from griefing all deposits to the network.
An attacker would observe a deposit in the mempool and frontrun it with a deposit
that purchases enough gas such that the other deposit reverts.
The smaller the max resource limit is, the easier this attack is to pull off.
This attack is mitigated by having a large resource limit as well as a large
elastcity multiplier. This means that the target resource usage is kept small,
giving a lot of room for the deposit base fee to rise when the max resource limit
is being purchased.
This attack should be too expensive to pull off in practice, but if an extremely
wealthy adversary does decide to grief network deposits for an extended period
of time, efforts will be placed to ensure that deposits are able to be processed
on the network.
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