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
4f2e1063
Unverified
Commit
4f2e1063
authored
Jul 12, 2021
by
Mark Tyneway
Committed by
GitHub
Jul 12, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1266 from ethereum-optimism/fix/prevent-too-low-fees
l2geth: prevent too low of fees from getting through
parents
fc297257
735ef774
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
9 deletions
+40
-9
dry-chairs-watch.md
.changeset/dry-chairs-watch.md
+5
-0
rollup_fee.go
l2geth/rollup/fees/rollup_fee.go
+7
-5
rollup_fee_test.go
l2geth/rollup/fees/rollup_fee_test.go
+28
-1
sync_service.go
l2geth/rollup/sync_service.go
+0
-3
No files found.
.changeset/dry-chairs-watch.md
0 → 100644
View file @
4f2e1063
---
'
@eth-optimism/l2geth'
:
patch
---
Fix a bug in the fee logic that allowed for fees that were too low to get through
l2geth/rollup/fees/rollup_fee.go
View file @
4f2e1063
...
...
@@ -3,6 +3,7 @@ package fees
import
(
"errors"
"fmt"
"math"
"math/big"
"github.com/ethereum/go-ethereum/common"
...
...
@@ -115,7 +116,7 @@ func PaysEnough(opts *PaysEnoughOpts) error {
return
fmt
.
Errorf
(
"%w: no expected fee"
,
errMissingInput
)
}
fee
:=
opts
.
ExpectedFee
fee
:=
new
(
big
.
Int
)
.
Set
(
opts
.
ExpectedFee
)
// Allow for a downward buffer to protect against L1 gas price volatility
if
opts
.
ThresholdDown
!=
nil
{
fee
=
mulByFloat
(
fee
,
opts
.
ThresholdDown
)
...
...
@@ -129,7 +130,7 @@ func PaysEnough(opts *PaysEnoughOpts) error {
if
opts
.
ThresholdUp
!=
nil
{
// overpaying = user fee - expected fee
overpaying
:=
new
(
big
.
Int
)
.
Sub
(
opts
.
UserFee
,
opts
.
ExpectedFee
)
threshold
:=
mulByFloat
(
o
verpaying
,
opts
.
ThresholdUp
)
threshold
:=
mulByFloat
(
o
pts
.
ExpectedFee
,
opts
.
ThresholdUp
)
// if overpaying > threshold, return error
if
overpaying
.
Cmp
(
threshold
)
==
1
{
return
ErrFeeTooHigh
...
...
@@ -140,9 +141,10 @@ func PaysEnough(opts *PaysEnoughOpts) error {
func
mulByFloat
(
num
*
big
.
Int
,
float
*
big
.
Float
)
*
big
.
Int
{
n
:=
new
(
big
.
Float
)
.
SetUint64
(
num
.
Uint64
())
n
=
n
.
Mul
(
n
,
float
)
value
,
_
:=
float
.
Uint64
()
return
new
(
big
.
Int
)
.
SetUint64
(
value
)
product
:=
n
.
Mul
(
n
,
float
)
pfloat
,
_
:=
product
.
Float64
()
rounded
:=
math
.
Ceil
(
pfloat
)
return
new
(
big
.
Int
)
.
SetUint64
(
uint64
(
rounded
))
}
// calculateL1GasLimit computes the L1 gasLimit based on the calldata and
...
...
l2geth/rollup/fees/rollup_fee_test.go
View file @
4f2e1063
...
...
@@ -157,13 +157,40 @@ func TestPaysEnough(t *testing.T) {
},
"fee-threshold-up"
:
{
opts
:
&
PaysEnoughOpts
{
UserFee
:
common
.
Big
3
,
UserFee
:
common
.
Big
256
,
ExpectedFee
:
common
.
Big1
,
ThresholdUp
:
new
(
big
.
Float
)
.
SetFloat64
(
1.5
),
ThresholdDown
:
nil
,
},
err
:
ErrFeeTooHigh
,
},
"fee-too-low-high"
:
{
opts
:
&
PaysEnoughOpts
{
UserFee
:
new
(
big
.
Int
)
.
SetUint64
(
10
_000
),
ExpectedFee
:
new
(
big
.
Int
)
.
SetUint64
(
1
),
ThresholdUp
:
new
(
big
.
Float
)
.
SetFloat64
(
3
),
ThresholdDown
:
new
(
big
.
Float
)
.
SetFloat64
(
0.8
),
},
err
:
ErrFeeTooHigh
,
},
"fee-too-low-down"
:
{
opts
:
&
PaysEnoughOpts
{
UserFee
:
new
(
big
.
Int
)
.
SetUint64
(
1
),
ExpectedFee
:
new
(
big
.
Int
)
.
SetUint64
(
10
_000
),
ThresholdUp
:
new
(
big
.
Float
)
.
SetFloat64
(
3
),
ThresholdDown
:
new
(
big
.
Float
)
.
SetFloat64
(
0.8
),
},
err
:
ErrFeeTooLow
,
},
"fee-too-low-down-2"
:
{
opts
:
&
PaysEnoughOpts
{
UserFee
:
new
(
big
.
Int
)
.
SetUint64
(
0
),
ExpectedFee
:
new
(
big
.
Int
)
.
SetUint64
(
10
_000
),
ThresholdUp
:
new
(
big
.
Float
)
.
SetFloat64
(
3
),
ThresholdDown
:
new
(
big
.
Float
)
.
SetFloat64
(
0.8
),
},
err
:
ErrFeeTooLow
,
},
}
for
name
,
tt
:=
range
tests
{
...
...
l2geth/rollup/sync_service.go
View file @
4f2e1063
...
...
@@ -858,9 +858,6 @@ func (s *SyncService) verifyFee(tx *types.Transaction) error {
// Only count the calldata here as the overhead of the fully encoded
// RLP transaction is handled inside of EncodeL2GasLimit
expectedTxGasLimit
:=
fees
.
EncodeTxGasLimit
(
tx
.
Data
(),
l1GasPrice
,
l2GasLimit
,
l2GasPrice
)
if
err
!=
nil
{
return
err
}
// This should only happen if the unscaled transaction fee is greater than 18.44 ETH
if
!
expectedTxGasLimit
.
IsUint64
()
{
...
...
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