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
38bff0ff
Unverified
Commit
38bff0ff
authored
Sep 01, 2021
by
Mark Tyneway
Committed by
GitHub
Sep 01, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1408 from ethereum-optimism/fix/l2geth-min-l2-gas-limit
l2geth: configurable min L2 gas limit
parents
911f40d8
0e14855c
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
69 additions
and
0 deletions
+69
-0
popular-tools-jog.md
.changeset/popular-tools-jog.md
+5
-0
main.go
l2geth/cmd/geth/main.go
+1
-0
usage.go
l2geth/cmd/geth/usage.go
+1
-0
flags.go
l2geth/cmd/utils/flags.go
+9
-0
config.go
l2geth/rollup/config.go
+4
-0
rollup_fee.go
l2geth/rollup/fees/rollup_fee.go
+3
-0
sync_service.go
l2geth/rollup/sync_service.go
+13
-0
sync_service_test.go
l2geth/rollup/sync_service_test.go
+33
-0
No files found.
.changeset/popular-tools-jog.md
0 → 100644
View file @
38bff0ff
---
'
@eth-optimism/l2geth'
:
patch
---
Add in min accepted L2 gas limit config flag
l2geth/cmd/geth/main.go
View file @
38bff0ff
...
@@ -168,6 +168,7 @@ var (
...
@@ -168,6 +168,7 @@ var (
utils
.
RollupMaxCalldataSizeFlag
,
utils
.
RollupMaxCalldataSizeFlag
,
utils
.
RollupBackendFlag
,
utils
.
RollupBackendFlag
,
utils
.
RollupEnforceFeesFlag
,
utils
.
RollupEnforceFeesFlag
,
utils
.
RollupMinL2GasLimitFlag
,
utils
.
RollupFeeThresholdDownFlag
,
utils
.
RollupFeeThresholdDownFlag
,
utils
.
RollupFeeThresholdUpFlag
,
utils
.
RollupFeeThresholdUpFlag
,
utils
.
GasPriceOracleOwnerAddress
,
utils
.
GasPriceOracleOwnerAddress
,
...
...
l2geth/cmd/geth/usage.go
View file @
38bff0ff
...
@@ -81,6 +81,7 @@ var AppHelpFlagGroups = []flagGroup{
...
@@ -81,6 +81,7 @@ var AppHelpFlagGroups = []flagGroup{
utils
.
RollupMaxCalldataSizeFlag
,
utils
.
RollupMaxCalldataSizeFlag
,
utils
.
RollupBackendFlag
,
utils
.
RollupBackendFlag
,
utils
.
RollupEnforceFeesFlag
,
utils
.
RollupEnforceFeesFlag
,
utils
.
RollupMinL2GasLimitFlag
,
utils
.
RollupFeeThresholdDownFlag
,
utils
.
RollupFeeThresholdDownFlag
,
utils
.
RollupFeeThresholdUpFlag
,
utils
.
RollupFeeThresholdUpFlag
,
utils
.
GasPriceOracleOwnerAddress
,
utils
.
GasPriceOracleOwnerAddress
,
...
...
l2geth/cmd/utils/flags.go
View file @
38bff0ff
...
@@ -892,6 +892,11 @@ var (
...
@@ -892,6 +892,11 @@ var (
Usage
:
"Disable transactions with 0 gas price"
,
Usage
:
"Disable transactions with 0 gas price"
,
EnvVar
:
"ROLLUP_ENFORCE_FEES"
,
EnvVar
:
"ROLLUP_ENFORCE_FEES"
,
}
}
RollupMinL2GasLimitFlag
=
cli
.
Uint64Flag
{
Name
:
"rollup.minl2gaslimit"
,
Usage
:
"Minimum accepted L2 gas limit"
,
EnvVar
:
"ROLLUP_MIN_L2_GAS_LIMIT"
,
}
RollupFeeThresholdDownFlag
=
cli
.
Float64Flag
{
RollupFeeThresholdDownFlag
=
cli
.
Float64Flag
{
Name
:
"rollup.feethresholddown"
,
Name
:
"rollup.feethresholddown"
,
Usage
:
"Allow txs with fees below the current fee up to this amount, must be < 1"
,
Usage
:
"Allow txs with fees below the current fee up to this amount, must be < 1"
,
...
@@ -1203,6 +1208,10 @@ func setRollup(ctx *cli.Context, cfg *rollup.Config) {
...
@@ -1203,6 +1208,10 @@ func setRollup(ctx *cli.Context, cfg *rollup.Config) {
if
ctx
.
GlobalIsSet
(
RollupEnforceFeesFlag
.
Name
)
{
if
ctx
.
GlobalIsSet
(
RollupEnforceFeesFlag
.
Name
)
{
cfg
.
EnforceFees
=
true
cfg
.
EnforceFees
=
true
}
}
if
ctx
.
GlobalIsSet
(
RollupMinL2GasLimitFlag
.
Name
)
{
val
:=
ctx
.
GlobalUint64
(
RollupMinL2GasLimitFlag
.
Name
)
cfg
.
MinL2GasLimit
=
new
(
big
.
Int
)
.
SetUint64
(
val
)
}
if
ctx
.
GlobalIsSet
(
RollupFeeThresholdDownFlag
.
Name
)
{
if
ctx
.
GlobalIsSet
(
RollupFeeThresholdDownFlag
.
Name
)
{
val
:=
ctx
.
GlobalFloat64
(
RollupFeeThresholdDownFlag
.
Name
)
val
:=
ctx
.
GlobalFloat64
(
RollupFeeThresholdDownFlag
.
Name
)
cfg
.
FeeThresholdDown
=
new
(
big
.
Float
)
.
SetFloat64
(
val
)
cfg
.
FeeThresholdDown
=
new
(
big
.
Float
)
.
SetFloat64
(
val
)
...
...
l2geth/rollup/config.go
View file @
38bff0ff
...
@@ -39,6 +39,10 @@ type Config struct {
...
@@ -39,6 +39,10 @@ type Config struct {
Backend
Backend
Backend
Backend
// Only accept transactions with fees
// Only accept transactions with fees
EnforceFees
bool
EnforceFees
bool
// Prevent transactions with a L2 gas limit lower than this value
// The L2 gas limit is parsed from the `tx.gasPrice`, see the
// `rollup/fees` package for more information
MinL2GasLimit
*
big
.
Int
// Allow fees within a buffer upwards or downwards
// Allow fees within a buffer upwards or downwards
// to take fee volatility into account between being
// to take fee volatility into account between being
// quoted and the transaction being executed
// quoted and the transaction being executed
...
...
l2geth/rollup/fees/rollup_fee.go
View file @
38bff0ff
...
@@ -18,6 +18,9 @@ var (
...
@@ -18,6 +18,9 @@ var (
// errMissingInput represents the error case of missing required input to
// errMissingInput represents the error case of missing required input to
// PaysEnough
// PaysEnough
errMissingInput
=
errors
.
New
(
"missing input"
)
errMissingInput
=
errors
.
New
(
"missing input"
)
// ErrL2GasLimitTooLow represents the error case of when a user sends a
// transaction to the sequencer with a L2 gas limit that is too small
ErrL2GasLimitTooLow
=
errors
.
New
(
"L2 gas limit too low"
)
)
)
// overhead represents the fixed cost of batch submission of a single
// overhead represents the fixed cost of batch submission of a single
...
...
l2geth/rollup/sync_service.go
View file @
38bff0ff
...
@@ -78,6 +78,7 @@ type SyncService struct {
...
@@ -78,6 +78,7 @@ type SyncService struct {
gasPriceOracleOwnerAddressLock
*
sync
.
RWMutex
gasPriceOracleOwnerAddressLock
*
sync
.
RWMutex
enforceFees
bool
enforceFees
bool
signer
types
.
Signer
signer
types
.
Signer
minL2GasLimit
*
big
.
Int
feeThresholdUp
*
big
.
Float
feeThresholdUp
*
big
.
Float
feeThresholdDown
*
big
.
Float
feeThresholdDown
*
big
.
Float
}
}
...
@@ -135,6 +136,11 @@ func NewSyncService(ctx context.Context, cfg Config, txpool *core.TxPool, bc *co
...
@@ -135,6 +136,11 @@ func NewSyncService(ctx context.Context, cfg Config, txpool *core.TxPool, bc *co
cfg
.
FeeThresholdUp
)
cfg
.
FeeThresholdUp
)
}
}
}
}
if
cfg
.
MinL2GasLimit
==
nil
{
value
:=
new
(
big
.
Int
)
log
.
Info
(
"Sanitizing minimum L2 gas limit"
,
"value"
,
value
)
cfg
.
MinL2GasLimit
=
value
}
service
:=
SyncService
{
service
:=
SyncService
{
ctx
:
ctx
,
ctx
:
ctx
,
...
@@ -155,6 +161,7 @@ func NewSyncService(ctx context.Context, cfg Config, txpool *core.TxPool, bc *co
...
@@ -155,6 +161,7 @@ func NewSyncService(ctx context.Context, cfg Config, txpool *core.TxPool, bc *co
gasPriceOracleOwnerAddressLock
:
new
(
sync
.
RWMutex
),
gasPriceOracleOwnerAddressLock
:
new
(
sync
.
RWMutex
),
enforceFees
:
cfg
.
EnforceFees
,
enforceFees
:
cfg
.
EnforceFees
,
signer
:
types
.
NewEIP155Signer
(
chainID
),
signer
:
types
.
NewEIP155Signer
(
chainID
),
minL2GasLimit
:
cfg
.
MinL2GasLimit
,
feeThresholdDown
:
cfg
.
FeeThresholdDown
,
feeThresholdDown
:
cfg
.
FeeThresholdDown
,
feeThresholdUp
:
cfg
.
FeeThresholdUp
,
feeThresholdUp
:
cfg
.
FeeThresholdUp
,
}
}
...
@@ -855,6 +862,12 @@ func (s *SyncService) verifyFee(tx *types.Transaction) error {
...
@@ -855,6 +862,12 @@ func (s *SyncService) verifyFee(tx *types.Transaction) error {
gas
:=
new
(
big
.
Int
)
.
SetUint64
(
tx
.
Gas
())
gas
:=
new
(
big
.
Int
)
.
SetUint64
(
tx
.
Gas
())
l2GasLimit
:=
fees
.
DecodeL2GasLimit
(
gas
)
l2GasLimit
:=
fees
.
DecodeL2GasLimit
(
gas
)
// When the L2 gas limit is smaller than the min L2 gas limit,
// reject the transaction
if
l2GasLimit
.
Cmp
(
s
.
minL2GasLimit
)
==
-
1
{
return
fmt
.
Errorf
(
"%w: %d, use at least %d"
,
fees
.
ErrL2GasLimitTooLow
,
l2GasLimit
,
s
.
minL2GasLimit
)
}
// Only count the calldata here as the overhead of the fully encoded
// Only count the calldata here as the overhead of the fully encoded
// RLP transaction is handled inside of EncodeL2GasLimit
// RLP transaction is handled inside of EncodeL2GasLimit
expectedTxGasLimit
:=
fees
.
EncodeTxGasLimit
(
tx
.
Data
(),
l1GasPrice
,
l2GasLimit
,
l2GasPrice
)
expectedTxGasLimit
:=
fees
.
EncodeTxGasLimit
(
tx
.
Data
(),
l1GasPrice
,
l2GasLimit
,
l2GasPrice
)
...
...
l2geth/rollup/sync_service_test.go
View file @
38bff0ff
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rollup/fees"
)
)
func
setupLatestEthContextTest
()
(
*
SyncService
,
*
EthContext
)
{
func
setupLatestEthContextTest
()
(
*
SyncService
,
*
EthContext
)
{
...
@@ -548,6 +549,38 @@ func TestSyncServiceL2GasPrice(t *testing.T) {
...
@@ -548,6 +549,38 @@ func TestSyncServiceL2GasPrice(t *testing.T) {
}
}
}
}
func
TestSyncServiceMinL2GasPrice
(
t
*
testing
.
T
)
{
service
,
_
,
_
,
err
:=
newTestSyncService
(
true
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
service
.
minL2GasLimit
=
new
(
big
.
Int
)
.
SetUint64
(
10
_000_000
)
signer
:=
types
.
NewEIP155Signer
(
big
.
NewInt
(
420
))
// Generate a key
key
,
_
:=
crypto
.
GenerateKey
()
// Create a transaction
gasLimit
:=
uint64
(
100
)
tx
:=
types
.
NewTransaction
(
0
,
common
.
Address
{},
big
.
NewInt
(
0
),
gasLimit
,
big
.
NewInt
(
15000000
),
[]
byte
{})
// Make sure the gas limit is set correctly
if
tx
.
Gas
()
!=
gasLimit
{
t
.
Fatal
(
"gas limit not set correctly"
)
}
// Sign the dummy tx with the owner key
signedTx
,
err
:=
types
.
SignTx
(
tx
,
signer
,
key
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
// Sanity check the L2 gas limit
if
tx
.
L2Gas
()
>
service
.
minL2GasLimit
.
Uint64
()
{
t
.
Fatal
(
"L2 gas limit expected to be smaller than min accepted by sequencer"
)
}
// Verify the fee of the signed tx, ensure it does not error
err
=
service
.
verifyFee
(
signedTx
)
if
!
errors
.
Is
(
err
,
fees
.
ErrL2GasLimitTooLow
)
{
t
.
Fatal
(
err
)
}
}
func
TestSyncServiceGasPriceOracleOwnerAddress
(
t
*
testing
.
T
)
{
func
TestSyncServiceGasPriceOracleOwnerAddress
(
t
*
testing
.
T
)
{
service
,
_
,
_
,
err
:=
newTestSyncService
(
true
)
service
,
_
,
_
,
err
:=
newTestSyncService
(
true
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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